分类 工作心德 下的文章

nginx配置多域名指向

第一步:打开nginx.conf 将vhost/*.conf打开
第二步:在vhost下创建aa.conf,这里的aa.conf可以自己起名称
第三部:编辑aa.conf

server
{
    listen       80;
    server_name t1.060dy.com;//域名
    index index.html index.htm index.php;
    root  /home/wwwroot/t1.060dy.com;//项目地址

    include enable-php.conf;

    if ( $host != 't1.060dy.com' )//这里配置可自己编辑
    {
      rewrite ^/(.*)$http://t1.060dy.com/$1 permanent;
    }

    rewrite ^/([_0-9a-zA-Z-]+)$ /index.php?surl=$1 last;

    location /nginx_status
    {
        stub_status on;
        access_log   off;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
    {
      expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }

    access_log  off;
    error_log  off;
}

curl采集数据请求

function ff_file_get_contents($url, $post_data=[], $timeout=5, $referer=''){
if(function_exists('curl_init')){
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_HEADER, 0);
    curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt ($ch, CURLOPT_REFERER, $referer);
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    //post
    if($post_data){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    }
    //https
    $http = parse_url($url);
    // var_dump($http);die;
    if($http['scheme'] == 'https'){
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    }
    $content = curl_exec($ch);
    curl_close($ch);
    // var_dump($content);die;
    if($content){
        return $content;
    }
}
$ctx = stream_context_create(array('http'=>array('timeout'=>$timeout)));
$content = @file_get_contents($url, 0, $ctx);
if($content){
    return $content;
}
return false;}

实现简单的翻页效果(mysql如何查询翻页)

$page = 1;//页数
$limit = 10;//条数
$start_limit = ($page-1)*$limit;//得出的开始条数
$this->limit($start_limit, $limit)->select();//查询

根据字段数字大小排序(这里用到php中array_multisort函数)

$arr =  $tickets_info;(这里的arr打印出来是2维数组)
$flag = array(); 
foreach ($arr as $v) {
    $flag[] = $v['start_time'];
}
array_multisort($flag, SORT_ASC, $arr);

foreach ($arr as $k=>$v) {
    $v['start_time'] = substr($v['start_time'],5,11);
    $arr[$k]['start_time'] = $v['start_time'];
}
备案号:粤ICP备18155514号-2