function getChampionRoles()
{
    // get the basic summoner info
    $result = 'http://127.0.0.1:8081/LeagueOfLegendsServer/ChampionList.json';
    $summoner = curl_get_contents($result);
    echo $summoner;
}
Beispiel #2
0
 function getVideoDetails($video_id = '')
 {
     $error = '';
     //check for a cached file
     $cachedFileName = './system/cache/youtubexml_' . $video_id;
     $url = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id={$this->dev_id}&video_id={$video_id}";
     #TODO check if file past cache limit
     if (file_exists($cachedFileName)) {
         $resultObj = simplexml_load_file($cachedFileName);
     } else {
         $contents = curl_get_contents($url);
         $resultObj = simplexml_load_string($contents);
         //if we want to cache the data write the data to a file
         if ($this->cacheData) {
             // delete the file if it already exists
             if (file_exists($cachedFileName)) {
                 unlink($cachedFileName);
             }
             // recreate file and recache data
             if ($file = fopen($cachedFileName, 'wb')) {
                 fwrite($file, $contents);
                 fclose($file);
             }
         }
     }
     return $resultObj;
 }
Beispiel #3
0
function new_access_token($db)
{
    $time = time();
    $ret = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
    $appid = $ret['appid'];
    //AppId 18
    $appsecret = $ret['appsecret'];
    //AppSecret 32
    $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
    if (function_exists(curl_exec)) {
        $ret_json = curl_get_contents($url);
        //access_token 150
    } else {
        echo '您的服务器不支持:curl_exec函数';
        exit;
    }
    $ret = json_decode($ret_json);
    //        $db->query("UPDATE `wxch_config` SET `access_token` = '',`dateline` = '$time' WHERE `id` =1;");
    if ($ret->access_token) {
        $db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
        return $ret->access_token;
    } else {
        return false;
    }
}
Beispiel #4
0
 public function notifications_crond()
 {
     $last_version = json_decode(curl_get_contents('http://wenda.wecenter.com/api/version_check.php'), true);
     $admin_notifications = get_setting('admin_notifications');
     $notifications = array('answer_approval' => $this->count('approval', "type = 'answer'"), 'question_approval' => $this->count('approval', "type = 'question'"), 'article_approval' => $this->count('approval', "type = 'article'"), 'article_comment_approval' => $this->count('approval', "type = 'article_comment'"), 'weibo_msg_approval' => $this->count('weibo_msg', 'question_id IS NULL'), 'received_email_approval' => $this->count('received_email', 'question_id IS NULL'), 'unverified_modify_count' => $this->count('question', 'unverified_modify_count <> 0'), 'user_report' => $this->count('report', 'status = 0'), 'register_approval' => $this->count('users', 'group_id = 3'), 'verify_approval' => $this->count('verify_apply', 'status = 0'), 'last_version' => array('version' => $last_version['version'], 'build_day' => $last_version['build_day']), 'sina_users' => $admin_notifications['sina_users'], 'receive_email_error' => $admin_notifications['receive_email_error']);
     $this->model('setting')->set_vars(array('admin_notifications' => $notifications));
 }
function access_token($db)
{
    $ret = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
    $appid = $ret['appid'];
    $appsecret = $ret['appsecret'];
    $access_token = $ret['access_token'];
    $dateline = $ret['dateline'];
    $time = time();
    if ($time - $dateline >= 7200) {
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
        $ret_json = curl_get_contents($url);
        $ret = json_decode($ret_json);
        if ($ret->access_token) {
            $db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
            return $ret->access_token;
        }
    } elseif (empty($access_token)) {
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
        $ret_json = curl_get_contents($url);
        $ret = json_decode($ret_json);
        if ($ret->access_token) {
            $db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
            return $ret->access_token;
        }
    } else {
        return $access_token;
    }
}
 static function add($request)
 {
     //Send any parameters that the worker needs.
     $request = http_build_query(compact('request'), '&amp');
     $url = self::$path_to_worker . "?{$request}";
     curl_get_contents($url, false, true);
 }
 function remote_get_contents($url)
 {
     if (function_exists('curl_get_contents') and function_exists('curl_init')) {
         return curl_get_contents($url);
     } else {
         return file_get_contents($url);
     }
 }
function remote_get_contents($url)
{
    if (function_exists('curl_get_contents') and function_exists('curl_init')) {
        return curl_get_contents($url);
    } else {
        // A litte slower, but (usually) gets the job done
        return file_get_contents($url);
    }
}
function id_by_token($token)
{
    $graph = curl_get_contents('https://graph.facebook.com/me?fields=id&access_token=' . $token);
    //echo $graph;
    $json = json_decode($graph, true);
    if (array_key_exists('id', $json)) {
        return $json['id'];
    }
    return NULL;
}
Beispiel #10
0
 public function notifications_crond()
 {
     $last_version = json_decode(curl_get_contents('http://wenda.HeavenSpree.com/api/version_check.php'), true);
     $admin_notifications = AWS_APP::cache()->get('admin_notifications');
     if (!$admin_notifications) {
         $admin_notifications = get_setting('admin_notifications');
     }
     $admin_notifications = array('answer_approval' => $this->count('approval', 'type = "answer"'), 'question_approval' => $this->count('approval', 'type = "question"'), 'article_approval' => $this->count('approval', 'type = "article"'), 'article_comment_approval' => $this->count('approval', 'type = "article_comment"'), 'weibo_msg_approval' => $this->count('weibo_msg', 'question_id IS NULL'), 'received_email_approval' => $this->count('received_email', 'question_id IS NULL'), 'unverified_modify_count' => $this->count('question', 'unverified_modify_count <> 0'), 'user_report' => $this->count('report', 'status = 0'), 'register_approval' => $this->count('users', 'group_id = 3'), 'verify_approval' => $this->count('verify_apply', 'status = 0'), 'last_version' => array('version' => $last_version['version'], 'build_day' => $last_version['build_day']), 'sina_users' => $admin_notifications['sina_users'], 'receive_email_error' => $admin_notifications['receive_email_error']);
     AWS_APP::cache()->set('admin_notifications', $admin_notifications, 1800);
     return $this->model('setting')->set_vars(array('admin_notifications' => $admin_notifications));
 }
Beispiel #11
0
 public static function GetProfile($email)
 {
     try {
         $profile = unserialize(curl_get_contents('http://www.gravatar.com/' . self::GetHash($email) . '.php'));
     } catch (Exception $e) {
         return FALSE;
     }
     if (!is_array($profile) || !isset($profile['entry'])) {
         return FALSE;
     }
     return $profile;
 }
Beispiel #12
0
function ifrget($a, $b, $f)
{
    $f = ajxg($f);
    if ($f) {
        $f = str_replace(array("\n", "\r"), ' ', $f);
        $r = explode(' ', $f);
        foreach ($r as $v) {
            $d = curl_get_contents($v);
            if (is_image($v) && $d) {
                $ret .= ifrim($v, $d);
            }
        }
    }
    return $ret;
}
Beispiel #13
0
function bookdescription($getbookTitle)
{
    if (!empty($getbookTitle)) {
        $bookdesc = curl_get_contents('https://www.googleapis.com/books/v1/volumes?q=' . urlencode($getbookTitle));
        $len = 100;
        while ($len < 300 || $len > 4000) {
            preg_match("/\",\\s*\"description\":\\s*\"(.*)\",\\s*\"/Us", $bookdesc, $results);
            $bookdesc = preg_replace("/\",\\s*\"description\":\\s*\"(.*)\",\\s*\"/Us", '', $bookdesc, 1);
            $len = strlen($results[1]);
        }
        echo '<br>' . stripslashes($results[1]) . '<br>';
    } else {
        echo 'Invalid URL';
    }
}
Beispiel #14
0
function ifrget($a, $b, $f)
{
    $f = ajxg($f);
    $f = http($f);
    if ($f) {
        $ret = curl_get_contents($f);
        if (is_image($f) && $ret) {
            $ret = ifrim($f, $ret);
        }
    }
    $encoding = embed_detect(strtolower($ret), "charset=", '"', "");
    if (strtolower($encoding) == "utf-8" or strpos($ret, 'é')) {
        $ret = utf8_decode_b($ret);
    }
    return $ret;
}
Beispiel #15
0
function new_access_token($db)
{
    $ret = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
    $appid = $ret['appid'];
    //AppId 18
    $appsecret = $ret['appsecret'];
    //AppSecret 32
    $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
    $ret_json = curl_get_contents($url);
    //access_token 150
    $ret = json_decode($ret_json);
    if ($ret->access_token) {
        $db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
    }
    return $ret->access_token;
}
Beispiel #16
0
 public function validate_access_token()
 {
     if (!$this->access_token) {
         $this->error_msg = AWS_APP::lang()->_t('access token 为空');
     }
     $result = curl_get_contents(self::OAUTH2_TOKEN_VALIDATION_URL . '?access_token=' . $this->access_token);
     if (!$result) {
         $this->error_msg = AWS_APP::lang()->_t('验证 access token 时,与 Google 通信失败');
     }
     $result = json_decode($result, true);
     if ($result['error_description']) {
         $this->error_msg = AWS_APP::lang()->_t('验证 access token 失败,错误为:%s', $result['error_description']);
     }
     $this->expires_time = time() + intval($result['expires_in']);
     return true;
 }
function google_docs_markdown_parse($url)
{
    include_once 'markdown.php';
    include_once 'smartypants.php';
    $doc = curl_get_contents($url);
    $start_of_div = strpos($doc, '<div id="doc-contents">');
    $end_of_div = strpos($doc, '<div id="google-view-footer">');
    if ($start_of_div === false) {
        return 'Sorry, cannot retrieve content at this time.';
    }
    // get just the content div
    $content = substr($doc, $start_of_div, $end_of_div - $start_of_div);
    // strip new lines, replace div's with new lines
    // strip remaining tags, trim the ends
    $content = trim(strip_tags(str_replace(array("\n", '<div>'), array('', "\n"), $content)));
    // format with Markdown and return
    return SmartyPants(Markdown($content));
}
Beispiel #18
0
    ?>
</td>
      </tr>
      <tr>
        <td>Version: </td><td> <?php 
    echo $app_info["app_version"];
    ?>
</td>
      </tr>
    </table>
    <br />
    <a href="http://www.heigoldinvestments.com/rest_get/REST_Client.php?action=get_app_list" alt="app list">Return to the app list</a>
  <?php 
} else {
    echo "Simple REST Application.  Choose one of the following applications for a description:<br>";
    $app_list = curl_get_contents('http://www.heigoldinvestments.com/rest_get/api.php?action=get_app_list');
    $app_list = json_decode($app_list, true);
    ?>
    <ul>
    <?php 
    foreach ($app_list as $app) {
        ?>
      <li>
        <a href=<?php 
        echo "http://www.heigoldinvestments.com/rest_get/REST_Client.php?action=get_app&id=" . $app["id"];
        ?>
 alt=<?php 
        echo "app" . $app["id"];
        ?>
><?php 
        echo $app["name"];
Beispiel #19
0
function yupload($url, $folder, $unzip, $delzip)
{
    global $meurl;
    if (empty($folder)) {
        $folder = "./";
    }
    $nfolder = $folder;
    $nurl = $url;
    $url = iconv("UTF-8", "GBK", $url);
    $folder = iconv("UTF-8", "GBK", $folder);
    if ($url !== "") {
        ignore_user_abort(true);
        // 要求离线也可下载
        set_time_limit(24 * 60 * 60);
        // 设置超时时间
        if (!file_exists($folder)) {
            mkdir($folder, 0755);
        }
        $newfname = $folder . basename($url);
        // 取得文件的名称
        if (function_exists('curl_init')) {
            $file = curl_get_contents($url);
            file_put_contents($newfname, $file);
        } else {
            $file = fopen($url, "rb");
            // 远程下载文件,二进制模式
            if ($file) {
                // 如果下载成功
                $newf = fopen($newfname, "wb");
                if ($newf) {
                    // 如果文件保存成功
                    while (!feof($file)) {
                        // 判断附件写入是否完整
                        fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
                        // 没有写完就继续
                    }
                }
            }
            if ($file) {
                fclose($file);
                // 关闭远程文件
            }
            if ($newf) {
                fclose($newf);
                // 关闭本地文件
            }
        }
        maintop("远程上传");
        echo "<div class='box'>文件 " . basename($url) . " 上传成功<br>\n";
        $end = explode('.', basename($url));
        if ((end($end) == "zip" || end($end) == "tar" || end($end) == "tar.gz" || end($end) == "gzip" || end($end) == "gz") && isset($unzip) && $unzip == "checkbox") {
            if (class_exists('ZipArchive')) {
                $zip = new ZipArchive();
                if ($zip->open($folder . basename($url)) === TRUE) {
                    if ($zip->extractTo($folder)) {
                        for ($i = 0; $i < $zip->numFiles; $i++) {
                            echo $zip->getNameIndex($i) . '<br>';
                        }
                        $zip->close();
                        echo $dename . " 已经解压完成 {$nndir}<br>";
                    } else {
                        echo '无法解压文件:' . $nfolder . $ndename;
                    }
                    echo basename($nurl) . " 已经被解压到{$nfolder}<br>";
                    if (isset($delzip) && $delzip == "checkbox") {
                        if (unlink($folder . basename($url))) {
                            echo basename($url) . " 删除成功<br>";
                        } else {
                            echo basename($url) . " 删除失败<br>";
                        }
                        echo "你可以 <a href=\"" . $meurl . "?op=home&folder=" . $folder . "\">访问文件夹</a> 或者 <a href=\"" . $meurl . "?op=home&folder=" . $_SESSION['folder'] . "\">返回上次浏览的文件夹</a>  或者 <a href=\"" . $meurl . "?op=up\">继续上传</a>\n";
                    }
                } else {
                    echo '<span class="error">无法解压文件:' . $nfolder . basename($nurl) . '</span><br>';
                }
            } else {
                echo '<span class="error">此服务器上的PHP不支持ZipArchive,无法解压文件!</span><br>';
            }
        } else {
            echo "你可以 <a href=\"" . $meurl . "?op=home&folder=" . $nfolder . "\">访问文件夹</a> 或者 <a href=\"" . $meurl . "?op=edit&fename=" . basename($url) . "&folder=" . $nfolder . "\">编辑文件</a> 或者 <a href=\"" . $meurl . "?op=home&folder=" . $_SESSION['folder'] . "\">返回上次浏览的文件夹</a>  或者 <a href=\"" . $meurl . "?op=up\">继续上传</a>\n";
        }
        echo '</div>';
        mainbottom();
        return true;
    } else {
        printerror('文件地址不能为空。');
    }
}
Beispiel #20
0
 public function create_qr_code($scene_id)
 {
     if (!$scene_id) {
         return AWS_APP::lang()->_t('scene_id 错误');
     }
     $result = $this->model('openid_weixin_weixin')->access_request(get_setting('weixin_app_id'), get_setting('weixin_app_secret'), 'qrcode/create', 'POST', $this->replace_post(array('action_name' => 'QR_LIMIT_SCENE', 'action_info' => array('scene' => array('scene_id' => intval($scene_id))))));
     if (!$result) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('远程服务器忙');
     }
     if ($result['errcode']) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return $result['errmsg'];
     }
     if (!$result['ticket']) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('获取 ticket 失败');
     }
     $this->update('weixin_qr_code', array('ticket' => $result['ticket']), 'scene_id = ' . intval($scene_id));
     $qr_code = curl_get_contents('https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . urlencode($result['ticket']));
     if (!$qr_code) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('换取二维码失败');
     }
     $img_file_name = intval($scene_id) . '.jpg';
     AWS_APP::upload()->initialize(array('allowed_types' => 'jpg', 'upload_path' => get_setting('upload_dir') . '/weixin_qr_code', 'is_image' => TRUE, 'overwrite' => TRUE, 'file_name' => $img_file_name));
     AWS_APP::upload()->do_upload($img_file_name, $qr_code);
     $upload_error = AWS_APP::upload()->get_error();
     if ($upload_error) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('保存二维码图片失败,错误为 %s', $upload_error);
     }
     $upload_data = AWS_APP::upload()->data();
     if (!$upload_data) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('保存二维码图片失败,请与管理员联系');
     }
 }
Beispiel #21
0
function new_access_token($db)
{
    $time = time();
    $ret = $db->getRow("SELECT * FROM `hhs_weixin_config` WHERE `id` = 1");
    $appid = $ret['appid'];
    $appsecret = $ret['appsecret'];
    $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
    $ret_json = curl_get_contents($url);
    $ret = json_decode($ret_json);
    setcookie("access_token", $ret->access_token, time() + 7000, '/');
    return $ret->access_token;
}
Beispiel #22
0
 public function get_url_title()
 {
     $html = curl_get_contents($this->in['url']);
     $result = match($html, "<title>(.*)<\\/title>");
     if (strlen($result) > 50) {
         $result = mb_substr($result, 0, 50, 'utf-8');
     }
     if (!$result || strlen($result) == 0) {
         $result = $this->in['url'];
         $result = str_replace(array('http://', '&', '/'), array('', '@', '-'), $result);
     }
     show_json($result);
 }
Beispiel #23
0
 /**
  * this function will handle calling api and error checking
  * 
  * @param string url the url of the api call
  * @param string debugName the name to pass as a debug title
  * @return array associative array of results
  * @author James Kleinschnitz
  */
 function callAPI($url, $debugName = '')
 {
     //get api contents decose with json to an array
     $cachedFileName = './system/cache/' . str_replace(array(':', '/', '?', '&'), '', substr($url, 28, strlen($url)));
     #TODO check if file past cache limit
     if (file_exists($cachedFileName)) {
         $resultsArray = json_decode(file_get_contents($cachedFileName), true);
     } else {
         $contents = curl_get_contents($url);
         $resultsArray = json_decode($contents, true);
         //if we want to cache the data write the data to a file
         if ($this->cacheData) {
             // delete the file if it already exists
             if (file_exists($cachedFileName)) {
                 unlink($cachedFileName);
             }
             // recreate file and recache data
             if ($file = fopen($cachedFileName, 'wb')) {
                 fwrite($file, $contents);
                 fclose($file);
             }
         }
     }
     //do some kind of error checking here and return false
     if ($this->debugLevel > 0) {
         echo "<b style='color:#FF0000;'>" . $debugName . ":</b><br />";
         foreach ($resultsArray as $key => $val) {
             if (is_array($val)) {
                 echo $key . "<br />";
                 foreach ($val as $index => $value) {
                     echo "  {$index} => {$value} <br />";
                 }
             } else {
                 echo "{$key} => {$val} <br />";
             }
         }
         echo "<br />";
     }
     return $resultsArray;
 }
Beispiel #24
0
 public function get_jsapi_ticket($access_token)
 {
     if (!$access_token) {
         return false;
     }
     $cached_ticket = 'weixin_jsapi_ticket_' . md5($access_token);
     $jsapi_ticket = AWS_APP::cache()->get($jsapi_ticket);
     if ($jsapi_ticket) {
         return $jsapi_ticket;
     }
     $result = curl_get_contents(self::WEIXIN_API . 'ticket/getticket?access_token=' . $access_token . '&type=jsapi');
     if (!$result) {
         return false;
     }
     $result = json_decode($result, true);
     if (!$result['ticket']) {
         return false;
     }
     AWS_APP::cache()->set($cached_ticket, $result['ticket'], 60);
     return $result['ticket'];
 }
Beispiel #25
0
<?php

function curl_get_contents($url)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    $data = curl_exec($curl);
    curl_close($curl);
    $data = preg_replace("/.*?<body.*?>/is", "", $data);
    $data = preg_replace("/<\\/body>.*?/is", "", $data);
    //$data = mb_convert_encoding($data, 'UTF-8', 'windows-1251');
    return $data;
}
echo curl_get_contents($_POST['url']);
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
//If the Album ID is set in the URL, get it and get  the data from facebook
if (isset($_GET['id'])) {
    $fields = "count,created_time,description,link,name";
    $id = $_GET['id'];
    $json_link = "https://graph.facebook.com/" . $_GET['id'] . "/?access_token={$access_token}&fields={$fields}";
    $album = json_decode(curl_get_contents($json_link));
} else {
    //If there's no ID set, DIE
    die;
}
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">		
		<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/fb-gallery-style.css">
		<!-- STYLESHEET for BOOTSTRAP LIGHTBOX -->
		<link href="css/ekko-lightbox.min.css" type="text/css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/fb-gallery-style.css">
		<title> <?php 
Beispiel #27
0
 public function associate_remote_avatar($uid, $headimgurl)
 {
     if (!$headimgurl) {
         return false;
     }
     if (!($user_info = $this->get_user_info_by_uid($uid))) {
         return false;
     }
     if ($user_info['avatar_file']) {
         return false;
     }
     if (!($avatar_stream = curl_get_contents($headimgurl, 1))) {
         return false;
     }
     $avatar_location = get_setting('upload_dir') . '/avatar/' . $this->get_avatar($uid, '');
     $avatar_dir = dirname($avatar_location) . '/';
     if (!file_exists($avatar_dir)) {
         make_dir($avatar_dir);
     }
     if (!@file_put_contents($avatar_location, $avatar_stream)) {
         return false;
     }
     foreach (AWS_APP::config()->get('image')->avatar_thumbnail as $key => $val) {
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $avatar_location, 'new_image' => $avatar_dir . $this->get_avatar($uid, $key, 2), 'width' => $val['w'], 'height' => $val['h']))->resize();
     }
     $this->update('users', array('avatar_file' => $this->get_avatar($uid)), 'uid = ' . intval($uid));
     if (!$this->model('integral')->fetch_log($new_user_id, 'UPLOAD_AVATAR')) {
         $this->model('integral')->process($new_user_id, 'UPLOAD_AVATAR', round(get_setting('integral_system_config_profile') * 0.2), '上传头像');
     }
     return true;
 }
Beispiel #28
0
 public function get_msg_from_sina($access_token, $since_id = 0, $max_id = 0)
 {
     if (!$access_token) {
         return false;
     }
     $args = array('access_token' => $access_token, 'since_id' => $since_id, 'max_id' => $max_id, 'count' => 100);
     $result = curl_get_contents(self::STATUSES_MENTIONS_URL . '?' . http_build_query($args));
     if (!$result) {
         return false;
     }
     return json_decode($result, true);
 }
Beispiel #29
0
$xml_data = curl_get_contents('http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.search.common&page_size=1&format=json&query=' . rawurlencode($name . ' ' . $singer));
if (!$xml_data) {
    output(array('status' => 'error', 'errcode' => -2));
}
$_songid = json_decode($xml_data, true);
if (is_array($_songid["song_list"])) {
    $lrc_data = array();
    $_lrc_url = curl_get_contents("http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.play&format=json&bit=128&songid=" . $_songid["song_list"][0]["song_id"]);
    if (!$_lrc_url) {
        output(array('status' => 'error', 'errcode' => -5));
    } else {
        $_lrc = json_decode($_lrc_url, true);
        if (!$_lrc) {
            output(array('status' => 'error', 'errcode' => -5));
        } else {
            $_lrc_data = curl_get_contents($_lrc["songinfo"]["lrclink"]);
            if (!$_lrc_data) {
                output(array('status' => 'error', 'errcode' => -4, 'baidu_errcode' => $_lrc['error_code']));
            }
            /* $lrc_data[]=iconv("GBK","UTF-8",str_replace(array("\r","\n"),array("","<br />"),$_lrc_data)); */
            $lrc_data[] = str_replace(array("\r", "\t", "\n"), array("", "    ", "<br />"), $_lrc_data);
        }
        if (empty($lrc_data)) {
            output(array('status' => 'error', 'errcode' => -5));
        } else {
            output(array('status' => 'success', 'errcode' => 0, 'result' => $lrc_data), $_GET['callback']);
        }
    }
} else {
    output(array('status' => 'error', 'errcode' => -3));
}
Beispiel #30
0
 public function get_msg_from_sina_crond()
 {
     $now = time();
     $lock_time = AWS_APP::cache()->get('weibo_msg_locker');
     if ($lock_time and $now - $lock_time <= 600) {
         return false;
     }
     if (!get_setting('sina_akey') or !get_setting('sina_skey')) {
         return false;
     }
     $services_info = $this->get_services_info();
     if (!$services_info) {
         return false;
     }
     AWS_APP::cache()->set('weibo_msg_locker', $now, 600);
     foreach ($services_info as $service_info) {
         $service_user_info = $this->model('account')->get_user_info_by_uid($service_info['uid']);
         if (!$service_user_info) {
             continue;
         }
         if (!$service_info['access_token'] or $service_info['expires_time'] <= time()) {
             $this->notification_of_refresh_access_token($service_user_info['uid'], $service_user_info['user_name']);
             continue;
         }
         $result = $this->model('openid_weibo_oauth')->get_msg_from_sina($service_info['access_token'], $service_info['last_msg_id']);
         if (!$result) {
             continue;
         }
         if ($result['error_code']) {
             if ($result['error_code'] == 21332) {
                 $this->notification_of_refresh_access_token($service_user_info['uid'], $service_user_info['user_name']);
             }
             continue;
         }
         $this->notification_of_refresh_access_token($service_user_info['uid'], null);
         foreach ($result['statuses'] as $msg) {
             $msg_info['created_at'] = strtotime($msg['created_at']);
             $msg_info['id'] = $msg['id'];
             if ($now - $msg_info['created_at'] > 604800 or $this->fetch_row('weibo_msg', 'id = "' . $this->quote($msg_info['id']) . '"')) {
                 continue;
             }
             $msg_info['text'] = htmlspecialchars_decode(str_replace('@' . $service_info['name'], '', $msg['text']));
             $msg_info['uid'] = $service_user_info['uid'];
             $msg_info['weibo_uid'] = $service_info['id'];
             $msg_info['msg_author_uid'] = $msg['user']['id'];
             $now++;
             $msg_info['access_key'] = md5($msg_info['uid'] . $now);
             if ($msg['pic_urls'] and get_setting('upload_enable') == 'Y') {
                 foreach ($msg['pic_urls'] as $pic_url) {
                     $pic_url_array = explode('/', substr($pic_url['thumbnail_pic'], 7));
                     $pic_url_array[2] = 'large';
                     $pic_url = 'http://' . implode('/', $pic_url_array);
                     $result = curl_get_contents($pic_url);
                     if (!$result) {
                         continue;
                     }
                     AWS_APP::upload()->initialize(array('allowed_types' => get_setting('allowed_upload_types'), 'upload_path' => get_setting('upload_dir') . '/questions/' . gmdate('Ymd'), 'is_image' => TRUE, 'max_size' => get_setting('upload_size_limit')));
                     AWS_APP::upload()->do_upload($pic_url_array[3], $result);
                     if (AWS_APP::upload()->get_error()) {
                         continue;
                     }
                     $upload_data = AWS_APP::upload()->data();
                     if (!$upload_data) {
                         continue;
                     }
                     foreach (AWS_APP::config()->get('image')->attachment_thumbnail as $key => $val) {
                         $thumb_file[$key] = $upload_data['file_path'] . $val['w'] . 'x' . $val['h'] . '_' . basename($upload_data['full_path']);
                         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
                     }
                     $this->model('publish')->add_attach('weibo_msg', $upload_data['orig_name'], $msg_info['access_key'], $now, basename($upload_data['full_path']), true);
                 }
                 $this->model('publish')->update_attach('weibo_msg', $msg_info['id'], $msg_info['access_key']);
             } else {
                 $msg_info['has_attach'] = 0;
             }
             $this->insert('weibo_msg', $msg_info);
             $this->update_service_account($msg_info['uid'], null, $msg_info['id']);
         }
     }
     AWS_APP::cache()->delete('weibo_msg_locker');
     return true;
 }