<?PHP
$ch = curl_init();
$site = "https://habr.com/";
$url = "https://www.google.com/search?hl=ru&q=site:$site";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0');
$content = curl_exec($ch);
if(!$content){
echo 'Ошибка curl: ' . curl_error($ch);
die;
}
curl_close($ch);
if(preg_match("/Результатов:\s*(примерно)?\s*([^(]+)/",$content,$matches))
echo "Количество: ".$matches[2];
else
echo "Не найдено";
?>
$(function() {
// TODO
// Google remarketing hack удалить после того как гугл перестанет использовать document.write
document.write = function(html) {
$('body').append(html);
};
wb.product.DomReady.init({
showTones: 'False' == 'True',
selectedCod1S: 10424026,
selectedSize: 0,
rowId: 0,
isPopup: false,
haveSizes:true,
data: {"dataForVisited":10424026,"goodsName":"Ботинки","description":"","brandName":"Lassie","brandId":2034,"nomenclatures":{"10424026":
{"isSoldOut":false,"cod1S":10424026,
"ordersCount":2200
<select name="status">
<?PHP
foreach(["Выберите статус","One","two","three"] as $k=>$v){
$selected = $status == $k && $status == 0?"selected disabled":($status == $k?"selected":"");
echo "<option value=\"$k\" $selected >$v</option>\n";
}
?>
</select>
<select name="status">
<?PHP
foreach(["Выберите статус","One","two","three"] as $k=>$v)
echo "<option value=\"$k\" ".($status == $k && $status == 0?"selected disabled":($status == $k?"selected":""))." >$v</option>\n";
?>
</select>
0 0 1 * * user /usr/bin/curl -s http://site.com/script.php >/dev/null 2>&1
0 0 1 * * /usr/bin/php /var/www/site/script.php >/dev/null 2>&1
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html .phtml
try {
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
$data = $db->query("SELECT * FROM FOO")->fetchAll(PDO::FETCH_ASSOC);
$res = [];
foreach($data as $row) {
array_push($res,[
$row["date"],
$row["colname_1"],
$row["colname_2"],
]);
}
$dbh = null;
var_dump($res);//ваш формат
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
function getFiles($path,$lvl = 0){
$res = [];
$dir2 = scandir($path);
foreach($dir2 as $file2){
if (($file2!='.') && ($file2!='..')){
$fullpath = $path . DIRECTORY_SEPARATOR . $file2;
if(is_dir($fullpath)){
$res = array_merge($res,getFiles($fullpath,$lvl+1));
array_push($res,["path"=>$fullpath,"name"=>$file2,"type"=>"DIR","level"=>$lvl,"size"=>filesize($fullpath)]);
}else if(is_file($fullpath))
array_push($res,[ "path"=>$fullpath,"name"=>$file2,"type"=>"FILE","level"=>$lvl,"size"=>filesize($fullpath)]);
}
}
return $lvl == 0 ? array_reverse($res): $res;
}
function showFiles($arr){
foreach($arr as $v){
$margin = $v["level"] * 15;
if($v["type"] == "DIR")
echo "<span style='display:block;font-weight:bold;margin-left:{$margin}px;'>$v[name]</span>";
if($v["type"] == "FILE")
echo "<a style='margin-left:{$margin}px;display:block;' href='$v[path]'>$v[name] ($v[size] байт)</a>";
}
}
showFiles(getFiles('yourdir'));
function ss(&$arr,$path,$cur = 0){
if(isset($arr[$path[$cur]])){
$arr[$path[$cur]]["active"] = true;
if($cur+1 < count($path))
ss($arr[$path[$cur]]["children"],$path,$cur+1);
}
}
$arr = array (
array (
'name' => '-1 пункт',
'active' => false,
'children'=> array(),
),
array (
'name' => '0 пункт',
'active' => false,
'children'=> array(),
),
array (
'name' => '1 пункт',
'active' => false,
'children'=> array(
array(
'name' => '1.0 пункт',
'active' => false,
'children' => array(),
),
array(
'name' => '1.1 пункт',
'active' => false,
'children' => array(
array(
'name' => '1.1.0 пункт',
'active' => false,
'children' => array(),
),
array(
'name' => '1.1.0 пункт',
'active' => false,
'children' => array(),
)
),
),
array(
'name' => '1.2 пункт',
'active' => false,
'children' => array(),
),
),
),
array (
'name' => '2 пункт',
'active' => false,
'children'=> array(),
),
);
$path = [ 2,1,1 ];
var_dump($arr);//реузльтат до входа
ss($arr,$path);
var_dump($arr);//реузльтат после входа
array(4) {
[0]=>
array(3) {
["name"]=>
string(13) "-1 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[1]=>
array(3) {
["name"]=>
string(12) "0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[2]=>
array(3) {
["name"]=>
string(12) "1 пункт"
["active"]=>
bool(false)
["children"]=>
array(3) {
[0]=>
array(3) {
["name"]=>
string(14) "1.0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[1]=>
array(3) {
["name"]=>
string(14) "1.1 пункт"
["active"]=>
bool(false)
["children"]=>
array(2) {
[0]=>
array(3) {
["name"]=>
string(16) "1.1.0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[1]=>
array(3) {
["name"]=>
string(16) "1.1.0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
}
}
[2]=>
array(3) {
["name"]=>
string(14) "1.2 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
}
}
[3]=>
array(3) {
["name"]=>
string(12) "2 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
}
array(4) {
[0]=>
array(3) {
["name"]=>
string(13) "-1 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[1]=>
array(3) {
["name"]=>
string(12) "0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[2]=>
array(3) {
["name"]=>
string(12) "1 пункт"
["active"]=>
bool(true)
["children"]=>
array(3) {
[0]=>
array(3) {
["name"]=>
string(14) "1.0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[1]=>
array(3) {
["name"]=>
string(14) "1.1 пункт"
["active"]=>
bool(true)
["children"]=>
array(2) {
[0]=>
array(3) {
["name"]=>
string(16) "1.1.0 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
[1]=>
array(3) {
["name"]=>
string(16) "1.1.0 пункт"
["active"]=>
bool(true)
["children"]=>
array(0) {
}
}
}
}
[2]=>
array(3) {
["name"]=>
string(14) "1.2 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
}
}
[3]=>
array(3) {
["name"]=>
string(12) "2 пункт"
["active"]=>
bool(false)
["children"]=>
array(0) {
}
}
}
processArray($value['children'], $key);
$output = array_merge($output,processArray($value['children'], $key));
function find($json,$id){
$arr = json_decode($json);
foreach($arr as $v)
if(strval($v->ID) == strval($id))
return true;
return false;
}