12 июня 2020
Нет комментариев
$date_from=strtotime(date('Y-m-d').' 00:00:00');
$date_from=strtotime(date('Y-m-d').' 00:00:00');
Как, например, xml:
if($dir=opendir(ROOT_DIR.IMPORT_DIR)){ while(false!==($file=readdir($dir))){ if(is_file(ROOT_DIR.IMPORT_DIR.$file)){ $offers=@simplexml_load_file(ROOT_DIR.IMPORT_DIR.$file); if($offers){ print_pre($offers); } } } }
Или csv:
if($dir=opendir(ROOT_DIR.IMPORT_DIR)){ while(false!==($file=readdir($dir))){ if(is_file(ROOT_DIR.IMPORT_DIR.$file)){ if(($handle=fopen(ROOT_DIR.IMPORT_DIR.$file,"r"))!==false){ while(($item=fgetcsv($handle,10000,";"))!==false){ print_pre($item); } } } } }
$curl=curl_init(); curl_setopt($curl,CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_HEADER,0); curl_setopt($curl,CURLOPT_POST,1); curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); curl_setopt($curl,CURLOPT_POSTFIELDS,$data); curl_setopt($curl,CURLOPT_PROXY,$proxy_ip); curl_setopt($curl,CURLOPT_PROXYPORT,$proxy_port); curl_setopt($curl,CURLOPT_PROXYAUTH,CURLAUTH_DIGEST); curl_setopt($curl,CURLOPT_PROXYUSERPWD,$proxy_user.':'.$proxy_password); $result=curl_exec($curl);
header("Content-Type: application/javascript");
.htacess:
Header set Access-Control-Allow-Origin *
или php:
header('Access-Control-Allow-Origin: *');
ini_set('session.gc_maxlifetime',120960); ini_set('session.cookie_lifetime',120960); ini_set('session.save_path',$_SERVER['DOCUMENT_ROOT'].'../sessions/');
https://habr.com/ru/post/28418/
Javascript:
$(document).ready(function(){ var select_brand=$('select[name=brand]'); var select_collection=$('select[name=collection]'); select_brand.on('change',function(){ $.ajax({ url:"/?ajax_action=get_collections&brand="+select_brand.val(), dataType:"json", success:function(data){ select_collection.find('option').not(':first').remove(); $.each(data,function(index,item){ select_collection.append('<option value="'+item.id+'">'+item.name+'</option>'); }); select_collection.trigger("chosen:updated"); } }); }); });
HTML:
<select name="brand" class="chosen"> <option value="0">Выбрать</option> <?if(count($brands)>0){?> <?foreach($brands as $item){?> <option value="<?=$item['id']?>"<?if($item['id']==$change_catalog["brand"]){?> selected="selected"<?}?>><?=$item['name']?></option> <?}?> <?}?> </select> <select name="collection" class="chosen"> <option value="0">Выбрать</option> <?if(count($collections)>0){?> <?foreach($collections as $item){?> <option value="<?=$item['id']?>"<?if($item['id']==$change_catalog["collection"]){?> selected="selected"<?}?>><?=$item['name']?></option> <?}?> <?}?> </select>
PHP:
if($_GET['ajax_action']=='get_collections'&&$_GET['brand']>0){ header("Content-Type: application/json"); $result=get_from_base('`id`,`name`','collections',"`parent`='".$_GET['brand']."'",'pos'); echo json_encode($result); exit(); } $brands=get_from_base('`id`,`name`','brands',"1",'`parent`,`pos`'); if($_GET["change_id"]){ $change_catalog=get_by_id($_GET["change_id"],'catalog'); if($change_catalog['brand']){ $collections=get_from_base('`id`,`name`','collections',"`parent`='".$change_catalog['brand']."'",'pos'); } }