• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP encode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中encode函数的典型用法代码示例。如果您正苦于以下问题:PHP encode函数的具体用法?PHP encode怎么用?PHP encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getAlert

/**
 * Sets and shows an alert
 *
 * @param string  $message
 * @param string  $type = "Error"
 * @param boolean $URL = NULL
 * @return string value
 */
function getAlert($message, $type = "error", $URL = NULL)
{
    if (!is_null($URL)) {
        $message = a(__(_($message)), encode($URL), TRUE);
    }
    if ($type === "error") {
        return '<div id="alert-message" class="alert alert-error">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    } elseif ($type === "success") {
        unset($_POST);
        return '<div id="alert-message" class="alert alert-success">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    } elseif ($type === "warning") {
        return '<div id="alert-message" class="alert alert-warning">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    } elseif ($type === "notice") {
        return '<div id="alert-message" class="alert alert-info">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    }
}
开发者ID:no2key,项目名称:MuuCMS,代码行数:36,代码来源:alerts.php


示例2: actiongetAutocompleteSuggestions

 public function actiongetAutocompleteSuggestions()
 {
     $db = $this->_environment->getDBConnector();
     list($search_word) = explode(' ', $this->_data['search_text']);
     /************************************************************************************
      * Instead of joining with the index table and taking the matching count as reference,
      * we just read from the search_word table
      ************************************************************************************/
     /*
     $query = '
     	SELECT
     		sw_word
     	FROM
     		search_word
     	LEFT JOIN
     		search_index
     	ON
     		search_word.sw_id = search_index.si_sw_id
     	WHERE
     		sw_word LIKE "' . encode(AS_DB, $search_word) . '%"
     	ORDER BY
     		si_count
     	LIMIT
     		0, 20
     	';
     */
     $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tsw_word\n\t\t\t\tFROM\n\t\t\t\t\tsearch_word\n\t\t\t\tWHERE\n\t\t\t\t\tsw_word LIKE '" . encode(AS_DB, $search_word) . "%';\n\t\t\t";
     $result = $db->performQuery($query);
     $words = array();
     foreach ($result as $word) {
         $words[] = $word['sw_word'];
     }
     $this->setSuccessfullDataReturn($words);
     echo $this->_return;
 }
开发者ID:a2call,项目名称:commsy,代码行数:35,代码来源:cs_ajax_search_controller.php


示例3: get_list

 public function get_list()
 {
     if ($this->input->is_ajax_request() && $this->input->get()) {
         $search = $this->input->get('search');
         $limit = $this->input->get('length');
         $offset = $this->input->get('start');
         $columns = $this->input->get('columns');
         $order_arr = $this->input->get('order');
         $order_direction = strtoupper($order_arr[0]['dir']);
         $order_column = $order_arr[0]['column'];
         $order_column = $columns[$order_column]['data'];
         $data = $this->account_model->get_list(trim($search), $order_column, $order_direction, $limit, $offset);
         $json['data'] = array();
         $i = $offset + 1;
         foreach ($data['rows'] as $row) {
             $row->no = $i++;
             $row->account_id = encode($row->account_id);
             $edit_url = base_url("accounting/account/edit/{$row->account_id}");
             $row->action = "<button title='Edit' class='btn btn-xs btn-success edit_btn' onclick='doEdit(\"{$edit_url}\")'><i class='fa fa-pencil'></i></button>\n          <button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$row->account_id}\", \"{$row->account_name}\")'><i class='fa fa-remove'></i></button>";
             array_push($json['data'], $row);
         }
         $json['recordsTotal'] = $data['total'];
         $json['recordsFiltered'] = $data['total'];
         $json['draw'] = $this->input->post('draw');
         echo json_encode($json);
     } else {
         echo 'Forbidden access!';
     }
 }
开发者ID:Gincusoft,项目名称:aksi,代码行数:29,代码来源:Account.php


示例4: index

 public function index($payid)
 {
     if (is_login()) {
         $uid = get_temp_uid();
         if (empty($payid)) {
             $payid = I('payid');
         }
         $db = D('Home/AccountGoods');
         $map['payid'] = $payid;
         $map['uid'] = $uid;
         $list = $db->where($map)->relation(true)->select();
         if (!empty($list)) {
             $this->assign('list', $list);
             $total = $this->total($list);
             $this->assign('total', $total);
         }
         //			echo $db->getLastSql();
         //			echo dump($list);
         $db = M('member');
         $user = $db->field('money,score')->find($uid);
         $score = intval($user['score']);
         $user['_score'] = $score;
         $score = floor($score / 100) * 100;
         $user['score'] = $score;
         $this->assign('account', $user);
         $this->assign('title', '结算支付');
         $this->assign('payid', $payid);
         layout(false);
         $this->display();
     } else {
         $this->redirect('Home/Person/login/' . encode('Pay/index'));
     }
 }
开发者ID:Jitlee,项目名称:YYG,代码行数:33,代码来源:PayController.class.php


示例5: formCheckbox

/**
 * formCheckbox
 * 
 * Sets a specific <input /> type Checkbox tag and its attributes
 * 
 * @param string  $text     = NULL
 * @param string  $position = "Right"
 * @param string  $name
 * @param string  $value
 * @param string  $ID       = NULL
 * @param boolean $checked  = FALSE
 * @param string  $events   = NULL
 * @param boolean $disabled = FALSE
 * @return string value
 */
function formCheckbox($attributes = FALSE)
{
    if (isset($attributes) and is_array($attributes)) {
        $attrs = NULL;
        foreach ($attributes as $attribute => $value) {
            if ($attribute !== "position" and $attribute !== "text" and $attribute !== "type" and $attribute !== "checked") {
                $attrs .= ' ' . strtolower($attribute) . '="' . encode($value) . '"';
            } else {
                ${$attribute} = encode($value);
            }
        }
        if (isset($checked) and $checked) {
            $check = ' checked="checked"';
        } else {
            $check = NULL;
        }
        if (isset($position) and $position === "left" and isset($text)) {
            return $text . ' <input' . $attrs . ' type="checkbox"' . $check . ' />';
        } elseif (isset($position) and $position === "right" and isset($text)) {
            return '<input' . $attrs . ' type="checkbox"' . $check . ' /> ' . $text;
        } elseif (isset($text)) {
            return $text . ' <input' . $attrs . ' type="checkbox"' . $check . ' />';
        } else {
            return '<input' . $attrs . ' type="checkbox"' . $check . ' />';
        }
    } else {
        return NULL;
    }
}
开发者ID:pokaxperia,项目名称:emus-itdp,代码行数:44,代码来源:forms.php


示例6: plugin_counter_get_count

function plugin_counter_get_count($page)
{
    global $vars;
    static $counters = array();
    static $default;
    $qm = get_qm();
    if (!isset($default)) {
        $default = array('total' => 0, 'date' => get_date('Y/m/d'), 'today' => 0, 'yesterday' => 0, 'ip' => '');
    }
    if (!is_page($page)) {
        return $default;
    }
    if (isset($counters[$page])) {
        return $counters[$page];
    }
    // Set default
    $counters[$page] = $default;
    $modify = FALSE;
    $file = COUNTER_DIR . encode($page) . PLUGIN_COUNTER_SUFFIX;
    $fp = fopen($file, file_exists($file) ? 'r+' : 'w+') or die('counter.inc.php: ' . $qm->replace('fmt_err_open_counterdir', basename($file)));
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    rewind($fp);
    foreach ($default as $key => $val) {
        // Update
        $counters[$page][$key] = rtrim(fgets($fp, 256));
        if (feof($fp)) {
            break;
        }
    }
    if ($counters[$page]['date'] != $default['date']) {
        // New day
        $modify = TRUE;
        $is_yesterday = $counters[$page]['date'] == get_date('Y/m/d', time() - 86400);
        $counters[$page]['ip'] = $_SERVER['REMOTE_ADDR'];
        $counters[$page]['date'] = $default['date'];
        $counters[$page]['yesterday'] = $is_yesterday ? $counters[$page]['today'] : 0;
        $counters[$page]['today'] = 1;
        $counters[$page]['total']++;
    } else {
        if ($counters[$page]['ip'] != $_SERVER['REMOTE_ADDR']) {
            // Not the same host
            $modify = TRUE;
            $counters[$page]['ip'] = $_SERVER['REMOTE_ADDR'];
            $counters[$page]['today']++;
            $counters[$page]['total']++;
        }
    }
    // Modify
    if ($modify && $vars['cmd'] == 'read') {
        rewind($fp);
        ftruncate($fp, 0);
        foreach (array_keys($default) as $key) {
            fputs($fp, $counters[$page][$key] . "\n");
        }
    }
    flock($fp, LOCK_UN);
    fclose($fp);
    return $counters[$page];
}
开发者ID:big2men,项目名称:qhm,代码行数:60,代码来源:counter.inc.php


示例7: __construct

 function __construct($schema)
 {
     if (!is_object($schema)) {
         $schema = decode(encode($schema));
     }
     $this->schema = $schema;
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:7,代码来源:schema.php


示例8: get_list

 public function get_list()
 {
     if ($this->input->is_ajax_request() && $this->input->get()) {
         $data_post = $this->input->get();
         $search = $data_post['search'];
         $limit = $data_post['length'];
         $offset = $data_post['start'];
         $columns = $data_post['columns'];
         $order_arr = $data_post['order'];
         $order_direction = strtoupper($order_arr[0]['dir']);
         $order_column = $order_arr[0]['column'];
         $order_column = $columns[$order_column]['data'];
         $data = $this->phonebook_model->get_list($search, $order_column, $order_direction, $limit, $offset);
         $json['data'] = array();
         $i = $offset + 1;
         $this->load->helper('text_helper');
         foreach ($data['rows'] as $row) {
             $phonebook_id = encode($row->phonebook_id);
             $row->no = $i++;
             $edit_url = base_url("messaging/phonebook/edit/{$row->phonebook_id}");
             $row->action = "<button title='Edit' class='btn btn-xs btn-success edit_btn' onclick='doEdit(\"{$edit_url}\")'><i class='fa fa-pencil'></i></button>\n          <button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$row->phonebook_id}\", \"{$row->name}\")'><i class='fa fa-remove'></i></button>";
             array_push($json['data'], $row);
         }
         $json['recordsTotal'] = $data['total'];
         $json['recordsFiltered'] = $data['total'];
         $json['draw'] = $data_post['draw'];
         echo json_encode($json);
     } else {
         echo '{^_^) Gincusoft.';
     }
 }
开发者ID:Gincusoft,项目名称:aksi,代码行数:31,代码来源:Phonebook.php


示例9: formCheckbox

 function formCheckbox($attributes = false)
 {
     if (isset($attributes) and is_array($attributes)) {
         $attrs = null;
         foreach ($attributes as $attribute => $value) {
             if ($attribute !== "position" and $attribute !== "text" and $attribute !== "type" and $attribute !== "checked") {
                 $attrs .= ' ' . strtolower($attribute) . '="' . encode($value) . '"';
             } else {
                 ${$attribute} = encode($value);
             }
         }
         $check = (isset($checked) and $checked) ? ' checked="checked"' : null;
         if (isset($position) and $position === "left" and isset($text)) {
             return '' . decode($text) . ' <input' . $attrs . ' type="checkbox"' . $check . ' /> ';
         } elseif (isset($position) and $position === "right" and isset($text)) {
             return '<input' . $attrs . ' type="checkbox"' . $check . ' /> ' . decode($text) . ' ';
         } elseif (isset($text)) {
             return '' . decode($text) . ' <input' . $attrs . ' type="checkbox"' . $check . ' /> ';
         } else {
             return '<input' . $attrs . ' type="checkbox"' . $check . ' /> ';
         }
     } else {
         return null;
     }
 }
开发者ID:jgianpiere,项目名称:ZanPHP,代码行数:25,代码来源:forms.php


示例10: get_list

 public function get_list()
 {
     if ($this->input->is_ajax_request() && $this->input->get()) {
         $data_post = $this->input->get();
         $search = $data_post['search'];
         $limit = $data_post['length'];
         $offset = $data_post['start'];
         $columns = $data_post['columns'];
         $order_arr = $data_post['order'];
         $order_direction = strtoupper($order_arr[0]['dir']);
         $order_column = $order_arr[0]['column'];
         $order_column = $columns[$order_column]['data'];
         $data = $this->inbox_model->get_list($search, $order_column, $order_direction, $limit, $offset);
         $json['data'] = array();
         $i = $offset + 1;
         $this->load->helper('text_helper');
         foreach ($data['rows'] as $row) {
             $inbox_id = encode($row->sms_sender);
             $row->no = $i++;
             $url_edit = base_url("messaging/inbox/detail/{$inbox_id}");
             $row->sms_sender = "<a class='text-black' onclick='doDetail(\"{$url_edit}\", this); return false;' href=''>{$row->sms_sender}</a>";
             $row->sms_text_short = word_limiter($row->sms_text, 5);
             $row->sms_text = "<a class='text-black' onclick='doDetail(\"{$url_edit}\", this); return false;'  href=''>" . word_limiter($row->sms_text, 15) . "</a>";
             $row->sms_date = timestamp_to_human($row->sms_date);
             $row->action = "<button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$inbox_id}\")'><i class='fa fa-remove'></i></button>";
             array_push($json['data'], $row);
         }
         $json['recordsTotal'] = $data['total'];
         $json['recordsFiltered'] = $data['total'];
         $json['draw'] = $data_post['draw'];
         echo json_encode($json);
     } else {
         echo '{^_^) Gincusoft.';
     }
 }
开发者ID:Gincusoft,项目名称:aksi,代码行数:35,代码来源:Inbox.php


示例11: get_list

 public function get_list()
 {
     if ($this->input->is_ajax_request() && $this->input->post()) {
         $data_post = $this->input->post();
         //      $search = $data_post['search'];
         $limit = $data_post['length'];
         $offset = $data_post['start'];
         $columns = $data_post['columns'];
         $order_arr = $data_post['order'];
         $order_direction = strtoupper($order_arr[0]['dir']);
         $order_column = $order_arr[0]['column'];
         $order_column = $columns[$order_column]['data'];
         $data = $this->journals_model->get_list($data_post, $order_column, $order_direction, $limit, $offset);
         $json['data'] = array();
         $i = $offset + 1;
         foreach ($data['rows'] as $row) {
             $journals_id = encode($row->journals_id);
             $row->no = $i++;
             $row->journals_date = sql_to_human($row->journals_date);
             $row->debit_txt = format_idr_currency($row->debit);
             $row->credit_txt = format_idr_currency($row->credit);
             $edit_url = base_url("accounting/journals/edit/{$journals_id}");
             $row->action = "<button onclick='doEdit(\"{$edit_url}\")' title='Edit' class='btn btn-xs btn-success edit_btn')'><i class='fa fa-pencil'></i></button>\n          <button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$journals_id}\", \"{$row->account_name}\")'><i class='fa fa-remove'></i></button>";
             //        $row->invoice = anchor("journals/view/{$journals_id}", $row->invoice, 'title="Klik untuk lebih lengkap" target="_blank"');
             array_push($json['data'], $row);
         }
         $json['recordsTotal'] = $data['total'];
         $json['recordsFiltered'] = $data['total'];
         $json['draw'] = $data_post['draw'];
         echo json_encode($json);
     } else {
         echo 'Forbidden access!';
     }
 }
开发者ID:Gincusoft,项目名称:aksi,代码行数:34,代码来源:Journals.php


示例12: indexAction

 function indexAction()
 {
     if (POST) {
         set_time_limit(999999);
         $emails = $users = array();
         $emailRaw = $this->user->ImportContacts($_POST['of'], $_POST["n"], $_POST["p"]);
         foreach ($emailRaw["out"] as $k => $v) {
             if ($this->user->CheckEmail($v[0])) {
                 $usr = $this->user->GetDetailsByEmail($v[0]);
                 $usrNam = strlen($usr["fname"] . $usr["lname"]) < 10 ? $usr["fname"] . " " . $usr["lname"] : (strlen($usr["fname"]) < 10 ? $usr["fname"] : substr($usr["fname"], 0, 10) . '..');
                 $users[] = array(encode($usr["id"]), $usr["image"], $usrNam, ($usr["gender"] == "M" ? "Male" : "Female") . ", " . timeDiff(strtotime($usr["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => '')));
             } else {
                 $eM = array("n" => $k, "i" => encode($v[1]));
                 if (strpos($v[0], "@")) {
                     $eM = array_merge($eM, array("e" => $v[0]));
                 }
                 if ($v[2] > 0) {
                     $eM = array_merge($eM, array("m" => $v[2]));
                 }
                 $emails[] = $eM;
             }
         }
         die(json_encode(array("emails" => $emails, "users" => $users, "m" => count($emails) > 0 ? "You got " . count($emails) . " contacts from your " . $_POST["of"] . " id." : "<strong>No contacts found.</strong><br />May be your login are invalid.", "mT" => count($emails) > 0 ? "yeppe" : "")));
     }
     $this->view->outContacts = $this->user->outContacts();
     $this->view->inContacts = $this->user->inContacts();
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:27,代码来源:InviteController.php


示例13: guestBookPost

function guestBookPost($intSpamFiler, $intIsSecret)
{
    global $DMC, $DBPrefix, $arrSideModule;
    $parent = 0;
    $_POST['isSecret'] = !empty($_POST['isSecret']) ? $_POST['isSecret'] : 0;
    $author = !empty($_POST['username']) ? $_POST['username'] : $_SESSION['username'];
    $replypassword = !empty($_POST['replypassword']) ? md5($_POST['replypassword']) : "";
    if (!empty($_POST['homepage'])) {
        if (strpos(";" . $_POST['homepage'], "http://") < 1) {
            $homepage = "http://" . $_POST['homepage'];
        } else {
            $homepage = $_POST['homepage'];
        }
    } else {
        $homepage = "";
    }
    $email = !empty($_POST['email']) ? $_POST['email'] : "";
    $_POST['bookface'] = !empty($_POST['bookface']) ? $_POST['bookface'] : "face1";
    $sql = "insert into " . $DBPrefix . "guestbook(author,password,homepage,email,ip,content,postTime,isSecret,parent,face,isSpam) values('{$author}','{$replypassword}','" . encode($homepage) . "','" . encode($email) . "','" . getip() . "','" . encode($_POST['message']) . "','" . time() . "','" . max(intval($intIsSecret), intval($_POST['isSecret'])) . "','{$parent}','" . substr(encode($_POST['bookface']), 4) . "','" . $intSpamFiler . "')";
    //echo $sql;
    $DMC->query($sql);
    //更新cache
    settings_recount("guestbook");
    settings_recache();
    recentGbooks_recache();
    logs_sidebar_recache($arrSideModule);
    //保存时间
    $_SESSION['replytime'] = time();
}
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:29,代码来源:guestbook.lib.php


示例14: indexAction

 function indexAction()
 {
     if ($this->getRequest()->getParam('ref')) {
         $user = new UsersModel();
         $this->view->InvitedUser = $user->InvitedContact(decode($this->getRequest()->getParam('ref')));
         if ($this->session->user["id"] > 0) {
             $this->_redirect("bio/" . encode($this->view->InvitedUser["uid"]) . "#slams/post");
         }
         $user = new UsersModel($this->view->InvitedUser["uid"]);
         $this->view->InviteeUser = $user->Info();
     }
     if ($this->getRequest()->getParam('userid')) {
         if ($this->session->user["id"] > 0) {
             $this->_redirect("bio/" . $this->getRequest()->getParam('userid'));
         }
         $user = new UsersModel(decode($this->getRequest()->getParam("userid")));
         $iV = $this->view->InviteeUser = $user->Info();
         $this->view->error = array("<strong>Login</strong> to view " . ($iV['gender'] == 'M' ? 'his' : 'her') . " <strong>tweets</strong>, <strong>slambook</strong> and other <strong>exciting</strong> stuffs.<br />New users can <strong>signup</strong> with a <strong>single step &raquo;</strong>", 60, "welcome");
     }
     if ($this->session->user["id"] > 0) {
         $this->_redirect("my");
     }
     $user = new UsersModel();
     $this->view->users = $user->Search(array(), array(0, 12), NULL, array("gender DESC"));
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:25,代码来源:IndexController.php


示例15: upload

function upload()
{
    $uemail = $_POST['uemail'];
    $sql = "SELECT uid FROM customers_auth WHERE email ='{$uemail}'";
    global $conn;
    $result = mysqli_query($conn, $sql);
    while ($row = $result->fetch_assoc()) {
        $userFolder = $row["uid"];
    }
    $target_dir = "uploads/{$userFolder}/";
    $exist = is_dir($target_dir);
    if (!$exist) {
        mkdir("{$target_dir}");
        chmod("{$target_dir}", 0755);
    } else {
    }
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
    // Check if image file is a actual image or fake image
    if (isset($_POST["submit"])) {
        $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
        if ($check !== false) {
            echo "File is an image - " . $check["mime"] . ".";
            $uploadOk = 1;
        } else {
            echo "File is not an image.";
            $uploadOk = 0;
        }
    }
    // Check if file already exists
    if (file_exists($target_file)) {
        echo $userFolder;
        echo "Sorry, file already exists.";
        echo $userFolder;
        $uploadOk = 0;
    }
    // Check file size
    if ($_FILES["fileToUpload"]["size"] > 50000000) {
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }
    // Allow certain file formats
    if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "mp3" && $imageFileType != "mp4" && $imageFileType != "doc" && $imageFileType != "pptx") {
        echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
        $uploadOk = 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
        // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
            encode($target_file);
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
}
开发者ID:briannci,项目名称:NPDS-Project,代码行数:59,代码来源:imageScript.php


示例16: baozhengjin

 public function baozhengjin($gid)
 {
     if (is_login()) {
         parent::baozhengjin($gid);
     } else {
         $this->redirect('P/Main/login/' . encode('Pay/baozhengjin/' . $gid, '', ''));
     }
 }
开发者ID:Jitlee,项目名称:YYG,代码行数:8,代码来源:PayController.class.php


示例17: printjs2

function printjs2($array)
{
    $arr = array();
    foreach ($array as $a) {
        $arr[] = encode($a);
    }
    echo json_encode($arr);
}
开发者ID:NO-TeamAwesomeSauce,项目名称:YoungCode-Website,代码行数:8,代码来源:appApi.php


示例18: multiRequest

/**
 * 批量请求
 * @param array $request_buffer_array ['ip:port'=>req_buf, 'ip:port'=>req_buf, ...]
 * @return multitype:unknown string
 */
function multiRequest($request_buffer_array)
{
    \Statistics\Lib\Cache::$lastSuccessIpArray = array();
    $client_array = $sock_to_ip = $ip_list = array();
    foreach ($request_buffer_array as $address => $buffer) {
        list($ip, $port) = explode(':', $address);
        $ip_list[$ip] = $ip;
        $client = stream_socket_client("tcp://{$address}", $errno, $errmsg, 1);
        if (!$client) {
            continue;
        }
        $client_array[$address] = $client;
        stream_set_timeout($client_array[$address], 0, 100000);
        fwrite($client_array[$address], encode($buffer));
        stream_set_blocking($client_array[$address], 0);
        $sock_to_address[(int) $client] = $address;
    }
    $read = $client_array;
    $write = $except = $read_buffer = array();
    $time_start = microtime(true);
    $timeout = 0.99;
    // 轮询处理数据
    while (count($read) > 0) {
        if (@stream_select($read, $write, $except, 0, 200000)) {
            foreach ($read as $socket) {
                $address = $sock_to_address[(int) $socket];
                $buf = fread($socket, 8192);
                if (!$buf) {
                    if (feof($socket)) {
                        unset($client_array[$address]);
                    }
                    continue;
                }
                if (!isset($read_buffer[$address])) {
                    $read_buffer[$address] = $buf;
                } else {
                    $read_buffer[$address] .= $buf;
                }
                // 数据接收完毕
                if (($len = strlen($read_buffer[$address])) && $read_buffer[$address][$len - 1] === "\n") {
                    unset($client_array[$address]);
                }
            }
        }
        // 超时了
        if (microtime(true) - $time_start > $timeout) {
            break;
        }
        $read = $client_array;
    }
    foreach ($read_buffer as $address => $buf) {
        list($ip, $port) = explode(':', $address);
        \Statistics\Lib\Cache::$lastSuccessIpArray[$ip] = $ip;
    }
    \Statistics\Lib\Cache::$lastFailedIpArray = array_diff($ip_list, \Statistics\Lib\Cache::$lastSuccessIpArray);
    ksort($read_buffer);
    return $read_buffer;
}
开发者ID:jwcn,项目名称:statistics,代码行数:63,代码来源:functions.php


示例19: forName

 /**
  * Generates a name of the product depending on the name and version of the product name.
  * @param str $productName product name
  * @param str $variantName variant name
  * @return str name for xml
  */
 private function forName($productName, $variantName)
 {
     if (encode($productName) == encode($variantName)) {
         $name = encode($productName);
     } else {
         $name = encode($productName . ' ' . $variantName);
     }
     return $name;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:15,代码来源:ymarket.php


示例20: set_page

 function set_page($page = '')
 {
     if ($page) {
         $this->page = $page;
         $this->tmpfile = CACHE_DIR . encode($page) . '.tmp';
         $this->tmprfile = CACHE_DIR . encode($this->page) . '.tmpr';
         $this->set_page = true;
     }
 }
开发者ID:big2men,项目名称:qhm,代码行数:9,代码来源:qhm_template.php



注:本文中的encode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP encodeHTML函数代码示例发布时间:2022-05-15
下一篇:
PHP enchant_dict_suggest函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap