Example #1
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $maj = $sgbl->__ver_major;
     switch ($subaction) {
         case "lxupdateinfo":
             $vlist['current_version_f'] = array('M', $sgbl->__ver_major_minor_release);
             $vlist['latest_version_f'] = array('M', getLatestVersion());
             if ($sgbl->__ver_major_minor_release === getLatestVersion()) {
                 $vlist['__v_button'] = array();
             } else {
                 $vlist['__v_button'] = "Update Now";
             }
             return $vlist;
         case "bugs":
             $file = "bugs/bugs-{$sgbl->__ver_major_minor_release}.txt";
             $content = curl_get_file_contents($file);
             $content = trim($content);
             if (!$content) {
                 $content = "There are no Bugs Reported for this Version";
             }
             $vlist['buglist_f'] = array('t', $content);
             return $vlist;
     }
 }
Example #2
0
/**
 * Created by PhpStorm.
 * User: Lee
 * Date: 15/11/4
 * Time: 16:28
 */
function curl_get_file_contents($url)
{
    # showAuthcode('http://weixin.sogou.com/antispider/util/seccode.php?tc='.time());
    #$cookieFile = SCRIPT_ROOT.'cookie.txt';
    $ch = curl_init();
    #curl_setopt($ch,CURLOPT_COOKIEFILE, $cookieFile); //同时发送Cookie
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    //curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36");
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;http://www.sogou.com)");
    $data = curl_exec($ch);
    $ret = $data;
    list($header, $data) = explode("\r\n\r\n", $data, 2);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    if ($http_code === 301 || $http_code === 302) {
        $matches = array();
        preg_match('/Location:(.*?)\\n/', $header, $matches);
        if (!isset($matches[1]) || empty($matches[1])) {
            return $data;
        }
        $new_url = stripslashes(trim($matches[1]));
        return curl_get_file_contents($new_url);
    } else {
        list($header, $data) = explode("\r\n\r\n", $ret, 2);
        return $data;
    }
}
Example #3
0
 function spider($userid, $total)
 {
     global $pat_url;
     $url = "http://www.patreon.com/userNext?p={$total}&ty=p&srt=&u={$userid}";
     $html = curl_get_file_contents($url);
     if (empty($html)) {
         echo "Pateron Backers List for {$pat_url} - Generated at https://aurous.me/who/<br>";
     } else {
         getPaterons($html);
     }
 }
 private function getHtml($uri)
 {
     #return phpQuery::newDocumentFile($uri);
     if (!$uri) {
         return false;
     }
     $contents = curl_get_file_contents($uri);
     if ($contents) {
         $doc = phpQuery::newDocumentHTML($contents);
         #phpQuery::$documents = array();
         return $doc;
     }
     return false;
 }
Example #5
0
function download_stock_info($ticker)
{
    global $dbh;
    $yahoodata = curl_get_file_contents("http://download.finance.yahoo.com/d/quotes.csv?s={$ticker}&f=ne1");
    $arr = explode(',', $yahoodata);
    $name = $arr[0];
    $err = $arr[1];
    if (preg_match("/No such ticker/", $err)) {
        echo "Error: Ticker {$ticker} does not exist.";
        exit;
    }
    $name = trim($name, "\" \t\n\r");
    // Download the CSV into a tmpfile
    $tf = tempnam('/tmp', '5charts');
    $csv = curl_get_file_contents("http://www.google.com/finance/historical?q={$ticker}&output=csv");
    $handle = fopen($tf, 'w');
    fwrite($handle, $csv);
    fclose($handle);
    chmod($tf, 0777);
    try {
        // See if we have the stock already
        $statement = $dbh->prepare("SELECT COUNT(*), id FROM Stock WHERE ticker = :ticker");
        $statement->execute(array(':ticker' => $ticker));
        $id = null;
        $result = $statement->fetch();
        if ($result[0] == 0) {
            // We don't have it.
            // Now, make the stock and get the id.
            $statement = $dbh->prepare("INSERT INTO Stock (id, ticker, name) \n          VALUES (NULL, :ticker, :name)");
            $statement->execute(array(':ticker' => $ticker, ":name" => $name));
            $id = $dbh->lastInsertId();
        } else {
            // We have it!
            $id = $result[1];
        }
        $statement = $dbh->prepare("LOAD DATA LOCAL INFILE :tf INTO TABLE OHLC \n          FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' \n          IGNORE 1 LINES (@in_date, open, high, low, close, volume) \n          SET Stock_id = :id, date = STR_TO_DATE(@in_date, '%d-%b-%y')");
        $statement->execute(array(':tf' => $tf, ':id' => $id));
        // Unlink temp file
        unlink($tf);
    } catch (PDOException $e) {
        echo $e->getMessage();
        // Unlink temp file
        unlink($tf);
    }
    return $id;
}
Example #6
0
function fetch_thumbnail_image($matches, $key, $post_content, $post_id)
{
    $imageTitle = '';
    preg_match_all('/<\\s*img [^\\>]*title\\s*=\\s*[\\""\']?([^\\""\'>]*)/i', $post_content, $matchesTitle);
    if (count($matchesTitle) && isset($matchesTitle[1])) {
        $imageTitle = $matchesTitle[1][$key];
    }
    $imageUrl = $matches[1][$key];
    $filename = substr($imageUrl, strrpos($imageUrl, '/') + 1);
    if (!(($uploads = wp_upload_dir(current_time('mysql'))) && false === $uploads['error'])) {
        return null;
    }
    $filename = wp_unique_filename($uploads['path'], $filename);
    $new_file = $uploads['path'] . "/{$filename}";
    if (!ini_get('allow_url_fopen')) {
        $file_data = curl_get_file_contents($imageUrl);
    } else {
        if (WP_Filesystem()) {
            global $wp_filesystem;
            $file_data = @$wp_filesystem->get_contents($imageUrl);
        }
    }
    if (!$file_data) {
        return null;
    }
    if (WP_Filesystem()) {
        global $wp_filesystem;
        $wp_filesystem->put_contents($new_file, $file_data);
    }
    $stat = stat(dirname($new_file));
    $perms = $stat['mode'] & 0666;
    @chmod($new_file, $perms);
    $wp_filetype = wp_check_filetype($filename, $mimes);
    extract($wp_filetype);
    if ((!$type || !$ext) && !current_user_can('unfiltered_upload')) {
        return null;
    }
    $url = $uploads['url'] . "/{$filename}";
    $attachment = array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => null, 'post_title' => $imageTitle, 'post_content' => '');
    $thumb_id = wp_insert_attachment($attachment, $file, $post_id);
    if (!is_wp_error($thumb_id)) {
        wp_update_attachment_metadata($thumb_id, wp_generate_attachment_metadata($thumb_id, $new_file));
        update_attached_file($thumb_id, $new_file);
        return $thumb_id;
    }
    return null;
}
/**
 * Function to fetch the image from URL and generate the required thumbnails
 */
function apt_generate_post_thumb($matches, $key, $post_content, $post_id)
{
    // Make sure to assign correct title to the image. Extract it from img tag
    $imageTitle = '';
    preg_match_all('/<\\s*img [^\\>]*title\\s*=\\s*[\\""\']?([^\\""\'>]*)/i', $post_content, $matchesTitle);
    if (count($matchesTitle) && isset($matchesTitle[1])) {
        $imageTitle = $matchesTitle[1][$key];
    }
    // Get the URL now for further processing
    $imageUrl = $matches[1][$key];
    // Get the file name
    $filename = substr($imageUrl, strrpos($imageUrl, '/') + 1);
    if (!(($uploads = wp_upload_dir(current_time('mysql'))) && false === $uploads['error'])) {
        return null;
    }
    // Generate unique file name
    $filename = wp_unique_filename($uploads['path'], $filename);
    // Move the file to the uploads dir
    $new_file = $uploads['path'] . "/{$filename}";
    if (!ini_get('allow_url_fopen')) {
        $file_data = curl_get_file_contents($imageUrl);
    } else {
        $file_data = @file_get_contents($imageUrl);
    }
    if (!$file_data) {
        return null;
    }
    file_put_contents($new_file, $file_data);
    // Set correct file permissions
    $stat = stat(dirname($new_file));
    $perms = $stat['mode'] & 0666;
    @chmod($new_file, $perms);
    // Get the file type. Must to use it as a post thumbnail.
    $wp_filetype = wp_check_filetype($filename, $mimes);
    extract($wp_filetype);
    // No file type! No point to proceed further
    if ((!$type || !$ext) && !current_user_can('unfiltered_upload')) {
        return null;
    }
    // Compute the URL
    $url = $uploads['url'] . "/{$filename}";
    // Construct the attachment array
    $attachment = array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => null, 'post_title' => $imageTitle, 'post_content' => '');
    $thumb_id = wp_insert_attachment($attachment, $file, $post_id);
    if (!is_wp_error($thumb_id)) {
        require_once ABSPATH . '/wp-admin/includes/image.php';
        // Added fix by misthero as suggested
        wp_update_attachment_metadata($thumb_id, wp_generate_attachment_metadata($thumb_id, $new_file));
        update_attached_file($thumb_id, $new_file);
        return $thumb_id;
    }
    return null;
}
Example #8
0
function curl_get_file($file)
{
    $res = curl_get_file_contents($file);
    $res = trim($res);
    if (!$res) {
        return null;
    }
    $data = explode("\n", $res);
    return $data;
}
Example #9
0
function iippcc_generate_post_thumb($imageUrl, $post_id)
{
    $filename = substr($imageUrl, strrpos($imageUrl, '/') + 1);
    if (!(($uploads = wp_upload_dir(current_time('mysql'))) && false === $uploads['error'])) {
        return null;
    }
    $filename = wp_unique_filename($uploads['path'], $filename);
    $new_file = $uploads['path'] . "/{$filename}";
    if (!ini_get('allow_url_fopen')) {
        $file_data = curl_get_file_contents($imageUrl);
    } else {
        $file_data = @file_get_contents($imageUrl);
    }
    if (!$file_data) {
        return null;
    }
    file_put_contents($new_file, $file_data);
    $stat = stat(dirname($new_file));
    $perms = $stat['mode'] & 0666;
    @chmod($new_file, $perms);
    $wp_filetype = wp_check_filetype($filename, $mimes);
    extract($wp_filetype);
    if ((!$type || !$ext) && !current_user_can('unfiltered_upload')) {
        return null;
    }
    $url = $uploads['url'] . "/{$filename}";
    $attachment = array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => null, 'post_title' => $imageTitle, 'post_content' => '');
    $thumb_id = wp_insert_attachment($attachment, $file, $post_id);
    if (!is_wp_error($thumb_id)) {
        require_once ABSPATH . '/wp-admin/includes/image.php';
        wp_update_attachment_metadata($thumb_id, wp_generate_attachment_metadata($thumb_id, $new_file));
        update_attached_file($thumb_id, $new_file);
        return $thumb_id;
    }
    return null;
}
Example #10
0
$output = '';
function curl_get_file_contents($URL)
{
    $c = curl_init();
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_URL, $URL);
    $contents = curl_exec($c);
    curl_close($c);
    if ($contents) {
        file_put_contents('feed.xml', $contents);
        return;
    } else {
        return FALSE;
    }
}
curl_get_file_contents($feed);
?>

<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Welcome to GD Blogify!</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="apple-touch-icon" href="apple-touch-icon.png">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
        <link href='https://fonts.googleapis.com/css?family=Laila:400,700|Merriweather:400,700' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/normalize.min.css">
Example #11
0
    $url = $data;
} elseif (substr($data, 0, 27) == "www.ikea.com/ru/ru/catalog/") {
    $url = "http://" . $data;
} elseif (preg_match("/^\\d{8}\$/", $data)) {
    $url = "http://www.ikea.com/ru/ru/catalog/products/" . $data . "/";
    $url2 = "http://www.ikea.com/ru/ru/catalog/products/S" . $data . "/";
} elseif (preg_match("/^[\\d\\.]{10}\$/", $data)) {
    $url = "http://www.ikea.com/ru/ru/catalog/products/" . str_replace(".", "", $data) . "/";
    $url2 = "http://www.ikea.com/ru/ru/catalog/products/S" . str_replace(".", "", $data) . "/";
} else {
    $url = "";
}
$content = curl_get_file_contents($url);
if (!$content && $url2) {
    $url = $url2;
    $content = curl_get_file_contents($url);
    $newtypes = true;
}
if ($content) {
    // "http://www.ikea.com".
    /*$pre = substr($content, strpos($content, '<div id="name" class="productName">'));
      $name = trim(strip_tags(substr($pre, 0, strpos($pre, '</div>'))));
      $pre = substr($content, strpos($content, '<div id="type" class="productType">'));
      $type = trim(strip_tags(substr($pre, 0, strpos($pre, '</div>'))));
      $pre = substr($content, strpos($content, '<span id="price1" class="packagePrice">'));
      $price = trim(strip_tags(substr($pre, 0, strpos($pre, '</span>'))));
      $price = preg_replace("/\s/", "", $price);
      $price = substr($price, 0, -2);
      */
    $pre = preg_match("/jProductData = (.*)\\};/i", $content, $matches);
    $json = json_decode($matches[1] . "}");
Example #12
0
 function getAPIResults($method, $query)
 {
   $json = curl_get_file_contents(generateAPIURL($method, $query));
   return json_decode($json, true);
 }
Example #13
0
{
    if (ini_get('allow_url_fopen')) {
        return file_get_contents($URL);
    }
    $c = curl_init();
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_URL, $URL);
    $contents = curl_exec($c);
    curl_close($c);
    if ($contents) {
        return $contents;
    } else {
        return FALSE;
    }
}
$downloads_page = curl_get_file_contents('https://sourceforge.net/project/showfiles.php?group_id=222844');
if ($downloads_page !== false) {
    $downloads_page = str_replace(array("\r\n", "\r", "\n", "\t"), '', $downloads_page);
    $downloads_page = explode('<th>Notes / Monitor</th><th>Downloads</th></tr></thead><tfoot><tr><td></td></tr></tfoot><tbody><tr><td>', $downloads_page);
    $first = strpos($downloads_page[1], '<td><a');
    $last = strpos($downloads_page[1], '</td><td><a ', $first + 10);
    $details = str_replace('</td>          <td>', '', substr($downloads_page[1], $first, $last - $first));
    $parts = explode('</a>', $details);
    $release_date = $parts[1];
    $release_version = substr($parts[0], strrpos($parts[0], '>') + 1);
    $link_start = strpos($parts[0], '"') + 1;
    $release_link = 'https://sourceforge.net' . substr($parts[0], $link_start, strrpos($parts[0], '"') - $link_start);
} else {
    $release_date = 'unknown';
    $release_version = 'unknown';
    $release_link = 'https://sourceforge.net/project/showfiles.php?group_id=222844';
Example #14
0
     }
 }
 //________________________________________________________PHPShield_______________________________________________________
 $phpshield_check_url = $install_domain . '/classes/config.php?setup=1';
 if (checkingINI('allow_url_fopen')) {
     $check_phpshield = file_get_contents($phpshield_check_url);
     $phpshield_proceed = true;
 }
 if (!$phpshield_proceed) {
     if (in_array('curl', get_loaded_extensions())) {
         $check_phpshield = curl_get($phpshield_check_url);
         $phpshield_proceed = true;
     }
 }
 if (file_get_contents($phpshield_check_url) != 532) {
     $check_phpshield = curl_get_file_contents($phpshield_check_url);
 }
 //____________if we managed to load url - but cant get output________________
 if ($phpshield_proceed && !ereg($config_output, $check_phpshield)) {
     //output produced by config.php for testing
     $pse = 1;
     //error log
     //error for php5.3
     if ($php_5_3) {
         $display_phpshield_help = 1;
         $phpshield_error_list_1 = 1;
         //php5.3 needs dynamic loader
         $phpshield_result_css = 'Install-Progress-Warning';
         $phpshield_result = 'Error! - See detailed explanation below';
     }
     //error for php5.2.5+
function getFacebookPageFeed($access_token, $facebook_page_id)
{
    $opengraph_query_url = 'https://graph.facebook.com/' . $facebook_page_id . '/feed?access_token=' . $access_token;
    return curl_get_file_contents($opengraph_query_url);
}
Example #16
0
<?php

$allowedExtensions = ["zip", "dmg", "tar.gz", "pkg", "xip", "exe", "app"];
require_once "credentials.php";
if (isset($_GET["q"]) && !empty($_GET["q"])) {
    $query = $_GET["q"];
    $query = str_replace("https://github.com/", "", $query);
    $query = trim($query, '/');
    $apiURL = "https://api.github.com/repos/" . $query . "/releases/latest";
    $apiURL .= "?client_id=" . $client_id . "&client_secret=" . $client_secret;
    $apiResult = curl_get_file_contents($apiURL);
    $json = json_decode($apiResult, true);
    if (count($json["assets"]) == 1) {
        $downloadURL = $json["assets"][0]["browser_download_url"];
        header("Location: " . $downloadURL);
        die;
    } else {
        if (count($json["assets"]) > 1) {
            foreach ($json["assets"] as $key => $value) {
                $ext = pathinfo($value["browser_download_url"], PATHINFO_EXTENSION);
                if (in_array($ext, $allowedExtensions)) {
                    header("Location: " . $value["browser_download_url"]);
                    die;
                }
            }
            http_response_code(404);
            die("Error: No binary release found.");
        } else {
            http_response_code(404);
            die("Error: No binary release found.");
        }