本文整理汇总了PHP中func::setCOOKIE方法的典型用法代码示例。如果您正苦于以下问题:PHP func::setCOOKIE方法的具体用法?PHP func::setCOOKIE怎么用?PHP func::setCOOKIE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类func
的用法示例。
在下文中一共展示了func::setCOOKIE方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detectLang
public function detectLang()
{
$lng = !empty($_GET[LANG_VAR]) ? $_GET[LANG_VAR] : (!empty($_POST[LANG_VAR]) ? $_POST[LANG_VAR] : false);
if ($lng) {
//инициировали смену языка
func::setCOOKIE(LANG_VAR, $lng);
} else {
$lng = isset($_COOKIE[LANG_VAR]) ? $_COOKIE[LANG_VAR] : false;
}
if (!$lng) {
$lng = $this->defaultLanguage;
func::setCOOKIE(LANG_VAR, $lng);
}
$this->currentLanguage = $lng;
$this->detected = true;
return $lng;
}
示例2: fav
function fav()
{
$fav = $this->getFavorites();
if (bff::$isAjax) {
$aResponse = array();
$nUserID = $this->security->getUserID();
switch (func::GET('act')) {
case 'fav':
$nItemID = $this->input->id('id', 'p');
if (!$nItemID || !$nUserID) {
$this->errors->set(Errors::IMPOSSIBLE);
break;
}
$exists = $this->db->one_data('SELECT item_id FROM ' . TABLE_BBS_ITEMS_FAV . ' WHERE item_id = ' . $nItemID . ' AND user_id = ' . $nUserID);
if (!empty($exists)) {
$this->db->execute('DELETE FROM ' . TABLE_BBS_ITEMS_FAV . ' WHERE item_id = ' . $nItemID . ' AND user_id = ' . $nUserID);
$aResponse['added'] = false;
} else {
$this->db->execute('INSERT INTO ' . TABLE_BBS_ITEMS_FAV . ' (item_id, user_id)
VALUES(' . $nItemID . ',' . $nUserID . ')');
$aResponse['added'] = true;
}
break;
case 'email_bulk':
if (!$nUserID) {
$this->errors->set(Errors::IMPOSSIBLE);
break;
}
$aData = $this->input->postm(array('items' => TYPE_ARRAY_UINT));
if (empty($aData['items'])) {
$this->errors->set('Необходимо отметить объявления в списке');
break;
}
$aData['items'] = $this->db->select('SELECT
I.id, I.status, I.publicated,
I.cat1_id, CAT1.title as cat1_title,
I.cat2_id, CAT2.title as cat2_title,
I.cat_id, C.regions as cat_regions, C.prices as cat_prices, C.prices_sett as cat_prices_sett,
I.cat_type, CT.title as cat_type_title,
I.cat_subtype, CST.title as cat_subtype_title,
I.imgfav, I.imgcnt, I.price, I.descr, I.descr_regions, I.price, I.price_torg, I.price_bart,
I.contacts_name, I.contacts_email, I.contacts_phone, I.contacts_skype, I.contacts_site
FROM ' . TABLE_BBS_ITEMS . ' I
LEFT JOIN ' . TABLE_BBS_CATEGORIES . ' CAT2 ON I.cat2_id = CAT2.id
LEFT JOIN ' . TABLE_BBS_CATEGORIES_TYPES . ' CT ON I.cat_type = CT.id
LEFT JOIN ' . TABLE_BBS_CATEGORIES_SUBTYPES . ' CST ON I.cat_subtype = CST.id
LEFT JOIN ' . TABLE_USERS . ' U ON I.user_id = U.user_id,
' . TABLE_BBS_CATEGORIES . ' CAT1,
' . TABLE_BBS_CATEGORIES . ' C
WHERE ' . $this->db->prepareIN('I.id', $aData['items']) . '
AND CAT1.id = I.cat1_id
AND C.id = I.cat_id
AND (I.user_id = 0 OR U.blocked!=1)
ORDER BY I.publicated ASC');
if (!empty($aData['items'])) {
$res = bff::sendMail($this->security->getUserEmail(), BFF_EMAIL_FROM_NAME, $this->tplFetchPHP($aData, 'items.list.fav2email.php'));
//$this->errors->set( ($res ? Errors::SUCCESS : Errors::IMPOSSIBLE) );
}
break;
case 'unfav_bulk':
$aItemsID = $this->input->post('items', TYPE_ARRAY_UINT);
$nResultTotal = 0;
if (empty($aItemsID)) {
$this->errors->set(Errors::IMPOSSIBLE);
break;
}
if ($fav['total'] == 0) {
$this->errors->set(Errors::IMPOSSIBLE);
break;
}
if ($nUserID) {
$res = $this->db->execute('DELETE FROM ' . TABLE_BBS_ITEMS_FAV . ' WHERE user_id = ' . $nUserID . ' AND ' . $this->db->prepareIN('item_id', $aItemsID));
$nResultTotal = $fav['total'] - intval($res);
} else {
$aRemoveID = array_intersect($fav['id'], $aItemsID);
$aResultID = array_diff($fav['id'], $aRemoveID);
func::setCOOKIE(BFF_COOKIE_PREFIX . 'bbs_fav', !empty($aResultID) ? join(',', $aResultID) : '', BBS_FAV_COOKIE_EXPIRE, '/', '.' . SITEHOST);
$nResultTotal = !empty($aResultID) ? sizeof($aResultID) : 0;
}
$aResponse['total'] = $nResultTotal;
break;
default:
$this->errors->set(Errors::IMPOSSIBLE);
}
$aResponse['res'] = $this->errors->no();
$this->ajaxResponse($aResponse);
}
$aData = array('items' => array());
if ($fav['total'] > 0) {
$sqlItemsIN = $this->db->prepareIN('I.id', $fav['id']);
$aData['items'] = $this->db->select('SELECT
I.id, I.status, I.svc,
I.cat1_id, CAT1.title as cat1_title,
I.cat2_id, CAT2.title as cat2_title,
I.cat_id, C.regions as cat_regions, C.prices as cat_prices, C.prices_sett as cat_prices_sett,
I.cat_type, CT.title as cat_type_title,
I.cat_subtype, CST.title as cat_subtype_title,
I.imgfav, I.imgcnt, I.price, I.descr, I.descr_regions, I.price, I.price_torg, I.price_bart,
I.views_total, IV.views,
U.blocked as user_blocked
//.........这里部分代码省略.........
示例3: clearRememberMe
function clearRememberMe($cookiePrefix = '')
{
func::setCOOKIE($cookiePrefix . 'rmlgn', FALSE, -1);
func::setCOOKIE($cookiePrefix . 'rmpwd', FALSE, -1);
}
示例4: getFavorites
function getFavorites($bResaveFromCookie = false)
{
static $cache;
if (isset($cache)) {
return $cache;
}
$cookieKey = BFF_COOKIE_PREFIX . 'bbs_fav';
if ($userID = $this->security->getUserID()) {
$res = $this->db->select_one_column('SELECT item_id FROM ' . TABLE_BBS_ITEMS_FAV . ' WHERE user_id = ' . $userID . ' GROUP BY item_id');
if (empty($res)) {
$res = array();
}
if ($bResaveFromCookie) {
$resCookie = func::getCOOKIE($cookieKey);
if (!empty($resCookie)) {
$resCookie = explode(',', $resCookie);
if (!empty($resCookie)) {
$this->input->clean($resCookie, TYPE_ARRAY_UINT);
}
if (!empty($resCookie)) {
$sqlInsert = array();
foreach ($resCookie as $id) {
if (!in_array($id, $res)) {
$sqlInsert[] = "({$id}, {$userID})";
$res[] = $id;
}
}
if (!empty($sqlInsert)) {
$this->db->execute('INSERT INTO ' . TABLE_BBS_ITEMS_FAV . ' (item_id, user_id)
VALUES ' . join(',', $sqlInsert));
}
}
func::setCOOKIE($cookieKey, '', BBS_FAV_COOKIE_EXPIRE, '/', '.' . SITEHOST);
}
}
} else {
$res = func::getCOOKIE($cookieKey);
if (empty($res)) {
$res = 0;
} else {
$res = explode(',', $res);
if (empty($res)) {
$res = 0;
} else {
$this->input->clean($res, TYPE_ARRAY_UINT);
}
}
}
$cache = $res = !empty($res) ? array('id' => $res, 'total' => count($res)) : array('id' => array(), 'total' => 0);
config::set('bbs_favs', $res);
return $res;
}
示例5: preparePerpage
function preparePerpage(&$nPerpage, $aValues = array(5, 10, 15), $sParamName = 'perpage', $nExpireDays = 7)
{
$nPerpage = $this->input->getpost($sParamName, TYPE_UINT);
$sCookieKey = BFF_COOKIE_PREFIX . $this->module_name . '_' . $sParamName;
$nCurCookie = func::getCOOKIE($sCookieKey, 0);
$this->input->clean($nCurCookie, TYPE_UINT);
if (!$nPerpage) {
$nPerpage = $nCurCookie;
if (!in_array($nPerpage, $aValues)) {
$nPerpage = current($aValues);
}
} else {
if (!in_array($nPerpage, $aValues)) {
$nPerpage = current($aValues);
}
if ($nCurCookie != $nPerpage) {
func::setCOOKIE($sCookieKey, $nPerpage, isset($nExpireDays) ? $nExpireDays : 7);
}
//default: one week
}
array_walk($aValues, create_function('&$item,$key,$cur', '$item = "<option value=\\"$item\\" ".($item==$cur?"selected=\\"selected\\"":"").">$item</option>";'), $nPerpage);
return join($aValues);
}