예제 #1
0
 public function execute()
 {
     if (false !== Common::getPost('quickjump')) {
         return $this->onQuickjump();
     }
     if (false === ($site = WC_Site::getByName(Common::getGetString('site', NULL)))) {
         return $this->module->error('err_unknown_site');
     }
     $_GET['sid'] = $site->getID();
     return $this->templateHistory($site);
 }
예제 #2
0
파일: SiteAdd.php 프로젝트: sinfocol/gwf3
 public function validate_site_name(Module_WeChall $m, $arg)
 {
     if (false !== WC_Site::getByName($arg)) {
         return $m->lang('err_site_dup');
     }
     $len = GWF_String::strlen($arg);
     $max = $m->cfgMaxSitenameLen();
     if ($len < 1 || $len > $max) {
         return $m->lang('err_site_name', array(1, $max));
     }
     return false;
 }
예제 #3
0
파일: API_Site.php 프로젝트: sinfocol/gwf3
 public function execute()
 {
     GWF_Website::plaintext();
     if (false === Common::getGet('no_session')) {
         die('The mandatory parameter \'no_session\' is not set. Try \'&no_session=1\'.');
     }
     if (false === ($sitename = Common::getGet('sitename'))) {
         die($this->showAllSites());
     }
     if (false === ($site = WC_Site::getByName($sitename)) && false === ($site = WC_Site::getByClassName($sitename))) {
         die($this->module->lang('err_site'));
     }
     die($this->showSite($site));
 }
예제 #4
0
파일: GraphSite.php 프로젝트: sinfocol/gwf3
 private function graph($sitename, $type)
 {
     if (false === ($site = WC_Site::getByName($sitename))) {
         return $this->module->error('err_site');
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_HistorySite.php';
     if (false === GDO::table('WC_HistorySite')->getWhitelistedBy($type, false)) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     $dir = dirname(GWF_JPGRAPH_PATH) . '/';
     require_once $dir . 'jpgraph.php';
     require_once $dir . 'jpgraph_date.php';
     require_once $dir . 'jpgraph_line.php';
     require_once $dir . 'jpgraph_plotline.php';
     return $this->graphB($site, $type);
 }
예제 #5
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;
 }
예제 #6
0
 public function execute()
 {
     $syntax = 'syntax: ' . Common::getAbsoluteURL('remoteupdate.php') . '?sitename=FOO&username=BAR';
     $server = htmlspecialchars($_SERVER['SERVER_NAME'], ENT_QUOTES);
     $unknownsite = 'Join us: ' . Common::getAbsoluteURL('join_us');
     # "Join us: http://$server/join.php";
     $unknownuser = '******' . Common::getAbsoluteURL('register') . ' for global ranking. Please note that the username is case sensitive for remoteupdates.';
     // flag for images. 0=normal text, 1=default image, we can assign different image styles to higher numbers
     $img = (int) Common::getGet('img', 0);
     if ($img === 1) {
         header("Content-Type: image/png");
     }
     if (false === ($sitename = Common::getRequest('sitename'))) {
         $this->outDie($syntax);
     }
     if (false === ($onsitename = Common::getRequest('username'))) {
         $this->outDie($syntax);
     }
     if ($sitename === 'FOO' && $onsitename === 'BAR') {
         $this->outDie('Doh! Not literally!');
     }
     if (false === ($site = WC_Site::getByName($sitename)) && false === ($site = WC_Site::getByClassName($sitename))) {
         $this->outExit($unknownsite);
     }
     $this->module->includeClass('WC_RegAt');
     if (false === ($user = WC_RegAt::getUserByOnsiteName($onsitename, $site->getID()))) {
         $this->outExit($unknownuser);
     }
     # Update him
     $result = $site->onUpdateUser($user);
     $site->saveOption(WC_Site::AUTO_UPDATE, true);
     # Output result
     switch ($img) {
         case 0:
             $this->outResult($result);
             break;
         case 1:
             $this->imgDisplayText($result->getMessage());
             break;
     }
 }
예제 #7
0
파일: API_Bot.php 프로젝트: sinfocol/gwf3
 private function rawOnSiteStats($sitename, $onsitename)
 {
     if (false === ($site = WC_Site::getByName($sitename)) && false === ($site = WC_Site::getByClassName($sitename))) {
         return $this->module->lang('err_site');
     }
     $site = $site->getSiteClass();
     $site instanceof WC_Site;
     $url = $site->getScoreURL($onsitename);
     if (false === ($result = $site->parseStats($url))) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     $rank = (int) $result[1];
     $score = (int) $result[0];
     $maxscore = $site->getOnsiteScore();
     $percent = $score / $maxscore * 100;
     $msg_rank = $rank > 0 ? ' and claims rank ' . $rank : '';
     $msg = sprintf('On %s , the user %s scores %d of %d points(%.02f%%)%s.', $site->getURL(), $onsitename, $score, $maxscore, $percent, $msg_rank);
     return $msg;
 }