Example #1
0
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
}
require_once MINDMETO_ROOT . 'inc/session.php';
require_once MINDMETO_ROOT . 'inc/reminder.php';
require_once MINDMETO_ROOT . 'inc/twitter/helper.php';
switch ($_REQUEST['a']) {
    /*
    	Handles the removal of a reminder from the web interface
    */
    case "remove":
        $id = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? intval($_REQUEST['id']) : false;
        $result = false;
        if ($id !== false && $session->loggedIn) {
            $result = cancelReminder($session->userId, $id);
        }
        if (!isAjax()) {
            header("Location: list.php");
        } else {
            echo json_encode($result);
        }
        break;
        /* 
        	Search the reminder table for the latest reminders set and send them 
        	out in JSON format for Javascript usage
        */
    /* 
    	Search the reminder table for the latest reminders set and send them 
    	out in JSON format for Javascript usage
    */
Example #2
0
 function parseCommand($type, $userId, $command)
 {
     global $db;
     $commandParsed = true;
     $command = trim(strtolower($command));
     if (substr($command, 0, 12) == "timezone gmt") {
         $offset = trim(substr($command, 12, 1));
         if ($offset == "+" || $offset == "-" || trim($command) == "timezone gmt") {
             if (trim($command) == "timezone gmt") {
                 $timezone = 0;
                 $offset = "+";
             } else {
                 $timezone = trim(substr($command, 13, strlen($command)));
             }
             if (is_numeric($timezone)) {
                 $dmTimezone = $offset == "+" ? '+' . $timezone : '-' . $timezone;
                 $finalTimezoneHour = intval($timezone) >= 0 && intval($timezone) <= 9 ? '0' . $timezone : $timezone;
                 $finalTimezone = $offset == "+" ? '+' . $finalTimezoneHour . ':00' : '-' . $finalTimezoneHour . ':00';
                 $this->updateUserSettings($userId, 'user_timezone', $finalTimezone);
                 return "All done! Your timezone has been set to GMT{$dmTimezone}";
             }
         }
         return "Whoops! You must provide a numeric value (number of hours relative to GMT) to set a timezone.";
     } else {
         if (substr($command, 0, 12) == "default time") {
             $defaultTime = trim(substr($command, 13, strlen($command)));
             if (is_numeric($defaultTime) && $defaultTime >= 0 && $defaultTime <= 23) {
                 $this->updateUserSettings($userId, 'user_default_time', $defaultTime);
                 return "All done! Your default reminder time has been set to " . $defaultTime . ".";
             } else {
                 return "Whoops! You must provide a numeric value (0 to 23) to set a default reminder time.";
             }
         } else {
             if ($command == "list reminders") {
                 return "Visit http://mindmeto.com/list/ to view your reminders.";
             } else {
                 if (substr($command, 0, 8) == "cancel #") {
                     $id = trim(substr($command, 8, strlen($command)));
                     if (is_numeric($id)) {
                         if (cancelReminder($userId, $id)) {
                             return "All done! The reminder with ID #{$id} has been removed.";
                         } else {
                             return "There was a problem deleting the reminder you specified.";
                         }
                     } else {
                         return "You must provide a numeric ID to delete a reminder. If you need to check a reminders ID, visit http://mindmeto.com/list/";
                     }
                 } else {
                     if ($command == "confirmations on") {
                         $this->updateUserSettings($userId, 'user_allow_confirmations', 1);
                         return "All done! You have now turned Direct Message confirmations on.";
                     } else {
                         if ($command == "confirmations off") {
                             $this->updateUserSettings($userId, 'user_allow_confirmations', 0);
                             if ($type == "web") {
                                 return "All done! You have now turned Direct Message confirmations off.";
                             } else {
                                 return "All done! You have now turned Direct Message confirmations off (this will be your last one).";
                             }
                         } else {
                             if ($command == "reminders on") {
                                 $this->updateUserSettings($userId, 'user_allow_reminders', 1);
                                 return "All done! You have now turned Direct Message reminders on.";
                             } else {
                                 if ($command == "reminders off") {
                                     $this->updateUserSettings($userId, 'user_allow_reminders', 0);
                                     return "All done! You have now turned Direct Message reminders off";
                                 } else {
                                     $commandParsed = false;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $commandParsed;
 }