function worksheetsToArray($id)
{
    $entries = array();
    $i = 1;
    while (true) {
        $url = 'https://spreadsheets.google.com/feeds/list/' . $id . '/' . $i . '/public/full?alt=json';
        $data = @json_decode(file_get_contents_curl($url), true);
        $starttag = substr($data['feed']['title']["\$t"], 0, strpos($data['feed']['title']["\$t"], " "));
        if (!isset($data['feed']['entry'])) {
            break;
        }
        foreach ($data['feed']['entry'] as $entryKey => $entry) {
            $data['feed']['entry'][$entryKey]['gsx$starttag']["\$t"] = $starttag;
        }
        $entries = array_merge($entries, $data['feed']['entry']);
        $i++;
    }
    return $entries;
}
function html_no_comment($url)
{
    $url = _urlencode($url);
    // create HTML DOM
    $check_curl = _isCurl();
    if (!($html = file_get_html($url))) {
        if (!($html = str_get_html(file_get_contents_curl($url))) or !$check_curl) {
            return false;
        }
    }
    // remove all comment elements
    foreach ($html->find('comment') as $e) {
        $e->outertext = '';
    }
    $ret = $html->save();
    // clean up memory
    $html->clear();
    unset($html);
    return $ret;
}
Beispiel #3
1
function getSteamNames($steamID)
{
    $steamUserNamesUrl = file_get_contents_curl("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=41AF33A7F00028D1E153D748597DEEF3&steamids=" . $steamID);
    $content = json_decode($steamUserNamesUrl, true);
    $pieces = explode(",%20", $steamID);
    if (count($pieces) > 99) {
        for ($x = 100; $x <= count($pieces) - 2; $x++) {
            if ($x >= count($pieces) - 2) {
                $steamfriendsExtended .= $pieces[$x];
            } else {
                $steamfriendsExtended .= $pieces[$x] . ',%20';
            }
        }
        $steamfriendsExtendedUrl = file_get_contents_curl("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=41AF33A7F00028D1E153D748597DEEF3&steamids=" . $steamfriendsExtended);
        $steamfriendsExtendedContent = json_decode($steamfriendsExtendedUrl, true);
        foreach ($steamfriendsExtendedContent['response']['players'] as $player) {
            array_push($content['response']['players'], $player);
        }
    }
    return $content['response']['players'];
}
function instagram_get_photos($username, $num = 5)
{
    //look for user id
    $requser = "******" . $username . "&client_id=" . INSTAGRAM_KEY;
    $res = file_get_contents_curl($requser);
    $user_data = json_decode($res);
    $user_id = 0;
    //print_r($user_data);
    foreach ($user_data->data as $user) {
        if ($user->username == $username) {
            $user_id = $user->id;
            break;
        }
    }
    if ($user_id == 0) {
        return false;
    }
    //and now get the pictures
    $uri = "https://api.instagram.com/v1/users/" . $user_id . "/media/recent?count=" . $num . "&client_id=" . INSTAGRAM_KEY;
    $res = file_get_contents_curl($uri);
    $content = json_decode($res);
    return $content;
}
function fn_sb_movie_infobox_cache($id, $detailType)
{
    //    $cacheage = get_option('imdbcacheage', -1);
    $cacheage = -1;
    $imageCacheDir = SB_CACHE_DIR . "/" . $id . ".jpg";
    $imageCacheUrl = SB_CACHE_URL . "/" . $id . ".jpg";
    $jsonCacheDir = SB_CACHE_DIR . "/" . $id . ".json";
    if (!file_exists($imageCacheDir) || $cacheage > -1 && filemtime($imageCacheDir) < time() - $cacheage || !file_exists($jsonCacheDir) || $cacheage > -1 && filemtime($jsonCacheDir) < time() - $cacheage) {
        //$url = "http://www.omdbapi.com/?i=".$movieid."&plot=short&r=json";
        $url = "http://www.omdbapi.com/?i={$id}&plot={$detailType}&r=json";
        $http_args = array('user-agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
        $rawResponse = wp_remote_request($url, $http_args);
        $rawResponse = $rawResponse['body'];
        //        $raw = file_get_contents_curl('http://www.omdbapi.com/?i=' . $id."&plot=short&r=json");
        $json = json_decode($rawResponse, true);
        $jsonResult = file_put_contents($jsonCacheDir, $rawResponse);
        //        echo("jsonResult". $jsonResult . "<br/>");
        $img = file_get_contents_curl($json['Poster']);
        $jsonResult = file_put_contents($imageCacheDir, $img);
        $json['Poster'] = $imageCacheUrl;
    } else {
        $rawResponse = file_get_contents($jsonCacheDir);
        $json = json_decode($rawResponse, true);
        $json['Poster'] = $imageCacheUrl;
    }
    return $json;
}
Beispiel #6
0
 /**
  * Делает запрос к Api VK
  * @param $method
  * @param $params
  */
 public function method($method, $params = null)
 {
     $p = "";
     if ($params && is_array($params)) {
         foreach ($params as $key => $param) {
             $p .= ($p == "" ? "" : "&") . $key . "=" . urlencode($param);
         }
     }
     /* $response = file_get_contents($this->url . $method . "?" . ($p ? $p . "&" : "") . "access_token=" . $this->access_token);
     
             if( $response ) {
                 return json_decode($response);
             } 
             return false;
         
     } */
     function file_get_contents_curl($url)
     {
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_HEADER, True);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         //Устанавливаем параметр, чтобы curl возвращал данные, вместо того, чтобы выводить их в браузер.
         curl_setopt($ch, CURLOPT_URL, $url);
         $data = curl_exec($ch);
         curl_close($ch);
         return $data;
     }
     $response = file_get_contents_curl($this->url . $method . "?" . ($p ? $p . "&" : "") . "access_token=" . $this->access_token);
     if ($response) {
         return json_decode($response);
     }
     return false;
 }
Beispiel #7
0
 private function _request($request)
 {
     $request = array_map('Comet_encode', $request);
     array_unshift($request, $this->ORIGIN);
     $ctx = stream_context_create(array('http' => array('timeout' => 200)));
     return json_decode(file_get_contents_curl(implode('/', $request)), true);
 }
Beispiel #8
0
function buildCSV()
{
    $html = file_get_contents_curl(FACULTY_WEB);
    $matches;
    $table_regex = '/<td[^>]*>(.*?)<\\/td>/';
    preg_match_all($table_regex, $html, $matches);
    $clean = array();
    $email = "";
    $name = "";
    $department = "";
    for ($i = 3; $i < count($matches[0]); $i++) {
        $text = strip_tags($matches[0][$i]);
        if ($i % 3 == 0) {
            $text = preg_replace('(\\(.*\\))', '', $text);
            $text = firstlast($text);
            $text = str_replace(",", "", $text);
            $name = $text;
        }
        if ($i % 3 == 1) {
            $text = preg_replace('(\\(.*\\))', '', $text);
            $text = str_replace(",", "", $text);
            $department = $text;
        }
        if ($i % 3 == 2) {
            $text = str_replace("*", "@uwo.ca", $text);
            $email = $text;
            array_push($clean, $email, $name, $department);
        }
    }
    $final = "";
    for ($i = 0; $i < count($clean); $i++) {
        $final .= "\"" . $clean[$i++] . "\", \"" . $clean[$i++] . "\", \"" . $clean[$i] . "\"\n";
    }
    file_put_contents(FACULTY_FILE, $final);
}
function cache_image($imageurl = '', $name)
{
    $imagename = $name . '.' . get_image_extension($imageurl);
    if (file_exists('./tmp/' . $imagename)) {
        return 'tmp/' . $imagename;
    }
    $image = file_get_contents_curl($imageurl);
    file_put_contents('tmp/' . $imagename, $image);
    return 'tmp/' . $imagename;
}
Beispiel #10
0
function login( $uacc, $upwd ){
    $login = (array)json_decode(
        file_get_contents_curl(
            'http://apit.cedric.testapi-1.stu.edu.tw/acc/auth/uacc/'.$uacc.'/?upwd='.$upwd),true);
    # Authentication fail.
    if ( $login['status'] )
        print_response_msg(3);

    # Analyze data.
    $ou_group;
    $start_tag = "ou=";
    $close_tag = ",";
    preg_match_all("($start_tag(.*)$close_tag)siU", $login['dn'], $ou_group);

    # If login user not is student, this column value set 0.
    if ( !preg_match('/\d{2,3}/', $ou_group[1][0]) )
        $ou_group[1][0] = 0;

    # Get record data.
    $sql = "SELECT record_id FROM record WHERE account=? ";
    $record_id = sql_q( $sql, array($login['uacc']) );

    # If this account not have play record in database, insert new row to database.
    if ( !count($record_id) ) {
        $addRecord = add_record(
            $login['uacc'],
            $ou_group[1][1]
        );
        if ( $addRecord )
            $record_id = sql_q( $sql, array($login['uacc']) );
        else
            print_response_msg(5);
    }

    # Session content
    $profile = array(
        'record_id' => $record_id[0]['record_id'],
        'account'   => $login['uacc'],
        'name'      => $login['uname'],
        'dep'       => $ou_group[1][1]
    );

    # Define session
    $_SESSION[ session_id() ] = $profile;

    # Print login success message and session data.
    print_response_msg( 2, $profile );
}
Beispiel #11
0
function power_ga_mp($keyword, $title = '(unknown)', $referer = '')
{
    $version = 1;
    $z = rand(100000000000, 999999999999);
    // Cache Buster  to ensure browsers and proxies don't cache hits
    $power_ga_mp_GAID = 'UA-33563207-5';
    $data = array('v' => $version, 'tid' => $power_ga_mp_GAID, 'cid' => power_ga_mp_gaParseCookie(), 'uip' => $_SERVER['REMOTE_ADDR'], 'z' => $z, 't' => 'pageview', 'dh' => $_SERVER['SERVER_NAME'], 'dp' => $keyword, 'dt' => $title, 'dr' => $referer);
    if ($data) {
        $getString = 'https://ssl.google-analytics.com/collect';
        $getString .= '?payload_data&';
        $getString .= http_build_query($data);
        $result = file_get_contents_curl($getString);
        return $result;
    }
    return false;
}
Beispiel #12
0
function get_facebook_id($url)
{
    $html = file_get_contents_curl($url);
    //parsing begins here:
    $doc = new DOMDocument();
    @$doc->loadHTML($html);
    $metas = $doc->getElementsByTagName('meta');
    for ($i = 0; $i < $metas->length; $i++) {
        $meta = $metas->item($i);
        if ($meta->getAttribute('name') == 'description') {
            $description = $meta->getAttribute('content');
        }
        if ($meta->getAttribute('property') == 'al:android:url') {
            preg_match('!\\d+!', $meta->getAttribute('content'), $fbid);
        }
    }
    return $fbid;
}
 public static function fetch_image_post($post_id = '', $link = '', $comment_fbid = '')
 {
     if (!$post_id || !$link) {
         return;
     }
     $image = '';
     if ($comment_fbid) {
         $app_id = FB_APP_ID;
         $app_secret = FB_SECRET;
         $url = "https://graph.facebook.com/{$comment_fbid}?access_token={$app_id}|{$app_secret}";
         $obj = json_decode(file_get_contents_curl($url));
         if (isset($obj->image) && $obj->image) {
             $image = $obj->image->url;
         }
     }
     var_dump($image);
     die;
     if (!empty($image)) {
         $graph = OpenGraph::fetch($link);
         var_dump($graph);
         die;
     }
 }
Beispiel #14
0
 public function grabSkyScanner($urls)
 {
     $folder = 'console.data_files.skyscanner';
     $doneFolder = 'console.data_files.done';
     foreach ($urls as $name => $url) {
         $saveTo = Yii::getPathOfAlias($folder) . '/' . $name . '.xml';
         $donePath = Yii::getPathOfAlias($doneFolder) . '/' . $name . '.xml';
         try {
             if (is_file($saveTo)) {
                 $this->analyzeFile($saveTo, $url);
                 rename($saveTo, $donePath);
                 continue;
             }
             if (is_file($donePath)) {
                 continue;
             }
             echo 'Grabbing using ' . $name . " ( {$url} ) ";
             $response = file_get_contents_curl($url);
             sleep(2);
             if ($response === false) {
                 throw new CException('Failed');
             }
             echo "Success.\n";
             file_put_contents($saveTo, $response);
             $this->analyzeFile($saveTo, $url);
             rename($saveTo, $donePath);
         } catch (Exception $e) {
             echo "Failed. {$e->getMessage()}\n";
         }
     }
 }
Beispiel #15
0
    //Database connection fails
    //--------------------------------------------------------------//
    print 'Database error';
    exit;
}
// connect to database
dbConnect();
if (!isset($HTTP_RAW_POST_DATA)) {
    $HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$data = json_decode($HTTP_RAW_POST_DATA);
$time = time();
$complaint_simulator_email = '*****@*****.**';
//Confirm SNS subscription
if ($data->Type == 'SubscriptionConfirmation') {
    file_get_contents_curl($data->SubscribeURL);
} else {
    //detect complaints
    $obj = json_decode($data->Message);
    $notificationType = $obj->{'notificationType'};
    $problem_email = $obj->{'complaint'}->{'complainedRecipients'};
    $problem_email = $problem_email[0]->{'emailAddress'};
    $from_email = get_email($obj->{'mail'}->{'source'});
    $messageId = $obj->{'mail'}->{'messageId'};
    $from_email = $from_email[0];
    //check if email is valid, if not, exit
    if (!filter_var($problem_email, FILTER_VALIDATE_EMAIL)) {
        exit;
    }
    if ($notificationType == 'Complaint') {
        //Update complaint status
Beispiel #16
0
function send($user)
{
    $url = 'http://www.ello.co/' . $user . '.json';
    echo file_get_contents_curl($url);
}
/**
 * Creates tinyurl
 * 
 * @author n/a
 * @version v2.0
 * @since v1.0
 * @todo -- document this function
*/
function ashford_get_tinyurl($url)
{
    if (function_exists('file_get_contents') && function_exists('curl_init')) {
        $tinyurl = file_get_contents_curl("http://tinyurl.com/api-create.php?url=" . $url);
        return $tinyurl;
    } else {
        return $url;
    }
}
<?php

require 'stuff.php';
$config = parse_ini_file($argv[1]);
if (!$config) {
    echo "Couldn't parse the config file.";
    exit(1);
}
$filename = getTempNam();
if (!file_get_contents_curl("http://www.geopostcodes.com/inc/download.php?f=ISO3166-2&t=9", $filename)) {
    exit(1);
}
$zip = new Zip_Manager();
$zip->open($filename);
$zip->filteredExtractTo('./');
$zip->close();
unlink($filename);
$filename = "GeoPC_ISO3166-2.csv";
$f = fopen($filename, 'rb');
if (!$f) {
    exit(1);
}
$row = fgetcsv($f, null, ';');
if ($row != array('iso', 'country', 'code', 'name', 'altname')) {
    exit(1);
}
$pdo = getPDOConnection($config);
$pdo->beginTransaction();
$st1 = $pdo->prepare('select id id from state a1 where a1.iso = ?');
$st2 = $pdo->prepare('select a1.id id from state a1 inner join country a2 on a1.country_id = a2.id where a2.iso = ? and translate(lower(a1.name),\'áàâãäāéèêëíìïóòôõöúùûüūÁÀÂÃÄĀÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜŪçÇ‘\',\'aaaaaaeeeeiiiooooouuuuuAAAAAAEEEEIIIOOOOOUUUUUcC\') = translate(lower(?),\'áàâãäāéèêëíìïóòôõöúùûüūÁÀÂÃÄĀÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜŪçÇ‘\',\'aaaaaaeeeeiiiooooouuuuuAAAAAAEEEEIIIOOOOOUUUUUcC\') ');
$st3 = $pdo->prepare('update state set iso = ?, name = ?, country_id = (select id from country where iso = ?) where id = ?');
 public function pdt()
 {
     if (isset($this->request->post)) {
         $p_msg = "DEBUG POST VARS::";
         foreach ($this->request->post as $k => $v) {
             $p_msg .= $k . "=" . $v . "&";
         }
     }
     if (isset($this->request->get)) {
         $g_msg = "DEBUG GET VARS::";
         foreach ($this->request->get as $k => $v) {
             $g_msg .= $k . "=" . $v . "&";
         }
     }
     if ($this->config->get('pp_standard_debug')) {
         $this->log->write("PP_STANDARD :: PDT INIT <-- {$g_msg}");
     }
     if (!isset($this->request->get['tx']) || $this->config->get('pp_standard_pdt_token') == '') {
         $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/success');
     }
     $this->load->language('payment/pp_standard');
     $this->load->library('encryption');
     $encryption = new Encryption($this->config->get('config_encryption'));
     if (isset($this->request->get['cm'])) {
         $order_id = $encryption->decrypt($this->request->get['cm']);
     } else {
         $order_id = 0;
     }
     $this->load->model('checkout/order');
     $this->order_info = $this->model_checkout_order->getOrder($order_id);
     if ($this->order_info) {
         if ($this->order_info['order_status_id'] != 0) {
             //if ($this->order_info['order_status_id'] == $this->config->get('pp_standard_order_status_id')) {
             $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/success');
         }
     }
     // Paypal possible values for payment_status
     $success_status = array('Completed', 'Pending', 'In-Progress', 'Processed');
     $failed_status = array('Denied', 'Expired', 'Failed');
     // read the post from PayPal system and add 'cmd'
     $request = 'cmd=_notify-synch';
     $request .= '&tx=' . $this->request->get['tx'];
     $request .= '&at=' . $this->config->get('pp_standard_pdt_token');
     if (!$this->config->get('pp_standard_test')) {
         $url = 'https://www.paypal.com/cgi-bin/webscr';
     } else {
         $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     }
     if (ini_get('allow_url_fopen')) {
         $response = file_get_contents($url . '?' . $request);
     } else {
         $response = file_get_contents_curl($url . '?' . $request);
     }
     if ($this->config->get('pp_standard_debug')) {
         $this->log->write("PP_STANDARD :: PDT REQ  --> {$request}");
         $this->log->write("PP_STANDARD :: PDT RESP <-- " . str_replace("\n", "&", $response));
     }
     $resp_array = array();
     $verified = false;
     if ($response) {
         $lines = explode("\n", $response);
         if ($lines[0] == 'SUCCESS') {
             for ($i = 1; $i < count($lines) - 1; $i++) {
                 list($key, $val) = explode("=", $lines[$i]);
                 $resp_array[urldecode($key)] = urldecode($val);
             }
         }
     }
     if (isset($resp_array['memo'])) {
         $memo = $resp_array['memo'];
     } else {
         $memo = '';
     }
     if (!$this->validate($resp_array)) {
         if ($this->order_info['order_status_id'] == '0') {
             $this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id_pending'), $memo . "\r\n\r\n" . $this->error);
         } elseif ($this->order_info['order_status_id'] != $this->config->get('pp_standard_order_status_id')) {
             $this->model_checkout_order->update($order_id, $this->config->get('pp_standard_order_status_id_pending'), $this->error, FALSE);
         }
         mail($this->config->get('config_email'), sprintf($this->language->get('text_attn_email'), $order_id), $this->error . "\r\n\r\n" . str_replace("&", "\n", $g_msg));
     }
     if (strcmp($lines[0], 'SUCCESS') == 0) {
         $verified = true;
     }
     $this->checkPaymentStatus($resp_array, $verified);
 }
function make_bitly_url($url, $login, $appkey, $format = 'xml', $version = '2.0.1')
{
    _deprecated_function(__FUNCTION__, '6.0.0', __('Shortlinks feature in WooDojo.', 'woothemes'));
    //create the URL
    $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $appkey . '&format=' . $format;
    //get the url
    //could also use cURL here
    $response = file_get_contents_curl($bitly);
    //parse depending on desired format
    if (strtolower($format) == 'json') {
        $json = @json_decode($response, true);
        return $json['results'][$url]['shortUrl'];
    } else {
        $xml = simplexml_load_string($response);
        return 'http://bit.ly/' . $xml->results->nodeKeyVal->hash;
    }
}
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //Set curl to return the data instead of printing it to the browser.
    curl_setopt($ch, CURLOPT_URL, $url);
    $contents = curl_exec($ch);
    curl_close($ch);
    return $contents;
}
//db내용지우기
delete_db();
//지역별 인터파크 공연리스트 가져오기
$url_array = array("http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42001&RegionName=%BC%AD%BF%EF", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42010&RegionName=%B0%E6%B1%E2", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42011&RegionName=%C0%CE%C3%B5", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42080&RegionName=%B0%AD%BF%F8", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42070&RegionName=%C3%E6%BA%CF", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42060&RegionName=%C3%E6%B3%B2", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42061&RegionName=%B4%EB%C0%FC", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42030&RegionName=%B0%E6%BA%CF", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42020&RegionName=%B0%E6%B3%B2", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42031&RegionName=%B4%EB%B1%B8", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42091&RegionName=%BF%EF%BB%EA", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42021&RegionName=%BA%CE%BB%EA", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42050&RegionName=%C0%FC%BA%CF", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42040&RegionName=%C0%FC%B3%B2", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42041&RegionName=%B1%A4%C1%D6", "http://ticket.interpark.com/TiKi/Special/TPRegionReserve.asp?Region=42090&RegionName=%C1%A6%C1%D6");
foreach ($url_array as $url) {
    //지역별 공연의 코드번호 가져오기
    // url 받아오기
    $play_list = file_get_contents_curl($url);
    $play_list = mb_convert_encoding($play_list, 'utf-8', 'euc-kr');
    $index = strpos($play_list, 'top_line');
    $play_list = substr($play_list, $index);
    $index = strpos($play_list, 'btn_genre_exhibit');
    //공연목록중 전시는 제외
    $play_list = substr($play_list, 0, $index);
    $index = strpos($play_list, 'http://ticket.interpark.com/TIKI/Main/TikiGoodsInfo.asp?GoodsCode=');
    $play_list = substr($play_list, $index);
    $play_array = explode("Line", $play_list);
    $index1 = 0;
    foreach ($play_array as $play) {
        //각각의 공연탭으로 이동하여 세부정보 가져오기
        $index1++;
        $index = strpos($play, 'http://ticket.interpark.com/TIKI/Main/TikiGoodsInfo.asp?GoodsCode=');
        $play = substr($play, $index);
 private static function process_crawl_data($rss_link, $term_id, $folders)
 {
     if (!$rss_link || !$term_id) {
         return;
     }
     $data = DLN_Source_Helper::load_rss_link($rss_link);
     //$data = DLN_Source_Helper::load_google_feed_rss( $rss_link );
     // get links added in db
     $hashes = $data['hash'];
     $posts = $data['post'];
     $arr_urls = $data['urls'];
     $arr_url = parse_url(esc_url($rss_link));
     $site = isset($arr_url['host']) ? $arr_url['host'] : '';
     $hashes_added = self::get_post_link_added($site, $hashes);
     // Exclude links added
     $post_added_ids = array();
     if (!empty($hashes_added)) {
         $arr_new_posts = array();
         foreach ($posts as $i => $post) {
             foreach ($hashes_added as $j => $hash) {
                 if (isset($hash['hash']) && $post->hash == $hash['hash']) {
                     unset($posts[$i]);
                     $post_added_ids[] = $hash['post_id'];
                 }
             }
         }
         $arr_new_posts = array_merge($posts);
         $posts = $arr_new_posts;
     }
     // Add relation for post and source
     self::add_relate_post_source($post_added_ids, $term_id);
     // Re-validate url
     foreach ($posts as $i => $post) {
         if (!self::is_valid_url($post->link)) {
             unset($posts[$i]);
         }
     }
     // Assign facebook information for posts
     $links = !empty($arr_urls) ? implode("','", $arr_urls) : '';
     if ($links) {
         $fql = urlencode("SELECT url, normalized_url, total_count, share_count, like_count, comment_count, comments_fbid FROM link_stat WHERE url IN ('{$links}')");
         $app_id = FB_APP_ID;
         $app_secret = FB_SECRET;
         $jfb_object = json_decode(file_get_contents_curl("https://graph.facebook.com/fql?q={$fql}&access_token={$app_id}|{$app_secret}"), false, 512, JSON_BIGINT_AS_STRING);
         if (!empty($jfb_object) && isset($jfb_object->data)) {
             foreach ($posts as $i => $post) {
                 foreach ($jfb_object->data as $j => $fb_obj) {
                     if ($post->link == $fb_obj->url) {
                         $posts[$i]->total_count = $fb_obj->total_count;
                         $posts[$i]->share_count = $fb_obj->share_count;
                         $posts[$i]->like_count = $fb_obj->like_count;
                         $posts[$i]->comment_count = $fb_obj->comment_count;
                         $posts[$i]->comments_fbid = $fb_obj->comments_fbid;
                     }
                 }
             }
         }
     }
     if (!empty($posts)) {
         $arr_post_ids = array();
         foreach ($posts as $i => $post) {
             // Get published date use google news api
             if ($post->title) {
                 //$post = DLN_Source_Helper::load_google_news( $post->title, $post->link, $post );
                 // Get image use google images api
                 //if ( empty( $post->image ) ) {
                 //$post    = DLN_Source_Helper::load_google_images( $post->title, $post->link, $post );
                 $post_id = self::insert_post_link($post, $term_id, $folders);
                 if ($post_id) {
                     // Insert to dln_post_link
                     $link = esc_url($post->link);
                     $arr_url = parse_url($link);
                     $site = isset($arr_url['host']) ? $arr_url['host'] : '';
                     $hash = DLN_Cron_Helper::generate_hash($link);
                     $data = array('post_id' => $post_id, 'site' => $site, 'link' => $link, 'hash' => $hash, 'time_create' => date('Y-m-d H:i:s'), 'total_count' => $post->total_count, 'comment_fbid' => $post->comments_fbid);
                     self::insert_dln_post_link($data);
                     $arr_post_ids[] = $post_id;
                 }
                 //}
             }
         }
         self::add_relate_post_source($arr_post_ids, $term_id);
     }
     // Update crawl count source link
     $crawl_count = 1;
     $data = array('crawl' => $crawl_count);
     self::update_source_link($data, $term_id);
     var_dump($posts, date('Y-m-d H:i:s'));
 }
Beispiel #23
0
    $opts = array('http' => array('method' => 'POST', 'header' => $header, 'content' => $query), 'ssl' => array('verify_peer' => false));
    function file_get_contents_curl($url, $params)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
        $data_curl = curl_exec($ch);
        curl_close($ch);
        return $data_curl;
    }
    //$context = stream_context_create($opts);
    $result = file_get_contents_curl('https://oauth.yandex.ru/token', $query);
    $result = json_decode($result);
    $token = $result->{'access_token'};
    $error_description = $result->{'error_description'};
    if (isset($token)) {
        echo "Получен токен: " . $token . "<br>";
    } else {
        echo "Ошибка: " . $error_description . "<br>";
    }
}
?>
<a href="https://oauth.yandex.ru/authorize?response_type=code&client_id=06441eef0fa841478f8b2f73d6519117">Login</a>
<br>
<a href='/auth/redirect'>Test connection</a>
function findTime2($url)
{
    $day = array('월', '화', '수', '목', '금', '토', '일', '평일', '주말');
    //날짜별로 시간정보를 가져오기위한 배열
    $inter_data = file_get_contents_curl($url);
    $inter_data = mb_convert_encoding($inter_data, 'utf-8', 'euc-kr');
    // 이름 구하기
    $title = $inter_data;
    $index = strpos($title, '<h1>');
    $title = substr($title, $index);
    $index = strpos($title, '</h1>');
    $title = substr($title, 0, $index);
    $title = strip_tags($title);
    $title = str_replace("“", "", $title);
    $title = str_replace("”", "", $title);
    $title = str_replace("‘", "", $title);
    $title = str_replace("’", "", $title);
    $title = str_replace(",", "", $title);
    $title = str_replace("\n", "", $title);
    $title = str_replace("\r", "", $title);
    $title = str_replace("\t", "", $title);
    $title = $title . trim();
    echo $title . "<br>";
    $title2 = $inter_data;
    $index = strpos($title2, '「');
    $title2 = substr($title2, $index);
    $index = strpos($title2, '」더 궁금하다면? ');
    $title2 = substr($title2, 0, $index);
    $title2 = str_replace("「", "", $title2);
    $title2 = str_replace("-", "", $title2);
    echo $title2 . "<br>";
    //이름 완료
    // 인스타api 이용해 인기도 구하기
    $popularity = getInstaTag($title2);
    echo "<br>" . $popularity . "<br>";
    // 인기도 완료
    // 이미지 구하기
    $img = $inter_data;
    $index = strpos($img, 'TabA_Poster');
    $img = substr($img, $index);
    $index = strpos($img, 'divMediaInfo');
    $img = substr($img, 0, $index);
    $index = strpos($img, 'http://');
    $img = substr($img, $index);
    $index = strpos($img, '" alt');
    $img = substr($img, 0, $index);
    echo $img . "<br>";
    //이미지 완료
    //장소이름 구하기
    $place_name = $inter_data;
    $index = strpos($place_name, '장소');
    $place_name = substr($place_name, $index);
    $index = strpos($place_name, '기간');
    $place_name = substr($place_name, 0, $index);
    $index = strpos($place_name, '</h4>');
    $place_name = substr($place_name, $index);
    $place_name = strip_tags($place_name);
    $place_name = str_replace("\n", "", $place_name);
    $place_name = str_replace("\r", "", $place_name);
    $place_name = str_replace("\t", "", $place_name);
    echo $place_name . "<br>";
    //장소이름 완료
    //기간안에 오늘날짜가 포함된 공연만 DB에 저
    $play_date = $inter_data;
    $index = strpos($play_date, '기간');
    $play_date = substr($play_date, $index);
    $index = strpos($play_date, '201');
    $play_date = substr($play_date, $index);
    $index = strpos($play_date, 'btn_moretime');
    $play_date = substr($play_date, 0, $index);
    $index = strpos($play_date, '~');
    if (!($index == 0)) {
        $play_date = substr($play_date, 0, $index);
    } else {
        $index = strpos($play_date, 'java');
        $play_date = substr($play_date, 0, $index);
    }
    $play_date = preg_replace("/[^0-9]/", "", $play_date);
    $play_date = trim($play_date);
    echo "play_date : " . $play_date . "<br>";
    $today = date("Ymd");
    echo $today . " ";
    echo $play_date . "<br>";
    //시작날짜가 오늘보다 뒤에있으면 DB에 저장하지 않
    if ((int) $play_date - (int) $today > 0) {
        echo "걸러라<br>";
        return 0;
    }
    //날짜 거르기
    //좌석수 구하기, 앞으로 추가될 기능
    $seat = $inter_data;
    $index = strpos($seat, 'var vPC');
    $seat = substr($seat, $index);
    $index = strpos($seat, 'var vBSYN');
    $seat = substr($seat, 0, $index);
    $seat = preg_replace("/[^0-9]/", "", $seat);
    //공연장정보 페이지로 이동하여 공연장의 좌석수 가져오기
    $url2 = "http://ticket.interpark.com/Ticket/Goods/ifrGoodsPlace.asp?PlaceCode=" . $seat;
    $place = file_get_contents_curl($url2);
    $place = mb_convert_encoding($place, 'utf-8', 'euc-kr');
    //좌석수 완료
    // 위도, 경도 구하기
    $index = strpos($place, '&Longitude');
    if (!$index) {
        return 0;
    }
    $xy = substr($place, $index);
    $index = strpos($xy, '&Width');
    $xy = substr($xy, 0, $index);
    $xy_array = explode('&', $xy);
    $xy_array[1] = preg_replace("/([a-zA-Z]{1,10})/", "", $xy_array[1]);
    //영어지우기
    $xy_array[1] = str_replace("=", "", $xy_array[1]);
    $longitude = (double) $xy_array[1];
    $xy_array[2] = preg_replace("/([a-zA-Z]{1,10})/", "", $xy_array[2]);
    //영어지우기
    $xy_array[2] = str_replace("=", "", $xy_array[2]);
    $latitude = (double) $xy_array[2];
    echo $longitude . "<br>";
    echo $latitude . "<br>";
    //long , lat 완료
    //공연 소요시간 구하기 -> 보여질때 시작시간 + 소요시간으로 제공될것
    $index = strpos($inter_data, '<dd class="etc">');
    $inter_data = substr($inter_data, $index);
    $inter_array = explode('<div class="dt_tSocial">', $inter_data);
    $runtime_array = explode('|', $inter_array[0]);
    $play_runtime = $runtime_array[1];
    $play_runtime = trim($play_runtime);
    if (strlen($play_runtime) >= 10000) {
        $play_runtime = "";
    }
    if (strpos($play_runtime, "분") === FALSE) {
        $play_runtime = 60;
    } else {
        $runtime_array = explode('분', $play_runtime);
        $play_runtime = $runtime_array[0];
    }
    echo $play_runtime . "<br>";
    // 공연 시간 구하기 -> 시작시간
    $index = strpos($inter_array[1], '<p class="m_T5">');
    $inter_data = substr($inter_array[1], $index);
    $index = strpos($inter_data, "</p>");
    $inter_data = substr($inter_data, 0, $index);
    $inter_data = strip_tags($inter_data);
    //특수문자 & 필요없는 문자 지우
    if ($index = strpos($inter_data, "http")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, '*')) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "#")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "▶")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "♥")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "♡")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "http")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "★")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "☞")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "싸니")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "*")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "'")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "※")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "습니다")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "4회")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "[9월")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "추석연휴")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "휴무")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "공연없음")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "단,")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "5/4")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "Open")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    if ($index = strpos($inter_data, "[월요일")) {
        $inter_data = substr($inter_data, 0, $index);
    }
    $inter_data = str_replace("'", "", $inter_data);
    $inter_data = trim($inter_data);
    if (strlen($inter_data) == 0) {
        $inter_data = "평일 6시";
    }
    $inter_data = str_replace("-", "", $inter_data);
    $inter_data = str_replace("&", "", $inter_data);
    $inter_data = str_replace(";", "", $inter_data);
    $inter_data = preg_replace("/(공휴일)/", "", $inter_data);
    $inter_data = preg_replace("/(오후)/", "", $inter_data);
    $inter_data = preg_replace("/([0-9]{1,2})+[.]+([0-9]{1,2})/", "", $inter_data);
    $inter_data = str_replace(",", "", $inter_data);
    $inter_data = str_replace("00", "", $inter_data);
    # code…
    $time2 = explode('(', $inter_data);
    $inter_data = implode(' /', $time2);
    $time2 = explode(')', $inter_data);
    $inter_data = implode(' /', $time2);
    $time2 = explode('~', $inter_data);
    $inter_data = implode(' /', $time2);
    $time2 = explode(' ', $inter_data);
    $inter_data = implode('/', $time2);
    $time2 = explode('년', $inter_data);
    //특정한날짜 지우기
    $inter_data = $time2[sizeof($time2) - 1];
    $time2 = explode('/', $inter_data);
    $inter_data = implode('/', $time2);
    $time2 = explode('시', $inter_data);
    //시로 나눠서 시간은 숫자만남게 만듬
    $inter_data = implode(' /', $time2);
    $time2 = explode('/', $inter_data);
    $time3 = array();
    $i = 0;
    foreach ($time2 as $value2) {
        # code…
        $value2 = preg_replace("/([0-9]{1,2})([가-힣]{1,3})/", "", $value2);
        $value2 = preg_replace("/([a-zA-Z]{1,10})/", "", $value2);
        //영어, 숫자와 한글이 합쳐진문자 지우기
        $len = mb_strlen($value2);
        if ($len > 0) {
            $time3[$i] = $value2;
            $i++;
        }
    }
    foreach ($day as $date) {
        //요일별로 시간찾기
        $kk = 0;
        $flag = true;
        foreach ($time3 as $date2) {
            //시간정보가 배열에 나눠 저장된상태 ex) 월 830 화 330
            # code…
            if ($flag == false) {
                break;
            }
            if (!(strpos($date2, $date) === false)) {
                $temp = $kk;
                while ($temp < sizeof($time3)) {
                    if (preg_match("/[0-9]{1,2}/", $time3[$temp], $a)) {
                        //숫자로만 되어있는 배열을 찾으면
                        $time3[$temp] = preg_replace("/[^0-9]/", "", $time3[$temp]);
                        //해당요일의 시간에 넣음
                        if (strlen($time3[$temp]) >= 3) {
                            //숫자가 3개이상이면 ex)630 ->6시30분
                            $var = substr($time3[$temp], 0, -2) . "시" . substr($time3[$temp], -2) . "분";
                            $time3[$temp] = $var;
                        } else {
                            $time3[$temp] .= "시";
                        }
                        if ($date == '평일') {
                            //평일이란 문구를 찾으면 월화수목금 다 적용
                            $result2['월'] = $time3[$temp];
                            $result2['화'] = $time3[$temp];
                            $result2['수'] = $time3[$temp];
                            $result2['목'] = $time3[$temp];
                            $result2['금'] = $time3[$temp];
                        } else {
                            if ($date == '주말') {
                                //주말이란 문구를 찾으면 토일만 적용
                                $result2['토'] = $time3[$temp];
                                $result2['일'] = $time3[$temp];
                            } else {
                                $result2[$date] = $time3[$temp];
                            }
                        }
                        $flag = false;
                        break;
                    }
                    $temp++;
                }
            } else {
                //숫자 못찾았을경우 해당날짜 공연없음
                $result2[$date] = "공연없음";
            }
            $kk++;
        }
    }
    //소요시간을 숫자만 남게함 ex) 100분 -> 100
    $play_runtime = preg_replace("/[^0-9]/", "", $play_runtime);
    foreach ($result2 as $key => $result3) {
        if ($result3 == "공연없음") {
            continue;
        }
        $hArr = explode('시', $result3);
        // hArr[0] : 시
        if (isset($hArr[1])) {
            $mArr = explode('분', $hArr[1]);
        } else {
            $mArr[0] = 0;
        }
        $tempTime = (int) $mArr[0] + (int) $play_runtime;
        $min = $tempTime % 60;
        $hour = (int) ($hArr[0] + $tempTime / 60);
        //소요시간과 시작시간 더함
        $result2[$key] = $hour . "시" . $min . "분";
    }
    print_r($result2);
    //db에 넣기
    insert($title2, $img, $place_name, $result2, $play_runtime, $longitude, $latitude, $popularity);
    echo "<br><br>";
}
<?php

function file_get_contents_curl($url)
{
    $chandle = curl_init();
    curl_setopt($chandle, CURLOPT_HEADER, 0);
    curl_setopt($chandle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($chandle, CURLOPT_URL, $url);
    $data = curl_exec($chandle);
    curl_close($chandle);
    return $data;
}
print_r(file_get_contents_curl('http://ua2.php.net/manual/ru/function.curl-setopt.php'));
Beispiel #26
0
    $ch = curl_init();
    //Initializing Curl
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $data = curl_exec($ch);
    //Executing CURL Function for getting the data
    curl_close($ch);
    // Closing Curl
    return $data;
    // Returning the HTML Page through data
}
$domain = $_POST["website_url"];
//Getting the URL From index.html
$html = file_get_contents_curl($domain);
// Calling the function
// Starting of Parsing
$doc = new DOMDocument();
//creating New Dom Document
@$doc->loadHTML($html);
// Loading HTML Source in docs
$nodes = $doc->getElementsByTagName('title');
// getting the attributes of Title Tags
//Putting Details into a variable
$title = $nodes->item(0)->nodeValue;
// Getting title
$metas = $doc->getElementsByTagName('meta');
//getting Elements with the tags meta
// Seperating meta description and meta keyword  with each other with running a loop.
for ($i = 0; $i < $metas->length; $i++) {
Beispiel #27
0
<?php

if (isset($_GET['code'])) {
    $answer = file_get_contents_curl('https://oauth.vk.com/access_token?client_id=' . APP_ID . '&client_secret=' . APP_SHARED_SECRET . '&redirect_uri=http://some.thing/cp&code=' . $_GET['code']);
    $answer = json_decode($answer);
    if (!isset($answer->error)) {
        $url = 'https://api.vk.com/method/users.get?user_id=' . $answer->user_id . '&fields=bdate&access_token=' . $answer->access_token;
        $answer = json_decode(file_get_contents_curl($url));
        $user = $answer->response[0];
        // uid, first_name, last_name, bdate
        $time = strtotime($user->bdate);
        echo date("Y-m-d H:i:s", $time);
    } else {
        echo '<p style="position: relative; top: -10px; bottom: -7px; color: #fff; padding: 9px; background-color: #ff696e;">Вам необходимо нажать на кнопку "Разрешить" на странице авторизации во ВКонтакте</p>';
    }
}
if (isset($_GET['error_description']) && $_GET['error_description'] == 'User denied your request') {
    echo '<p style="position: relative; top: -10px; bottom: -7px; color: #fff; padding: 9px; background-color: #ff696e;">Вам необходимо нажать на кнопку "Разрешить" на странице авторизации во ВКонтакте</p>';
}
function file_get_contents_curl($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //Устанавливаем параметр, чтобы curl возвращал данные, вместо того, чтобы выводить их в браузер.
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
?>
function getpagerank($url)
{
    $query = "http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=" . CheckHash(HashURL($url)) . "&features=Rank&q=info:" . $url . "&num=100&filter=0";
    $data = file_get_contents_curl($query);
    //print_r($data);
    $pos = strpos($data, "Rank_");
    if ($pos === false) {
    } else {
        $pagerank = mb_substr($data, $pos + 9);
        return $pagerank;
    }
}
Beispiel #29
-1
function processUrl($url)
{
    libxml_use_internal_errors(true);
    $html = @file_get_contents_curl($url);
    if (!$html) {
        debuglog("* no response from {$url}");
        return null;
    }
    $encoding = mb_detect_encoding($html, 'UTF-8, ISO-8859-1', true);
    if ($encoding == 'UTF-8') {
        $html = mb_convert_encoding($html, 'HTML-ENTITIES', $encoding);
    }
    $doc = new DOMDocument();
    $res = $doc->loadHTML($html);
    $info = array();
    $nodes = $doc->getElementsByTagName('title');
    if (!$nodes) {
        return null;
    }
    $info['title'] = substr($nodes->item(0)->nodeValue, 0, 256);
    $metas = $doc->getElementsByTagName('meta');
    for ($i = 0; $i < $metas->length; $i++) {
        $meta = $metas->item($i);
        $info['overview'] = processUrlKeyword($meta, 'name', 'description', $info['overview'], 512, false);
        $info['overview'] = processUrlKeyword($meta, 'property', 'og:description', $info['overview'], 512);
        $info['overview'] = processUrlKeyword($meta, 'property', 'rnews:description', $info['overview'], 512);
        $info['image_url'] = processUrlKeyword($meta, 'name', 'image', $info['image_url'], 1024, false);
        $info['image_url'] = processUrlKeyword($meta, 'property', 'og:image', $info['image_url'], 1024);
        $info['site_name'] = processUrlKeyword($meta, 'name', 'site_name', $info['site_name'], 64, false);
        $info['site_name'] = processUrlKeyword($meta, 'property', 'og:site_name', $info['site_name'], 64);
        $info['site_name'] = processUrlKeyword($meta, 'name', 'application-name', $info['site_name'], 64, false);
        $info['type'] = processUrlKeyword($meta, 'name', 'type', $info['type'], 64, false);
        $info['type'] = processUrlKeyword($meta, 'property', 'og:type', $info['type'], 64);
        $info['image_url'] = processUrlKeyword($meta, 'name', 'twitter:image', $info['image_url'], 1024);
        $info['player'] = processUrlKeyword($meta, 'name', 'twitter:player', $info['player'], 1024);
        $info['player_width'] = processUrlKeyword($meta, 'name', 'twitter:player:width', $info['player_width']);
        $info['player_height'] = processUrlKeyword($meta, 'name', 'twitter:player:height', $info['player_height']);
    }
    return $info;
}
function pect_cache_get_file($cacheDir, $url, $cacheTime, $useHash = true, $useDrift = true, $fileName = 'source')
{
    $baseDir = PECT_CACHE_DIR . $cacheDir . '/';
    if ($useHash) {
        $baseDir .= md5($url) . '/';
        $cacheFile = $baseDir . '/' . $fileName;
    } else {
        $cacheFile = $baseDir . '/' . $url;
    }
    $isFileCached = file_exists($cacheFile);
    $cacheDrift = 0;
    if ($useDrift) {
        $cacheDrift = rand(0, PECT_CACHE_DRIFT * 2) - PECT_CACHE_DRIFT;
    }
    if ($isFileCached && time() - $cacheTime + $cacheDrift < filemtime($cacheFile)) {
        $html = file_get_contents($cacheFile);
    } else {
        $html = null;
        if ($fileName == 'source' || !$useHash) {
            $retryCount = PECT_CACHE_RETRY;
            while (!$html && $retryCount > 0) {
                $html = file_get_contents_curl($url);
                $retryCount--;
            }
            if ($html) {
                if (!is_dir($baseDir)) {
                    mkdir($baseDir, 0755, true);
                }
                file_put_contents($cacheFile, $html);
            } elseif ($isFileCached) {
                $html = file_get_contents($cacheFile);
            } else {
                exit('Could not cache ' . $url);
            }
        }
    }
    return $html;
}