isLoggedIn(); $sResult = ''; if($sAction=='logmein') $sResult = $oMyThoughts->logMeIn($sToken); elseif($sAction!='' && $bLoggedIn) { switch ($sAction) { case 'load': $sResult = $oMyThoughts->getThought($iId, MyThoughts::JSON); break; case 'update': $sResult = $oMyThoughts->updateThought($sContent, $iId); break; default: $sResult = MyThoughts::getJsonResult(false, MyThoughts::NOT_FOUND); } } elseif($sAction!='' && !$bLoggedIn) { if($oMyThoughts->checkApiKey($iApiKey)) { switch ($sAction) { case '': //$sResult = $oMyThoughts->apifunction(); break; default: $sResult = MyThoughts::getJsonResult(false, MyThoughts::NOT_FOUND); } } elseif($sAction=='register') $sResult = $oMyThoughts->register($sToken, $sNickName); else $sResult = MyThoughts::getJsonResult(false, MyThoughts::UNAUTHORIZED); } else $sResult = $oMyThoughts->getPage(); $sDebug = ob_get_clean(); if(Settings::DEBUG && $sDebug!='') $oMyThoughts->addUncaughtError($sDebug); echo $sResult; /* //load classes session_start(); require_once 'config.php'; //clean sent values cleanPost($_POST); cleanPost($_GET); cleanPost($_REQUEST); //general $sPage = (isset($_GET['p']) && $_GET['p']!='')?$_GET['p']:'w'; $sPostToken = isset($_POST['post_token'])?$_POST['post_token']:''; //logon $sLogin = (isset($_POST['login']) && $_POST['login']!='Nickname')?$_POST['login']:''; $sPass = (isset($_POST['pass']) && $_POST['pass']!='Password')?$_POST['pass']:''; $bRegister = (isset($_POST['register']) && $_POST['register']==1); //writing pad $sThought = isset($_POST['thoughts'])?$_POST['thoughts']:''; $iThoughtId = (isset($_POST['thought_id']) && $_POST['thought_id']!='')?$_POST['thought_id']:0; //update or insert $bFinishedWriting = isset($_POST['finished']); //calendar $iDay = isset($_GET['d'])?$_GET['d']:date(MyThoughts::URL_DATE_FORMAT); //d = yyyymmdd $iCalYear = isset($_GET[Calendar::CAL_YEAR])?$_GET[Calendar::CAL_YEAR]:0; //cy = yyyy $iCalMonth = isset($_GET[Calendar::CAL_MONTH])?$_GET[Calendar::CAL_MONTH]:0; //cm = m $oMyThougths = new MyThoughts(); $bValidPost = ($sPostToken!='' && $oMyThougths->checkPostToken($sPostToken)); if($bValidPost) { if($bRegister) { $oMyThougths->register($sLogin, $sPass); $sPage = 'r'; } elseif($sLogin!='' && $sPass!='') { $oMyThougths->logMeIn($sLogin, $sPass); } } //if loggued in if(!$oMyThougths->isLogguedIn()) { $oMyThougths->logonPage($sLogin); } else { $oMyThougths->activateMenu(); $oMyThougths->setCalendarDate(); switch($sPage) { case 'w': //write a thought if($bValidPost && $sThought!='' && $sThought!='Talk to me.') { if($iThoughtId==0) { $iThoughtId = $oMyThougths->addThought($sThought); } else { $oMyThougths->updateThought($iThoughtId, $sThought); } } if($bFinishedWriting) { $oMyThougths->readingPage(); } else { $oMyThougths->writingPage($iThoughtId); } break; case 'r': //read a thought (per day) if($iDay<=0 || !$oMyThougths->readingPage(strtotime($iDay))) { $oMyThougths->writingPage(); } break; case 's': // go to settings page if($bValidPost) { $asSettings = array_intersect_key($_POST, array_flip($oMyThougths->getSettingsList())); $oMyThougths->setSettings($asSettings); $oMyThougths->writingPage(); } else { $oMyThougths->settingsPage(); } break; case 'q': //quit $oMyThougths->logMeOut(); } if($iCalYear!=0 && $iCalMonth!=0) { $oMyThougths->setCalendarDate($iCalYear, $iCalMonth); } } echo $oMyThougths->getPage(); */ ?>