Beispiel #1
0
 private function validate()
 {
     if (false === ($this->client = GWF_Client::getByToken(Common::getGet('token')))) {
         return $this->module->error('err_token');
     }
     $datestamp = Common::getGet('datestamp', '');
     if (!GWF_Time::isValidDate($datestamp, true, GWF_Date::LEN_SECOND)) {
         return $this->module->error('err_datestamp');
     }
     $this->datestamp = $datestamp;
     return false;
 }
Beispiel #2
0
 public function execute()
 {
     $_GET['ajax'] = 1;
     header('Content-Type: text/plain');
     if (false === ($date = Common::getGetString('datestamp', false))) {
         return 'Missing parameter: datestamp.';
     }
     if (!GWF_Time::isValidDate($date, false, GWF_Date::LEN_SECOND)) {
         return 'Error in parameter: datestamp.';
     }
     $amt = Common::clamp(Common::getGetInt('amt', 5), 1, self::MAX_OUT);
     return $this->templateOutput($date, $amt);
 }
Beispiel #3
0
 private function sanitize()
 {
     if (false === Common::getGet('no_session')) {
         return 'The mandatory parameter \'no_session\' is not set. Try \'&no_session=1\'.';
     }
     # Validate Date
     if (false !== ($date = Common::getGet('datestamp'))) {
         if (GWF_Time::isValidDate($date, false, GWF_Date::LEN_SECOND)) {
             $this->time = GWF_Time::getTimestamp($date);
         }
     }
     # Validate username
     if (false !== ($username = Common::getGet('username'))) {
         if (false === ($this->user = GWF_User::getByName($username))) {
             return GWF_HTML::err('ERR_UNKNOWN_USER');
         }
         if (false !== ($error = $this->module->isExcludedFromAPI($this->user, Common::getGet('password')))) {
             return $error;
         }
     }
     # Validate sitename
     if (false !== ($sitename = Common::getGet('sitename'))) {
         if (false === ($this->site = WC_Site::getByName($sitename)) && false === ($this->site = WC_Site::getByClassName($sitename))) {
             return $this->module->error('err_site');
         }
     }
     # Validate Limit
     if (in_array(Common::getGet('masterkey'), self::$masterKeys)) {
         $max_limit = PHP_INT_MAX;
     } elseif ($this->user === false && $this->site === false) {
         $max_limit = self::MAX_LIMIT_ALL;
     } else {
         $max_limit = self::MAX_LIMIT_SINGLE;
     }
     $this->limit = Common::clamp(Common::getGet('limit', self::DEFAULT_LIMIT), 1, $max_limit);
     //		if (!isset($no_block))
     //		{
     //			require_once 'core/module/WeChall/WC_API_Block.php';
     //			if (WC_API_Block::isBlocked())
     //			{
     //				return $this->module->error('err_api_block');
     //			}
     //		}
     return false;
 }
Beispiel #4
0
 public function validate_birthdate(Module_Register $module, $arg)
 {
     if (!GWF_Time::isValidDate($arg, true, 8)) {
         return $this->module->lang('err_birthdate');
     }
     if (0 < ($minage = $this->module->getMinAge())) {
         if ($minage > ($age = GWF_Time::getAge($arg))) {
             return $this->module->lang('err_minage', array($minage));
         }
     }
     return false;
 }
Beispiel #5
0
 public static function validateDate($m, $key, $arg, $datelen, $allow_zero = true, $unset = true)
 {
     $_POST[$key] = $arg = trim($arg);
     if (!GWF_Time::isValidDate($arg, $allow_zero, $datelen)) {
         if ($unset) {
             $_POST[$key] = '';
         }
         return $m->lang('err_' . $key);
     }
     return false;
 }
Beispiel #6
0
 public function fetchEntries($gwf_date, $limit)
 {
     if (false === ($content = $this->sendRequest($gwf_date, $limit))) {
         return false;
     }
     $entries = array();
     $lines = explode("\n", $content);
     foreach ($lines as $line) {
         if ('' === ($line = trim($line))) {
             continue;
         }
         $thedata = explode('::', $line);
         if (count($thedata) !== 6) {
             echo 'Invalid line in dog_wc_forum: ' . $line . PHP_EOL;
             return false;
         }
         $thedata = array_map(array(__CLASS__, 'unescape_csv_like'), $thedata);
         # Fetch line
         list($threadid, $lastdate, $boardid, $url, $username, $title) = $thedata;
         if ($lastdate < $gwf_date) {
             continue;
         }
         if (!Common::isNumeric($threadid)) {
             echo 'Invalid threadid in dog_wc_forum: ' . $line . PHP_EOL;
             return false;
         }
         if (!GWF_Time::isValidDate($lastdate, false, 14)) {
             echo 'Invalid date in dog_wc_forum: ' . $line . PHP_EOL;
             return false;
         }
         if (!Common::isNumeric($boardid)) {
             echo 'Invalid boardid in dog_wc_forum: ' . $line . PHP_EOL;
             return false;
         }
         $entries[] = new Dog_ForumEntry($thedata);
     }
     if (count($entries) > 0) {
         $deleting = 1;
         foreach ($entries as $id => $entry) {
             $entry instanceof Dog_ForumEntry;
             if ($entry->getLastDate() === $this->getDate()) {
                 if ($deleting) {
                     if ($entry->getThreadID() === $this->getLast()) {
                         $deleting = 0;
                     }
                     unset($entries[$id]);
                 }
             }
         }
     }
     return array_values($entries);
 }
Beispiel #7
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<gwf_date>|<countrycode_iso1>]. Print the current bot-time, a gwf_date as uniox timestamp, or the current time in a country.', 'bot' => 'The bot\'s time is %s %s. Unix timestamp: %s', 'err_tz_stub' => 'I cannot parse timezones yet. I blame Hirsch.', 'err_date' => 'Invalid gwf_date!', 'out' => 'The date %s will have the unix timestamp of %d.'));
$plugin = Dog::getPlugin();
$message = $plugin->msg();
if ($message === '') {
    $timezone = date('T');
    $gdo_date = GWF_Time::getDate(GWF_Date::LEN_SECOND);
    $plugin->rply('bot', array(GWF_Time::displayDate($gdo_date), $timezone, time()));
} elseif (preg_match('/^[a-z]{2}$/i', $message)) {
    $plugin->rply('err_tz_stub');
} elseif (preg_match('/^[0-9]{2,21}$/', $message)) {
    if (!GWF_Time::isValidDate($message, false, strlen($message), 100000)) {
        $plugin->rply('err_date');
    } else {
        $plugin->rply('out', array(GWF_Time::displayDate($message), GWF_Time::getTimestamp($message)));
    }
} else {
    $plugin->showHelp();
}
Beispiel #8
0
 private function validate()
 {
     $this->validateDimension();
     if (false === ($this->user1 = GWF_User::getByName(Common::getRequest('user1', '')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if (false === ($this->user2 = GWF_User::getByName(Common::getRequest('user2', '')))) {
         //			return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     // Check end date
     $this->end = sprintf('%04d%02d%02d', intval(Common::getGet('y', 0), 10), intval(Common::getGet('m', 0), 10), intval(Common::getGet('d', 0), 10));
     if (!GWF_Time::isValidDate($this->end, false, GWF_Date::LEN_DAY)) {
         return $this->module->error('err_end_date');
     }
     // Check start date
     $regdate1 = $this->user1->getVar('user_regdate');
     $regdate2 = $this->user2 === false ? $regdate1 : $this->user2->getVar('user_regdate');
     $this->start = $regdate1 < $regdate2 ? $regdate1 : $regdate2;
     $this->start = substr($this->start, 0, GWF_Date::LEN_DAY);
     if (0 < ($nm = intval(Common::getGet('nm', 0)))) {
         $time = GWF_Time::getTimestamp($this->end);
         $time -= $nm * GWF_Time::ONE_MONTH;
         $time = GWF_Time::getDate(GWF_Date::LEN_DAY, $time);
         if ($time > $this->start) {
             $this->start = $time;
         }
     }
     //		var_dump($this->start);
     // Check sites
     $sites = Common::getGetString('sites');
     if ($sites === 'all') {
         if ($this->user2 === false) {
             $this->sites = WC_Site::getLinkedSites($this->user1->getID());
         } else {
             $this->sites = WC_Site::getLinkedSitesVS2($this->user1->getID(), $this->user2->getID());
         }
         $temp = array();
         foreach ($this->sites as $site) {
             $temp[$site->getID()] = $site;
         }
         $this->sites = $temp;
     } else {
         $this->sites = array();
         $sites = explode(',', $sites);
         foreach ($sites as $siteid) {
             //				var_dump($siteid);
             $siteid = intval(trim($siteid));
             if (false !== ($site = WC_Site::getByID($siteid))) {
                 $this->sites[$siteid] = $site;
             }
         }
     }
     //		if (count($this->sites) === 0) {
     //			return $this->module->error('err_no_sites');
     //		}
     // Options
     $opts = explode(',', Common::getGet('opt', ''));
     foreach ($opts as $opt) {
         $opt = trim($opt);
         if ($opt === 'icons') {
             $this->withIcons = true;
         } elseif ($opt === 'nums') {
             $this->withNumbers = true;
         } elseif ($opt === 'zoom') {
             $this->withZoom = true;
         }
     }
     // All ok
     return false;
 }
Beispiel #9
0
 public function validate_birthdate(Module_Account $module, $arg)
 {
     if (false === GWF_Time::isValidDate($arg, true, 8)) {
         return $this->module->lang('err_birthdate');
     }
     return false;
 }
Beispiel #10
0
 private function cacheManifestB(Module_VersionClient $module, $fullpath)
 {
     $this->manifest = file($fullpath);
     if (1 !== preg_match('/^GWF2:DATESTAMP:(\\d{' . GWF_Date::LEN_SECOND . '})$/D', $this->manifest[0], $matches)) {
         return $module->error('err_manifest2');
     }
     $this->datestamp = $matches[1];
     if (!GWF_Time::isValidDate($this->datestamp, false, GWF_Date::LEN_SECOND)) {
         return $module->error('err_manifest3');
     }
     @unlink($fullpath);
     unset($this->manifest[0]);
     return false;
 }