本文整理汇总了PHP中encode函数的典型用法代码示例。如果您正苦于以下问题:PHP encode函数的具体用法?PHP encode怎么用?PHP encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>';
}
}
示例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;
}
示例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!';
}
}
示例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'));
}
}
示例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;
}
}
示例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];
}
示例7: __construct
function __construct($schema)
{
if (!is_object($schema)) {
$schema = decode(encode($schema));
}
$this->schema = $schema;
}
示例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.';
}
}
示例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;
}
}
示例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.';
}
}
示例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!';
}
}
示例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();
}
示例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();
}
示例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 »</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"));
}
示例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.";
}
}
}