Sakuraのシンプル監視からSlackにサーバのApacheが止まったよと連絡が来てたのでサーバに入ってApacheの再起動をすると、
Apache start [OK]
とは出るものの、psコマンドで確認してもプロセスは立ち上がらず。
Apache start [OK]
とは出るものの、psコマンドで確認してもプロセスは立ち上がらず。
Linuxサーバの設定やプログラムのことなどを中心にブログを書いています。
//月 var month = ("0"+(date.getMonth() + 1)).slice(-2), //日 var date = ("0"+date.getDate()).slice(-2)
というダイアログが出てくる。
Detected newer version of FileZilla
The file '/Users/XXXXX/.filezilla/sitemanager.xml' has been created by a more recent version of FileZilla.
Loading files created by newer versions can result in loss of data.
Do you want to continue?
<input TYPE="hidden" name="custom" value="<?php echo $serviceid;?>,<?php echo $userid">※何個もカスタム値を入れるなら、わかりやすくするために、serviceid=1,userid=hoge のような入れ方のほうが良いかも。
function confirmPaypalTransaction($posts) { $paypal_domain = "www.paypal.com"; //テスト環境はsandbox.paypal.com $req = 'cmd=_notify-validate'; foreach ($posts as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&".$key."=".$value; } $url = 'https://'.$paypal_domain.'/cgi-bin/webscr'; $cmd = '/usr/bin/curl '.$url.' --tlsv1.2 -d "'.$req.'"'; exec($cmd, $res, $ret); /* 以下のcurl関数では叩けなくなった(PHP5.3) $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'rsa_aes_128_sha'); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); if ( !$res = curl_exec($ch) ) { $this->writeLog("FATAL", "CURL ERROR:". curl_error($ch)); } curl_close($ch);*/ return $res; }
function setBenchMarker() { if ( !is_array($GLOBALS["benchmark"]) ) { $GLOBALS["benchmark"] = array(); } $trace = debug_backtrace(); $line = $trace[0]["line"]; $file = $trace[0]["file"]; array_push($GLOBALS["benchmark"], array("point"=>$file.":".$line, "time"=>microtime(true))); } function getBenchMarkResult($delim="\n") { $lasttime = 0; $lastpoint = 0; $retbuf = ""; $records = $GLOBALS["benchmark"]; foreach ( $records as $record ) { $point = $record["point"]; $time = $record["time"]; if ( $lasttime != 0 ) { $retbuf = "[".$lastpoint."]--[".$point."] = ".sprintf('%0.5f', $time-$lasttime).$delim; } $lastpoint = $point; $lasttime = $time; } return $retbuf; }
class Hoge { public function __construct( ){} public function moge() { setBenchMarker(); } } function foo() { setBenchMarker(); } setBenchMarker(); foo(); $hoge = new Hoge(); $hoge->moge(); setBenchMarker(); $bench = getBenchMarkResult(); echo $bench;最終結果を文字列として返しているのはerror_logなどに出力することもあるだろうなので、 中でechoはしないようにしている。
$ ./test.php [/home/ec2-user/test/test.php:4]--[/home/ec2-user/test/test.php:21] = 0.087116003 [/home/ec2-user/test/test.php:21]--[/home/ec2-user/test/test.php:30] = 0.010456085 [/home/ec2-user/test/test.php:30]--[/home/ec2-user/test/test.php:9] = 0.000001907
print_r(getGoogleGeoCode("東京")); function getGoogleGeoCode($location, $lang="ja") { $url = "http://maps.google.com/maps/api/geocode/json?sensor=false"; $url.= "&language=".$lang; $url.= "&address=".urlencode($location); $rawdata = file_get_contents($url); return json_decode($rawdata,TRUE); }第一引数は、地名、第二引数は返ってくる地名の言語(例えば、languageの指定をしないと、入力が東京だとTokyoという結果が返ってきてしまう)
Array ( [results] => Array ( [0] => Array ( [address_components] => Array ( [0] => Array ( [long_name] => 東京都 [short_name] => 東京都 [types] => Array ( [0] => administrative_area_level_1 [1] => political ) ) [1] => Array ( [long_name] => 日本 [short_name] => JP [types] => Array ( [0] => country [1] => political ) ) ) [formatted_address] => 日本, 東京都 [geometry] => Array ( [bounds] => Array ( [northeast] => Array ( [lat] => 35.8986468 [lng] => 153.9875217 ) [southwest] => Array ( [lat] => 24.2242343 [lng] => 138.942758 ) ) [location] => Array ( [lat] => 35.6894875 [lng] => 139.6917064 ) [location_type] => APPROXIMATE [viewport] => Array ( [northeast] => Array ( [lat] => 35.817813 [lng] => 139.910202 ) [southwest] => Array ( [lat] => 35.528873 [lng] => 139.510574 ) ) ) [place_id] => ChIJ51cu8IcbXWARiRtXIothAS4 [types] => Array ( [0] => administrative_area_level_1 [1] => political ) ) ) [status] => OK )