Exemplo n.º 1
0
function getStaffvalue($staff)
{
    global $config;
    $param = "objectlist/by-fieldvalue/" . urlencode($staff);
    $url = $config['cmdb']['url'] . $param;
    return curlGet($url);
}
Exemplo n.º 2
0
function priceAt2($price, $name = 'Payment')
{
    global $rateObj, $BTC_JSON_URL, $BTC_AVG_COM, $BTC_WINK;
    $rateFile = 'rates.ser';
    if (!isset($rateObj)) {
        if (($fTime = @filemtime($rateFile)) && time() - $fTime > 1200) {
            @unlink($rateFile);
        }
        if (($fRate = @file_get_contents($rateFile)) === false) {
            $rateJS = curlGet("http://ws.goldmoney.com/metal/prices/currentSpotPrices?currency=usd&units=ounces");
            $metals = json_decode($rateJS);
            $rateObj = new stdClass();
            foreach ($metals->spotPrices as $rate) {
                $prc = $rate->spotPrice;
                switch ($rate->metal) {
                    case 'au':
                        $rateObj->rateAu = $prc;
                        break;
                    case 'ag':
                        $rateObj->rateAr = $prc;
                        break;
                }
            }
            $btc = curlGet($BTC_JSON_URL);
            if ($btc > '' && ($rates = json_decode($btc))) {
                $rates = get_object_vars($rates->USD);
                $rateObj->rateBTC = $rates['24h'];
            } else {
                $btc = curlGet($BTC_AVG_COM);
                if ($rates = json_decode($btc)) {
                    $rates = get_object_vars($rates);
                    $rateObj->rateBTC = $rates['24h_avg'];
                } else {
                    $btc = curlGet($BTC_WINK);
                    if ($rates = json_decode($btc)) {
                        $rates = get_object_vars($rates);
                        $rateObj->rateBTC = $rates['price'] / 100;
                    } else {
                        $rateObj->rateBTC = -1;
                    }
                }
            }
            $fRate = serialize($rateObj);
            file_put_contents($rateFile, $fRate, LOCK_EX);
        }
        $rateObj = unserialize($fRate);
        if ($rateObj->rateBTC == -1) {
            @unlink($rateFile);
        }
    }
    echo "<!-- btc3: {$btc},  -->";
    $inAr = $rateObj->rateAr > 0 ? number_format($price / $rateObj->rateAr, 3) : 'N/A';
    $inAuz = $rateObj->rateAu > 0 ? number_format($price / $rateObj->rateAu, 5) : 'N/A';
    $inAu = $rateObj->rateAu > 0 ? number_format($price / $rateObj->rateAu * 31.1034768, 3) : 'N/A';
    $inBTC = $rateObj->rateBTC > 0 ? number_format($price / $rateObj->rateBTC, 5) : 'N/A';
    $pp1 = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=JGMXUNFVK7U94&lc=US";
    $pp2 = "&currency_code=USD&button_subtype=products&add=1&bn=PP%2dShopCartBF%3abtn_cart_LG%2egif%3aNonHosted";
    echo " <a href='{$pp1}&item_name={$name}&amount={$price}{$pp2}'\r\n        title='Pay with Paypal'>\${$price}.00</a>\r\n        (<select>\r\n        <option>Or Real Money...</option>\r\n        <option>{$inAr} oz. Silver</option>\r\n        <option>{$inAu} grams gold</option>\r\n        <option>{$inAuz} troy oz. gold</option>\r\n        <option>{$inBTC} bitcoins</option></select>)";
}
Exemplo n.º 3
0
function geturls($url)
{
    $data = curlGet($url);
    print_r($data);
    preg_match_all('/http:\\/\\/mp.weixin.qq.com\\/s(.*)#rd/', $data, $urls);
    $urls = array_unique($urls[0]);
    //return $urls;
}
Exemplo n.º 4
0
function doOutboundCall($from, $to)
{
    global $api_key, $api_url;
    $call_url = 'http://www.kookoo.in/outbound/outbound.php?phone_no=' . $from . '&api_key=' . $api_key;
    $callback_url = $api_url . '/agentcustomerflow.php?custno=' . $to . '&agentid=' . $from;
    $call_url .= '&url=' . rawurlencode($callback_url);
    curlGet($call_url);
}
Exemplo n.º 5
0
function get_description($url)
{
    $fullpage = curlGet($url);
    $dom = new DOMDocument();
    @$dom->loadHTML($fullpage);
    $xpath = new DOMXPath($dom);
    $tags = $xpath->query('//div[@class="info-description-body"]');
    foreach ($tags as $tag) {
        $my_description .= trim($tag->nodeValue);
    }
    return utf8_decode($my_description);
}
Exemplo n.º 6
0
echo "--- xAuth Auto-Updater ---", PHP_EOL;
$version = yaml_parse_file("phar://" . __FILE__ . "/plugin.yml")["version"];
echo "Current version: {$version}", PHP_EOL;
echo "Checking for new versions from GitHub...", PHP_EOL;
$ret = curlGet("https://api.github.com/repos/xxFlare/xAuth/releases", 5);
if (strlen((string) $ret) > 0) {
    $data = json_decode($ret);
    if (is_array($data) and isset($data[0])) {
        $first = $data[0];
        $name = $first->tag_name;
        if (version_compare($version, $name, '<') and !$version->prerelease) {
            echo "Updating to version {$name}...", PHP_EOL;
            $assets = $first->assets;
            foreach ($assets as $asset) {
                if ($asset->name === "xAuth.phar") {
                    $phar = curlGet($asset->browser_download_url);
                    file_put_contents(__FILE__, $phar);
                    echo "Updated!", PHP_EOL;
                    exit(0);
                }
            }
        }
    }
}
echo "Not updated.", PHP_EOL;
exit(1);
function curlGet($url, $timeout)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 xAuth-Updater"], $extraHeaders));
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
Exemplo n.º 7
0
<?php

require_once 'basic.php';
# Google Image Scraping
if (isset($_GET['q']) && !empty($_GET['q'])) {
    $count = 0;
    $urlFormat = 'https://www.google.co.id/search?tbm=isch&start=%s&q=%s';
    $fImg = '<img src="%s" alt="%s">';
    $limit = isset($_GET['limit']) && is_numeric($_GET['limit']) ? $_GET['limit'] : 500;
    $q = urlencode($_GET['q']);
    while (true) {
        $page = curlGet(sprintf($urlFormat, $count, $q));
        $cleanPage = htmlspecialchars_decode($page);
        $doc = new DOMDocument();
        @$doc->loadHTML($cleanPage);
        $imageTags = $doc->getElementsByTagName('img');
        foreach ($imageTags as $tag) {
            $parent = $tag->parentNode;
            if ($parent->tagName == 'a' && $count < $limit) {
                printf($fImg, $tag->getAttribute('src'), 'Kristen Stewart');
                ++$count;
            }
        }
        if ($imageTags->length <= 1 || $count >= $limit) {
            break;
        }
    }
} else {
    echo 'q is missing.';
}
Exemplo n.º 8
0
$url = $api;
$i = 0;
$sum = count($_GET);
foreach ($_GET as $k => $v) {
    if ($k == "chl" || $k == "chdl") {
        $v = urlencode($v);
    }
    $i++;
    if ($i < $sum) {
        $url .= $k . "=" . $v . "&";
    } else {
        $url .= $k . "=" . $v;
    }
}
//die($url);
/*
if(isset($_GET['cht'])) {
	$cht = $_GET['cht'];
}
if(isset($_GET['chl'])) {
	$chl = $_GET['chl'];
}
if(isset($_GET['chof'])) {
	$chof = $_GET['chof'];
}
$chl = urlencode($chl);
$url = $api . $cht . "&chl=" . $chl . "&chof=" . $chof;
*/
header("Content-Type: image/webp; charset=UTF-8");
$data = curlGet($url);
die($data);
Exemplo n.º 9
0
 function Parse($rss_url)
 {
     // Open and load RSS file
     if ($rss_content = curlGet($rss_url)) {
         // Parse document encoding
         $result['encoding'] = $this->my_preg_match("'encoding=[\\'\"](.*?)[\\'\"]'si", $rss_content);
         // if document codepage is specified, use it
         if ($result['encoding'] != '') {
             $this->rsscp = $result['encoding'];
         } else {
             $this->rsscp = $this->default_cp;
         }
         // This is used in my_preg_match()
         // Parse CHANNEL info
         preg_match("'<channel.*?>(.*?)</channel>'si", $rss_content, $out_channel);
         foreach ($this->channeltags as $channeltag) {
             $temp = $this->my_preg_match("'<{$channeltag}.*?>(.*?)</{$channeltag}>'si", $out_channel[1]);
             if ($temp != '') {
                 $result[$channeltag] = $temp;
             }
             // Set only if not empty
         }
         // If date_format is specified and lastBuildDate is valid
         if ($this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !== -1) {
             // convert lastBuildDate to specified date format
             $result['lastBuildDate'] = date($this->date_format, $timestamp);
         }
         // Parse TEXTINPUT info
         preg_match("'<textinput(|[^>]*[^/])>(.*?)</textinput>'si", $rss_content, $out_textinfo);
         // This a little strange regexp means:
         // Look for tag <textinput> with or without any attributes, but skip truncated version <textinput /> (it's not beggining tag)
         if (isset($out_textinfo[2])) {
             foreach ($this->textinputtags as $textinputtag) {
                 $temp = $this->my_preg_match("'<{$textinputtag}.*?>(.*?)</{$textinputtag}>'si", $out_textinfo[2]);
                 if ($temp != '') {
                     $result['textinput_' . $textinputtag] = $temp;
                 }
                 // Set only if not empty
             }
         }
         // Parse IMAGE info
         preg_match("'<image.*?>(.*?)</image>'si", $rss_content, $out_imageinfo);
         if (isset($out_imageinfo[1])) {
             foreach ($this->imagetags as $imagetag) {
                 $temp = $this->my_preg_match("'<{$imagetag}.*?>(.*?)</{$imagetag}>'si", $out_imageinfo[1]);
                 if ($temp != '') {
                     $result['image_' . $imagetag] = $temp;
                 }
                 // Set only if not empty
             }
         }
         // Parse ITEMS
         preg_match_all("'<item(| .*?)>(.*?)</item>'si", $rss_content, $items);
         $rss_items = $items[2];
         $i = 0;
         $result['items'] = array();
         // create array even if there are no items
         foreach ($rss_items as $rss_item) {
             // If number of items is lower then limit: Parse one item
             if ($i < $this->items_limit || $this->items_limit == 0) {
                 foreach ($this->itemtags as $itemtag) {
                     $temp = $this->my_preg_match("'<{$itemtag}.*?>(.*?)</{$itemtag}>'si", $rss_item);
                     if ($temp != '') {
                         $result['items'][$i][$itemtag] = $temp;
                     }
                     // Set only if not empty
                 }
                 // Strip HTML tags and other bullshit from DESCRIPTION
                 if ($this->stripHTML && $result['items'][$i]['description']) {
                     $result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description'])));
                 }
                 // Strip HTML tags and other bullshit from TITLE
                 if ($this->stripHTML && $result['items'][$i]['title']) {
                     $result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title'])));
                 }
                 // If date_format is specified and pubDate is valid
                 if ($this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !== -1) {
                     // convert pubDate to specified date format
                     $result['items'][$i]['pubDate'] = date($this->date_format, $timestamp);
                 }
                 // Item counter
                 $i++;
             }
         }
         $result['items_count'] = $i;
         return $result;
     } else {
         return False;
     }
 }
Exemplo n.º 10
0
 *
 * RuneAudio website and logo
 * copyright (C) 2013-2014 - ACX webdesign (Andrea Coiutti)
 *
 * This Program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * This Program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with RuneAudio; see the file COPYING.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.txt>.
 *
 *  file: app/tun_ctl.php
 *  version: 1.3
 *  coder: Simone De Gregori
 *
 */
// disable main template output
$tplfile = 0;
$proxy = $redis->hGetall('proxy');
if ($proxy['enable'] === '1') {
    echo curlGet(substr($_SERVER["REQUEST_URI"], 5), $proxy);
} else {
    echo curlGet(substr($_SERVER["REQUEST_URI"], 5));
}
Exemplo n.º 11
0
<?php

$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
// 给下列参数赋值
/*$appid= AppId;
$secret= AppSecret;
$appkey= 支付专用签名串PaySignKey*/
$appid = 'wxfea3e92ddf4936d5';
$secret = '674828c37381378ba816825c3d533a82';
$appkey = 'd1qOVI3KEMQWz2uX2koFros8U2NZpTN5CX8JU6cN50UU4SO38fqRKZ3GD8jv3Ut6UzMmChnc1JerftH1Opdg0hnCW4GC35f09HCkqad3ashj9MVJVVSglknlMZMsJCgi';
$url_get = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $secret;
$json = json_decode(curlGet($url_get));
$access_token = $json->access_token;
$openid = $postObj->OpenId;
$deliver_msg = "ok";
$deliver_status = "1";
$deliver_timestamp = time();
$out_trade_no = $_GET['out_trade_no'];
$transid = $_GET['transaction_id'];
$sign = getSign($appid, $appkey, $deliver_msg, $deliver_status, $deliver_timestamp, $openid, $out_trade_no, $transid);
$url = "https://api.weixin.qq.com/pay/delivernotify?access_token=" . $access_token;
$data = '{
		"appid" : "' . $appid . '",
		"openid" : "' . $openid . '",
		"transid" : "' . $transid . '",
		"out_trade_no" : "' . $out_trade_no . '",
		"deliver_timestamp" : "' . $deliver_timestamp . '",
		"deliver_status" : "' . $deliver_status . '",
		"deliver_msg" : "' . $deliver_msg . '",
		"app_signature" : "' . $sign . '",
Exemplo n.º 12
0
// plain text
$my_description = 'Description';
// plain text
$my_link = 'http://www.youtube.com/user/username/';
// full URL to show homepage
$my_install_url = 'http://example.com/yt/';
// url where script is installed
/* 
 * URL where your cron job will save the feed output - this is used for the 
 * atom self-reference in the feed and should match where the feed will be 
 */
$my_feed_url = 'http://example.com/feed.xml';
$itunes_image = 'http://example.com/photo.jpg';
/* nothing to configure below here */
include_once 'curl.php';
if ($rs = curlGet($source_feed)) {
    //print_r($rs);
} else {
    die('Error: Feed file not found, dude.');
}
$my_videos = simplexml_load_string($rs);
/* write out the outer shell, channel, globals */
$updated = $my_videos->updated;
$updated = date("D, d M Y H:i:s T", strtotime($updated));
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\t<rss version=\"2.0\" xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\"\r\n\t\t xmlns:atom=\"http://www.w3.org/2005/Atom\">\t\r\n\t<channel>\r\n\t\t<title>{$my_title}</title>\r\n\t\t<link>{$my_link}</link>\r\n\t\t<description>{$my_description}</description>\r\n\t\t<image>\r\n\t\t\t<url>{$itunes_image}</url>\r\n\t\t\t<link>{$my_link}</link>\r\n\t\t\t<description>{$my_title}</description>\r\n\t\t\t<title>{$my_title}</title>\r\n\t\t</image>\r\n\t\t<language>en-us</language>\r\n\t\t<lastBuildDate>{$updated}</lastBuildDate>\r\n\t\t<pubDate>{$updated}</pubDate>\r\n\t\t<itunes:explicit>no</itunes:explicit>\r\n\t\t<atom:link href=\"{$my_feed_url}\" rel=\"self\" type=\"application/rss+xml\" /> \r\n\r\n\t\t";
/* now get the info on each item in the feed */
foreach ($my_videos as $entry) {
    $pubDate = $entry->published;
    $pubDate = date("D, d M Y H:i:s T", strtotime($pubDate));
    $videoid = explode('/', $entry->id);
    $item_url = htmlentities($entry->link[0]['href']);
Exemplo n.º 13
0
//}
//
//$auth->streaming('user', function ($stream) use ($screen_name) {
//
////$auth->streaming('statuses/sample', function ($status) {
//
//	if (isset($stream->friends)) {
//		echo "friends : ", count($stream->friends);
//	}
//	if (isset($stream->text) && $stream->user->screen_name === $screen_name) {
//		echo "tweet: {$stream->user->screen_name}";
//	}
//
//});
$endpoint_url = "https://profsnapshot.suzutan.jp/api/snapshot/list.json";
$result = curlGet($endpoint_url, ["hello"]);
var_dump($result);
function curlGet($url, $params = [])
{
    $ch = curlInit($url);
    curl_setopt_array($ch, [CURLOPT_URL => $url . ($params ? "?" . http_build_query($params, "", "&") : ""), CURLOPT_POST => false]);
    $response = curlAction($ch);
    return $response;
}
function curlPost($url, $params = [])
{
    $ch = curlInit($url);
    curl_setopt_array($ch, [CURLOPT_URL => $url, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($params, '', '&')]);
    $response = curlAction($ch);
    return $response;
}
Exemplo n.º 14
0
 function getLinks($my_id = NULL, $my_type = NULL, $debug = NULL)
 {
     include_once 'curl.php';
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "getLinks");
     //----------------------------------------------------------
     if (isset($_REQUEST['videoid']) && is_null($my_id)) {
         $my_id = $_REQUEST['videoid'];
     } else {
         if (is_null($my_id)) {
             $chk['bool'] = false;
             $chk['message'] = 'No video id passed in';
             return $chk;
         }
     }
     if (isset($_REQUEST['type']) && is_null($my_type)) {
         $my_type = $_REQUEST['type'];
     } else {
         if (is_null($my_type)) {
             $my_type = 'redirect';
         }
     }
     if (isset($_REQUEST['debug']) && is_null($debug)) {
         $debug = TRUE;
     } else {
         if (is_null($debug)) {
             $debug = FALSE;
         }
     }
     if ($my_type == 'Download') {
     }
     // end of if for type=Download
     /* First get the video info page for this video id */
     $my_video_info = 'http://www.youtube.com/get_video_info?&video_id=' . $my_id;
     $my_video_info = curlGet($my_video_info);
     /* TODO: Check return from curl for status code */
     $thumbnail_url = $title = $url_encoded_fmt_stream_map = $type = $url = '';
     parse_str($my_video_info);
     if ($thumbnail_url == "") {
         $chk['bool'] = false;
         $chk['message'] = "Check if video id was written correctly.";
     }
     /*if ($video['bool'] && !$chk['bool']) {
     			$video['result'] = $video['result'][0];
     			$video['result']['formats'] = $chk['result']['formats'];
     			return $chk = $video;
     		} else if(!$chk['bool']){
     			return $chk;
     		}*/
     $chk['result']['img_url'] = $this->thumbnail_url = $thumbnail_url;
     $this->my_title = $title;
     //if (!$video['bool']) $chk['result']['title'] = stripslashes($my_title);
     if (isset($url_encoded_fmt_stream_map)) {
         /* Now get the url_encoded_fmt_stream_map, and explode on comma */
         $my_formats_array = explode(',', $url_encoded_fmt_stream_map);
         //if($debug) {
         //	echo '<pre>';
         //	print_r($my_formats_array);
         //	echo '</pre>';
         //}
     } else {
         $chk['bool'] = false;
         $chk['message'] = 'No encoded format stream found.Here is what we got from YouTube:' . $my_video_info;
     }
     if (count($my_formats_array) == 0 || $my_formats_array[0]['ip'] == "" && $my_formats_array[0]['type'] == "") {
         $chk['bool'] = false;
         $chk['message'] = 'No format stream map found - was the video id correct?';
         return $chk;
     }
     /* create an array of available download formats */
     $avail_formats[] = '';
     $i = 0;
     $ipbits = $ip = $itag = $sig = $quality = '';
     $expire = time();
     foreach ($my_formats_array as $format) {
         parse_str($format);
         $avail_formats[$i]['itag'] = $itag;
         $avail_formats[$i]['quality'] = $quality;
         $type = explode(';', $type);
         $avail_formats[$i]['type'] = $type[0];
         $avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig;
         parse_str(urldecode($url));
         $avail_formats[$i]['expires'] = date("G:i:s T", $expire);
         $avail_formats[$i]['ipbits'] = $ipbits;
         $avail_formats[$i]['ip'] = $ip;
         $avail_formats[$i]['download'] = "http://" . $_SERVER["HTTP_HOST"] . str_replace($_SERVER['DOCUMENT_ROOT'], "", "/var/chroot" . dirname(__FILE__)) . '/download.php?mime=' . $avail_formats[$i]['type'] . '&title=' . urlencode($my_title) . '&token=' . base64_encode($avail_formats[$i]['url']);
         $i++;
     }
     $chk['result']['formats'] = $avail_formats;
     //file_put_contents("files/Tmpfile.flv", fopen($avail_formats[0]['url'], 'r'));
     if ($debug) {
         echo '<p>These links will expire at ' . $avail_formats[0]['expires'] . '</p>';
         echo '<p>The server was at IP address ' . $avail_formats[0]['ip'] . ' which is an ' . $avail_formats[0]['ipbits'] . ' bit IP address. ';
         echo 'Note that when 8 bit IP addresses are used, the download links may fail.</p>';
     }
     if ($my_type == 'Download') {
         echo $avail_formats;
     } else {
         /* In this else, the request didn't come from a form but from something else
          * like an RSS feed.
          * As a result, we just want to return the best format, which depends on what
          * the user provided in the url.
          * If they provided "format=best" we just use the largest.
          * If they provided "format=free" we provide the best non-flash version
          * If they provided "format=ipad" we pull the best MP4 version
          *
          * Thanks to the python based youtube-dl for info on the formats
          *   							http://rg3.github.com/youtube-dl/
          */
         $format = $_REQUEST['format'];
         $target_formats = '';
         switch ($format) {
             case "best":
                 /* largest formats first */
                 $target_formats = array('38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13');
                 break;
             case "free":
                 /* Here we include WebM but prefer it over FLV */
                 $target_formats = array('38', '46', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13');
                 break;
             case "ipad":
                 /* here we leave out WebM video and FLV - looking for MP4 */
                 $target_formats = array('37', '22', '18', '17');
                 break;
             default:
                 /* If they passed in a number use it */
                 if (is_numeric($format)) {
                     $target_formats[] = $format;
                 } else {
                     $target_formats = array('38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13');
                 }
                 break;
         }
         /* Now we need to find our best format in the list of available formats */
         $best_format = '';
         for ($i = 0; $i < count($target_formats); $i++) {
             for ($j = 0; $j < count($avail_formats); $j++) {
                 if ($target_formats[$i] == $avail_formats[$j]['itag']) {
                     //echo '<p>Target format found, it is '. $avail_formats[$j]['itag'] .'</p>';
                     $best_format = $j;
                     break 2;
                 }
             }
         }
         //echo '<p>Out of loop, best_format is '. $best_format .'</p>';
         if (isset($best_format) && isset($avail_formats[$best_format]['url']) && isset($avail_formats[$best_format]['type'])) {
             $redirect_url = $avail_formats[$best_format]['url'];
             $content_type = $avail_formats[$best_format]['type'];
         }
         if (isset($redirect_url)) {
             //header("Location: $redirect_url");
         }
         /*if ($video['bool']) {
         			$video['result'] = $video['result'][0];
         			$video['result']['formats'] = $chk['result']['formats'];
         			$chk = $video;
         		}*/
         return $chk;
     }
     // end of else for type not being Download
 }
Exemplo n.º 15
0
// downloading pages with list of products
<?php 
function curlGet($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_URL, $url);
    $results = curl_exec($ch);
    curl_close($ch);
    return $results;
}
for ($i = 1; $i <= 97; $i++) {
    echo "downloading page" . $i;
    $down = curlGet("http://www.kaymu.com.np/mobile-phones/?page={$i}");
    file_put_contents("/home/spontaneous/Desktop/kaymu/mobile/page{$i}", $down);
}
function sendSMS($no, $message)
{
    global $api_key;
    $sms_url = 'http://www.kookoo.in/outbound/outbound_sms.php?phone_no=' . $no . '&api_key=' . $api_key . '&message=' . $message;
    curlGet($sms_url);
}
Exemplo n.º 17
0
function getPageFromCourse($courseID, $page_url)
{
    $apiUrl = "courses/" . $courseID . "/pages/" . $page_url;
    $response = curlGet($apiUrl);
    return $response;
}
Exemplo n.º 18
0
            } else {
                echo '<p>No video id passed in</p>';
                exit;
            }
        } else {
            echo '<p>Invalid URL</p>';
            exit;
        }
    }
} else {
    echo '<p>No video id passed in</p>';
    exit;
}
// Get the video info page
$info_link = 'http://www.youtube.com/get_video_info?&video_id=' . $v_id . '&asv=3&el=detailpage&hl=en_US';
$video_info = curlGet($info_link);
if (empty($video_info)) {
    echo '<p>No data received from YouTube.</p>';
    if ($debug) {
        echo "<a href={$info_link}>Data_Link</a>";
    }
    exit;
}
parse_str($video_info);
if (isset($url_encoded_fmt_stream_map)) {
    $formats_array = explode(',', $url_encoded_fmt_stream_map);
} else {
    echo '<p>No encoded format stream found.</p>';
    echo '<p>Here is what we got from YouTube:</p>';
    echo '<p>';
    echo $video_info;
Exemplo n.º 19
0
function listModules($courseID)
{
    $apiUrl = "courses/" . $courseID . "/modules/";
    $response = curlGet($apiUrl);
    return $response;
}
Exemplo n.º 20
0
     if ($activePlayer === 'MPD') {
         $apikey = $redis->hGet('jamendo', 'clientid');
         $proxy = $redis->hGetall('proxy');
         if ($_POST['querytype'] === 'radio') {
             $jam_channels = json_decode(curlGet('http://api.jamendo.com/v3.0/radios/?client_id=' . $apikey . '&format=json&limit=200', $proxy));
             foreach ($jam_channels->results as $station) {
                 $channel = json_decode(curlGet('http://api.jamendo.com/v3.0/radios/stream?client_id=' . $apikey . '&format=json&name=' . $station->name, $proxy));
                 $station->stream = $channel->results[0]->stream;
             }
             // TODO: add cache jamendo channels on Redis
             // $redis->hSet('jamendo', 'ch_cache', json_encode($jam_channels));
             // echo $redis->hGet('jamendo', 'ch_cache');
             echo json_encode($jam_channels);
         }
         if ($_POST['querytype'] === 'radio' && !empty($_POST['args'])) {
             echo curlGet('http://api.jamendo.com/v3.0/radios/stream?client_id=' . $apikey . '&format=json&name=' . $_POST['args'], $proxy);
         }
     }
     break;
 case 'spotify':
     if ($activePlayer === 'Spotify') {
         if (isset($_POST['plid'])) {
             echo spopDB($spop, $_POST['plid']);
         } else {
             echo spopDB($spop);
         }
     }
     break;
 case 'spadd':
     if ($activePlayer === 'Spotify') {
         if ($_POST['querytype'] === 'spotify-playlist') {
Exemplo n.º 21
0
                    var_dump($wouafData);
                    exit;
                }
            }
        }
    } catch (Exception $e) {
        if (__DEV__) {
            var_dump($e);
            exit;
        }
    }
} else {
    if ($userId) {
        try {
            //Get user data from API
            $userData = curlGet('https://<%= htmlWebpackPlugin.options.data.apiDomain %>/users/' . $userId, array('html' => 1));
            if ($userData) {
                $userData = json_decode($userData, true);
                if ($userData['code'] === 200) {
                    $data['canonical'] = 'https://' . $_SERVER['HTTP_HOST'] . '/user/' . $userId . '/';
                    $data['content'] .= '<script>window.wouafit.user = '******'user']) . ';</script>' . PHP_EOL . getUserHTML($userData['user']);
                    $data['head'] = getUserMeta($userData['user']) . PHP_EOL . '<link rel="alternate" hreflang="fr" href="https://fr-fr.<%= htmlWebpackPlugin.options.data.domain %>/user/' . $userId . '/" />' . PHP_EOL . '<link rel="alternate" hreflang="en" href="https://en-us.<%= htmlWebpackPlugin.options.data.domain %>/user/' . $userId . '/" />';
                } elseif ($userData['code'] === 404) {
                    header("HTTP/1.1 404 Not Found");
                    $data['head'] = getDefaultMeta();
                    $data['content'] .= '<h1>404 not Found</h1>';
                } else {
                    if (__DEV__) {
                        var_dump($userData);
                        exit;
                    }
Exemplo n.º 22
0
<?php

// Function to make GET request using cURL
function curlGet($url)
{
    $ch = curl_init();
    // Initialising cURL session
    // Setting cURL options
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_URL, $url);
    $results = curl_exec($ch);
    // Executing cURL session
    curl_close($ch);
    // Closing cURL session
    return $results;
    // Return the results
}
$packtPage = curlGet('http://www.google.com');
echo $packtPage;
Exemplo n.º 23
0
<?php

$name = _get('key');
$count = _get('count');
if ($count == null) {
    $count = 1;
}
$url = 'http://www.xiami.com/web/search-songs?key=' . $name;
$content = curlGet($url);
$array = json_decode($content);
if ($array != null) {
    $array = array_slice($array, 0, $count);
    $array = json_encode($array);
    echo $array;
} else {
    echo $content;
}
function curlGet($url)
{
    $ch = curl_init();
    $header = array("Accept-Charset: utf-8");
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $temp = curl_exec($ch);
Exemplo n.º 24
0
function ui_lastFM_coverart($artist, $album, $lastfm_apikey, $proxy)
{
    if (!empty($album)) {
        $url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=" . $lastfm_apikey . "&artist=" . urlencode($artist) . "&album=" . urlencode($album) . "&format=json";
        unset($artist);
    } else {
        $url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&api_key=" . $lastfm_apikey . "&artist=" . urlencode($artist) . "&format=json";
        $artist = 1;
    }
    // debug
    //echo $url;
    $output = json_decode(curlGet($url, $proxy), true);
    // debug
    runelog('coverart lastfm query URL', $url);
    // debug++
    // echo "<pre>";
    // print_r($output);
    // echo "</pre>";
    // key [3] == extralarge last.fm image
    // key [4] == mega last.fm image
    if (isset($artist)) {
        runelog('coverart lastfm query URL', $output['artist']['image'][3]['#text']);
        return $output['artist']['image'][3]['#text'];
    } else {
        runelog('coverart lastfm query URL', $output['album']['image'][3]['#text']);
        return $output['album']['image'][3]['#text'];
    }
}
// Now we have the item count, figure out the page count and create an offset of 0
$itemCount = $curlOutput->data->items;
$pageCount = ceil($itemCount / $limit);
$offset = 0;
// Loop through the pages and extract the item ids into the $itemIds array.
while ($pageCount > 0) {
    $curlOutput = curlGet('https://oc-index.library.ubc.ca/collections/' . $collection . '/items?api_key=' . $apiKey . '&offset=' . $offset . '&limit=' . $limit);
    foreach ($curlOutput->data as $item) {
        $itemIds[] = $item->_id;
    }
    $pageCount--;
    $offset = $offset + 100;
}
// Loop through the item ids and extract metadata into the $items array.
foreach ($itemIds as $itemId) {
    $curlOutput = curlGet('https://oc-index.library.ubc.ca/collections/' . $collection . '/items/' . $itemId . '?api_key=' . $apiKey);
    $item = $curlOutput->data;
    $items[] = array("id" => $itemId, "title" => $item->Title[0]->value, "description" => $item->Description[0]->value, "fullText" => property_exists($item, 'FullText') ? $item->FullText[0]->value : null);
}
// We now have the items stored in $items, uncomment below to check it out.
// echo json_encode($items);
// exit;
// For more fun lets add them into a CSV file. ( You could have file permission problems attempting this )
$fp = fopen($collection . '.csv', 'w');
fputcsv($fp, ['ID', 'TITLE', 'DESCRIPTION', 'FULLTEXT'], '~', '"');
foreach ($items as $item) {
    fputcsv($fp, $item, '~', '"');
}
fclose($fp);
//Simple curl function to keep code DRY, will exit on error.
function curlGet($url)
Exemplo n.º 26
0
<?php

function curlGet($url)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER, false);
    $data = curl_exec($curl);
    curl_close($curl);
    return $data;
}
$bloggerapi = 'https://www.googleapis.com/blogger/v3/blogs/';
$blogid = '{blogid here}';
// http://currentlyunderdevelopment.blogspot.com
$bloggerapi .= $blogid;
$key = '?key={key here}';
$pages = curlGet($bloggerapi . '/pages' . $key);
$posts = curlGet($bloggerapi . '/posts' . $key);
$homepage = file_get_contents('_index.html');
$homepage = str_replace('%PAGES%', $pages, $homepage);
$homepage = str_replace('%POSTS%', $posts, $homepage);
echo $homepage;
if (isset($_REQUEST['type'])) {
    $my_type = $_REQUEST['type'];
} else {
    $my_type = 'redirect';
}
$html = "";
if ($my_type == 'Download') {
    $html .= '<div class="download-all">';
    $html .= '<h1 class="download-heading">Youtube Downloader Results</h1>';
}
// end of if for type=Download
/* First get the video info page for this video id */
//$my_video_info = 'http://www.youtube.com/get_video_info?&video_id='. $my_id;
$my_video_info = 'http://www.youtube.com/get_video_info?&video_id=' . $my_id . '&el=vevo&asv=3&el=detailpage&hl=en_US';
//video details fix *1
$my_video_info = curlGet($my_video_info);
/* TODO: Check return from curl for status code */
$thumbnail_url = $title = $url_encoded_fmt_stream_map = $type = $url = '';
parse_str($my_video_info);
$html .= '<div id="info-video">';
/*switch($config['ThumbnailImageMode'])
{
  // case 2: $html .= '<a href="http://vikasjain.in/youtube/getimage.php?videoid='. $my_id .'&sz=hd" target="_blank"><img src="http://vikasjain.in/youtube/getimage.php?videoid='. $my_id .'" border="0" hspace="2" vspace="2"></a>'; break;
  // case 1: $html .= '<a href="getimage.php?videoid='. $my_id .'&sz=hd" target="_blank"><img src="'. $thumbnail_url .'" border="0" hspace="2" vspace="2"></a>'; break;
  // case 0:  default:  // nothing
  case 2: $html .= '<img src="http://vikasjain.in/youtube/getimage.php?videoid='. $my_id .'" border="0" hspace="2" vspace="2">'; break;
  case 1: $html .= '<img src="'. $thumbnail_url .'" border="0" hspace="2" vspace="2">'; break;
  case 0:  default:  // nothing
}
*/
$html .= '<div class="video-wrapper"><iframe  src="http://www.youtube.com/embed/' . $my_id . '?rel=0&hd=1" frameborder="0" allowfullscreen></iframe></div>';
Exemplo n.º 28
0
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.64 Safari/537.36');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $tmpInfo = curl_exec($ch);
    $error = curl_errno($ch);
    var_dump($tmpInfo);
    var_dump($error);
}
if ($url) {
    curlGet($url, array());
    exit;
}
/*检测并清除BOM*/
if (isset($_GET['dir'])) {
    $basedir = $_GET['dir'];
} else {
    $basedir = '.';
}
$auto = 1;
checkdir($basedir);
function checkdir($basedir)
{
    if ($dh = opendir($basedir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file != '.' && $file != '..') {
Exemplo n.º 29
0
    $xmlPageXPath = new DOMXPath($xmlPageDom);
    return $xmlPageXPath;
}
function curlGet($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_URL, $url);
    $results = curl_exec($ch);
    curl_close($ch);
    return $results;
}
$file = 'links.txt';
$handle = fopen($file, "r");
$i = 1;
// while(!feof($handle))
while ($i != 3104) {
    if ($i < 100) {
        $link = fgets($handle);
        $i++;
        continue;
    }
    echo "downloading file" . $i . "\n";
    $link = fgets($handle);
    $link = str_replace("\n", "", $link);
    $link = str_replace("\r", "", $link);
    echo $link . "\n";
    $down = curlGet($link);
    file_put_contents("/home/spontaneous/Desktop/kaymu/mob/page{$i}", $down);
    $i++;
}
Exemplo n.º 30
0
    curl_setopt($my_ch, CURLOPT_NOBODY, true);
    curl_setopt($my_ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($my_ch, CURLOPT_TIMEOUT, 10);
    $r = curl_exec($my_ch);
    foreach (explode("\n", $r) as $header) {
        if (strpos($header, 'Content-Length:') === 0) {
            return trim(substr($header, 16));
        }
    }
    return '';
}
$video_id = "";
$line = readline("YouTube Video ID: ");
$video_id = $line;
$url = 'http://www.youtube.com/get_video_info?&video_id=' . $video_id . '&asv=3&el=detailpage&hl=en_US';
$curl_result = curlGet($url);
$result_info = array();
// fwrite(handle, string)
parse_str($curl_result, $result_info);
if ($result_info['status'] == "ok") {
    echo "\nVideo Info:\n\nTitle: " . $result_info['title'];
    echo "\nAuthor:" . $result_info['author'];
    echo "\nDuration:" . floor($result_info['length_seconds'] / 60) . " minutes " . $result_info['length_seconds'] % 60 . " Seconds\n\n";
    echo "\nVideo Types:\n";
    $video_types = array();
    $my_formats_array = explode(',', $result_info['url_encoded_fmt_stream_map']);
    $i = 0;
    $sig = "";
    foreach ($my_formats_array as $format) {
        parse_str($format);
        $avail_formats[$i]['itag'] = $itag;