This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = [ | |
['A', 'B', 'C', 'D'], | |
['A', 'B', 'TT', 'D'], | |
['A', 'F', 'G', 'H'], | |
['11', '12', '13', '14'], | |
['11', '12', '13', '15'], | |
['18', '19', '20', '21'], | |
['18', 'A', '20', '21'], | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rawTitle = '<meta name="description" content="hello world">'; | |
$res = preg_match("/<meta name=\"(\w+)\" content=\"(.*?)\">/is",$rawTitle,$booktitle); | |
var_dump($booktitle, $res); | |
$str = 'foobar: 2008'; | |
preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches); | |
var_dump($matches); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header("charset=utf-8;"); | |
function StrToBin($str){ | |
//1.列出每个字符 | |
$arr = preg_split('/(?<!^)(?!$)/u', $str); | |
//2.unpack字符 | |
foreach($arr as &$v){ | |
$temp = unpack('H*', $v); | |
$v = base_convert($temp[1], 16, 2); | |
unset($temp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function int2ip($num) { | |
$tmp = (double)$num; | |
return sprintf('%u.%u.%u.%u', $tmp & 0xFF, (($tmp >> 8) & 0xFF), | |
(($tmp >> 16) & 0xFF), (($tmp >> 24) & 0xFF)); | |
} | |
function ip2int($ip) { | |
$n = ip2long($ip); | |
/** convert to network order */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error: RPC failed; result=22, HTTP code = 411 | |
fatal: The remote end hung up unexpectedly | |
解决方式:git config http.postBuffer 524288000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Have my user agent code: | |
<?php | |
/* USER-AGENTS | |
================================================== */ | |
function check_user_agent ( $type = NULL ) { | |
$user_agent = strtolower ( $_SERVER['HTTP_USER_AGENT'] ); | |
if ( $type == 'bot' ) { | |
// matches popular bots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$autonumberquery = "ALTER TABLE {{survey_{$iSurveyID}}} AUTO_INCREMENT = ".$row['autonumber_start']; | |
$result = @Yii::app()->db->createCommand($autonumberquery)->execute(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$survey = Survey::model()->findByAttributes(array('sid' => $iSurveyID)); | |
$survey->anonymized = Yii::app()->request->getPost('anonymized'); | |
$survey->datestamp = Yii::app()->request->getPost('datestamp'); | |
$survey->ipaddr = Yii::app()->request->getPost('ipaddr'); | |
$survey->refurl = Yii::app()->request->getPost('refurl'); | |
$survey->savetimings = Yii::app()->request->getPost('savetimings'); | |
$survey->save(); | |
Survey::model()->resetCache(); // Make sure the saved values will be picked up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sTableName=Yii::app()->db->tablePrefix.str_replace(array('{','}'),array('',''),$sTableName); | |
return in_array($sTableName,Yii::app()->db->schema->getTableNames()); | |
// 刷新新的数据表(比如在修改表名称之后执行该操作) | |
Yii::app()->db->schema->refresh(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sQuery = "SELECT p.entity_id, p.uid, u.users_name, u.full_name FROM {{permissions}} AS p INNER JOIN {{users}} AS u ON p.uid = u.uid | |
WHERE p.entity_id = :surveyid AND u.uid != :userid and p.entity='survey' | |
GROUP BY p.entity_id, p.uid, u.users_name, u.full_name | |
ORDER BY u.users_name"; | |
$iUserID=Yii::app()->user->getId(); | |
return Yii::app()->db->createCommand($sQuery)->bindParam(":userid", $iUserID, PDO::PARAM_INT)->bindParam("surveyid", $surveyid, PDO::PARAM_INT)->query()->readAll(); //Checked |
NewerOlder