function excute($url = '', $data)
{
    connectRedis();
    $response = array();
    $loop = count($data);
    for ($i = 0; $i < $loop; $i++) {
        # code...
        $pid = pcntl_fork();
        if (!$pid) {
            // sleep(1);
            print "In child {$i}\n";
            if (array_key_exists($i, $data)) {
                $x = 7;
                $k = get_url($data[$i]);
                setRedis("data", $i);
            }
            exit($i);
        }
    }
    #process
    while (pcntl_waitpid(0, $status) != -1) {
        $status = pcntl_wexitstatus($status);
        echo "Child {$status} completed\n";
    }
    // dd($response);
    return $response;
}
Esempio n. 2
0
 public function reg()
 {
     $state = $this->in_get('state', None, 2, 'True');
     $wx_data = base64_decode($state);
     $code = $this->in_get('code', None, 2, 'True');
     $wx_data_arr = explode('@@', $wx_data);
     $schId = intval($wx_data_arr[0]);
     $room = in($wx_data_arr[1]);
     $phone = in($wx_data_arr[2]);
     $msg = Check::rule(array(check::mobile($phone), '手机电话号码格式不对'));
     if ($msg != 1) {
         $this->alert('您的手机号码不正确');
     }
     $r = connectRedis($this->config['RD_HOST'], $this->config['RD_PORT'], $this->config['RD_PWD']);
     $apiUser = new api_userMod();
     $wx_res = $apiUser->get_info_user_weixin($code, $r);
     if (!$wx_res) {
         $this->alert('请用微信登陆');
     }
     $check_con['openid'] = $wx_res['openid'];
     $field = 'p_id';
     $check_res = $this->model->table($this->config['info_person'])->field($field)->where($check_con)->find();
     if ($check_res) {
         // 如果此微信号已经存在,直接登陆
         $apiUser->set_login_mark($check_res['p_id'], $code, $r);
         disconnect($r);
         $this->redirect(__ROOT__ . '/order/water');
     } else {
         // 否则插入数据
         $data['s_id'] = $schId;
         $res = $this->model->table($this->config['school'])->where($data)->find();
         if ($res) {
             $data['name'] = $wx_res['nickname'];
             $data['addr'] = $room;
             $data['phone'] = $phone;
             $data['openid'] = $wx_res['openid'];
             $data['pic'] = $wx_res['headimgurl'];
             $data['s_name'] = $res['name'];
             $data['sex'] = $wx_res['sex'];
             $data['city'] = $wx_res['city'];
             $data['province'] = $wx_res['province'];
             $data['point'] = 100;
             $res = $this->model->table($this->config['info_person'])->data($data)->insert();
             if ($res) {
                 $apiUser->set_login_mark($res, $code, $r);
                 disconnect($r);
                 setcookie('susCode', time(), time() + EX_TIME_COOKIE, __ROOT__);
                 $this->redirect(__URL__ . '/suss');
             } else {
                 disconnect($r);
                 $this->alert('对不起,网络暂时出了点小问题');
             }
         } else {
             disconnect($r);
             $this->alert('对不起,贵校暂时没有开通此服务');
         }
     }
 }
Esempio n. 3
0
 /**
  * 进行登陆标记,设置 cookie,存入 redis,表示此用户已经登陆
  * @param p_id  表示此用户在本系统的 id 编号
  * @param code  表示此用户本次登陆的 code,由微信提供
  * @param r  表示 redis ,若有值,表示此资源已存在,直接使用即可
  */
 public function set_login_mark($p_id, $code, $r = '')
 {
     $key = md5($p_id . $code);
     $redis_json = json_encode(array('key' => $key, 'code' => $code));
     // 将用户的 p_id 、key  存进redis 中,并设置生命期
     if (empty($r)) {
         $r = connectRedis($this->config['RD_HOST'], $this->config['RD_PORT'], $this->config['RD_PWD']);
         $r->set($p_id, $redis_json, EX_TIME_COOKIE);
         disconnect($r);
     } else {
         $r->set($p_id, $redis_json, EX_TIME_COOKIE);
     }
     setcookie('key', $key, time() + EX_TIME_COOKIE, __ROOT__);
     setcookie('pId', $p_id, time() + EX_TIME_COOKIE, __ROOT__);
 }
Esempio n. 4
0
 /**
  * 当用户第一次关注公众号的时候,进行数据库插入操作
  * @param referer  0 为搜索关注,1 为二维码关注
  * @param type  二维码类型,1 为临时二维码,2为永久
  */
 public function weixin_subscribe($openid, $referer = 0, $sell_id = 0)
 {
     $sqlUser = new sql_userMod();
     $res = $sqlUser->get_user_openid($openid);
     if ($res) {
         $sqlUser->set_user_subscribe($res['p_id'], $res['sub_time'] + 1);
     } else {
         $r = connectRedis($this->config['RD_HOST'], $this->config['RD_PORT'], $this->config['RD_DB']);
         $token = $r->get('token');
         $wx_res = Weixin::get_user_info($token, $openid);
         if ($wx_res) {
             $res = $sqlUser->add_user_subscribe($wx_res, $referer, str_replace('sell_id', '', $sell_id));
             dump($res);
         }
     }
 }
Esempio n. 5
0
<?php

session_start();
require 'common/function.php';
require 'common/MyRedis.php';
global $system_config;
$return = ['status' => 0, 'info' => ''];
$con = arrayItem($_SESSION, 'connect');
$redis = connectRedis($con);
$instruction = arrayItem($_POST, 'instruction');
$return['post_info'] = $instruction;
foreach ($system_config['instruction_syntx'][$instruction] as $key => $value) {
    $data[$key] = trim(arrayItem($_POST, $value['name']));
    $return['post_info'] .= ' | ' . $value['name'] . ' : ' . $data[$key];
    if ($data[$key] === FALSE) {
        $return['info'] = $value['name'] . '不存在~';
        exit(json_encode($return));
    }
    if ($data[$key] == '' && $value['require']) {
        $return['info'] = $value['name'] . '不能为空~';
        exit(json_encode($return));
    }
    #	判断是否需要把该值转为数组形式
    if (!isset($value['value_type'])) {
        continue;
    }
    switch ($value['value_type']) {
        case 1:
            $data[$key] = explode('|', $data[$key]);
            break;
        case 2:
Esempio n. 6
0
             <?php 
 $j = 0;
 foreach ($config as $key => $value) {
     $j++;
     $result = '';
     # Check
     $start_time = slog_time();
     switch ($value['type']) {
         case 'database':
             $result = connectMysql($value['config']);
             break;
         case 'api_curl_get':
             $result = curlTruemoveHStandardGet($value['config']);
             break;
         case 'redis':
             $result = connectRedis($value['config']);
             break;
         case 'test_wsdl':
             $result = getWsdl($value['config']);
             break;
     }
     $time = elog_time($start_time);
     if ($result != 'success') {
         $error[] = $result;
     }
     $class = "hl-row1";
     if ($j % 2 == 0) {
         $class = "hl-row2";
     }
     ?>
                 <tr class="<?php