本文整理汇总了PHP中gmtime函数的典型用法代码示例。如果您正苦于以下问题:PHP gmtime函数的具体用法?PHP gmtime怎么用?PHP gmtime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gmtime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* 发送邮件
*
* @author Garbin
* @param int $limit
* @return void
*/
function send($limit = 5)
{
/* 清除不能发送的邮件 */
$this->clear();
/* 获取待发送的邮件,按发送时间,优先及除序,错误次数升序 */
$gmtime = gmtime();
/* 取出所有未锁定的 */
$mails = $this->find(array('conditions' => "lock_expiry < {$gmtime}", 'order' => 'add_time DESC, priority DESC, err_num ASC', 'limit' => "0, {$limit}"));
if (!$mails) {
/* 没有邮件,不需要发送 */
return 0;
}
/* 锁定待发送邮件 */
$queue_ids = array_keys($mails);
$lock_expiry = $gmtime + 30;
//锁定30秒
$this->edit($queue_ids, "err_num = err_num + 1, lock_expiry = {$lock_expiry}");
/* 获取邮件发送接口 */
$mailer =& get_mailer();
$mail_count = count($queue_ids);
$error_count = 0;
$error = '';
/* 逐条发送 */
for ($i = 0; $i < $mail_count; $i++) {
$mail = $mails[$queue_ids[$i]];
$result = $mailer->send($mail['mail_to'], $mail['mail_subject'], $mail['mail_body'], $mail['mail_encoding'], 1);
if ($result) {
/* 发送成功,从队列中删除 */
$this->drop($queue_ids[$i]);
} else {
$error_count++;
}
}
return array('mail_count' => $mail_count, 'error_count' => $error_count, 'error' => $mailer->errors);
}
示例2: isLogin
protected function isLogin()
{
if (empty($_SESSION[APP_NAME . '_USERINFO'])) {
/* session 不存在,检查cookie */
if (!empty($_COOKIE['ECTOUCHCP']['ADMIN_ID']) && !empty($_COOKIE['ECTOUCHCP']['ADMIN_PWD'])) {
// 找到了cookie, 验证cookie信息
$condition['user_id'] = intval($_COOKIE['ECTOUCHCP']['ADMIN_ID']);
$userInfo = $this->model->table('admin_user')->field('user_id, user_name, password, email, last_login, ec_salt')->where($condition)->find();
if (empty($userInfo)) {
// 没有找到这个记录
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
return false;
} else {
// 检查密码是否正确
if (md5(md5($userInfo['user_id'] . $userInfo['user_name']) . C('hash_code')) == $_COOKIE['ECTOUCHCP']['ADMIN_PWD']) {
$this->setLogin($userInfo);
$data['last_login'] = gmtime();
$data['last_ip'] = get_client_ip();
$this->model->table('admin_user')->data($data)->where($condition)->update();
$this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
return true;
} else {
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
return false;
}
}
}
return false;
} else {
$this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
return true;
}
}
示例3: gc
function gc($time = false)
{
if (!$time) {
$time = gmtime();
}
$dir = opendir($this->cache_dir);
while ($file = readdir($dir)) {
if (strpos($file, 'cache_') === 0) {
$name = preg_replace(array('/cache_/', '/.php/'), '', $file);
$unset = false;
if (empty($this->expires[$name])) {
include $this->cache_dir . $name;
$unset = true;
}
if ($time > $this->expires[$name]) {
unlink($this->cache_dir . $file);
$this->remove($name);
}
if ($unset) {
$this->remove($name);
}
}
}
closedir($dir);
}
示例4: send
/**
* 发送邮件
*
* @author wj
* @param int $num
*
* @return void
*/
function send($limit = 5)
{
$this->clear();
$gmtime = gmtime();
$lock_expiry = $gmtime + $this->_lock_expire;
//获取符合条件mail
$sql = "SELECT queue_id, mail_to, mail_encoding, mail_subject, mail_body" . " FROM `ecm_mail_queue`" . " WHERE lock_expiry < {$gmtime} " . " ORDER BY add_time DESC, priority DESC, err_num ASC " . " LIMIT {$limit} ";
$mail_count = 0;
$error_count = 0;
if ($mail_list = $this->db->getAll($sql)) {
$mail_count = count($mail_list);
$mail_ids = array();
for ($i = 0; $i < $mail_count; $i++) {
$mail_ids[] = $mail_list[$i]['queue_id'];
}
//锁定
$sql = "UPDATE `ecm_mail_queue` SET err_num = err_num + 1, lock_expiry = {$lock_expiry} WHERE queue_id " . db_create_in($mail_ids);
$this->db->query($sql);
for ($i = 0; $i < $mail_count; $i++) {
$res = $this->mailer->send($mail_list[$i]['mail_to'], $mail_list[$i]['mail_subject'], $mail_list[$i]['mail_body'], $mail_list[$i]['mail_encoding'], 1);
if ($res) {
$this->db->query("DELETE FROM `ecm_mail_queue` WHERE queue_id='" . $mail_list[$i]['queue_id'] . '\'');
} else {
$error_count++;
}
}
}
return array('mail_count' => $mail_count, 'error_count' => $error_count, 'error' => $this->mailer->errors);
}
示例5: check_order
function check_order($con, $goods)
{
$msg = '';
$btime = "";
$ntimestamp = gmtime() + 32 * 3600;
//24小时后时间戳
$now = gmtime();
$tmd = date('Y-m-d', $now + 32 * 3600);
if (empty($con)) {
$msg .= '请您填写收货信息|';
} else {
$btime = $con['best_time'];
}
$btimestamp = strtotime($btime);
if (empty($goods)) {
$msg .= '购物车没有商品|';
}
if (empty($btime) || strlen($btime) < 19) {
$msg .= '请填写送货时间|';
}
if ($btimestamp < gmtime() + 13.25 * 3600) {
$msg .= '送货时间不足5小时,重新填写送货时间';
}
if (local_date('H', $now) > 21 && substr($btime, 0, 13) < $tmd . ' 14' && $con['country'] == '441') {
$msg .= '请注意,此时订货最早14点送货,请修改送货时间 ';
}
if (local_date('H', $now) < 10 && substr($btime, 0, 13) < date('Y-m-d', $now + 8 * 3600) . ' 14' && $con['country'] == '441') {
$msg .= '请注意,此时订货最早14点送货,请修改送货时间 ';
}
return $msg;
}
示例6: get_promote_goods
/**
* 获得促销商品
*
* @access public
* @return array
*/
function get_promote_goods($cats = '')
{
$time = gmtime();
$order_type = C('recommend_order');
/* 取得促销lbi的数量限制 */
$num = model('Common')->get_library_number("recommend_promotion");
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, " . "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd " . 'FROM ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'brand AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $this->pre . "member_price AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ' . " AND g.is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}' ";
$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY rnd';
$sql .= " LIMIT {$num} ";
$result = $this->query($sql);
$goods = array();
foreach ($result as $idx => $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
} else {
$goods[$idx]['promote_price'] = '';
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('goods_name_length')) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$goods[$idx]['url'] = url('goods/index', array('id' => $row['goods_id']));
}
return $goods;
}
示例7: get_user_orders_1
/**
* 获取用户指定范围的订单列表
*
* @access public
* @param int $user_id 用户ID号
* @param int $num 列表最大数量
* @param int $start 列表起始位置
* @return array $order_list 订单列表
*/
function get_user_orders_1($user_id, $num = 10, $start = 0, $where = '')
{
/* 取得订单列表 */
$arr = array();
$sql = "SELECT o.*, ifnull(ssc.value,'网站自营') as shopname, " . "(goods_amount + shipping_fee + insure_fee + pay_fee + pack_fee + card_fee + tax - discount) AS total_fee " . " FROM " . $GLOBALS['ecs']->table('order_info') . ' as o ' . " LEFT JOIN " . $GLOBALS['ecs']->table('supplier_shop_config') . 'as ssc ' . " ON o.supplier_id=ssc.supplier_id AND ssc.code='shop_name' " . " WHERE user_id = '{$user_id}' {$where} ORDER BY add_time DESC";
$res = $GLOBALS['db']->SelectLimit($sql, $num, $start);
while ($row = $GLOBALS['db']->fetchRow($res)) {
if ($row['order_status'] == OS_UNCONFIRMED) {
$row['handler'] = "<a href=\"user.php?act=cancel_order&order_id=" . $row['order_id'] . "\" onclick=\"if (!confirm('" . $GLOBALS['_LANG']['confirm_cancel'] . "')) return false;\">" . $GLOBALS['_LANG']['cancel'] . "</a>";
} else {
if ($row['order_status'] == OS_SPLITED) {
/* 对配送状态的处理 */
if ($row['shipping_status'] == SS_SHIPPED) {
$back_num = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('back_order') . " WHERE order_id = " . $row['order_id'] . " AND status_back < 6 AND status_back != 3");
if ($back_num > 0) {
$back_info = "此单存在正在退货商品,确认收货退货申请将取消。";
} else {
$back_info = "";
}
@($okgoods_time = $GLOBALS['db']->getOne("select value from " . $GLOBALS['ecs']->table('shop_config') . " where code='okgoods_time'"));
@($row_time = $okgoods_time - (local_date('d', gmtime()) - local_date('d', $row['shipping_time'])));
@($row['handler'] = "<strong><img src='themesmobile/" . $GLOBALS['_CFG']['template'] . "/images/time.png' height='30px' style='vertical-align:middle;'/>还剩" . $row_time . "天自动收货</strong><a href=\"user.php?act=affirm_received&order_id=" . $row['order_id'] . "\" onclick=\"if (!confirm('" . $back_info . $GLOBALS['_LANG']['confirm_received'] . "')) return false;\" style='display:inline-block; margin-top:12px; width:80px; height:25px; font-size:14px; line-height:25px; border:1px solid #F60; color:#fff; text-align:center;border-radius:5px; background:#F60 '>" . $GLOBALS['_LANG']['received'] . "</a>");
} elseif ($row['shipping_status'] == SS_RECEIVED) {
@($row['handler'] = '<span style="color:red">' . $GLOBALS['_LANG']['ss_received'] . '</span>');
} else {
if ($row['pay_status'] == PS_UNPAYED) {
@($row['handler'] = "<a href=\"user.php?act=order_detail&order_id=" . $row['order_id'] . '">' . $GLOBALS['_LANG']['pay_money'] . '</a>');
} else {
@($row['handler'] = "<a href=\"user.php?act=order_detail&order_id=" . $row['order_id'] . '">' . $GLOBALS['_LANG']['view_order'] . '</a>');
}
}
} else {
$row['handler'] = '<span style="color:red">' . $GLOBALS['_LANG']['os'][$row['order_status']] . '</span>';
}
}
$row['shipping_status'] = $row['shipping_status'] == SS_SHIPPED_ING ? SS_PREPARING : $row['shipping_status'];
$row['order_status1'] = $row['order_status'];
$row['order_status'] = $GLOBALS['_LANG']['os'][$row['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$row['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$row['shipping_status']];
$cod_code = $GLOBALS['db']->getOne("select pay_code from " . $GLOBALS['ecs']->table('payment') . " where pay_id=" . $row['pay_id']);
$weixiu_time = $GLOBALS['db']->getOne("select value from " . $GLOBALS['ecs']->table('ecsmart_shop_config') . " where code='weixiu_time'");
$row['weixiu_time'] = $weixiu_time - (local_date('d', gmtime()) - local_date('d', $order['shipping_time_end'])) <= 0 ? 0 : 1;
$back_can_a = 1;
$comment_s = 0;
$shaidan_s = 0;
$goods_list_r = get_order_goods($row);
foreach ($goods_list_r as $g_val) {
if ($g_val['back_can'] == 0) {
$back_can_a = 0;
}
if ($g_val['comment_state'] == 0 && $g_val['is_back'] == 0 && $comment_s == 0) {
$comment_s = $g_val['rec_id'];
}
if ($g_val['shaidan_state'] == 0 && $g_val['is_back'] == 0 && $shaidan_s == 0) {
$shaidan_s = $g_val['rec_id'];
}
}
$arr[$row['order_id']] = array('order_id' => $row['order_id'], 'order_sn' => $row['order_sn'], 'shopname' => $row['shopname'], 'order_time' => local_date($GLOBALS['_CFG']['time_format'], $row['add_time']), 'order_status' => str_replace(',', ' ', $row['order_status']), 'order_status1' => $row['order_status1'], 'back_can_a' => $back_can_a, 'comment_s' => $comment_s, 'shaidan_s' => $shaidan_s, 'total_fee' => price_format($row['total_fee'], false), 'goods_list' => $goods_list_r, 'pay_online' => $row['pay_online'], 'is_suborder' => $row['parent_order_id'] ? "(子订单)" : "", 'pay_status' => $row['pay_status'], 'handler' => $row['handler'], 'shipping_id' => $row['shipping_id'], 'shipping_name' => $row['shipping_name'], 'shipping_status' => $row['shipping_status'], 'pay_id' => $cod_code == 'cod' ? '' : $row['pay_id'], 'invoice_no' => $row['invoice_no'], 'weixiu_time' => $row['weixiu_time'], 'supplier_id' => $row['supplier_id'], 'count' => count($goods_list_r));
}
return $arr;
}
示例8: maketable
function maketable($res)
{
global $tracker_lang, $use_ttl, $ttl_days;
$ret = "<table class=main border=1 cellspacing=0 cellpadding=5>" . "<tr><td class=colhead align=left>" . $tracker_lang['type'] . "</td><td class=colhead>" . $tracker_lang['name'] . "</td>" . ($use_ttl ? "<td class=colhead align=center>" . $tracker_lang['ttl'] . "</td>" : "") . "<td class=colhead align=center>" . $tracker_lang['size'] . "</td><td class=colhead align=right>" . $tracker_lang['details_seeding'] . "</td><td class=colhead align=right>" . $tracker_lang['details_leeching'] . "</td><td class=colhead align=center>" . $tracker_lang['uploaded'] . "</td>\n" . "<td class=colhead align=center>" . $tracker_lang['downloaded'] . "</td><td class=colhead align=center>" . $tracker_lang['ratio'] . "</td></tr>\n";
while ($arr = mysql_fetch_assoc($res)) {
if ($arr["downloaded"] > 0) {
$ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3);
$ratio = "<font color=" . get_ratio_color($ratio) . ">{$ratio}</font>";
} else {
if ($arr["uploaded"] > 0) {
$ratio = "Inf.";
} else {
$ratio = "---";
}
}
$catid = $arr["catid"];
$catimage = htmlspecialchars_uni($arr["image"]);
$catname = htmlspecialchars_uni($arr["catname"]);
$ttl = $ttl_days * 24 - floor((gmtime() - sql_timestamp_to_unix_timestamp($arr["added"])) / 3600);
if ($ttl == 1) {
$ttl .= " час";
} else {
$ttl .= " часов";
}
$size = str_replace(" ", "<br />", mksize($arr["size"]));
$uploaded = str_replace(" ", "<br />", mksize($arr["uploaded"]));
$downloaded = str_replace(" ", "<br />", mksize($arr["downloaded"]));
$seeders = number_format($arr["seeders"]);
$leechers = number_format($arr["leechers"]);
$ret .= "<tr><td style='padding: 0px'><a href=\"browse.php?cat={$catid}\"><img src=\"pic/cats/{$catimage}\" alt=\"{$catname}\" border=\"0\" /></a></td>\n" . "<td><a href=details.php?id={$arr['torrent']}&hit=1><b>" . $arr["torrentname"] . "</b></a></td>" . ($use_ttl ? "<td align=center>{$ttl}</td>" : "") . "<td align=center>{$size}</td><td align=right>{$seeders}</td><td align=right>{$leechers}</td><td align=center>{$uploaded}</td>\n" . "<td align=center>{$downloaded}</td><td align=center>{$ratio}</td></tr>\n";
}
$ret .= "</table>\n";
return $ret;
}
示例9: commenttable
function commenttable($rows, $redaktor = "comment")
{
global $CURUSER, $avatar_max_width;
$count = 0;
foreach ($rows as $row) {
if ($row["downloaded"] > 0) {
$ratio = $row['uploaded'] / $row['downloaded'];
$ratio = number_format($ratio, 2);
} elseif ($row["uploaded"] > 0) {
$ratio = "Inf.";
} else {
$ratio = "---";
}
if (strtotime($row["last_access"]) > gmtime() - 600) {
$online = "online";
$online_text = "В сети";
} else {
$online = "offline";
$online_text = "Не в сети";
}
print "<table class=maibaugrand width=100% border=1 cellspacing=0 cellpadding=3>";
print "<tr><td class=colhead align=\"left\" colspan=\"2\" height=\"24\">";
if (isset($row["username"])) {
$title = $row["title"];
if ($title == "") {
$title = get_user_class_name($row["class"]);
} else {
$title = htmlspecialchars_uni($title);
}
print ":: <img src=\"pic/buttons/button_" . $online . ".gif\" alt=\"" . $online_text . "\" title=\"" . $online_text . "\" style=\"position: relative; top: 2px;\" border=\"0\" height=\"14\">" . " <a name=comm" . $row["id"] . " href=userdetails.php?id=" . $row["user"] . " class=altlink_white><b>" . get_user_class_color($row["class"], htmlspecialchars_uni($row["username"])) . "</b></a> ::" . ($row["donor"] == "yes" ? "<img src=pic/star.gif alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src=\"/pic/warned.gif\" alt=\"Warned\">" : "") . " {$title} ::\n" . " <img src=\"pic/upl.gif\" alt=\"upload\" border=\"0\" width=\"12\" height=\"12\"> " . mksize($row["uploaded"]) . " :: <img src=\"pic/down.gif\" alt=\"download\" border=\"0\" width=\"12\" height=\"12\"> " . mksize($row["downloaded"]) . " :: <font color=\"" . get_ratio_color($ratio) . "\">{$ratio}</font> :: ";
} else {
print "<a name=\"comm" . $row["id"] . "\"><i>[Anonymous]</i></a>\n";
}
$avatar = $CURUSER["avatars"] == "yes" ? htmlspecialchars_uni($row["avatar"]) : "";
if (!$avatar) {
$avatar = "pic/default_avatar.gif";
}
if (md5($row['text']) == $row['text_hash']) {
$text = $row['text_parsed'];
} else {
$text = format_comment($row['text']);
sql_query('INSERT INTO comments_parsed (cid, text_hash, text_parsed) VALUES (' . implode(', ', array_map('sqlesc', array($row['id'], md5($row['text']), $text))) . ')') or sqlerr(__FILE__, __LINE__);
}
if ($row["editedby"]) {
//$res = mysql_fetch_assoc(sql_query("SELECT * FROM users WHERE id = $row[editedby]")) or sqlerr(__FILE__,__LINE__);
$text .= "<p><font size=1 class=small>Последний раз редактировалось <a href=userdetails.php?id={$row['editedby']}><b>{$row['editedbyname']}</b></a> в {$row['editedat']}</font></p>\n";
}
print "</td></tr>";
print "<tr valign=top>\n";
print "<td style=\"padding: 0px; width: 5%;\" align=\"center\"><img src={$avatar} width=\"{$avatar_max_width}\"> </td>\n";
print "<td width=100% class=text>";
//print("<span style=\"float: right\"><a href=\"#top\"><img title=\"Top\" src=\"pic/top.gif\" alt=\"Top\" border=\"0\" width=\"15\" height=\"13\"></a></span>");
print "{$text}</td>\n";
print "</tr>\n";
print "<tr><td class=colhead align=\"center\" colspan=\"2\">";
print "<div style=\"float: left; width: auto;\">" . ($CURUSER ? " [<a href=\"" . $redaktor . ".php?action=quote&cid={$row['id']}\" class=\"altlink_white\">Цитата</a>]" : "") . ($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? " [<a href=" . $redaktor . ".php?action=edit&cid={$row['id']} class=\"altlink_white\">Изменить</a>]" : "") . (get_user_class() >= UC_MODERATOR ? " [<a href=\"" . $redaktor . ".php?action=delete&cid={$row['id']}\" class=\"altlink_white\">Удалить</a>]" : "") . ($row["editedby"] && get_user_class() >= UC_MODERATOR ? " [<a href=\"" . $redaktor . ".php?action=vieworiginal&cid={$row['id']}\" class=\"altlink_white\">Оригинал</a>]" : "") . (get_user_class() >= UC_MODERATOR ? " IP: " . ($row["ip"] ? "<a href=\"usersearch.php?ip={$row['ip']}\" class=\"altlink_white\">" . $row["ip"] . "</a>" : "Неизвестен") : "") . "</div>";
print "<div align=\"right\"><!--<font size=1 class=small>-->Комментарий добавлен: " . $row["added"] . " GMT<!--</font>--></td></tr>";
print "</table><br>";
}
}
示例10: get_index_best
/**
* 获得推荐商品
*
* @access public
* @param string $type 推荐类型,可以是 best, new, hot
* @return array
*/
function get_index_best($limit = '')
{
$time = gmtime();
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_id, g.goods_name,g.click_count, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' ";
$sql .= ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = "best" ';
$sql .= ' ORDER BY g.sort_order, g.last_update DESC';
$sql .= " {$limit}";
$result = $GLOBALS['db']->getAll($sql);
foreach ($result as $idx => $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
} else {
$goods[$idx]['promote_price'] = '';
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']);
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$goods[$idx]['sell_count'] = selled_count($row['goods_id']);
$goods[$idx]['pinglun'] = get_evaluation_sum($row['goods_id']);
$goods[$idx]['count'] = selled_count($row['goods_id']);
$goods[$idx]['click_count'] = $row['click_count'];
}
return $goods;
}
示例11: card_info_add
function card_info_add()
{
/* 检测是否 绑定了此店铺的会员卡 */
$store_id = intval($_GET['id']);
if (empty($store_id)) {
$this->show_message('hack');
}
$store = $this->_store_mod->get($store_id);
if (empty($store)) {
$this->show_message('hack');
}
$membership_card_infos = $this->_membership_card_info_mod->find(array('conditions' => 'store_id=' . $store_id . ' AND user_id=' . $this->_user_id));
if (count($membership_card_infos) != 0) {
$this->show_message('error');
return;
}
if (!IS_POST) {
$region_mod =& m('region');
$this->assign('regions', $region_mod->get_options(0));
$this->display('membership.card_info.html');
} else {
$data = array('user_id' => $this->_user_id, 'store_id' => $store_id, 'user_name' => $_POST['user_name'], 'card_num' => 1000000 + $this->_user_id, 'phone' => $_POST['phone'], 'sex' => $_POST['sex'], 'region_id' => $_POST['region_id'], 'region_name' => $_POST['region_name'], 'address' => $_POST['address'], 'create_time' => gmtime());
$this->_membership_card_info_mod->add($data);
$this->show_message('add_ok', 'back_list', 'index.php?app=membership&id=' . $store_id);
}
}
示例12: core_user
function core_user()
{
$this->browser = mb_substr(empty($_SERVER['HTTP_USER_AGENT']) ? getenv('HTTP_USER_AGENT') : $_SERVER['HTTP_USER_AGENT'], 0, 255);
$this->url = $_SERVER['REQUEST_URI'];
$this->ip = empty($_SERVER['REMOTE_ADDR']) ? getenv('REMOTE_ADDR') : $_SERVER['REMOTE_ADDR'];
$this->time = (int) gmtime();
if (($pos = mb_strpos($this->url, INDEX_PAGE . '?mod=')) !== false) {
$pos = $pos + mb_strlen(INDEX_PAGE . '?mod=');
$this->url = mb_substr($this->url, $pos);
} elseif (mb_substr($this->url, -5) === '.html') {
$this->url = str_replace(array('/', '.html'), array('&', ''), $this->url);
if ($this->url[0] === '&') {
$this->url = mb_substr($this->url, 1);
}
} else {
$this->url = '';
}
if ($this->url) {
if (($pos = mb_strpos($this->url, 'sid=')) !== false) {
$this->url = mb_substr($this->url, 0, $pos - 1);
}
$this->url = htmlspecialchars($this->url, ENT_QUOTES);
$this->url = mb_substr($this->url, 0, 255);
}
}
示例13: send
/**
* 发送短消息
*
* @author Hyber
* @param int $from_id
* @param mixed $to_id 发送给哪些user_id 可以是逗号分割 可以是数组
* @param string $title 短信标题
* @param string $content 短信内容
* @param int $parent_id 如果是回复则需要主题msg_id
* @return mixed
*/
function send($from_id, $to_id, $title = '', $content, $parent_id = 0)
{
$to_ids = is_array($to_id) ? $to_id : explode(',', $to_id);
foreach ($to_ids as $k => $to_id) {
if ($from_id == $to_id) {
$this->_error('cannot_sent_to_myself');
return false;
//不能发给自己
}
$data[$k] = array('from_id' => $from_id, 'to_id' => $to_id, 'title' => $title, 'content' => $content, 'parent_id' => $parent_id, 'add_time' => gmtime());
if ($parent_id > 0) {
if ($k == 0) {
$message = $this->get_info($parent_id);
$edit_data = array('last_update' => gmtime(), 'status' => 3);
$edit_data['new'] = $from_id == $message['from_id'] ? 1 : 2;
//如果回复自己发送的主题时
//unset($this->_autov['title']['required']); //允许标题为空
}
} else {
$data[$k]['new'] = 1;
//收件方新消息
$data[$k]['status'] = 3;
//双方未删除
$data[$k]['last_update'] = gmtime();
//更新时间
}
}
//dump($data);
$msg_ids = $this->add($data);
$edit_data && $msg_ids && $this->edit($parent_id, $edit_data);
return $msg_ids;
}
示例14: add
function add()
{
if (!IS_POST) {
$this->import_resource(array('script' => 'jquery.plugins/jquery.validate.js'));
$ugrade = $this->_grade_mod->get_option();
$this->assign('ugrade', max($ugrade) + 1);
$this->display('ugrade.form.html');
} else {
/* 检查名称是否已存在 */
if (!$this->_grade_mod->unique('grade_name', trim($_POST['grade_name']))) {
$this->show_warning('name_exist');
return;
}
$data = array('grade_name' => $_POST['grade_name'], 'grade' => $_POST['grade'], 'growth_needed' => $_POST['growth_needed'], 'add_time' => gmtime());
$last_grade = $this->_grade_mod->get(array('conditions' => 'grade=' . ($_POST['grade'] - 1)));
$data['floor_growth'] = $_POST['growth_needed'] + $last_grade['floor_growth'];
$grade_id = $this->_grade_mod->add($data);
if (!$grade_id) {
$this->show_warning($this->_grade_mod->get_error());
return;
}
$this->_grade_mod->edit($last_grade['grade_id'], array('top_growth' => $data['floor_growth']));
//修改上一等级的top_growth
$grade_icon = $this->_upload_logo($grade_id);
if ($grade_icon === false) {
return;
}
$grade_icon && $this->_grade_mod->edit($grade_id, array('grade_icon' => $grade_icon));
//将icon地址记下
$this->show_message('add_ok', 'back_list', 'index.php?app=ugrade', 'continue_add', 'index.php?app=ugrade&act=add');
}
}
示例15: _group_auto_cancel
function _group_auto_cancel()
{
/* 自动取消团购的天数 */
$interval = GROUP_CANCEL_INTERVAL * 3600 * 24;
$groupbuy_mod =& m('groupbuy');
$groups = $groupbuy_mod->findAll(array('conditions' => "gb.state = '" . GROUP_END . "' AND gb.end_time > 0 AND gb.end_time + {$interval} < '" . gmtime() . "'", 'join' => 'belong_store', 'include' => array('be_join')));
// 短信通知
$ms =& ms();
$userpriv_mod =& m('userpriv');
foreach ($groups as $group) {
// 管理员
$admin_id = $userpriv_mod->get_admin_id();
$to_id = array_keys($admin_id);
$group_ids[] = $group['group_id'];
// 参与团购的用户
if (!empty($group['member'])) {
foreach ($group['member'] as $join_user) {
$to_id[] = $join_user['user_id'];
}
$to_id = array_unique($to_id);
}
$content = get_msg('tobuyer_group_auto_cancel_notify', array('cancel_days' => GROUP_CANCEL_INTERVAL, 'url' => SITE_URL . '/' . url("app=groupbuy&id=" . $group['group_id'])));
$ms->pm->send(MSG_SYSTEM, $to_id, '', $content);
}
// 取消团购活动
empty($group_ids) || $groupbuy_mod->edit($group_ids, array('state' => GROUP_CANCELED));
}