コード例 #1
0
ファイル: WordOfTheDay.php プロジェクト: florinp/dexonline
 public function imageExists()
 {
     if (!$this->image) {
         return true;
         // Not the case since there is no image
     }
     list($ignored, $httpCode) = util_fetchUrl($this->getImageUrl());
     return $httpCode == 200;
 }
コード例 #2
0
ファイル: OpenIDConnect.php プロジェクト: florinp/dexonline
 function getUserInfo($token)
 {
     if (!isset($this->wellKnownConfig['userinfo_endpoint'])) {
         throw new OpenIDException('Nu pot cere datele dumneavoastră de la furnizor.');
     }
     $url = $this->wellKnownConfig['userinfo_endpoint'];
     $url .= "?schema=openid&access_token={$token}";
     list($contents, $responseCode) = util_fetchUrl($url);
     return $contents && $responseCode == 200 ? json_decode($contents, true) : null;
 }
コード例 #3
0
 if (overwrite($book, $opts, 'i')) {
     $book->imageUrl = IMG_URL_PREFIX . $fields[$opts['i']];
 }
 if (overwrite($book, $opts, 'u')) {
     $book->url = $fields[$opts['u']];
 }
 $book->save();
 print "  [{$book->title}] by [{$book->author}]\n";
 // Grab the image unless we already have it
 $fileName = ORIG_FILE_PREFIX . "{$sku}.jpg";
 $thumbName = THUMB_PREFIX . "{$sku}.jpg";
 if (file_exists($fileName)) {
     $haveFile = true;
 } else {
     $haveFile = false;
     $img = util_fetchUrl($book->imageUrl);
     if ($img !== false) {
         // Dump the image to a file
         $file = fopen($fileName, "w");
         fwrite($file, $img);
         fclose($file);
         $haveFile = true;
     }
 }
 $alreadyResized = file_exists($thumbName);
 if ($haveFile && !$alreadyResized) {
     $imgType = isImage($fileName);
     if ($imgType == IMG_NORMAL) {
         list($width, $height, $bytes) = preg_split('/\\|/', getImageInfo($fileName));
         print "  {$width}x{$height}, {$bytes} bytes ";
         OS::executeAndAssert("convert -trim -fuzz \"3%\" -geometry 200x84 \"{$fileName}\" \"{$thumbName}\"");
コード例 #4
0
$count = db_getSingleValue("select count(*) from Definition where status = 0 and length(internalRep) > 250;");
$nr = rand(1, $count);
$definition = db_getSingleValue("select htmlRep from Definition where status = 0 and length(internalRep) > 200 limit {$nr} ,1;");
# Parse definition and create string to search
$v = explode(" ", strip_tags($definition));
$to_search = "\"";
# Set string to search start + end
$WORD_START = 5;
$WORD_NO = 16;
$to_search .= implode(" ", array_slice($v, $WORD_START, $WORD_NO));
$to_search .= "\"";
$to_search = str_replace(array(",", "(", ")", "[", "]", "-", ";", "◊", "♦", "<", ">", "?", "\\", "/"), array_pad(array(), 14, ''), $to_search);
$urlGoogle = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0";
$apiKey = pref_getServerPreference('googleSearchApiKey');
$url = $urlGoogle . "&q=" . urlencode($to_search) . "&key=" . $apiKey;
$body = util_fetchUrl($url);
# now, process the JSON string
$json = json_decode($body);
$rezultate = $json->responseData->results;
$listAll = array();
$content = "";
$messageAlert = array();
$blackList = array();
foreach ($rezultate as $iter) {
    # Skip dexonline.ro from results
    #if(stripos($iter->url, "dexonline.ro") == true)
    #	continue;
    $components = parse_url($iter->url);
    if (StringUtil::endsWith($components['host'], 'dexonline.ro')) {
        continue;
    }