示例#1
0
 /**
  * 上传永久图片素材
  * @param string $img
  * @return string URL
  */
 public static function upload_img($img = '', $access_token = '')
 {
     $url = self::post_url('media/uploadimg', $access_token);
     //$img_path = str_replace('/', '\\', getcwd()."/uploads/build/whoami.png") ;
     if (strpos($img, 'http') !== FALSE) {
         $file = curl_file_get_contents($img);
         $type = substr($img, strrpos($img, '.') + 1);
         $img = '/uploads/build/tmp_wechat.' . $type;
         file_put_contents('.' . $img, $file);
     }
     $img = str_replace('/', '\\', getcwd() . $img);
     $ch = curl_init();
     // 微信服务器CURL版本,低于PHP5.5
     //$cfile = curl_file_create($img_path,'image/png','media');
     $_data = array('media' => '@' . $img);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     @curl_setopt($ch, CURLOPT_SAFE_UPLOAD, FALSE);
     @curl_setopt($ch, CURLOPT_POSTFIELDS, $_data);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     curl_setopt($ch, CURLOPT_SSLVERSION, 1);
     //CURL_SSLVERSION_TLSv1
     $return_data = curl_exec($ch);
     curl_close($ch);
     if (is_string($return_data)) {
         $json = json_decode($return_data);
         $return_data = empty($json->errcode) ? $json->url : false;
     }
     return $return_data;
 }
示例#2
0
function get_content_by_url($url)
{
    $md5 = md5($url);
    $content = S('file_content_' . $md5);
    if (is_bool($content)) {
        $content = curl_file_get_contents($url);
        S('file_content_' . $md5, $content, 60 * 60);
    }
    return $content;
}
 function createRIFCSfromORCID($identifier)
 {
     $target_uri = $this->orcidServiceURI . $identifier . "?callback=?";
     echo $target_uri . " Is the URI </br>";
     $response = curl_file_get_contents($target_uri);
     print "<pre>";
     print_r($response);
     print "</pre>";
     /* if ($response)
     		{
     			try
     			{
     				$sxml = @simplexml_load_string($response);
     				if (!$sxml) { throw new Exception("No valid data! " . $target_uri); }
     				$sxml->registerXPathNamespace("srw", "http://www.loc.gov/zing/srw/");
     				$count = $sxml->xpath("//srw:searchRetrieveResponse/srw:numberOfRecords");
     				if (is_array($count))
     				{
     					// Get the matching element
     					$count = array_pop($count);
     					$count = (int) $count;
     				}
     
     				if ($count)
     				{
     					$data = $sxml->xpath("//srw:recordData");
     					if (is_array($data))
     					{
     						// Get the matching element
     						$data = array_pop($data);
     						if ($data->registryObjects)
     						{
     							return $data->registryObjects->asXML();
     						}
     						else
     						{
     							echo "No registryObjects elements discovered inside SRW response: " . $identifier . NL;
     						}
     					}
     				}
     				else
     				{
     					echo "No matches from NLA SRU service on retrieving records for: " . $identifier . NL;
     				}
     			}
     			catch (Exception $e)
     			{
     				echo "Unable to load XML from NLA endpoint for ".$identifier.". Response: " . $e->getMessage() . NL;
     			}
     		} */
     ob_flush();
     flush();
     return;
 }
示例#4
0
function gmailContactEmail()
{
    $client_id = '1092531224599.apps.googleusercontent.com';
    $client_secret = 'HiLLtnhNibIDe8uPA0UVUVgW';
    $redirect_uri = 'http://as.smurti.com/users/gmailContacts';
    $max_results = 100;
    $auth_code = $_GET["code"];
    $fields = array('code' => urlencode($auth_code), 'client_id' => urlencode($client_id), 'client_secret' => urlencode($client_secret), 'redirect_uri' => urlencode($redirect_uri), 'grant_type' => urlencode('authorization_code'));
    $post = '';
    foreach ($fields as $key => $value) {
        $post .= $key . '=' . $value . '&';
    }
    $post = rtrim($post, '&');
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
    curl_setopt($curl, CURLOPT_POST, 5);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    $result = curl_exec($curl);
    curl_close($curl);
    $response = json_decode($result);
    $accesstoken = $response->access_token;
    $url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results=' . $max_results . '&oauth_token=' . $accesstoken;
    $xmlresponse = curl_file_get_contents($url);
    if (strlen(stristr($xmlresponse, 'Authorization required')) > 0 && strlen(stristr($xmlresponse, 'Error ')) > 0) {
        echo "<h2>OOPS !! Something went wrong. Please try reloading the page.</h2>";
        exit;
    }
    $xml = new SimpleXMLElement($xmlresponse);
    foreach ($xml->entry as $entry) {
        $contact_Name[] = $entry->title;
    }
    $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
    $result = $xml->xpath('//gd:email');
    foreach ($result as $title) {
        $contact_Email[] = $title->attributes()->address;
    }
    return $contact_Email;
}
示例#5
0
function DetectImage($uri, $local = 0)
{
    global $filterImage;
    if ($filterImage) {
        $exif_types = array(IMAGETYPE_GIF => 'image/gif', IMAGETYPE_JPEG => 'image/jpeg', IMAGETYPE_PNG => 'image/png');
        $use_exif = function_exists('exif_imagetype');
        // get image info
        $mime = $use_exif && ($a = @exif_imagetype($uri)) && isset($exif_types[$a]) ? $exif_types[$a] : (($a = @getimagesize($uri)) ? $a['mime'] : null);
        // valid mime type
        if (empty($mime) or !preg_match('/(jpeg|jpg|gif|png)$/', $mime)) {
            DefaultImage();
        }
        // detect image type 'png'
        if (image_type_to_mime_type(IMAGETYPE_PNG) === $mime) {
            $send = imagecreatefrompng($uri);
        }
        // detect image type 'jpeg'
        if (image_type_to_mime_type(IMAGETYPE_JPEG) === $mime) {
            $send = imagecreatefromjpeg($uri);
        }
        // detect image type 'gif'
        if (image_type_to_mime_type(IMAGETYPE_GIF) === $mime) {
            $send = imagecreatefromgif($uri);
        }
    }
    // detect image from string
    if ($local) {
        $send = imagecreatefromstring(file_get_contents($uri));
    } elseif (empty($send) && ($content = curl_file_get_contents($uri))) {
        $send = imagecreatefromstring($content['content']);
    }
    // valid new image created
    if (empty($send) or !is_resource($send)) {
        DefaultImage();
    }
    // callback
    return $send;
}
function google_get_groups($token)
{
    // retrieve groups
    $url = 'https://www.google.com/m8/feeds/groups/default/full?alt=json&v=3.0&oauth_token=' . $token;
    $xml_response = curl_file_get_contents($url);
    $records = json_decode($xml_response, true);
    //check for authentication errors
    if ($records['error']['code']) {
        header("Location: contact_auth.php?source=google&target=" . substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"], '/') + 1));
        exit;
    }
    //create new array of groups
    foreach ($records['feed']['entry'] as $group['number'] => $group) {
        $group_id = substr($group['id']['$t'], strrpos($group['id']['$t'], "/") + 1);
        $groups[$group_id]['name'] = $group['gContact$systemGroup']['id'] ? $group['gContact$systemGroup']['id'] : $group['title']['$t'];
        $groups[$group_id]['count'] = 0;
        unset($group_id);
    }
    unset($group);
    //set account holder info
    $_SESSION['contact_auth']['name'] = $records['feed']['author'][0]['name']['$t'];
    $_SESSION['contact_auth']['email'] = $records['feed']['author'][0]['email']['$t'];
    return $groups;
}
示例#7
0
function getIlceListFunc($sehir_id)
{
    $sehir_id = (int) $sehir_id;
    $ilceler_json = curl_file_get_contents('http://www.diyanet.gov.tr/PrayerTime/FillCity?itemId=' . $sehir_id);
    if ($ilceler_json == '[]') {
        return '[{"error":"Bu sehire ait ilceler bulunamadi."}]';
    } else {
        $ilceler_json = str_replace('"Selected":false,', '', $ilceler_json);
        $ilceler_json = str_replace('"Selected":true,', '', $ilceler_json);
        $ilceler_json = str_replace('"Text":', '"IlceAdi":', $ilceler_json);
        $ilceler_json = str_replace('"Value":', '"IlceId":', $ilceler_json);
        return $ilceler_json;
    }
}
示例#8
0
文件: index.php 项目: nbtetreault/igo
 } else {
     $xmlPath = $di->getConfig()->configurationsDir . $configKey . '.xml';
 }
 if (!file_exists($xmlPath) && !curl_url_exists($xmlPath)) {
     $app->response->setStatusCode(404, "Not Found");
     $error = new stdClass();
     $error->error = "La configuration « {$configuration} » n'existe pas!";
     $app->response->send();
     die(json_encode($error));
 }
 if ($encoding === "json") {
     $app->response->setContentType('application/json; charset=UTF-8')->sendHeaders();
     if (file_exists($xmlPath)) {
         $element = simplexml_load_file($xmlPath, 'SimpleXMLElement', LIBXML_NOCDATA);
     } else {
         $element = simplexml_load_string(curl_file_get_contents($xmlPath), 'SimpleXMLElement', LIBXML_NOCDATA);
     }
     if ($element->getName() === "navigateur") {
         //Gerer le cas des couches seulement avec un Id
         //Retourner l'info pour creer correctement la couche cote client
         $result = $element->xpath('//couche[boolean(@idbd)]');
         $avertissement = null;
         $debug = $app->getDI()->get("config")->application->debug;
         foreach ($result as $couche) {
             $coucheId = $couche->attributes()->idbd->__toString();
             if (is_numeric($coucheId)) {
                 $coucheBd = IgoVueCouche::findFirst("id=" . $coucheId);
             } else {
                 $coucheBd = IgoVueCouche::findFirst("mf_layer_name='" . $coucheId . "'");
             }
             if ($coucheBd === false) {
 public function actionImportGoogleContacts()
 {
     if (isset($_GET["code"]) and $_GET["code"] != NULL) {
         $client_id = '762232144092.apps.googleusercontent.com';
         $client_secret = '5csDrunh7dufwm0nl-N6lyTw';
         $redirect_uri = 'http://127.0.0.1/womv2.0/importcsv/default/importGoogleContacts';
         $max_results = 1000;
         $auth_code = $_GET["code"];
         function curl_file_get_contents($url)
         {
             $curl = curl_init();
             $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
             curl_setopt($curl, CURLOPT_URL, $url);
             //The URL to fetch. This can also be set when initializing a session with curl_init().
             curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
             //TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
             curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
             //The number of seconds to wait while trying to connect.
             curl_setopt($curl, CURLOPT_USERAGENT, $userAgent);
             //The contents of the "User-Agent: " header to be used in a HTTP request.
             curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
             //To follow any "Location: " header that the server sends as part of the HTTP header.
             curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE);
             //To automatically set the Referer: field in requests where it follows a Location: redirect.
             curl_setopt($curl, CURLOPT_TIMEOUT, 10);
             //The maximum number of seconds to allow cURL functions to execute.
             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
             //To stop cURL from verifying the peer's certificate.
             curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
             $contents = curl_exec($curl);
             curl_close($curl);
             return $contents;
         }
         $fields = array('code' => urlencode($auth_code), 'client_id' => urlencode($client_id), 'client_secret' => urlencode($client_secret), 'redirect_uri' => urlencode($redirect_uri), 'grant_type' => urlencode('authorization_code'));
         $post = '';
         foreach ($fields as $key => $value) {
             $post .= $key . '=' . $value . '&';
         }
         $post = rtrim($post, '&');
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
         curl_setopt($curl, CURLOPT_POST, 5);
         curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
         $result = curl_exec($curl);
         curl_close($curl);
         $response = json_decode($result);
         if ($response != NULL and isset($response->access_token)) {
             $accesstoken = $response->access_token;
             $url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results=' . $max_results . '&oauth_token=' . $accesstoken;
             $xmlresponse = curl_file_get_contents($url);
             if (strlen(stristr($xmlresponse, 'Authorization required')) > 0 && strlen(stristr($xmlresponse, 'Error ')) > 0) {
                 echo "<h2>OOPS !! Something went wrong. Please try reloading the page.</h2>";
                 exit;
             }
             $xml = new SimpleXMLElement($xmlresponse);
             $contacts = array();
             $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
             $result = $xml->xpath('//gd:email');
             /*$names 		= 	$xml->xpath('//gd:phoneNumber');				
             		$i=0;
             		foreach($names as $name){
             			$contacts[$i++]['name']		=	(string)$name;
             		}*/
             $i = 0;
             foreach ($result as $title) {
                 $contacts[$i++]['email'] = (string) $title->attributes()->address;
             }
             if (count($contacts) > 0) {
                 $addedCons = 0;
                 foreach ($contacts as $contact) {
                     $f_name = '';
                     $s_name = '';
                     $email = $contact['email'];
                     /*$parts	=	explode(' ',trim($contact['name']));
                     		if(isset($parts[0])) $f_name=$parts[0];
                     		if(isset($parts[1])) $s_name=$parts[1];*/
                     $con = new EmailContacts();
                     /*$con->first_name	=	$f_name;
                     		$con->last_name		=	$s_name;*/
                     $con->email = $email;
                     $con->owner = Yii::app()->user->id;
                     $con->created = date('Y-m-d h:i:s');
                     if ($con->save()) {
                         $addedCons++;
                     }
                 }
                 Yii::app()->user->setFlash('message', $addedCons . ' contacts imported from Google');
             } else {
                 Yii::app()->user->setFlash('message', 'No contacts found');
             }
         } else {
             Yii::app()->user->setFlash('message', 'No response found');
         }
     } else {
         Yii::app()->user->setFlash('message', 'Verification code not found');
     }
     $this->redirect('index');
 }
示例#10
0
    $xslt->importStylesheet(new SimpleXMLElement($xsl));
    return $xslt->transformToXml(new SimpleXMLElement($xml));
}
$GLOBALS['data'] = null;
$url = null;
if (isset($_REQUEST['url_metadata'])) {
    $url = $_REQUEST['url_metadata'];
} else {
    if (isset($_REQUEST['id'])) {
        $url = "http://" . $GLOBALS['apps_config']['geonetwork']['host'] . "/geonetwork/srv/eng/csw?SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&outputSchema=csw:IsoRecord&ID={$_REQUEST['id']}&elementSetName=full";
    }
}
if (isset($url)) {
    $parseUrl = parse_url($_SERVER['REQUEST_URI']);
    $base = dirname($parseUrl['path']);
    $xml = curl_file_get_contents($url);
    if (isset($_REQUEST['full'])) {
        $GLOBALS['data'] = transform($xml, fopen_file_get_contents("./xsl/bs_full.xsl"));
    } else {
        $GLOBALS['data'] = transform($xml, fopen_file_get_contents("./xsl/bs_full.xsl"));
    }
    $GLOBALS['data'] = str_replace("{base}", $base, $GLOBALS['data']);
    //IncrementPopularity($_REQUEST['id']);
}
?>
<!DOCTYPE HTML>
<html xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
示例#11
0
 private function estAuthentificationRequise($configuration)
 {
     if (!isset($this->getDi()->getConfig()->application->authentification) || $this->getDi()->getConfig()->application->authentification == false) {
         return false;
     }
     if (isset($this->getDi()->getConfig()->configurations[$configuration])) {
         $xmlPath = $this->getDi()->getConfig()->configurations[$configuration];
     } else {
         $xmlPath = $this->getDi()->getConfig()->configurationsDir . $configuration . '.xml';
     }
     if (file_exists($xmlPath)) {
         $element = simplexml_load_file($xmlPath);
     } else {
         //url externe
         $element = simplexml_load_string(curl_file_get_contents($xmlPath));
     }
     if (isset($element->attributes()->authentification)) {
         $authentification = $element->attributes()->authentification;
     } else {
         $authentification = "true";
         // Est-ce qu'on devrait forcer l'authentification par defaut? En attendant de décider, on le force par défaut.
     }
     // Si la configuration demande que l'utilisateur soit authentifié et qu'il ne l'est pas encore, le rediriger vers la fenetre de connexion
     if ($authentification == "true") {
         return true;
     } else {
         return false;
     }
 }
示例#12
0
                    break;
                }
            }
            file_put_contents($cookie_file, '<?php return ' . var_export($cookies, true) . ';');
            $_cookie = '';
            foreach ($cookies as $k => $v) {
                $_cookie .= "{$k}={$v}; ";
            }
            array_pop($header);
            $header[] = 'Cookie: ' . trim($_cookie);
        }
        $product['url'] = trim($url[1]);
        $html = curl_file_get_contents($product['url'], null, $header, config('web.refresh_timeout'), $proxy, true);
    }
} else {
    $html = curl_file_get_contents($product['url'], null, $header, config('web.refresh_timeout'), $proxy);
}
if (!$html) {
    json_return(null, 1, 'Load page\'s data fail, please retry.');
}
if (!$product['cover'] || !$product['title']) {
    // preg product's title
    preg_match('/<span id="productTitle".*?>(.*?)<\\/span>/is', $html, $title);
    if (!empty($title[1])) {
        $product['title'] = html_entity_decode(trim($title[1]));
    }
    // preg product's cover
    preg_match('/data\\:image\\/jpeg;base64,(.+)/i', $html, $cover);
    if (!empty($cover[0])) {
        $product['cover'] = 1;
        //trim($cover[0]);
<div id="sidemenu">
<?php 
include 'setup_sidemenu.php';
?>
</div>

<?php 
$setupModel = Setup::model()->findByPk(1);
//$request='http://rapportsoftware.co.uk/versions';
$update_url = $setupModel->version_update_url;
$request = $update_url . '/latest_stocksystem_version.txt';
//echo "<br>request = ".$request;
$available_version = curl_file_get_contents($request, true);
$current_version = Yii::app()->params['software_version'];
?>


<table style="width:40%;">
<tr>
	<td style="vertical-align:top;"><h4>Version</h4></td>
	<td style="vertical-align :top;"><?php 
echo Yii::app()->params['software_version'];
?>
</td>
	<td style="vertical-align :top;">
	<?php 
if ($available_version != $current_version) {
    $step = 1;
    //echo "Please delete all contents of update directory";
    echo CHtml::button('Update', array('submit' => 'index.php?r=/Setup/showUpdateProgress&curr_step=' . $step));
    //echo CHtml::button('Update',array($this->showUpdateProgress($step)));
示例#14
0
 // Create a random file name for temporary kml and map file.
 $randomFileName = uniqid();
 $vecteurFilePath = $GLOBALS['apps_config']['impression']['imagepath'] . $randomFileName . ".kml";
 $vecteurMapFilePath = $GLOBALS['apps_config']['impression']['imagepath'] . $randomFileName . ".map";
 $vecteurTemplateMapFilePath = $GLOBALS['apps_config']['impression']['map_template'];
 $mapTemplateFileHandler = fopen($vecteurTemplateMapFilePath, 'r') or die("can't open file");
 $mapTemplateFileContent = fread($mapTemplateFileHandler, filesize($vecteurTemplateMapFilePath));
 $kml = $_POST['vecteurs'];
 //Check SVG
 if (preg_match_all('/<Icon><href>([^<]+\\.svg)<\\/href><\\/Icon>/', $kml, $matches)) {
     foreach ($matches[1] as $key => $value) {
         $dir = $GLOBALS['apps_config']['impression']['imagepath'];
         //Trouver le nom et l'extension
         $name = substr($value, strrpos($value, '/') + 1);
         //aller chercher le symbol
         $svg = curl_file_get_contents($value);
         $handle = fopen($dir . $randomFileName . $name, "w");
         fwrite($handle, $svg);
         fclose($handle);
         //Ajout du symbol dans le Mapfile
         $symbolTemplate = "#SYMBOL_TAG \n" . "SYMBOL \n" . " NAME \"" . $randomFileName . $name . "\" \n" . " TYPE svg \n" . " IMAGE \"" . $randomFileName . $name . "\" \n" . " END \n";
         $mapTemplateFileContent = str_ireplace('#SYMBOL_TAG', $symbolTemplate, $mapTemplateFileContent);
         //modification du kml pour faire référence au nom du symbol
         $kml = str_ireplace($value, $randomFileName . $name, $kml);
     }
 }
 // Read the template map file and replace the filename tag with the path of the kml file
 $vecteurMapFileContent = str_replace("mapfilename", $vecteurMapFilePath, $mapTemplateFileContent);
 $vecteurMapFileContent = str_replace("kmlfilename", $vecteurFilePath, $vecteurMapFileContent);
 fclose($mapTemplateFileHandler);
 // Write the KML File to disk.
示例#15
0
 /**
  * Get orcid XML of orcid id, if access_token is not set, it will return public information
  * @return object_xml         
  */
 function get_full()
 {
     $opts = array('method' => 'GET', 'header' => 'Accept: application/orcid+json');
     $header = array("Accept:application/orcid+json; charset=utf-8");
     if (!$this->get_orcid_id() && !$this->get_access_token()) {
         return false;
     } else {
         $url = $this->api_uri . 'v1.1/' . $this->get_orcid_id() . '/orcid-profile/';
         // $context = stream_context_create($opts);
         if ($this->get_access_token()) {
             $url .= '?access_token=' . $this->get_access_token();
         }
         // $result = @file_get_contents($url.'s', true, $context);
         // $result = curl_post($url,'', array('header'=>'Accept: application/orcid+json'));
         $result = curl_file_get_contents($url, $header);
         $re = json_decode($result, true);
         if (isset($re['error'])) {
             return false;
         } else {
             return $result;
         }
     }
 }
示例#16
0
文件: get.php 项目: hsiun/yoyo
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $durl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // 获取数据返回
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
    $r = curl_exec($ch);
    curl_close($ch);
    return $r;
}
/*
 * 访问公有Bucket的例子
 */
$url = UCloud_MakePublicUrl($bucket, $key);
echo "download url(public): ", $url . "\n";
/*
 * 访问私有Bucket的例子
 */
$url = UCloud_MakePrivateUrl($bucket, $key);
echo "download url(private): ", $url . "\n";
/*
 * 访问包含过期时间的私有Bucket例子
 */
$curtime = time();
$curtime += 60;
// 有效期60秒
$url = UCloud_MakePrivateUrl($bucket, $key, $curtime);
$content = curl_file_get_contents($url);
echo "download file with expires: ", $url . "\n";
echo $content . "\n";
/**
 * VALIDATE FORM FIELD DATA
 * ==================================================================
 *
 * Add any custom validation you want for your form below.
 * Simply add a new "case" for each field in your form(s) for them
 * to be checked and validated against.
 *
 * e.g.
 * case 'field_name':
 *     if(empty($value)){ array_push($errors, 'Your message'); }
 *     break;
 *
 */
function getValidationErrors()
{
    global $translations, $lang, $fdata, $files, $options;
    // list of error messages to keep
    $errors = array();
    // loop through each of our form fields
    foreach ($fdata as $field => $value) {
        // Now switch functionality based on field name
        switch ($field) {
            // name
            case 'name':
                if (empty($value)) {
                    array_push($errors, parseMessage($translations->form->error->required->{$lang}, array($field)));
                }
                break;
                // email
            // email
            case 'email':
                if (empty($value)) {
                    array_push($errors, parseMessage($translations->form->error->required->{$lang}, array($field)));
                } elseif (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                    array_push($errors, $translations->form->error->email->{$lang});
                }
                break;
                // phone number
            // phone number
            case 'phone':
                if (!empty($value) && !is_numeric($value)) {
                    array_push($errors, parseMessage($translations->form->error->numeric->{$lang}, array($field)));
                }
                break;
                // message
            // message
            case 'message':
                if (empty($value)) {
                    array_push($errors, parseMessage($translations->form->error->required->{$lang}, array($field)));
                }
                break;
                // message
            // message
            case 'honey':
                if (!empty($value)) {
                    array_push($errors, $translations->form->error->honeypot->{$lang});
                }
                break;
        }
    }
    // loop through any files and attempt to upload them
    // report any errors when files are uploaded
    if (!empty($files['name'][0])) {
        $upload_errs = attachmentUploaded();
        if (!empty($upload_errs)) {
            for ($i = 0; $i < count($upload_errs); $i++) {
                array_push($errors, $upload_errs[$i]);
            }
        }
    }
    // check if reCAPTCHA has been used
    if (isset($_POST['g-recaptcha-response'])) {
        // grab the value
        $captcha = $_POST['g-recaptcha-response'];
        // if there's no value, tell the user it's not set
        if (!$captcha) {
            array_push($errors, $translations->form->error->captcha->empty->{$lang});
        } else {
            $recaptcha = "https://www.google.com/recaptcha/api/siteverify?secret={$options['captcha_secret']}&response={$captcha}&remoteip={$_SERVER['REMOTE_ADDR']}";
            // get recaptcha
            $response = curlEnabled() ? curl_file_get_contents($recaptcha) : file_get_contents($recaptcha);
            $response = json_decode($response);
            // if the response comes back negative, it's a bot, error out
            if (!$response->success) {
                removeUploadsFromServer();
                array_push($errors, parseMessage($translations->form->error->captcha->bot->{$lang}, $response->{'error-codes'}));
            }
        }
    }
    // spit the errors out for use
    return $errors;
}
示例#18
0
 function getExtentFromGoogle($value)
 {
     $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=";
     $url = $url . urlencode($value);
     $resp_json = curl_file_get_contents($url);
     $resp = json_decode($resp_json, true);
     $coords = array();
     if ($resp['status'] == 'OK') {
         if ($resp['results'][0]['geometry']['viewport']) {
             $coords['north'] = floatval($resp['results'][0]['geometry']['viewport']['northeast']['lat']);
             $coords['south'] = floatval($resp['results'][0]['geometry']['viewport']['southwest']['lat']);
             $coords['east'] = floatval($resp['results'][0]['geometry']['viewport']['northeast']['lng']);
             $coords['west'] = floatval($resp['results'][0]['geometry']['viewport']['southwest']['lng']);
         } elseif ($resp['results'][0]['geometry']['location']) {
             $coords['north'] = floatval($resp['results'][0]['geometry']['location']['lat']);
             $coords['south'] = floatval($resp['results'][0]['geometry']['location']['lat']);
             $coords['east'] = floatval($resp['results'][0]['geometry']['location']['lng']);
             $coords['west'] = floatval($resp['results'][0]['geometry']['location']['lng']);
         }
     } else {
         //print ("ERROR:    ".$resp['status']."<br/>");
         return false;
     }
     return $coords;
 }
            ?>
.<BR>
					There is a new updated version <?php 
            echo $available_version;
            ?>
 available for this software.<BR> Please go to rapportsoftware.co.uk to download and update the package.
				</li>
				<?php 
        }
        //end if inner if(version compare)
        ?>

				<li style="text-align:justify; margin-left:10px;">	
					<?php 
        $server_msg_url = 'http://www.rapportsoftware.co.uk/versions/rapport_stocksystem_general_message.txt';
        $server_msg = curl_file_get_contents($server_msg_url, true);
        echo $server_msg;
        ?>
				</li>
		<?php 
    } else {
        echo "<span style='color:red'><b>No Internet. All internet features like notifications, email, sms have been disabled.</b></span>";
        //We will set the settings in the database back to offline so that the performance is not affected
        Yii::app()->controller->redirect(array('Setup/Disableinternet', 'current_url' => $current_url));
    }
} else {
    echo "<span style='color:red'><b>Internet connection not available.You will not be able to use any internet serivce like emails, sms or notifications<br>Please Connect to Internet and enable connection from here.</b></span><br><br>";
    echo CHtml::link('Enable Internet', array('Setup/Enableinternet', 'current_url' => $current_url));
}
?>
function google_get_contacts($token, $max_results = 50)
{
    //global $records;
    global $groups;
    //$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results='.$max_results.'&oauth_token='.$_SESSION['contact_auth']['token']; // all contacts as xml
    //$url = 'https://www.google.com/m8/feeds/contacts/default/full/78967d550d3fdd99?alt=json&v=3.0&oauth_token='.$_SESSION['contact_auth']['token']; // single contact
    $url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results=' . $max_results . '&alt=json&v=3.0&oauth_token=' . $token;
    // all contacts as json
    $xml_response = curl_file_get_contents($url);
    $records = json_decode($xml_response, true);
    //check for authentication errors (logged out of google account, or app access permission revoked, etc)
    if ($records['error']['code']) {
        header("Location: contact_auth.php?source=google&target=" . substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"], '/') + 1));
        exit;
    }
    //create new array of contacts
    foreach ($records['feed']['entry'] as $contact['number'] => $contact) {
        $contact_id = substr($contact['id']['$t'], strrpos($contact['id']['$t'], "/") + 1);
        $contacts[$contact_id]['etag'] = $contact['gd$etag'];
        $contacts[$contact_id]['updated'] = $contact['updated']['$t'];
        $contacts[$contact_id]['name_prefix'] = $contact['gd$name']['gd$namePrefix']['$t'];
        $contacts[$contact_id]['name_given'] = $contact['gd$name']['gd$givenName']['$t'];
        $contacts[$contact_id]['name_middle'] = $contact['gd$name']['gd$additionalName']['$t'];
        $contacts[$contact_id]['name_family'] = $contact['gd$name']['gd$familyName']['$t'];
        $contacts[$contact_id]['name_suffix'] = $contact['gd$name']['gd$nameSuffix']['$t'];
        $contacts[$contact_id]['nickname'] = $contact['gContact$nickname']['$t'];
        $contacts[$contact_id]['title'] = $contact['gd$organization'][0]['gd$orgTitle']['$t'];
        $contacts[$contact_id]['organization'] = $contact['gd$organization'][0]['gd$orgName']['$t'];
        foreach ($contact['gd$email'] as $contact_email['number'] => $contact_email) {
            if ($contact_email['label']) {
                $contact_email_label = $contact_email['label'];
            } else {
                $contact_email_label = substr($contact_email['rel'], strpos($contact_email['rel'], "#") + 1);
                $contact_email_label = ucwords(str_replace("_", " ", $contact_email_label));
            }
            $contacts[$contact_id]['emails'][$contact_email['number']]['label'] = $contact_email_label;
            $contacts[$contact_id]['emails'][$contact_email['number']]['address'] = $contact_email['address'];
            $contacts[$contact_id]['emails'][$contact_email['number']]['primary'] = $contact_email['primary'] ? 1 : 0;
        }
        foreach ($contact['gd$phoneNumber'] as $contact_phone['number'] => $contact_phone) {
            if ($contact_phone['label']) {
                $contact_phone_label = $contact_phone['label'];
            } else {
                $contact_phone_label = substr($contact_phone['rel'], strpos($contact_phone['rel'], "#") + 1);
                $contact_phone_label = ucwords(str_replace("_", " ", $contact_phone_label));
            }
            $contacts[$contact_id]['numbers'][$contact_phone['number']]['label'] = $contact_phone_label;
            $contacts[$contact_id]['numbers'][$contact_phone['number']]['number'] = preg_replace('{\\D}', '', $contact_phone['$t']);
        }
        foreach ($contact['gContact$website'] as $contact_website['number'] => $contact_website) {
            $contact_website_label = $contact_website['label'] ? $contact_website['label'] : ucwords(str_replace("_", " ", $contact_website['rel']));
            $contacts[$contact_id]['urls'][$contact_website['number']]['label'] = $contact_website_label;
            $contacts[$contact_id]['urls'][$contact_website['number']]['url'] = $contact_website['href'];
        }
        foreach ($contact['gd$structuredPostalAddress'] as $contact_address['number'] => $contact_address) {
            if ($contact_address['label']) {
                $contact_address_label = $contact_address['label'];
            } else {
                $contact_address_label = substr($contact_address['rel'], strpos($contact_address['rel'], "#") + 1);
                $contact_address_label = ucwords(str_replace("_", " ", $contact_address_label));
            }
            $contacts[$contact_id]['addresses'][$contact_address['number']]['label'] = $contact_address_label;
            $contacts[$contact_id]['addresses'][$contact_address['number']]['street'] = $contact_address['gd$street']['$t'];
            $contacts[$contact_id]['addresses'][$contact_address['number']]['extended'] = $contact_address['gd$pobox']['$t'];
            $contacts[$contact_id]['addresses'][$contact_address['number']]['community'] = $contact_address['gd$neighborhood']['$t'];
            $contacts[$contact_id]['addresses'][$contact_address['number']]['locality'] = $contact_address['gd$city']['$t'];
            $contacts[$contact_id]['addresses'][$contact_address['number']]['region'] = $contact_address['gd$region']['$t'];
            $contacts[$contact_id]['addresses'][$contact_address['number']]['postal_code'] = $contact_address['gd$postcode']['$t'];
            $contacts[$contact_id]['addresses'][$contact_address['number']]['country'] = $contact_address['gd$country']['$t'];
        }
        foreach ($contact['gContact$groupMembershipInfo'] as $contact_group['number'] => $contact_group) {
            $contact_group_id = substr($contact_group['href'], strrpos($contact_group['href'], "/") + 1);
            $contacts[$contact_id]['groups'][$contact_group_id] = $groups[$contact_group_id]['name'];
        }
        $contacts[$contact_id]['notes'] = $contact['content']['$t'];
    }
    //set account holder info
    $_SESSION['contact_auth']['name'] = $records['feed']['author'][0]['name']['$t'];
    $_SESSION['contact_auth']['email'] = $records['feed']['author'][0]['email']['$t'];
    return $contacts;
}
示例#21
0
 public function systemcheck()
 {
     cacheHeaders(false);
     $this->load->Model('YSPro');
     header('Content-type: text/plain; charset=utf-8');
     header('X-OTT-Server-Ip: ' . $_SERVER['SERVER_ADDR']);
     if ($this->config->item('platform') == 'dev') {
         $this->readdb = $this->load->database('thomasdev', true);
     } else {
         $this->readdb = $this->load->database('prod_read', true);
         if (!$this->readdb->initialize()) {
             $this->readdb = $this->load->database('prod', true);
         }
     }
     $res = $this->db->count_all('movies');
     if (!$res) {
         header('Status: 500 Internal Server Error', true, 500);
         syslog(LOG_ERR, 'OTT SYSTEMCHECK: Cannot read from p-mysql01');
         echo 'Cannot read from p-mysql01';
         return;
     }
     $res = $this->readdb->count_all('movies');
     if (!$res) {
         header('Status: 500 Internal Server Error', true, 500);
         syslog(LOG_ERR, 'OTT SYSTEMCHECK: Cannot read from ottsqlslave');
         echo 'Cannot read from ottsqlslave';
         return;
     }
     $response = curl_file_get_contents('http://ptays.yousee.tv/ipscopes/?ip=8.8.8.8', false, 6);
     if (!$response) {
         header('Status: 500 Internal Server Error', true, 500);
         syslog(LOG_ERR, 'OTT SYSTEMCHECK: PTAYS does not respond');
         echo 'PTAYS does not respond';
         return;
     }
     $response = $this->YSPro->ping();
     if (!$response) {
         header('Status: 500 Internal Server Error', true, 500);
         syslog(LOG_ERR, 'OTT SYSTEMCHECK: YSPro does not respond');
         echo 'YSPro does not respond';
         return;
     }
     $response = json_decode($response);
     if ((int) $response->Status !== 0) {
         header('Status: 500 Internal Server Error', true, 500);
         syslog(LOG_ERR, 'OTT SYSTEMCHECK: YSPro says it is down');
         echo 'YSPro says it is down';
         return;
     }
     header('Status: 200 OK', true, 200);
     echo 'Everything is OK';
 }
示例#22
0
 foreach ($fields as $key => $value) {
     $post .= $key . '=' . $value . '&';
 }
 $post = rtrim($post, '&');
 $curl = curl_init();
 curl_setopt($curl, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
 curl_setopt($curl, CURLOPT_POST, 5);
 curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
 $result = curl_exec($curl);
 curl_close($curl);
 $response = json_decode($result);
 $accesstoken = $response->access_token;
 $url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results=' . $max_results . '&oauth_token=' . $accesstoken;
 $xmlresponse = curl_file_get_contents($url);
 if (strlen(stristr($xmlresponse, 'Authorization required')) > 0 && strlen(stristr($xmlresponse, 'Error ')) > 0) {
     echo "<h2>OOPS !! Something went wrong. Please try reloading the page.</h2>";
     exit;
 }
 $xml = new SimpleXMLElement($xmlresponse);
 $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
 $result = $xml->xpath('//gd:email');
 foreach ($result as $title) {
     $stmt = $conn->prepare('INSERT INTO emails (list_id, email) VALUES (:id, :email)');
     $result = $stmt->execute(array('id' => $_SESSION['list'], 'email' => $title->attributes()->address));
     // echo $title->attributes()->address . "<br>";
 }
 $stmtlist = $conn->prepare('SELECT id, name FROM lists WHERE id = :id');
 $resultlist = $stmtlist->execute(array('id' => $_SESSION['list']));
 $rowlist = $stmtlist->fetch();
示例#23
0
 public function configurationAction($configuration)
 {
     $this->definirVariablesCommunes();
     if (isset($this->getDi()->getConfig()->configurations[$configuration])) {
         $xmlPath = $this->getDi()->getConfig()->configurations[$configuration];
     } else {
         $xmlPath = $this->getDi()->getConfig()->configurationsDir . $configuration . '.xml';
     }
     if (file_exists($xmlPath)) {
         $element = simplexml_load_file($xmlPath);
     } else {
         //url externe
         $element = simplexml_load_string(curl_file_get_contents($xmlPath));
     }
     if (isset($element->attributes()->titre)) {
         $titre = $element->attributes()->titre;
     } else {
         $titre = "Navigateur";
     }
     $this->view->setVar("titre", $titre);
     if (file_exists($xmlPath)) {
         $filemtime = filemtime($xmlPath);
     } else {
         $curl = curl_init($xmlPath);
         curl_setopt($curl, CURLOPT_NOBODY, true);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($curl, CURLOPT_FILETIME, true);
         curl_exec($curl);
         $timestamp = curl_getinfo($curl, CURLINFO_FILETIME);
         $filemtime = $timestamp;
     }
     $this->view->setVar("configuration", $configuration . "?v={$filemtime}");
     $contexteArrayId = array();
     $contexteArrayCode = array();
     $this->view->setVar("couche", "null");
     if (isset($element->contexte)) {
         $contexte = null;
         for ($i = 0; $i < count($element->contexte); $i++) {
             if (isset($element->contexte[$i]->attributes()->id)) {
                 $contexteId = $element->contexte[$i]->attributes()->id;
                 $contexte = IgoContexte::findFirst("id={$contexteId}");
                 if ($contexte) {
                     $contexteArrayId[] = $element->contexte[$i]->attributes()->id . "?v=" . md5($contexte->date_modif);
                 } else {
                     $this->view->setVar("avertissement", "Le contexte avec le id:{$contexteId} n'existe pas");
                 }
             } else {
                 if (isset($element->contexte[$i]->attributes()->code)) {
                     $contexteCode = $element->contexte[$i]->attributes()->code;
                     $contexte = IgoContexte::findFirst("code='{$contexteCode}'");
                     if ($contexte) {
                         $contexteArrayCode[] = $element->contexte[$i]->attributes()->code . "?v=" . md5($contexte->date_modif);
                     } else {
                         $this->view->setVar("avertissement", "Le contexte '{$contexteCode}' n'existe pas");
                     }
                 }
             }
         }
     }
     $this->view->setVar("contexteCode", $contexteArrayCode);
     $this->view->setVar("contexteId", $contexteArrayId);
     if (isset($element->attributes()->baseUri) && isset($element->attributes()->libUri)) {
         $this->config->uri->librairies = $element->attributes()->baseUri . $element->attributes()->libUri;
     }
     if (isset($element->attributes()->baseUri) && isset($element->attributes()->serviceUri)) {
         $this->config->uri->services = $element->attributes()->baseUri . $element->attributes()->serviceUri;
     }
     if (isset($element->attributes()->baseUri) && isset($element->attributes()->apiUri)) {
         $this->config->uri->api = $element->attributes()->baseUri . $element->attributes()->apiUri;
     }
     if (isset($element->attributes()->baseUri) && isset($element->attributes()->mapserver)) {
         $this->config->uri->mapserver = $element->attributes()->mapserver;
     }
     $this->getDi()->getView()->config = $this->config;
     if (isset($element->attributes()->baseUri)) {
         $this->config->uri->navigateur = $element->attributes()->baseUri;
         $this->config->application->baseUri = $this->config->uri->navigateur;
     }
 }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    if ($data) {
        return $data;
    } else {
        echo "?";
    }
}
$url = $_GET["url"];
// first, confirm the URL exists
if (!url_exists($url)) {
    echo "{ \"success\": false, \"message\": \"Sorry, that URL doesn't seem to contain an image!\" }";
    exit;
}
// second, that it's a filetype we can work with
$extension = get_file_type($url);
if (!in_array($extension, array("png", "gif", "jpg"))) {
    echo "{ \"success\": false, \"message\": \"Sorry, please only supply URLs of images in PNG, GIF and JPG format.\" }";
    exit;
}
// okay, now lets make a copy of it locally with a random filename, and return that to the client
$image_data = curl_file_get_contents($url);
$filename = "tmp" . time() . "." . $extension;
$fh = fopen(dirname(__FILE__) . "/../remote/{$filename}", "w");
fwrite($fh, $image_data);
fclose($fh);
echo "{ \"success\": true, \"message\": \"{$filename}\" }";
exit;
示例#25
0
         $sqlSelectUpload .= " and upload_sourceid='" . $srcid . "'";
     }
     $sqlSelectUpload .= " and uploadedby='" . $user_id . "'  order by uploaddetail_id DESC";
 } else {
     $sqlSelectUpload = "select * from fn_uploaddetails where  upload_sourcetype='" . strtolower($srclookup_id) . "' and (uploadtype='35' or uploadtype='62')";
     if ($srcid != "") {
         $sqlSelectUpload .= " and upload_sourceid='" . $srcid . "'";
     }
     $sqlSelectUpload .= " and uploadedby='" . $user_id . "'  order by uploaddetail_id DESC";
 }
 $sqlSelectVideoRes = mysql_query($sqlSelectUpload);
 if (mysql_num_rows($sqlSelectVideoRes) > 0) {
     while ($sqlSelectVideoDet = mysql_fetch_assoc($sqlSelectVideoRes)) {
         if (!empty($sqlSelectVideoDet['videoid'])) {
             //$videosource = file_get_contents("http://api.viddler.com/api/v2/viddler.videos.getDetails.json?sessionid=".$session_id."&key=1mn4s66e3c44f11rx1xd&video_id=".$sqlSelectVideoDet['videoid']);
             $videosource = curl_file_get_contents("http://api.viddler.com/api/v2/viddler.videos.getDetails.json?sessionid=" . $session_id . "&key=1mn4s66e3c44f11rx1xd&video_id=" . $sqlSelectVideoDet['videoid']);
             $video = json_decode(unserialize($videosource), true);
             $sqlSelectVideoDet['videofrom'] = "";
             foreach ($video['video']['files'] as $k => $v) {
                 if ($v['html5_video_source'] != "") {
                     $sqlSelectVideoDet['videosource'] = $v['html5_video_source'];
                 }
             }
             $rows[] = unstrip_array($sqlSelectVideoDet);
         } else {
             $str = str_replace("/default.jpg", "", $sqlSelectVideoDet['video_img']);
             $str = str_replace("http://img.youtube.com/vi/", "", $str);
             $sqlSelectVideoDet['video_embedurl'] = "";
             $sqlSelectVideoDet['videofrom'] = "youtube";
             if ($str != "") {
                 $str = "http://www.youtube.com/embed/" . $str;
示例#26
0
 protected static function exchange($to, $from = 'JPY')
 {
     static $rate = 0;
     if ($rate) {
         return $rate;
     }
     $log = PT_PATH . 'log/' . $from . '_' . $to . '.rate';
     if (file_exists($log) && date('Ymd', filemtime($log)) == date('Ymd')) {
         $rate = file_get_contents($log);
     } else {
         $i = 0;
         while (true) {
             $i++;
             if ($i >= 10) {
                 return false;
             }
             $json = curl_file_get_contents("http://free.currencyconverterapi.com/api/v3/convert?q={$from}_{$to}&compact=y");
             if (!$json) {
                 continue;
             }
             $data = json_decode($json, true);
             if (!$data || !$data["{$from}_{$to}"]) {
                 continue;
             }
             $rate = $data["{$from}_{$to}"]['val'];
             file_put_contents($log, $rate);
             break;
         }
     }
     return $rate;
 }
示例#27
0
 /**
  * 获取JS票据
  * @return string
  */
 public function jsapi_ticket()
 {
     // 从没有获取过access_token或者已经过期
     if (empty($_SESSION['jsapi_ticket']) || $_SESSION['jsapi_ticket_expire'] - time() <= 0) {
         $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi';
         $json = json_decode(curl_file_get_contents(sprintf($url, $this->access_token)));
         if ($json->errcode) {
             log_msg($json, '获取jsapi_ticket失败');
             die('get jsapi_ticket fail!');
         }
         $_SESSION['jsapi_ticket'] = $json->ticket;
         $_SESSION['jsapi_ticket_expire'] = time() + $json->expires_in;
         // 过期的时间
     }
     return $_SESSION['jsapi_ticket'];
 }
示例#28
0
function wpinstaroll_getInstagramPhotosWithTag($tag)
{
    if (empty($tag)) {
        return null;
    }
    $accessToken = get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX . '_instagram_user_accesstoken');
    if (empty($accessToken)) {
        return null;
    }
    $show_useronly = get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX . '_instagram_show_useronly_photos_by_tag');
    if ($show_useronly != 'show_useronly_by_tag') {
        // all photos
        $file_contents = @curl_file_get_contents(WP_ROLL_INSTAGRAM_STREAM_BYTAG_URL_A . $tag . WP_ROLL_INSTAGRAM_STREAM_BYTAG_URL_B . $accessToken);
        if (empty($file_contents)) {
            return null;
        }
        $photo_data = json_decode($file_contents);
    } else {
        // only user photos
        $instagram_user_id = get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX . '_instagram_user_userid');
        if (empty($instagram_user_id)) {
            return false;
        }
        $file_contents = @curl_file_get_contents(WP_ROLL_INSTAGRAM_USER_PHOTOS_URL_A . $instagram_user_id . WP_ROLL_INSTAGRAM_USER_PHOTOS_URL_B . $accessToken);
        if (empty($file_contents)) {
            return null;
        }
        $photo_data = json_decode($file_contents);
        // we filter the data, removing the ones without the specified tag
        $data = $photo_data->data;
        $new_data = array();
        foreach ($data as $element) {
            $tags = $element->tags;
            foreach ($tags as $single_tag) {
                if (trim($tag) == trim($single_tag)) {
                    $new_data[] = $element;
                    break;
                }
            }
        }
        // replace the old data with the filtered version
        $photo_data->data = $new_data;
    }
    wpinstaroll_updateLocalDBWithNewPhotos($photo_data);
    return $photo_data;
}
/**
 * Downloads the character portrait from EVE as the new user's avatar.
 * @param mixed $id The ID of the character whose portrait is being retrieved.
 * @param int $user_id User ID of the account to apply the avatar to.  Optional.  Used during registration. 
 * @return filename for the newly downloaded avatar.
 */
function eveapi_getPortrait($id, $user_id = false)
{
    global $config, $user, $phpbb_root_path;
    $user_id = $user_id ? $user_id : $user->data['user_id'];
    $input = 'http://image.eveonline.com/Character/' . $id . '_256.jpg';
    $db_filename = $user_id . "_" . time() . ".jpg";
    $filename = get_avatar_filename($db_filename);
    $output = !defined('ADMIN_START') ? $config['avatar_path'] . "/" . $filename : $phpbb_root_path . $config['avatar_path'] . "/" . $filename;
    $fgc = curl_file_get_contents($input);
    if (!$fgc) {
        return false;
    }
    if (file_exists($output)) {
        unlink($output);
    }
    file_put_contents($output, $fgc);
    return $db_filename;
}
示例#30
0
                    $errors[] = '用户名 或 密码 太长了';
                }
            } else {
                $errors[] = '用户名、密码  必填';
            }
        }
    }
}
/////
if (isset($gotohome)) {
    if ($_SESSION["avatar"] && isset($getavatar)) {
        $imgurl = $_SESSION["avatar"];
        $opts = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6\r\n" . "Referer: " . $imgurl . "\r\n"));
        //$context = stream_context_create($opts);
        //$avatardata = file_get_contents($imgurl, false, $context);
        $avatardata = curl_file_get_contents($imgurl);
        $img_obj = imagecreatefromstring($avatardata);
        if ($img_obj !== false) {
            // 缩略图比例
            $new_w = 73;
            $new_h = 73;
            $new_image = imagecreatetruecolor($new_w, $new_h);
            $bg = imagecolorallocate($new_image, 255, 255, 255);
            imagefill($new_image, 0, 0, $bg);
            ////目标文件,源文件,目标文件坐标,源文件坐标,目标文件宽高,源宽高
            imagecopyresampled($new_image, $img_obj, 0, 0, 0, 0, $new_w, $new_h, 180, 180);
            imagedestroy($img_obj);
            ob_start();
            imagejpeg($new_image, NULL, 95);
            $out_img = ob_get_contents();
            ob_end_clean();