예제 #1
0
파일: wiki_Pb.php 프로젝트: sinfocol/gwf3
 function getWikiText($term, $wikiurl, $notfound)
 {
     $term = str_replace(" ", "_", $term);
     $term[0] = strtoupper($term[0]);
     $content = GWF_HTTP::getFromUrl($wikiurl . str_replace("%23", "#", urlencode($term)));
     if ($content === false || stristr($content, $notfound)) {
         return false;
     }
     $pos = strpos($content, '<div id="contentSub">');
     $content = substr($content, $pos);
     $content = preg_replace("#<tr.*?</tr>#", '', $content);
     $content = str_replace("</li>", ",</li>", $content);
     preg_match_all("#<(p|li)>(.*?)</(p|li)>#", $content, $arr);
     $content = "";
     foreach ($arr[2] as $row) {
         $row = trim(strip_tags($row));
         if (!empty($row)) {
             $content .= $row . " ";
         }
     }
     $content = html_entity_decode($content);
     $content = str_replace(chr(160), " ", $content);
     $output['text'] = $content;
     $output['link'] = $wikiurl . urlencode($term);
     return $output;
 }
예제 #2
0
 private function onCheckout(array $argv)
 {
     if (count($argv) < 3) {
         return $this->showRepoHelp('checkout');
     }
     $type = strtolower($argv[0]);
     if (!Dog_Repo::isValidType($type)) {
         return $this->error('err_type');
     }
     $url = $argv[1];
     if (!GWF_Validator::isValidURL($url) || !GWF_HTTP::pageExists($url)) {
         // 			return $this->error('err_url');
     }
     $name = $argv[2];
     if (!Dog_Repo::isNameValid($name)) {
         return $this->error('err_name_invalid');
     }
     if (Dog_Repo::repoExists($name, $url)) {
         return $this->error('err_dup');
     }
     $user = NULL;
     $pass = NULL;
     if (isset($argv[3])) {
         $user = $argv[3];
         $pass = isset($argv[4]) ? $argv[4] : '';
     }
     $repo = new Dog_Repo(array('repo_id' => '0', 'repo_type' => $type, 'repo_name' => $name, 'repo_url' => $url, 'repo_user' => $user, 'repo_pass' => $pass, 'repo_options' => '0'));
     if (!$repo->insert()) {
         return $this->error('err_database');
     }
     $this->rply('msg_checking_out', array($name));
     $repo->checkout();
 }
예제 #3
0
파일: php_Pb.php 프로젝트: sinfocol/gwf3
 function fetchFunctionDescription($func, $language = 'en')
 {
     global $message, $redirects;
     $notfoundtext = 'Nothing matches your query, try search:';
     Dog_Log::debug('phpmanual: fetching ' . $func . ' info');
     $res = GWF_HTTP::getFromUrl('http://' . ($language != 'en' ? $language . '.' : '') . 'php.net/' . $func, false, 'LAST_LANG=' . $language);
     if ($res === false) {
         return 'Timeout on contacting ' . ($language != 'en' ? $language . '.' : '') . 'php.net';
     }
     if (preg_match('/<span class=\\"refname\\">(.*?)<\\/span> &mdash; <span class=\\"dc\\-title\\">(.*?)<\\/span>/si', $res, $match)) {
         $match[2] = str_replace(array("\n", "\r"), ' ', strip_tags($match[2]));
         preg_match('/<div class=\\"methodsynopsis dc\\-description\\">(.*?)<\\/div>/si', $res, $descmatch);
         $decl = isset($descmatch[1]) ? strip_tags($descmatch[1]) : $match[1];
         $decl = html_entity_decode(str_replace(array("\n", "\r"), ' ', $decl));
         $decl = str_replace($func, "" . $func . "", $decl);
         $output = $decl . ' - ' . html_entity_decode($match[2]) . ' ( http://' . ($language != 'en' ? $language . '.' : '') . 'php.net/' . $func . ' )';
     } else {
         // if several possibilities
         $output = '';
         if (preg_match_all('/<a href=\\"\\/manual\\/[a-z]+\\/(?:.*?)\\.php\\">(?:<b>)?(.*?)(?:<\\/b>)?<\\/a><br/i', $res, $matches, PREG_SET_ORDER)) {
             if ($redirects++ < 2) {
                 return fetchFunctionDescription($matches[0][1]);
             } else {
                 return $notfoundtext . ' http://' . ($language != 'en' ? $language . '.' : '') . 'php.net/search.php?show=wholesite&pattern=' . $message;
             }
         } else {
             $output = $notfoundtext . ' http://' . ($language != 'en' ? $language . '.' : '') . 'php.net/search.php?show=wholesite&pattern=' . $func;
         }
     }
     return $output;
 }
예제 #4
0
 static function getYoutubeData($youtube_id)
 {
     if (empty($youtube_id)) {
         return false;
     }
     $html = GWF_HTTP::getFromURL('http://gdata.youtube.com/feeds/api/videos/' . $youtube_id);
     $xml = simplexml_load_string($html);
     if ($xml === false) {
         return false;
     }
     $data = array();
     $media = $xml->children('http://search.yahoo.com/mrss/');
     $data['title'] = (string) $media->group->title;
     $data['description'] = (string) $media->group->description;
     $data['category'] = (string) $media->group->category;
     $data['keywords'] = explode(', ', $media->group->keywords);
     $data['link'] = (string) $media->group->player->attributes()->url;
     $data['duration'] = (int) $media->children('http://gdata.youtube.com/schemas/2007')->duration->attributes()->seconds;
     $data['thumbnails'] = array();
     foreach ($media->group->thumbnail as $thumbnail) {
         array_push($data['thumbnails'], array('url' => (string) $thumbnail->attributes()->url, 'width' => (int) $thumbnail->attributes()->width, 'height' => (int) $thumbnail->attributes()->height));
     }
     $data['published'] = strtotime($xml->published);
     $data['author'] = (string) $xml->author->name;
     $gd = $xml->children('http://schemas.google.com/g/2005')->rating->attributes();
     $data['rating'] = (double) $gd->average;
     $data['num_raters'] = (int) $gd->numRaters;
     $data['views'] = (int) $xml->children('http://gdata.youtube.com/schemas/2007')->statistics->attributes()->viewCount;
     return $data;
 }
예제 #5
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $result = str_replace("", '', $result);
     # BOM
     $result = trim($result);
     $stats = explode(":", $result);
     if (count($stats) !== 7) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $i = 0;
     $username = $stats[$i++];
     $rank = intval($stats[$i++]);
     $onsitescore = intval($stats[$i++]);
     $onsitescore = Common::clamp($onsitescore, 0);
     $maxscore = intval($stats[$i++]);
     $challssolved = intval($stats[$i++]);
     $challcount = intval($stats[$i++]);
     $usercount = intval($stats[$i++]);
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
 }
예제 #6
0
파일: WCSite_VH.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(':', $result);
     if (count($stats) !== 7) {
         //			if ($result === '0') {
         //				return array(0, 0);
         //			}
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     # username:rank:score:maxscore:challssolved:challcount:usercount
     $uname = $stats[0];
     $rank = intval($stats[1]);
     $onsitescore = intval($stats[2]);
     $maxscore = intval($stats[3]);
     $challssolved = intval($stats[4]);
     $challcount = intval($stats[5]);
     $usercount = intval($stats[6]);
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
 }
예제 #7
0
 /**
  * Start http stream.
  * @return unknown_type
  */
 public static function streamHeader()
 {
     $boundary = self::BOUNDARY;
     GWF_HTTP::noCache();
     header("Content-type: multipart/x-mixed-replace;boundary={$boundary}");
     echo "\n--{$boundary}\n";
 }
예제 #8
0
파일: WCSite_WC.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     $result2 = GWF_HTTP::getFromURL($url, false);
     $result = explode(':', $result2);
     if (count($result) !== 6) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result2), $this->displayName())));
     }
     list($rank, $score, $maxscore, $challsolved, $challcount, $usercount) = $result;
     return array(intval($score), (int) $rank, $challsolved, $maxscore, $usercount, $challcount);
 }
예제 #9
0
파일: index.php 프로젝트: sinfocol/gwf3
function www_basic_go(WC_Challenge $chall, $url, $content)
{
    if (false === ($response = GWF_HTTP::getFromURL($url))) {
        echo GWF_HTML::error('WWW Basics', $chall->lang('err_file_not_found'));
    } elseif ($response !== $content) {
        echo GWF_HTML::error('WWW Basics', $chall->lang('err_wrong', array(htmlspecialchars($response), htmlspecialchars($content), strlen($response), strlen($content))));
    } else {
        $chall->onChallengeSolved(GWF_Session::getUserID());
    }
}
예제 #10
0
파일: Slay_PNow.php 프로젝트: sinfocol/gwf3
 public static function requestSlay(Module_Slaytags $module)
 {
     if (false === ($page = GWF_HTTP::getFromURL(self::URL))) {
         return false;
     }
     if (false === ($data = json_decode($page, true))) {
         return false;
     }
     return $data;
 }
예제 #11
0
파일: Dog_Forum.php 프로젝트: sinfocol/gwf3
 private function sendRequest($gwf_date, $limit)
 {
     GWF_HTTP::setTimeout(3);
     GWF_HTTP::setConnectTimeout(2);
     $url = $this->getReplacedUrl($this->getDate(), $limit);
     echo "CHECKING FORUM WITH URL: {$url}\n";
     $content = GWF_HTTP::getFromURL($url);
     GWF_HTTP::setTimeout();
     GWF_HTTP::setConnectTimeout();
     return $content;
 }
예제 #12
0
파일: radio_Pb.php 프로젝트: sinfocol/gwf3
 function getRandomRadio($term)
 {
     $term = str_replace(" ", "+", $term);
     $url = 'http://hagbard.host-ed.me/intranet/radio.php?out=inline&shuffle=true&limit=1&search=' . urlencode($term);
     $content = GWF_HTTP::getFromUrl($url . str_replace("%23", "#", urlencode($term)) . '*');
     if ($content === false || strlen($content) == 0) {
         return false;
     }
     echo $content . PHP_EOL;
     $temp = explode('|', $content, 2);
     return array(Common::substrFrom($temp[1], ') ', $temp[1]), $temp[0]);
 }
예제 #13
0
파일: index.php 프로젝트: sinfocol/gwf3
function www_rewrite_go(WC_Challenge $chall, $url)
{
    $n1 = rand(1000000, 1000000000) . rand(1000000, 1000000000);
    $n2 = rand(1000000, 1000000000) . rand(1000000, 1000000000);
    $solution = bcmul($n1, $n2);
    $url .= $n1 . '_mul_' . $n2 . '.html';
    if (false === ($response = GWF_HTTP::getFromURL($url))) {
        echo GWF_HTML::error('WWW Rewrite', $chall->lang('err_file_not_found'));
    } elseif ($response !== $solution) {
        echo GWF_HTML::error('WWW Rewrite', $chall->lang('err_wrong', array(htmlspecialchars($response), htmlspecialchars($solution), strlen($response), strlen($solution))));
    } else {
        $chall->onChallengeSolved(GWF_Session::getUserID());
    }
}
예제 #14
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(':', $result);
     if (count($stats) !== 3) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     list($onsitescore, $challcount, $usercount) = $stats;
     if ($challcount == 0 || $usercount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, -1, -1, $challcount, $usercount, $challcount);
 }
예제 #15
0
파일: WCSite_NF.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $result = explode(":", $result);
     if (count($result) !== 4) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     list($rank, $score, $challcount, $usercount) = $result;
     if ($rank < 1 || $challcount == 0 || $usercount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($score, $rank, $score, $challcount, $usercount, $challcount);
 }
예제 #16
0
파일: WCSite_BQ.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $data = explode(':', $result);
     if (count($data) !== 5) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     list($rank, $score, $maxscore, $usercount, $challcount) = $data;
     if ($rank == 0 || $maxscore == 0 || $usercount == 0 || $challcount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array(round($score), $rank, -1, $maxscore, $usercount, $challcount);
 }
예제 #17
0
 public function parseStats($url)
 {
     $result = GWF_HTTP::getFromURL($url, false);
     if ($result === false) {
         return false;
     }
     if ($result === "Unknown User") {
         return htmlDisplayError(WC_HTML::lang('err_onsitename', array($this->displayName())));
     }
     $data = explode(":", $result);
     if (count($data) !== 5 || $data[3] < 0 || $data[3] > $data[4] || $data[2] == 0 || $data[4] == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($data[3], Common::clamp($data[1], 0), $data[3], $data[4], $data[2], $data[4]);
 }
예제 #18
0
파일: WCSite_HQ.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(":", $result);
     if (count($stats) !== 4) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     if ($stats[0] < 0 || $stats[0] > $stats[1] || $stats[3] == 0 || $stats[2] == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $score = round($stats[0] / $stats[1] * 10000);
     return array($score, -1, -1, 10000, $stats[3], $stats[2]);
 }
예제 #19
0
 private static function googleTranslate($text, $from = 'auto', $to = 'de', $return_source_lang = false)
 {
     $html = GWF_HTTP::post('https://translate.google.com/', array('sl' => $from, 'tl' => $to, 'js' => 'n', 'hl' => 'en', 'ie' => 'UTF-8', 'text' => $text));
     if (!preg_match('#<span id=result_box .+?>(.+?)</div>#', $html, $arr)) {
         return false;
     }
     $translation = html_entity_decode(strip_tags($arr[1]), ENT_QUOTES);
     if ($return_source_lang) {
         if (!preg_match('#<div id=autotrans.+?<h3.+?>(.+?) to .+? translation</h3>#', $html, $arr)) {
             return false;
         }
         return array('translation' => $translation, 'source_lang' => $arr[1]);
     } else {
         return $translation;
     }
 }
예제 #20
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $data = explode(":", $result);
     if (count($data) !== 7) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $challcount = isset($data[5]) ? intval($data[5]) : $this->getVar('challcount');
     $usercount = isset($data[6]) ? intval($data[6]) : $this->getVar('usercount');
     if ($data[1] < 0 || $data[1] > $data[2] || $challcount == 0 || $usercount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($data[1], $data[4], -1, $data[2], $usercount, $challcount);
 }
예제 #21
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $data = explode(':', $result);
     $percent = $data[0];
     if (!is_numeric($percent) || $percent < 0 || $percent > 1) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $usercount = isset($data[1]) ? $data[1] : $this->getUsercount();
     if ($usercount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $maxscore = $this->getOnsiteScore();
     $challcount = $this->getChallcount();
     return array(round($percent * $maxscore), -1, -1, $maxscore, $usercount, $challcount);
 }
예제 #22
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(':', $result);
     if (count($stats) < 2) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $onsitescore = intval($stats[0]);
     $maxscore = intval($stats[1]);
     $challcount = $maxscore;
     $usercount = intval($stats[2]);
     if ($onsitescore === 0 || $maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, -1, $onsitescore, $maxscore, $usercount, $challcount);
 }
예제 #23
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(":", $result);
     if (count($stats) < 3) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $challs = $stats[1];
     $done = $stats[0];
     #$usercount = $stats[2];
     if ($challs == 0) {
         # || $usercount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($done, -1, $done, $challs, 0, $challs);
 }
예제 #24
0
파일: Captcha.php 프로젝트: sinfocol/gwf3
 public function execute()
 {
     # Don't store this url.
     GWF3::setConfig('store_last_url', false);
     # Load the Captcha class
     require GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
     # disable Logging
     GWF3::setConfig('log_request', false);
     # disable HTTP Caching
     GWF_HTTP::noCache();
     # Setup Font, Color, Size
     $aFonts = $this->module->cfgCaptchaFont();
     $rgbcolor = $this->module->cfgCaptchaBG();
     $width = $this->module->cfgCaptchaWidth();
     $height = $this->module->cfgCaptchaHeight();
     $oVisualCaptcha = new PhpCaptcha($aFonts, $width, $height, $rgbcolor);
     # Output the captcha
     die($oVisualCaptcha->Create('', Common::getGetString('chars', true)));
 }
예제 #25
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $data = explode(":", $result);
     if (count($data) !== 5) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $rank = (int) $data[0];
     $score = (int) ($data[1] * 100);
     $maxscore = (int) ($data[2] * 100);
     $users = (int) $data[3];
     $challs = (int) $data[4];
     if ($score > $maxscore || $score < 0 || $maxscore == 0 || $challs == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($score, $rank, -1, $maxscore, $users, $challs);
 }
예제 #26
0
파일: jbot_Pb.php 프로젝트: sinfocol/gwf3
 /**
  * Used to minify URLs
  *
  * @param string $url The URL you want to be minified by http://jbot.de
  * @return array An Array containing a Title(1) and an URL(0)
  */
 function jbot_minify($url)
 {
     // Magic Values
     $SERVICE = 'http://jbot.de/create.php';
     $PREFIX = '<p class="redirect">';
     $POSTFIX = '</p>';
     $response = GWF_HTTP::post($SERVICE, array('url' => $url));
     // 1:1 html leech umgesetzt wie in Ralfs js example http://jbot.de/js/jbotcreate.js
     if (false === ($posStart = strpos($response, $PREFIX))) {
         return false;
     } else {
         $posStart += strlen($PREFIX);
         if (false === ($posEnd = strpos($response, $POSTFIX, $posStart))) {
             return false;
         }
         $minified = substr($response, $posStart, $posEnd - $posStart);
     }
     return $minified;
 }
예제 #27
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(":", $result);
     if (count($stats) < 3) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $onsitescore = intval($stats[0]);
     $onsitescore = Common::clamp($onsitescore, 0);
     $maxscore = intval($stats[1]);
     $usercount = intval($stats[2]);
     $onsiterank = isset($stats[3]) ? intval($stats[3]) : -1;
     $challcount = $maxscore;
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $onsiterank, $onsitescore, $maxscore, $usercount, $challcount);
 }
예제 #28
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(":", $result);
     if (count($stats) !== 4) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $onsitescore = intval($stats[2]);
     $score = intval($stats[1]);
     $rankname = $stats[0];
     $usercount = 39500;
     $challcount = 102;
     #intval($stats[3]);
     if ($score > $onsitescore * 2 || $challcount <= 2 || $onsitescore < 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($score, -1, -1, $onsitescore, $usercount, $challcount);
 }
예제 #29
0
 public static function validate_href(Module_Links $module, $arg, $check_dups)
 {
     $arg = trim($arg);
     $_POST['link_href'] = $arg;
     if (strlen($arg) > $module->cfgMaxUrlLen()) {
         return $module->lang('err_url_long', array($module->cfgMaxUrlLen()));
     }
     if (false === GWF_Validator::isValidURL($arg)) {
         return $module->lang('err_url');
     }
     if (false === GWF_HTTP::pageExists($arg)) {
         return $module->lang('err_url_down');
     }
     if ($check_dups === true) {
         if (false !== GWF_Links::getByHREF($arg)) {
             return $module->lang('err_url_dup');
         }
     }
     return false;
 }
예제 #30
0
파일: WCSite_HS.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $data = explode(':', $result);
     if (count($data) !== 6) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $rank = (int) $data[0];
     $score = (int) $data[1];
     $maxscore = (int) $data[2];
     // on site max score
     $usercount = (int) $data[3];
     $challcount = (int) ($data[4] = (int) $maxscore);
     $onsitename = (int) $data[5];
     if ($score > $maxscore || $score < 0 || $challcount == 0 || $usercount == 0 || $maxscore == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($score, $rank, -1, $maxscore, $usercount, $challcount);
 }