Example #1
0
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Code source hosted on https://github.com/Devenet/MoodPicker
*/
use Utils\Cookie;
use Utils\Session;
use Picker\Mood;
use Picker\MoodLevel;
use Core\Config;
if (isset($_POST['mood']) && $this->acceptToken()) {
    $_POST['mood'] = $_POST['mood'] + 0;
    if (!MoodLevel::isValidValue($_POST['mood'])) {
        $this->errorPage('Invalid value', 'The given value for your current mood is unknow.');
    }
    if (!Cookie::Exists('voted') && !Session::Exists('voted')) {
        $m = new Mood($_POST['mood'], time(), Config::IP());
        $m->save();
        Cookie::add('voted', true, Cookie::HOUR * 2);
        Session::add('voted', true);
        header('Location: ./review');
        exit;
    }
    $this->errorPage('Already voted', 'An entry has already been enregistred from your computer. <br />You have to wait some times before submitting an other mood.');
} else {
    $this->getToken();
    $this->assign('good', MoodLevel::GOOD);
    $this->assign('bad', MoodLevel::BAD);
}
Example #2
0
         default:
             $api->error(400);
     }
     break;
 case 'documentation':
     $auth = new Authentification();
     if (!(new Setting('api_display_doc'))->getValue() && !$auth->isLogged()) {
         break;
     }
     $this->page('api/documentation');
     $this->fakePage('api');
     $this->assign('api_path', API::API_PATH);
     $this->assign('api_request', (new Setting('api_requests'))->getValue());
     if (!Cookie::Exists('notice_apidoc')) {
         $this->assign('displayNotice', TRUE);
         $this->assign('cookie_display_name', Cookie::Name('notice_apidoc'));
         $this->register('script_file', 'cookie.min.js');
     }
     break;
 case 'request':
     if (!(new Setting('api_requests'))->getValue()) {
         break;
     }
     $this->fakePage('api');
     switch ($this->request(2)) {
         case 'sent':
             $this->page('api/request_sent');
             break;
         case NULL:
             if (!empty($_POST)) {
                 $this->acceptToken();
Example #3
0
 public function checkTheme()
 {
     // want to update ?
     if (isset($_GET['theme'])) {
         $this->theme->setTheme(htmlspecialchars($_GET['theme']));
         Cookie::Add('theme', $this->theme->getTheme(), Cookie::MONTH);
         $this->template->clean(-1);
     } else {
         if (Cookie::Exists('theme')) {
             $this->theme->setTheme(Cookie::Get('theme'));
         }
     }
 }