ラベル PHP の投稿を表示しています。 すべての投稿を表示
ラベル PHP の投稿を表示しています。 すべての投稿を表示

2021年3月6日土曜日

phpでWebServerを動かす方法

php -S 192.168.11.113:8080 -t ../memo

 -S <addr>:<port> Run with built-in web server.

 -t <docroot>     Specify document root <docroot> for built-in web server.


PHP 8.0.2 (cli) (built: Feb  3 2021 18:36:40) ( ZTS Visual C++ 2019 x64 )

Copyright (c) The PHP Group

Zend Engine v4.0.2, Copyright (c) Zend Technologies

2016年6月1日水曜日

PHP オブジェクト アクセス

$temp = json_decode($_POST['array']);

echo $temp[0];       // NG
echo $temp['0']       // NG
echo $temp(0)         //NG
echo $temp('0')       //NG
echo $temp->0      //NG
echo $temp->'0'     //NG
echo $temp{0};       //NG

echo $temp->{0}     //OK

2015年10月26日月曜日

YouTube Player API

YouTube Player API



class player{
public function player(){
if(array_key_exists('t',$_REQUEST)
  and array_key_exists('l',$_REQUEST)
      and array_key_exists('url',$_REQUEST)){
$this->urltime = $_GET['t'];
$this->playlist = $_GET['l'];
$this->yturl = $_GET['url'];
$this->yturl_3item = $this->para($_GET['url']);
$temp = array();
foreach ($this->yturl_3item as $val){
$temp[count($temp)] = sprintf("'%s'",$val);
}
$this->list_item = '['.implode(",",$temp ).']';
$this->you_player_api($this->playlist,$this->yturl_3item[0],$this->list_item);
}else{
$this->you_player_api('PLvswSo32Xlu_tBfEDzpuFQ-lUFP1_Aq5I','_sQSXwdtxlY','["GLyYUyVH2PI","RgKAFK5djSk"]');
}
}

public function player_area(){
$div_area = sprintf('<div id = "player_area" >
<div id = "player"></div>
</div>
');
echo $div_area;
}

public function debug_show(){
echo '<pre>';
echo $this->urltime;
echo '<br>';
echo $this->playlist;
echo '<br>';
echo $this->yturl;
echo '<br>';
print_r( $this->yturl_3item);
echo $this->yturl_3item[0];
}

public function para($url){
$temp=array();
$temp2=array();
$temp=explode('=',$url);
$temp2=explode('|',$temp['1']);
return $temp2;
}

public function you_player_api($playlist,$videoid,$array_list){
$player = sprintf("
<script>
var tag = document.createElement('script');
tag.src = 'https://www.youtube.com/iframe_api';
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
var playlist = '%s';
var videoid = '%s';
var array_list = %s;
var h = '240';
var w = '320'
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: h,
width: w,
videoId: 'CNNDRO3imrs',
playerVars:{
'controls':'1',
'disablekb':'0',
'playsinline':'0'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'onError':onPlayerError
}
});
}

   function onPlayerReady(event) {
//event.target.cuePlaylist({list:'PLvswSo32Xlu9BOn94xy-Xd_mTsMIny639'});
var j = event.target.cuePlaylist({list:playlist});
console.log (j.length);
if(j.length == 0){
one_list_play(event.target);
}
}

function onPlayerStateChange(event) {
console.log('onPlayerStateChange');
console.log(player.getAvailableQualityLevels());
console.log(player.getPlaybackQuality());
event.target.setPlaybackQuality('tiny');
if(event.target.getPlayerState() === 5 ){
event.target.setSize(w,h);
var list_items = event.target.getPlaylist();
var list_index = list_items.indexOf(videoid);
if(list_index >-1 ){
//event.target.loadPlaylist({list:playlist,index:list_index,startSeconds:3});
event.target.playVideoAt(list_index);
}
if(list_index == -1 ){
//event.target.loadPlaylist({playlist:array_list});
one_list_play(event.target);
}
}
}

function one_list_play(event){
console.log('000111');
event.loadPlaylist({playlist:array_list});
}

function onPlayerError(event){
event.target.nextVideo();
console.log('onPlayerError');
}

</script>"
,$playlist,$videoid,$array_list);
echo $player;
}
}








2015年8月29日土曜日

HTTP_USER_AGENT

HTTP_USER_AGENT


Mozilla/5.0 (Linux; Android 5.0.2; ASUS_Z00ED Build/LRX22G) AppleWebKit/
537.36 (KHTML, like Gecko) Chrome/39.0.2171.93 Mobile Safari/537.36


Mozilla/5.0 (Linux; Android 5.0; ALE-L02 Build/HuaweiALE-L02) AppleWebKi
t/537.36 (KHTML, like Gecko) Chrome/39.0.2171.93 Mobile Safari/537.36


Mozilla/5.0 (Linux; Android 4.4.4; HM NOTE 1LTE Build/KTU84P) AppleWebKi
t/537.36 (KHTML, like Gecko) Chrome/44.0.2403.133 Mobile Safari/537.36

2015年8月24日月曜日

SQLITE データーベースのデーター追加(途中の記録)

SQLITE データーベースのデーター追加(途中の記録)

<?php
error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//print_r(SQLite3::version());

//
//
//
//


$x = new xtext();
echo json_encode($x->title('title',json_decode($_REQUEST['p'])));

class xtext {
public $db_name = 'xtext.db';
//
public function xtext(){
}

//
public function title($title,$paras){

$para['ad_ip'] = $_SERVER['REMOTE_ADDR'];
$para['ad_agent'] = $this->agent($_SERVER['HTTP_USER_AGENT'],"agent");
$para['ad_time'] = $_SERVER["REQUEST_TIME"];
$para['access_time'] = $_SERVER["REQUEST_TIME"];
$para['set_active'] = '1';
$para['ad_user'] = htmlentities($paras->ad_user);
$para['ad_ps'] =  htmlentities($paras->ad_ps);
$para['title'] =  htmlentities($paras->title);

$table_name = 'title';
$url_id = $this->uniq_id('title');
$this->update($table_name,$url_id,$para);

//test pint print_r($para);
return $url_id;
}


//
public function update($table,$url_id,$para ){
$db = new sqlite3($this->db_name);
foreach ($para as $key=>$val){
$insert = sprintf("update %s set %s = \"%s\" where url_id == \"%s\"" , $table,$key,$val,$url_id);
$db->exec($insert);
}
$db->close();
return 'ture';
}

// Uniquid
public function uniq_id($table_name){
$str = array(range('z','a'),range('Z','A'),range('9','0'));
$length = 11;
$str_r =array();
for ($i=0; $i<$length ;$i++){
$temp = $str[array_rand($str)];
$str_r[count($str_r)] = $temp[array_rand($temp)];
}

$db = new sqlite3($this->db_name);
do{
do{
shuffle($str_r);
$temp_id_str = implode($str_r);
$id_check = $db->querySingle(sprintf("select * from %s where url_id='%s'",$table_name,$temp_id_str),true);
if($id_check){
print_r ( $id_check);
}
}while($id_check);

$insert = sprintf("insert into %s(url_id)VALUES('%s')",$table_name,$temp_id_str);
$check = $db->exec($insert);
if($check){
$db->close();
return $temp_id_str;
}
}while(!$check);

}

// Agent
public function agent($agent,$table_name){
$db = new sqlite3($this->db_name);
$up = sprintf("update %s set count = count +1 where agent == '%s'",$table_name,$agent);
$db->exec($up);
$sch = sprintf("select ROWID from %s where agent == '%s'",$table_name,$agent);
$rowid = $db->querySingle($sch);
if(is_null($rowid)){
$new = sprintf("insert into %s (agent,count)values('%s',1)",$table_name,$agent);
$db->exec($new);
$db->close();
return 1;
}else{
$db->close();
return $rowid;
}
$db->close();
}

}


?>

SQLITE データーベース 作成 PHP

SQLITE  データーベース 作成 PHP


<?php
error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
print_r(SQLite3::version());

if(!file_exists('xtext.db')){
$db = new sqlite3('xtext.db');
$create_title =
"create table title (
url_id text UNIQUE,
title text,
ad_user text default 'admin',
ad_ps text default 'admin_password',
ad_ip text default '0.0.0.0',
ad_agent text default 'Mozilla/5.0',
ad_time text default current_timestamp,
access_time text default current_timestamp,
set_active text default '1',
request_cont integer default 0,
sue_cont integer default 0)";
// set_active 1=非公開、2=公開、3=限定公開、4=削除
// sue_cont >10 非公開
//
$db->exec($create_title);

$create_items =
"create table items (
title_ROWID integer,
item text
)";
$db->exec($create_items);

$create_endusers =
"create table end_user (
url_id UNIQUE,
title_ROWID integer,
item_ROWID integer,
end_name text,
end_ip text default '0.0.0.0',
end_time text default current_timestamp
)";
$db->exec($create_endusers);


$create_agents =
"create table agent (
agent text,
count integer default 0
)";
$db->exec($create_agents);
$db->close();


}else{
echo 'exists';
}
exit;
?>

2015年8月16日日曜日

ランダム文字列 その2

ランダム文字列 その2


function mf_rand()で作成した文字列は重複することがよくあります。
今回の変更は、function mf_rand()は文字列のArrayを作成することに
し、データーベースの比較して、重複する場合、文字列の順番を変える
ことにしました。


<?php
set_time_limit(0);

$db = new sqlite3('xtext.db');
$db->busyTimeout(10000);

for ($i=0; $i<3000; $i++){
//$temp_id = uniqid(mf_rand());
//$temp_id = uniqid();
$temp_id = mf_rand();
do{
shuffle($temp_id);
$temp_id_str = implode($temp_id);
$id_check = $db->querySingle(sprintf("select * from title where url_id='%s'",$temp_id_str),true);
if($id_check){
//print_r ( $id_check);
}
}while($id_check);
$insert = sprintf("insert into title(url_id)VALUES('%s')",$temp_id_str);
$db->exec($insert);
}
$db->close();

function mf_rand(){
$str = array(range('z','a'),range('Z','A'),range('9','0'));
$length = 11;
$str_r =array();
for ($i=0; $i<$length ;$i++){
$temp = $str[array_rand($str)];
$str_r[count($str_r)] = $temp[array_rand($temp)];
}
return($str_r);
}
?>

ランダム文字列

ランダム文字列


結果
18439|kC-EU6_n_Ki||admin|admin_password||1|0
18440|34L95b28gAj||admin|admin_password||1|0
18441|i1U9_95_O2_||admin|admin_password||1|0
18442|NvNl-WklsLm||admin|admin_password||1|0
18443|NwG1_F1-H7n||admin|admin_password||1|0
18444|S--7z5-m7_-||admin|admin_password||1|0
18445|re02t7Z-yXq||admin|admin_password||1|0
18446|sN487lP8_-5||admin|admin_password||1|0
18447|GJo9l_4MN-M||admin|admin_password||1|0
18448|nav-HcE9M3H||admin|admin_password||1|0
18449|w--bl6n1Lh_||admin|admin_password||1|0
18450|-5269e50Hb2||admin|admin_password||1|0
18451|l-71gTkJeSh||admin|admin_password||1|0
18452|G38Pz0Nn21M||admin|admin_password||1|0
18453|-A-A67Hnq1W||admin|admin_password||1|0
18454|1pw890B6X_3||admin|admin_password||1|0
18455|t_Qxo_59nj-||admin|admin_password||1|0
18456|97u7_7B5_qg||admin|admin_password||1|0


Github
https://raw.githubusercontent.com/kankanla/Function/master/rand_uniqid.php



<?php
set_time_limit(0);

$db = new sqlite3('xtext.db');
$db->busyTimeout(10000);

for ($i=0; $i<1000; $i++){
do{
//$temp_id = uniqid(mf_rand());
$temp_id = mf_rand();
//$temp_id = uniqid();
$id_check = $db->querySingle(sprintf("select url_id from title where url_id='%s'",$temp_id));
if($id_check){
echo $id_check;
echo '<br>';
}
}while($id_check);
$insert = sprintf("insert into title(url_id)VALUES('%s')",$temp_id);
$db->exec($insert);
}
$db->close();




function mf_rand(){
$str = array(range('z','a'),range('Z','A'),range('9','0'),range('a','z'),range('A','Z'),range('1','9'),array('_','-'));
$length = 11;
$str_r ='';
for ($i=0; $i<$length ;$i++){
$temp = $str[array_rand($str)];
$str_r = $str_r.$temp[array_rand($temp)];
}
return($str_r);
}

?>



その2

<?php
set_time_limit(0);

$db = new sqlite3('xtext.db');
$db->busyTimeout(10000);

for ($i=0; $i<3000; $i++){
//$temp_id = uniqid(mf_rand());
//$temp_id = uniqid();
$temp_id = mf_rand();
do{
shuffle($temp_id);
$temp_id_str = implode($temp_id);
$id_check = $db->querySingle(sprintf("select * from title where url_id='%s'",$temp_id_str),true);
if($id_check){
//print_r ( $id_check);
}
}while($id_check);
$insert = sprintf("insert into title(url_id)VALUES('%s')",$temp_id_str);
$db->exec($insert);
}
$db->close();

function mf_rand(){
$str = array(range('z','a'),range('Z','A'),range('9','0'));
$length = 11;
$str_r =array();
for ($i=0; $i<$length ;$i++){
$temp = $str[array_rand($str)];
$str_r[count($str_r)] = $temp[array_rand($temp)];
}
return($str_r);
}
?>



2014年3月16日日曜日

HTML Head

HTML Head



<?php
// ページ先頭のパラメータ
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
echo '<title>hpapi</title>';
echo '<link rel="stylesheet" type="text/css" href="link.css" media="screen,all" />';
//echo '<link rel="shortcut icon" href="favicon.ico">';
echo '<link rel="icon" type="image/gif" href="./pic/favicon.gif">';
echo '<meta name="keywords" content="hpapi" />';
echo '<meta name="description" content="hpapi" />';
echo '<link rel="alternate" type="application/atom+xml" title="Atom" href="" />';
echo '<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="" />';
echo '</head>';
echo '<body>';

?>



<?php
//ページの終了
echo '</body>';
echo '</html>';
?>


自己流、ロゴ記録

自己流、ロゴ記録


<?php
function mf_log($log){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;

$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>

userAgent の仕分け

userAgent の仕分け


<?php
switch($_SERVER['HTTP_USER_AGENT']){
case null:
$url='null';
break;

case 'Twitterbot/1.0':
$url='twitter';
break;

case 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)':
$url='facebook';
break;

default:
$url='default';
}

//header("location:{$url}");
echo '<br>';
echo $url;

?>

PHPファイルの直接アクセス拒否する

PHPファイルの直接アクセス拒否する



if (basename(__FILE__)==basename($_SERVER["REQUEST_URI"])){
       header("location:{$url}");
exit('Error: Cannot modify header information !!!');
}

2014年3月2日日曜日

訳の分からないuserAgent(ユーザーエージェント)

訳の分からないuserAgent(ユーザーエージェント)


ロポットとユーザーを区別して対応するための Function 。


<?php
mf_rot();

function mf_rot(){
//echo '<br>';
//echo $_SERVER['HTTP_USER_AGENT'];
//echo '<br>';
//echo $_SERVER['HTTP_ACCEPT_LANGUAGE'];
//echo '<br><br><br><br><br><br>';

$ulg=array();
$robots=array(' ',
'Java/1.7.0_25',
'Twitterbot/1.0',
'ceron.jp/1.0',
'NING/1.0',
'Apache-HttpClient/4.3 (java 1.5)',
'Google-HTTP-Java-Client/1.17.0-rc (gzip)',
'MetaURI API/2.0 +metauri.com',
'Yahoo:LinkExpander:Slingstone',
'EventMachine HttpClient',
'ShortLinkTranslate',
'msnbot/1.1 (+http://search.msn.com/msnbot.htm)',
'QuerySeekerSpider ( http://queryseeker.com/bot.html )',
'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)',
'Y!J-BRW/1.0 crawler (http://help.yahoo.co.jp/help/jp/search/indexing/indexing-15.html)',
'HTTP_Request2/2.2.1 (http://pear.php.net/package/http_request2) PHP/5.5.9',
'Mozilla/5.0 ()',
'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; SLCC1; .NET CLR 1.1.4322)',
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)',
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25',
'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko',
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1',
'Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)', //***
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', //***
);

if(!empty($_SERVER['HTTP_USER_AGENT']) and !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
if (!in_array($_SERVER['HTTP_USER_AGENT'],$robots)){
$ulg=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);

if($ulg['0']=='ja' or $ulg['0']=='ja-jp'){
echo '<br>ja-jP<br>';
echo '<br>is user<br>';
echo '<br>is japanese<br>';
}else{
echo '<br>is not japanese<br>';
echo '<br>exit1<br>';
}
}else{
echo '<br>is Robot<br>';
echo '<br>exit2<br>';
}
}else{
echo '<br>Empty<br>';
}
}
?>

2014年2月22日土曜日

$value foreach 内部で解除すべきか、外部解除すべきか?

警告
foreach ループを終えた後でも、 $value は配列の最後の要素を参照したままとなります。 unset() でその参照を解除しておくようにしましょう。

と書いてありますが、foreach 内部で解除すべきか、外部解除すべきか?





<?php
$v=array('A'=>'aaa',
'B'=>'bbb',
'C'=>'ccc'
);

foreach ($v as $key=>$val){
echo $key;
echo '=>';
echo $val;
echo '<br>';
unset($key);
unset($val);

}

unset($key);
unset($val);

echo 'end foreach<br>';
echo $key;
echo '=>';
echo $val;
echo '<br>';

?>

2013年11月25日月曜日

View HTTP Request and Response Header

View HTTP Request and Response Header


http://web-sniffer.net/


<?php
$url='http://t.co/gW5Y1PYqNM';
echo '<pre>';
print_r(get_headers($url));

echo '<br>';
print_r(get_headers($url,1));


?>


Array
(
    [0] => HTTP/1.0 301 Moved Permanently
    [1] => cache-control: private,max-age=300
    [2] => date: Mon, 25 Nov 2013 16:16:38 GMT
    [3] => expires: Thu, 01-Jan-1970 00:00:00 GMT
    [4] => location: http://www.dodofei.com/player.php?url=https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?uo=2
    [5] => server: tfe
    [6] => set-cookie: muc=1;Domain=t.co;Expires=Sat, 07-Nov-2015 16:16:38 GMT
    [7] => Content-Length: 0
    [8] => HTTP/1.1 302 Found
    [9] => Date: Mon, 25 Nov 2013 16:15:47 GMT
    [10] => Server: Apache/2.2.22 (Win32) PHP/5.4.15
    [11] => X-Powered-By: PHP/5.4.15
    [12] => location: https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?uo=2&at=10ldd8
    [13] => Content-Length: 119
    [14] => Connection: close
    [15] => Content-Type: text/html; charset=UTF-8
    [16] => Content-Language: ja
    [17] => HTTP/1.0 301 Moved Permanently
    [18] => Last-Modified: Mon, 25 Nov 2013 16:16:39 GMT
    [19] => Content-Type: text/html; charset=UTF-8
    [20] => x-apple-translated-wo-url: /WebObjects/MZStore.woa/wa/viewMusicVideo?uo=2&at=10ldd8&id=720776643&cc=fr
    [21] => x-apple-orig-url: https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?uo=2&at=10ldd8
    [22] => x-apple-application-site: ST11
    [23] => apple-timing-app: 3 ms
    [24] => Location: https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?ign-mpt=uo%3D2
    [25] => x-apple-lokamai-no-cache: true
    [26] => x-apple-application-instance: 2125714
    [27] => x-apple-aka-ttl: Generated Mon Nov 25 08:16:39 PST 2013, Expires Mon Nov 25 08:16:39 PST 2013, TTL 0s
    [28] => x-webobjects-loadaverage: 0
    [29] => x-apple-jingle-correlation-key: DA6WMX2UOPXMS
    [30] => Content-Length: 0
    [31] => Server: ATS/4.1.0
    [32] => Expires: Mon, 25 Nov 2013 16:16:39 GMT
    [33] => Cache-Control: max-age=0, no-cache
    [34] => Pragma: no-cache
    [35] => Date: Mon, 25 Nov 2013 16:16:39 GMT
    [36] => Connection: close
    [37] => Set-Cookie: ls=1; version="1"; max-age=10; expires=Mon, 25-Nov-2013 16:16:49 GMT; path=/; domain=.apple.com
    [38] => Set-Cookie: a=QQAJAAAACwAfUZAGMTBsZGQ4AAAAACr2LcM=; version="1"; expires=Sat, 30-Nov-2013 16:16:39 GMT; path=/; domain=.apple.com
    [39] => X-Apple-Partner: origin.0
    [40] => HTTP/1.0 200 OK
    [41] => Last-Modified: Mon, 25 Nov 2013 16:16:39 GMT
    [42] => x-apple-lok-response-date: Mon Nov 25 08:16:39 PST 2013
    [43] => x-apple-translated-wo-url: /WebObjects/MZStore.woa/wa/viewMusicVideo?ign-mpt=uo%3D2&id=720776643&cc=fr
    [44] => x-apple-orig-url: https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?ign-mpt=uo%3D2
    [45] => x-apple-application-site: NWK
    [46] => apple-timing-app: 149 ms
    [47] => x-apple-aka-ttl: Generated Mon Nov 25 08:16:39 PST 2013, Expires Mon Nov 25 08:17:39 PST 2013, TTL 60s
    [48] => x-apple-application-instance: 1003405
    [49] => Content-Type: text/html; charset=UTF-8
    [50] => x-webobjects-loadaverage: 0
    [51] => x-apple-jingle-correlation-key: 3U2NYZPIBCE2S
    [52] => Server: ATS/4.1.0
    [53] => Cache-Control: no-transform, max-age=60
    [54] => Date: Mon, 25 Nov 2013 16:16:39 GMT
    [55] => Connection: close
    [56] => X-Apple-Partner: origin.0
)

Array
(
    [0] => HTTP/1.0 301 Moved Permanently
    [cache-control] => private,max-age=300
    [date] => Mon, 25 Nov 2013 16:16:39 GMT
    [expires] => Thu, 01-Jan-1970 00:00:00 GMT
    [location] => Array
        (
            [0] => http://www.dodofei.com/player.php?url=https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?uo=2
            [1] => https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?uo=2&at=10ldd8
        )

    [server] => tfe
    [set-cookie] => muc=1;Domain=t.co;Expires=Sat, 07-Nov-2015 16:16:39 GMT
    [Content-Length] => Array
        (
            [0] => 0
            [1] => 119
            [2] => 0
        )

    [1] => HTTP/1.1 302 Found
    [Date] => Array
        (
            [0] => Mon, 25 Nov 2013 16:15:48 GMT
            [1] => Mon, 25 Nov 2013 16:16:40 GMT
            [2] => Mon, 25 Nov 2013 16:16:40 GMT
        )

    [Server] => Array
        (
            [0] => Apache/2.2.22 (Win32) PHP/5.4.15
            [1] => ATS/4.1.0
            [2] => ATS/4.1.0
        )

    [X-Powered-By] => PHP/5.4.15
    [Connection] => Array
        (
            [0] => close
            [1] => close
            [2] => close
        )

    [Content-Type] => Array
        (
            [0] => text/html; charset=UTF-8
            [1] => text/html; charset=UTF-8
            [2] => text/html; charset=UTF-8
        )

    [Content-Language] => ja
    [2] => HTTP/1.0 301 Moved Permanently
    [Last-Modified] => Array
        (
            [0] => Mon, 25 Nov 2013 16:16:40 GMT
            [1] => Mon, 25 Nov 2013 16:16:39 GMT
        )

    [x-apple-translated-wo-url] => Array
        (
            [0] => /WebObjects/MZStore.woa/wa/viewMusicVideo?uo=2&at=10ldd8&id=720776643&cc=fr
            [1] => /WebObjects/MZStore.woa/wa/viewMusicVideo?ign-mpt=uo%3D2&id=720776643&cc=fr
        )

    [x-apple-orig-url] => Array
        (
            [0] => https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?uo=2&at=10ldd8
            [1] => https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?ign-mpt=uo%3D2
        )

    [x-apple-application-site] => Array
        (
            [0] => ST11
            [1] => NWK
        )

    [apple-timing-app] => Array
        (
            [0] => 3 ms
            [1] => 149 ms
        )

    [Location] => https://itunes.apple.com/fr/music-video/game-over-feat.-maitre-gims/id720776643?ign-mpt=uo%3D2
    [x-apple-lokamai-no-cache] => true
    [x-apple-application-instance] => Array
        (
            [0] => 2125634
            [1] => 1003405
        )

    [x-apple-aka-ttl] => Array
        (
            [0] => Generated Mon Nov 25 08:16:40 PST 2013, Expires Mon Nov 25 08:16:40 PST 2013, TTL 0s
            [1] => Generated Mon Nov 25 08:16:39 PST 2013, Expires Mon Nov 25 08:17:39 PST 2013, TTL 60s
        )

    [x-webobjects-loadaverage] => Array
        (
            [0] => 0
            [1] => 0
        )

    [x-apple-jingle-correlation-key] => Array
        (
            [0] => 736QQ6BZ67AXU
            [1] => 3U2NYZPIBCE2S
        )

    [Expires] => Mon, 25 Nov 2013 16:16:40 GMT
    [Cache-Control] => Array
        (
            [0] => max-age=0, no-cache
            [1] => no-transform, max-age=59
        )

    [Pragma] => no-cache
    [Set-Cookie] => Array
        (
            [0] => ls=1; version="1"; max-age=10; expires=Mon, 25-Nov-2013 16:16:50 GMT; path=/; domain=.apple.com
            [1] => a=QQAJAAAACwAfUZAGMTBsZGQ4AAAAACr2LcM=; version="1"; expires=Sat, 30-Nov-2013 16:16:40 GMT; path=/; domain=.apple.com
        )

    [X-Apple-Partner] => Array
        (
            [0] => origin.0
            [1] => origin.0
        )

    [3] => HTTP/1.0 200 OK
    [x-apple-lok-response-date] => Mon Nov 25 08:16:39 PST 2013
)

2013年10月14日月曜日

PHP JSON header('Access-Control-Allow-Origin: *') 出力

PHP JSON 出力して、異なるクライアントをアクセスするにはサーバー側に
header('Access-Control-Allow-Origin: *'); 設定が必要に成ります。


  header('Access-Control-Allow-Origin: *');
  echo $test=json_encode($this->items);

Chrome  アクセス可能
Firefox   アクセス可能

2013年10月5日土曜日

mb_strimwidth 文字化け

変更前
echo mb_strimwidth($temp->Result->Content.'   (知恵袋)',0,280);

変更後
echo mb_strimwidth($temp->Result->Content.'   (知恵袋)',0,280,',',UTF8);

2013年7月11日木曜日

確認したいPHP 関数 2つ

確認したいPHP 関数 2つあります。



print_r(get_headers($url));
print_r(get_meta_tags($url));

2013年5月26日日曜日

usleep() - マイクロ秒単位で実行を遅延する

usleep() - マイクロ秒単位で実行を遅延する
usleep(500000);    0.5秒

2013年5月12日日曜日

error_reporting — 出力する PHP エラーの種類を設定する


error_reporting()

<?php

// 全てのエラー出力をオフにする
error_reporting(0);

// 単純な実行時エラーを表示する
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// E_NOTICE を表示させるのもおすすめ(初期化されていない
// 変数、変数名のスペルミスなど…)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// E_NOTICE 以外の全てのエラーを表示する
// これは php.ini で設定されているデフォルト値
error_reporting(E_ALL ^ E_NOTICE);

// 全ての PHP エラーを表示する (Changelog を参照ください)
error_reporting(E_ALL);

// 全ての PHP エラーを表示する
error_reporting(-1);

// error_reporting(E_ALL); と同じ
ini_set('error_reporting', E_ALL);

?> 



 参考