From 5b742890010650da9ca61765032316f9fa530814 Mon Sep 17 00:00:00 2001 From: "francois.lutran" Date: Fri, 16 Dec 2016 10:42:04 +1300 Subject: [PATCH] set up quill library --- .gitignore | 3 + config.php | 40 +- inc/auth.php | 32 +- inc/calendar.php | 4 +- inc/mythoughts.php | 58 +-- masks/index.html | 10 +- masks/write.html | 100 ++--- scripts/jquery.min.js | 8 +- scripts/quill.min.js | 14 + style/_font-awesome.scss | 6 +- style/_quill.bubble.scss | 854 +++++++++++++++++++++++++++++++++++++++ style/_write.scss | 6 + style/mythoughts.css | 2 + style/mythoughts.css.map | 7 + style/mythoughts.scss | 119 +----- style/scss.bat | 1 + 16 files changed, 1008 insertions(+), 256 deletions(-) create mode 100644 scripts/quill.min.js create mode 100644 style/_quill.bubble.scss create mode 100644 style/_write.scss create mode 100644 style/mythoughts.css create mode 100644 style/mythoughts.css.map create mode 100644 style/scss.bat diff --git a/.gitignore b/.gitignore index 51131f6..ffbf549 100755 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ /settings.php /.buildpath /.settings/ +/style/.sass-cache/ +/.externalToolBuilders/ +/settings.php diff --git a/config.php b/config.php index fa48f61..c140aa2 100755 --- a/config.php +++ b/config.php @@ -171,14 +171,14 @@ class Session extends PhpObject { $this->addError('Nickname: HTML characters are forbidden'); } - elseif($this->oMySql->selectRow(MySqlManager::USERS_TABLE, array('user'=>$sLogin))) + elseif($this->oMySql->selectRow(Db::USERS_TABLE, array('user'=>$sLogin))) { $this->addError('Nickname: This is already a user called by that name, choose a different one'); } else { $asData['pass'] = self::encryptPassword($sPass); - $iUserId = $this->oMySql->insertRow(MySqlManager::USERS_TABLE, $asData); + $iUserId = $this->oMySql->insertRow(Db::USERS_TABLE, $asData); return $this->logMeIn($sLogin, $sPass); } return false; @@ -187,7 +187,7 @@ class Session extends PhpObject public function logMeIn($sLogin, $sPass) { $bResult = false; - $asUser = $this->oMySql->selectRow(MySqlManager::USERS_TABLE, array('user'=>$sLogin)); + $asUser = $this->oMySql->selectRow(Db::USERS_TABLE, array('user'=>$sLogin)); if(!$asUser) { $this->addError('Utilisateur inconnu'); @@ -198,7 +198,7 @@ class Session extends PhpObject } else { - $this->setSession($asUser[MySqlManager::getId(MySqlManager::USERS_TABLE)], $sLogin); + $this->setSession($asUser[Db::getId(Db::USERS_TABLE)], $sLogin); $bResult = true; } return $bResult; @@ -228,9 +228,9 @@ class Session extends PhpObject $asConstraints = array('user'=>$sUserName); if($iUserId>0) { - $asConstraints[MySqlManager::getId(MySqlManager::USERS_TABLE)] = $iUserId; + $asConstraints[Db::getId(Db::USERS_TABLE)] = $iUserId; } - return $this->oMySql->selectValue(MySqlManager::USERS_TABLE, 'COUNT(1)', $asConstraints); + return $this->oMySql->selectValue(Db::USERS_TABLE, 'COUNT(1)', $asConstraints); } public function logMeOut() @@ -534,7 +534,7 @@ class MyThoughts extends PhpObject function __construct() { parent::__construct(); - $this->oMySql = new MySqlManager(); + $this->oMySql = new Db(); $this->oSession = new Session($this->oMySql); $this->oCalendar = new Calendar($this->oMySql, $this->oSession); $this->oMainMask = new Mask('index'); @@ -589,9 +589,9 @@ class MyThoughts extends PhpObject public function updateThought($iThoughtId, $sThought) { $asValues = array('thought'=>$this->encodeThought($sThought)); - $asConstraints = array( MySqlManager::getId(MySqlManager::THOUGHTS_TABLE)=>$iThoughtId, - MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId()); - $this->oMySql->updateRow(MySqlManager::THOUGHTS_TABLE, $asConstraints, $asValues); + $asConstraints = array( Db::getId(Db::THOUGHTS_TABLE)=>$iThoughtId, + Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId()); + $this->oMySql->updateRow(Db::THOUGHTS_TABLE, $asConstraints, $asValues); } @@ -635,8 +635,8 @@ class MyThoughts extends PhpObject { if(!array_key_exists($sSettingName, $this->asSettings)) { - $asConstraint = array(MySqlManager::getText(MySqlManager::SETTINGS_TABLE)=>$sSettingName, MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId()); - $oValue = $this->oMySql->selectValue(MySqlManager::SETTINGS_TABLE, 'value', $asConstraint); + $asConstraint = array(Db::getText(Db::SETTINGS_TABLE)=>$sSettingName, Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId()); + $oValue = $this->oMySql->selectValue(Db::SETTINGS_TABLE, 'value', $asConstraint); $this->asSettings[$sSettingName] = (!$oValue)?self::getDefaultSetting($sSettingName):$oValue; } return $this->asSettings[$sSettingName]; @@ -644,7 +644,7 @@ class MyThoughts extends PhpObject private function setSetting($sValue, $sSettingName) { - $this->oMySql->insertUpdateRow(MySqlManager::SETTINGS_TABLE, array('setting'=>$sSettingName, MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId()), array('value'=>$sValue)); + $this->oMySql->insertUpdateRow(Db::SETTINGS_TABLE, array('setting'=>$sSettingName, Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId()), array('value'=>$sValue)); } public function setSettings($asSettings) @@ -669,9 +669,9 @@ class MyThoughts extends PhpObject if($iThoughtId!=0) { //load a thought - $asConstraints = array( MySqlManager::getId(MySqlManager::THOUGHTS_TABLE)=>$iThoughtId, - MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId()); - $asThought = $this->oMySql->selectRow(MySqlManager::THOUGHTS_TABLE, $asConstraints); + $asConstraints = array( Db::getId(Db::THOUGHTS_TABLE)=>$iThoughtId, + Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId()); + $asThought = $this->oMySql->selectRow(Db::THOUGHTS_TABLE, $asConstraints); $sThought = $this->decodeThought($asThought['thought']); $iThoughtTime = 'Saved at '.date(self::LAYOUT_TIME_FORMAT, strtotime($asThought['led'])); } @@ -694,8 +694,8 @@ class MyThoughts extends PhpObject $sMySqlDate = date(self::MYSQL_DATE_FORMAT, $iTimeStamp); $sLayoutDate = date(self::LAYOUT_DATE_FORMAT, $iTimeStamp); - $asConstraints = array('DATE(led)'=>$sMySqlDate, MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId()); - $asThougths = $this->oMySql->selectRows(array('from'=>MySqlManager::THOUGHTS_TABLE, 'constraint'=>$asConstraints)); + $asConstraints = array('DATE(led)'=>$sMySqlDate, Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId()); + $asThougths = $this->oMySql->selectRows(array('from'=>Db::THOUGHTS_TABLE, 'constraint'=>$asConstraints)); $this->setPage('read_thought'); $this->setPageTitle('Thoughts on '.$sLayoutDate); @@ -825,8 +825,8 @@ class Calendar extends PhpObject { //TODO essayer avec selectRows $sQuery = "SELECT DATE_FORMAT(led, '%d') AS day - FROM ".MySqlManager::THOUGHTS_TABLE." - WHERE ".MySqlManager::getId(MySqlManager::USERS_TABLE)." = ".$this->oSession->getUserId()." + FROM ".Db::THOUGHTS_TABLE." + WHERE ".Db::getId(Db::USERS_TABLE)." = ".$this->oSession->getUserId()." AND YEAR(led) = ".$this->iYear." AND MONTH(led) = ".$this->iMonth." GROUP BY day diff --git a/inc/auth.php b/inc/auth.php index 2aedf19..0e07606 100755 --- a/inc/auth.php +++ b/inc/auth.php @@ -9,15 +9,15 @@ class Auth extends PhpObject /** * Database Connection - * @var MySqlManager + * @var Db */ - private $oMySql; + private $oDb; private $iUserId; private $sApiKey; - public function __construct($oMySql, $sApiKey='', $bAutoLogin=true) + public function __construct($oDb, $sApiKey='', $bAutoLogin=true) { - $this->oMySql = $oMySql; + $this->oDb = $oDb; $this->setUserId(0); $this->sApiKey = $sApiKey; if($bAutoLogin) $this->autoLogIn(); @@ -47,12 +47,12 @@ class Auth extends PhpObject $sPassToken = substr(strstr($sToken, self::TOKEN_SEP), strlen(self::TOKEN_SEP)); if($sLoginToken!='' && $sPassToken!='') { - $asEmpl = $this->oMySql->selectRow(MyThoughts::USER_TABLE, array("MD5(".MySqlManager::getText(MyThoughts::USER_TABLE).")"=>$sLoginToken)); + $asEmpl = $this->oDb->selectRow(MyThoughts::USER_TABLE, array("MD5(".Db::getText(MyThoughts::USER_TABLE).")"=>$sLoginToken)); if(!empty($asEmpl)) { if(self::CheckPassword($sPassToken, $asEmpl['pass'])) { - $this->setUserId($asEmpl[MySqlManager::getId(MyThoughts::USER_TABLE)]); + $this->setUserId($asEmpl[Db::getId(MyThoughts::USER_TABLE)]); $this->resetAuthCookie($this->getUserId()); } else $sDesc = 'wrong password'; @@ -74,17 +74,17 @@ class Auth extends PhpObject $iUserId = addslashes(strstr($sCookie, self::TOKEN_SEP, true)); $sCookie = substr(strstr($sCookie, self::TOKEN_SEP), strlen(self::TOKEN_SEP)); - $asEmpl = $this->oMySql->selectRow(MyThoughts::USER_TABLE, array(MySqlManager::getId(MyThoughts::USER_TABLE)=>$iUserId)); + $asEmpl = $this->oDb->selectRow(MyThoughts::USER_TABLE, array(Db::getId(MyThoughts::USER_TABLE)=>$iUserId)); if(!empty($asEmpl)) { if($sCookie==$asEmpl['cookie']) { - $this->setUserId($asEmpl[MySqlManager::getId(MyThoughts::USER_TABLE)]); + $this->setUserId($asEmpl[Db::getId(MyThoughts::USER_TABLE)]); //Reset pass once a day if(mb_substr($asEmpl['led'], 0, 10) != date('Y-m-d')) $this->resetAuthCookie($this->getUserId()); } - else $this->addError('token corrompu pour le user '.$asEmpl[MySqlManager::getId(MyThoughts::USER_TABLE)]); + else $this->addError('token corrompu pour le user '.$asEmpl[Db::getId(MyThoughts::USER_TABLE)]); } else $this->addError('Utilisateur '.$iUserId.' inconnu'); } @@ -93,11 +93,11 @@ class Auth extends PhpObject public function addUser($sSafeNickName, $sNickName, $bLogMeIn=false) { $sPass = self::HashPassword(self::getLoginToken($sSafeNickName)); - $bExist = $this->oMySql->pingValue(MyThoughts::USER_TABLE, array(MySqlManager::getText(MyThoughts::USER_TABLE)=>$sSafeNickName)); + $bExist = $this->oDb->pingValue(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$sSafeNickName)); if($bExist) return -1; else { - $iUserId = $this->oMySql->insertRow(MyThoughts::USER_TABLE, array(MySqlManager::getText(MyThoughts::USER_TABLE)=>$sSafeNickName, 'nickname'=>$sNickName)); + $iUserId = $this->oDb->insertRow(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$sSafeNickName, 'nickname'=>$sNickName, 'pass'=>$sPass)); if($iUserId>0) { $this->resetPass($iUserId); @@ -115,17 +115,17 @@ class Auth extends PhpObject private function resetPass($iUserId=0) { - $sUserIdCol = MySqlManager::getId(MyThoughts::USER_TABLE); - $sUserTextCol = MySqlManager::getText(MyThoughts::USER_TABLE); + $sUserIdCol = Db::getId(MyThoughts::USER_TABLE); + $sUserTextCol = Db::getText(MyThoughts::USER_TABLE); $asInfo = array('select'=>array($sUserIdCol, $sUserTextCol), 'from'=>MyThoughts::USER_TABLE); if($iUserId>0) $asInfo['constraint'] = array($sUserIdCol=>$iUserId); - $asUsers = $this->oMySql->selectRows($asInfo); + $asUsers = $this->oDb->selectRows($asInfo); foreach($asUsers as $asUser) { $sToken = self::HashPassword(self::getLoginToken($asUser[$sUserTextCol])); - $this->oMySql->updateRow(MyThoughts::USER_TABLE, array(MySqlManager::getId(MyThoughts::USER_TABLE)=>$asUser[$sUserIdCol]), array('pass'=>$sToken)); + $this->oDb->updateRow(MyThoughts::USER_TABLE, array(Db::getId(MyThoughts::USER_TABLE)=>$asUser[$sUserIdCol]), array('pass'=>$sToken)); } } @@ -143,7 +143,7 @@ class Auth extends PhpObject $sNewPass = self::getAuthCookie($iUserId); $iTimeLimit = time()+60*60*24*30; //mysqli_query($con, "UPDATE EMPLOYEE SET COOKIE = '".addslashes($sNewPass)."' WHERE ID = ".$iUserId); - $this->oMySql->updateRow(MyThoughts::USER_TABLE, array(MySqlManager::getId(MyThoughts::USER_TABLE)=>$iUserId), array("cookie"=>$sNewPass)); + $this->oDb->updateRow(MyThoughts::USER_TABLE, array(Db::getId(MyThoughts::USER_TABLE)=>$iUserId), array("cookie"=>$sNewPass)); setcookie(self::USER_COOKIE_PASS, $iUserId.self::TOKEN_SEP.$sNewPass, $iTimeLimit); } diff --git a/inc/calendar.php b/inc/calendar.php index 610af0c..eb42960 100755 --- a/inc/calendar.php +++ b/inc/calendar.php @@ -40,8 +40,8 @@ class Calendar extends PhpObject { //TODO essayer avec selectRows $sQuery = "SELECT DATE_FORMAT(led, '%d') AS day - FROM ".MySqlManager::THOUGHTS_TABLE." - WHERE ".MySqlManager::getId(MySqlManager::USERS_TABLE)." = ".$this->oSession->getUserId()." + FROM ".Db::THOUGHTS_TABLE." + WHERE ".Db::getId(Db::USERS_TABLE)." = ".$this->oSession->getUserId()." AND YEAR(led) = ".$this->iYear." AND MONTH(led) = ".$this->iMonth." GROUP BY day diff --git a/inc/mythoughts.php b/inc/mythoughts.php index 9c8b4da..3556e34 100755 --- a/inc/mythoughts.php +++ b/inc/mythoughts.php @@ -41,9 +41,9 @@ class MyThoughts extends PhpObject /** * Database Connection - * @var MySqlManager + * @var Db */ - private $oMySql; + private $oDb; /** * @@ -67,22 +67,22 @@ class MyThoughts extends PhpObject $this->setContext($sProcessPage); //Load classes - $this->oClassManagement->incClass('mysqlmanager'); + $this->oClassManagement->incClass('db'); $this->oClassManagement->incClass('auth', true); //$this->oClassManagement->incClass('calendar', true); //Init objects - $this->oMySql = new MySqlManager(Settings::DB_SERVER, Settings::DB_LOGIN, Settings::DB_PASS, Settings::DB_NAME, self::getSqlOptions() , Settings::DB_ENC); - if($this->oMySql->sDbState == MySqlManager::DB_NO_DATA) $this->install(); - else $this->oAuth = new Auth($this->oMySql, Settings::API_KEY); + $this->oDb = new Db(Settings::DB_SERVER, Settings::DB_LOGIN, Settings::DB_PASS, Settings::DB_NAME, self::getSqlOptions() , Settings::DB_ENC); + if($this->oDb->sDbState == Db::DB_NO_DATA) $this->install(); + else $this->oAuth = new Auth($this->oDb, Settings::API_KEY); } private function install() { - $this->oAuth = new Auth($this->oMySql, Settings::API_KEY, false); + $this->oAuth = new Auth($this->oDb, Settings::API_KEY, false); //Install DB - $this->oMySql->install(); + $this->oDb->install(); $this->addUser('franzz'); } @@ -156,7 +156,7 @@ class MyThoughts extends PhpObject return file_get_contents($sPageFile); } - /* DB structure. See MySqlManager::__construct */ + /* DB structure. See Db::__construct */ private static function getSqlOptions() { @@ -164,26 +164,26 @@ class MyThoughts extends PhpObject ( 'tables' => array ( - self::USER_TABLE =>array(MySqlManager::getText(self::USER_TABLE), 'nickname', 'pass', 'cookie'), - self::THOUGHT_TABLE =>array(MySqlManager::getId(self::USER_TABLE), - MySqlManager::getText(self::THOUGHT_TABLE)), - self::SETTINGS_TABLE=>array(MySqlManager::getId(self::USER_TABLE), - MySqlManager::getText(self::SETTINGS_TABLE), + self::USER_TABLE =>array(Db::getText(self::USER_TABLE), 'nickname', 'pass', 'cookie'), + self::THOUGHT_TABLE =>array(Db::getId(self::USER_TABLE), + Db::getText(self::THOUGHT_TABLE)), + self::SETTINGS_TABLE=>array(Db::getId(self::USER_TABLE), + Db::getText(self::SETTINGS_TABLE), 'value') ), 'types' => array ( - MySqlManager::getText(self::USER_TABLE)=>"varchar(50) NOT NULL", + Db::getText(self::USER_TABLE)=>"varchar(50) NOT NULL", 'nickname'=>'varchar(60) NOT NULL', - 'pass'=>"varchar(256) NOT NULL", - 'cookie'=>"varchar(255) NOT NULL", - MySqlManager::getText(self::THOUGHT_TABLE)=>"longtext", - MySqlManager::getText(self::SETTINGS_TABLE)=>"varchar(20) NOT NULL", + 'pass'=>"varchar(256)", + 'cookie'=>"varchar(255)", + Db::getText(self::THOUGHT_TABLE)=>"longtext", + Db::getText(self::SETTINGS_TABLE)=>"varchar(20) NOT NULL", 'value'=>"varchar(20) NOT NULL" ), 'constraints' => array ( - self::USER_TABLE=>"UNIQUE KEY `username` (`".MySqlManager::getText(self::USER_TABLE)."`)" + self::USER_TABLE=>"UNIQUE KEY `username` (`".Db::getText(self::USER_TABLE)."`)" ), 'cascading_delete' => array ( @@ -222,10 +222,10 @@ class MyThoughts extends PhpObject } else { - $asKeys = array(MySqlManager::getId(self::USER_TABLE) => $this->oAuth->getUserId(), - MySqlManager::getId(self::THOUGHT_TABLE)=> $iThoughtId); - $asThought = array(MySqlManager::getText(self::THOUGHT_TABLE) => self::encodeThought($sThought)); - $iThoughtId = $this->oMySql->updateRow(self::THOUGHT_TABLE, $asKeys, $asThought); + $asKeys = array(Db::getId(self::USER_TABLE) => $this->oAuth->getUserId(), + Db::getId(self::THOUGHT_TABLE)=> $iThoughtId); + $asThought = array(Db::getText(self::THOUGHT_TABLE) => self::encodeThought($sThought)); + $iThoughtId = $this->oDb->updateRow(self::THOUGHT_TABLE, $asKeys, $asThought); $sDesc = 'updated'; } $bSuccess = ($iThoughtId>0); @@ -247,9 +247,9 @@ class MyThoughts extends PhpObject if($iUserId==-1) $iUserId = $this->oAuth->getUserId(); if($iUserId!=0) { - $asThought = array( MySqlManager::getId(self::USER_TABLE) => $iUserId, - MySqlManager::getText(self::THOUGHT_TABLE) => self::encodeThought($sThought)); - $ithoughtId = $this->oMySql->insertRow(self::THOUGHT_TABLE, $asThought); + $asThought = array( Db::getId(self::USER_TABLE) => $iUserId, + Db::getText(self::THOUGHT_TABLE) => self::encodeThought($sThought)); + $ithoughtId = $this->oDb->insertRow(self::THOUGHT_TABLE, $asThought); } else $this->addError('Adding a thought with no user id'); return $ithoughtId; @@ -260,8 +260,8 @@ class MyThoughts extends PhpObject $asThoughtInfo = array(); if($iThoughtId>0) { - $asThoughtInfo = $this->oMySql->selectRow(self::THOUGHT_TABLE, $iThoughtId); - if(!$bThoughtContent) unset($asThoughtInfo[MySqlManager::getText(self::THOUGHT_TABLE)]); + $asThoughtInfo = $this->oDb->selectRow(self::THOUGHT_TABLE, $iThoughtId); + if(!$bThoughtContent) unset($asThoughtInfo[Db::getText(self::THOUGHT_TABLE)]); } else $this->addError('getting thought info with no thought id'); return $asThoughtInfo; diff --git a/masks/index.html b/masks/index.html index be88851..ed93ba6 100755 --- a/masks/index.html +++ b/masks/index.html @@ -3,15 +3,11 @@ - - - - - + + + - - My Thoughts diff --git a/masks/write.html b/masks/write.html index d986aaf..b71ff79 100755 --- a/masks/write.html +++ b/masks/write.html @@ -5,18 +5,18 @@ 1 - +
+

So, I'm there, wondering about myself and my future - such a luxury by the way - when suddenly, someone approaches. mid-40s i'd say, elegant cold women, the kind you've learned not to talk to, to eventually avoid feeling repressed, or bad for yourself, or both.

+

Anyhow, it would seem that in this particular situation, the choice wasn't given to me to decide whether or not to talk to that precise women. She seats down next to me and engage a conversation. 'How is it you're here today?' I'm already regretting not having gone away when i still had the chance.

+

'Hello to you too' I say, still willing to show some manhood, even though I already know this women crushes manhood by pairs as a breakfast ritual.

+

In-extremist, I manage to babble some excuses about a rigorous lunch break time and leave the premises.

+

So, I'm there, wondering about myself and my future - such a luxury by the way - when suddenly, someone approaches. mid-40s i'd say, elegant cold women, the kind you've learned not to talk to, to eventually avoid feeling repressed, or bad for yourself, or both.

+

Anyhow, it would seem that in this particular situation, the choice wasn't given to me to decide whether or not to talk to that precise women. She seats down next to me and engage a conversation. 'How is it you're here today?' I'm already regretting not having gone away when i still had the chance.

+

'Hello to you too' I say, still willing to show some manhood, even though I already know this women crushes manhood by pairs as a breakfast ritual.

+

In-extremist, I manage to babble some excuses about a rigorous lunch break time and leave the premises.

+