/**
  *    发送邮件
  *
  *    @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);
 }
Example #2
0
 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;
     }
 }
 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);
 }
 /**
  * 发送邮件
  *
  * @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);
 }
Example #5
0
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;
}
Example #6
0
 /**
  * 获得促销商品
  *
  * @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;
 }
/**
 *  获取用户指定范围的订单列表
 *
 * @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;
}
Example #8
0
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 .= "&nbsp;час";
        } else {
            $ttl .= "&nbsp;часов";
        }
        $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']}&amp;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;
}
Example #9
0
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&amp;cid={$row['id']}\" class=\"altlink_white\">Цитата</a>]" : "") . ($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? " [<a href=" . $redaktor . ".php?action=edit&amp;cid={$row['id']} class=\"altlink_white\">Изменить</a>]" : "") . (get_user_class() >= UC_MODERATOR ? " [<a href=\"" . $redaktor . ".php?action=delete&amp;cid={$row['id']}\" class=\"altlink_white\">Удалить</a>]" : "") . ($row["editedby"] && get_user_class() >= UC_MODERATOR ? " [<a href=\"" . $redaktor . ".php?action=vieworiginal&amp;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>";
    }
}
Example #10
0
/**
 * 获得推荐商品
 *
 * @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;
}
 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);
     }
 }
Example #12
0
 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);
     }
 }
Example #13
0
 /**
  * 发送短消息
  *
  * @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;
 }
Example #14
0
 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&amp;act=add');
     }
 }
Example #15
0
 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));
 }
Example #16
0
 /**
  * 获得积分兑换商品的详细信息
  *
  * @access  public
  * @param   integer     $goods_id
  * @return  void
  */
 function get_exchange_goods_info($goods_id)
 {
     $time = gmtime();
     $sql = 'SELECT g.*, c.measure_unit, b.brand_id, b.brand_name AS goods_brand, eg.exchange_integral, eg.is_exchange ' . 'FROM ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'exchange_goods AS eg ON g.goods_id = eg.goods_id ' . 'LEFT JOIN ' . $this->pre . 'category AS c ON g.cat_id = c.cat_id ' . 'LEFT JOIN ' . $this->pre . 'brand AS b ON g.brand_id = b.brand_id ' . "WHERE g.goods_id = '{$goods_id}' AND g.is_delete = 0 " . 'GROUP BY g.goods_id';
     $row = $this->row($sql);
     if ($row !== false) {
         /* 处理商品水印图片 */
         $watermark_img = '';
         if ($row['is_new'] != 0) {
             $watermark_img = "watermark_new";
         } elseif ($row['is_best'] != 0) {
             $watermark_img = "watermark_best";
         } elseif ($row['is_hot'] != 0) {
             $watermark_img = 'watermark_hot';
         }
         if ($watermark_img != '') {
             $row['watermark_img'] = $watermark_img;
         }
         /* 修正重量显示 */
         $row['goods_weight'] = intval($row['goods_weight']) > 0 ? $row['goods_weight'] . L('kilogram') : $row['goods_weight'] * 1000 . L('gram');
         /* 修正上架时间显示 */
         $date_format = C('date_format');
         $row['add_time'] = local_date($date_format, $row['add_time']);
         /* 修正商品图片 */
         $row['goods_img'] = get_image_path($goods_id, $row['goods_img']);
         $row['goods_thumb'] = get_image_path($goods_id, $row['goods_thumb'], true);
         $row['original_img'] = get_image_path($goods_id, $row['original_img'], true);
         $row['goods_brand_url'] = url('brand/goods_list', array('id' => $row['brand_id']));
         return $row;
     } else {
         return false;
     }
 }
Example #17
0
 function index()
 {
     $page = $this->_get_page(10);
     $this->_user_mod =& m('member');
     $this->_store_mod =& m('store');
     $this->_coupon_mod =& m('coupon');
     $msg = $this->_user_mod->findAll(array('conditions' => 'user_id = ' . $this->visitor->get('user_id'), 'count' => true, 'limit' => $page['limit'], 'include' => array('bind_couponsn' => array())));
     $page['item_count'] = $this->_user_mod->getCount();
     $coupon = array();
     $coupon_ids = array();
     $msg = current($msg);
     if (!empty($msg['coupon_sn'])) {
         foreach ($msg['coupon_sn'] as $key => $val) {
             $coupon_tmp = $this->_coupon_mod->get(array('fields' => "this.*,store.store_name,store.store_id", 'conditions' => 'coupon_id = ' . $val['coupon_id'], 'join' => 'belong_to_store'));
             $coupon_tmp['valid'] = 0;
             $time = gmtime();
             if ($val['remain_times'] > 0 && ($coupon_tmp['end_time'] == 0 || $coupon_tmp['end_time'] > $time)) {
                 $coupon_tmp['valid'] = 1;
             }
             $coupon[$key] = array_merge($val, $coupon_tmp);
         }
     }
     $this->import_resource(array('script' => array(array('path' => 'dialog/dialog.js', 'attr' => 'id="dialog_js"'), array('path' => 'jquery.ui/jquery.ui.js', 'attr' => ''), array('path' => 'jquery.ui/i18n/' . i18n_code() . '.js', 'attr' => ''), array('path' => 'jquery.plugins/jquery.validate.js', 'attr' => '')), 'style' => 'jquery.ui/themes/ui-lightness/jquery.ui.css'));
     /* 当前位置 */
     $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_coupon'), 'index.php?app=my_coupon', LANG::get('coupon_list'));
     $this->_curitem('my_coupon');
     $this->_curmenu('coupon_list');
     $this->assign('page_info', $page);
     //将分页信息传递给视图,用于形成分页条
     $this->_config_seo('title', Lang::get('member_center') . ' - ' . Lang::get('coupon_list'));
     $this->_format_page($page);
     $this->assign('coupons', $coupon);
     $this->display('my_coupon.index.html');
 }
Example #18
0
 public function orderid_arr($order, $order_key)
 {
     $where = " WHERE 1 ";
     $i = 0;
     foreach ($order as $key => $value) {
         if (!empty($value)) {
             $i++;
             $where .= " AND {$order_key[$key]} = '{$value}'";
         }
     }
     $order_id_arr = '';
     if ($i >= 2) {
         $time = gmtime() - 3600 * 24 * 15;
         $sql = 'SELECT order_id FROM ' . $this->ecs->table('order_info') . " {$where} ORDER BY order_id desc";
         $order_id_arr = $this->db->getAll($sql);
     }
     //四个条件分别组成不重复的两两组合
     /*$num = count($order);
     		for($i=0;$i<=$num;$i++){
     			for($ii=$i+1;$ii<=$num-1;$ii++){
     				if($order[$i] && $order[$ii]){
     					$time = gmtime() - 3600*24*15;
     					$where = " WHERE $order_key[$i] = '$order[$i]' AND $order_key[$ii] = '$order[$ii]' AND add_time > '$time'";
     					$order_id_arr = $this->db->getAll('SELECT order_id FROM '.$this->ecs->table('order_info')." $where ORDER BY order_id desc");
     					if($order_id_arr[0]['order_id']) break;
     				}
     			}
     			if($order_id_arr[0]['order_id']) break;
     		}*/
     return $order_id_arr ? $order_id_arr : '';
 }
Example #19
0
 public static function getCouponsConditions($type = '')
 {
     $con = array("notUsed" => "is_used = 0 AND validate_time > " . gmtime(), "used" => "is_used = 1", "invalid" => "is_used = 0 AND validate_time <= " . gmtime());
     if (empty($type)) {
         return $con;
     }
     return $con[$type];
 }
Example #20
0
/**
 * 记录管理员的操作内容
 *
 * @access  public
 * @param   string      $sn         数据的唯一值
 * @param   string      $action     操作的类型
 * @param   string      $content    操作的内容
 * @param   string      $log_info   直接插入操作的内容
 * @return  void
 */
function admin_log($sn = '', $action, $content, $log_info = '')
{
    if (!$log_info) {
        $log_info = $GLOBALS['_LANG']['log_action'][$action] . $GLOBALS['_LANG']['log_action'][$content] . ': ' . addslashes($sn);
    }
    $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('admin_log') . ' (log_time, user_id, log_info, ip_address) ' . " VALUES ('" . gmtime() . "', {$_SESSION['admin_id']}, '" . stripslashes($log_info) . "', '" . real_ip() . "')";
    $GLOBALS['db']->query($sql);
}
Example #21
0
function random_filename()
{
    $str = '';
    for ($i = 0; $i < 9; $i++) {
        $str .= mt_rand(0, 9);
    }
    return gmtime() . $str . '.jpg';
}
Example #22
0
 /**
  * 记录订单操作记录
  * @access  public
  * @param   string  $order_sn           订单编号
  * @param   integer $order_status       订单状态
  * @param   integer $shipping_status    配送状态
  * @param   integer $pay_status         付款状态
  * @param   string  $note               备注
  * @param   string  $username           用户名,用户自己的操作则为 buyer
  * @return  void
  */
 function order_action($order_sn, $order_status, $shipping_status, $pay_status, $note = '', $username = null, $place = 0)
 {
     if (is_null($username)) {
         $username = $_SESSION['admin_name'];
     }
     $sql = 'INSERT INTO ' . $this->pre . 'order_action (order_id, action_user, order_status, shipping_status, pay_status, action_place, action_note, log_time) ' . " SELECT order_id, '{$username}', '{$order_status}', '{$shipping_status}', '{$pay_status}', '{$place}', '{$note}', '" . gmtime() . "' " . 'FROM ' . $this->pre . "order_info WHERE order_sn = '{$order_sn}'";
     $this->query($sql);
 }
Example #23
0
/**
 * 检查手机验证码
 *
 * @access  public
 * @param   string       $mobile            手机号
 * @param   string       $verifycode        手机验证码
 * @param   string       $act               绑定类型
 *
 * @return  bool         $bool
 */
function check_sms_verifycode($mobile, $verifycode, $act = SMS_REGISTER)
{
    global $db, $ecs, $_CFG;
    $ip = real_ip();
    $expire = gmtime() - intval($_CFG['ecsdxt_sms_validtime']);
    //验证码10分钟内有效
    $SQL = "SELECT COUNT(id) FROM " . $ecs->table('verifycode') . " WHERE mobile='{$mobile}' AND verifycode='{$verifycode}' AND getip='{$ip}' AND status=1 AND `type`={$act} AND dateline>={$expire}";
    return $db->getOne($SQL) > 0;
}
Example #24
0
function current_time()
{
    //Dragonfly 10+
    if (version_compare(CPG_NUKE, '10.0.0', '>=')) {
        return time();
        //Older
    } else {
        return gmtime();
    }
}
Example #25
0
function gz_get_category_recommend_goods($type = '', $cats = '', $brand = 0, $min = 0, $max = 0, $ext = '')
{
    $brand_where = $brand > 0 ? " AND g.brand_id = '{$brand}'" : '';
    $price_where = $min > 0 ? " AND g.shop_price >= {$min} " : '';
    $price_where .= $max > 0 ? " AND g.shop_price <= {$max} " : '';
    $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, g.original_img, b.brand_name ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('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 ' . $brand_where . $price_where . $ext;
    $num = 0;
    $type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot', 'promote' => 'recommend_promotion');
    $num = get_library_number($type2lib[$type]);
    switch ($type) {
        case 'best':
            $sql .= ' AND is_best = 1';
            break;
        case 'new':
            $sql .= ' AND is_new = 1';
            break;
        case 'hot':
            $sql .= ' AND is_hot = 1';
            break;
        case 'promote':
            $time = gmtime();
            $sql .= " AND is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}'";
            break;
    }
    if (!empty($cats)) {
        $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) . ")";
    }
    $order_type = $GLOBALS['_CFG']['recommend_order'];
    $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY RAND()';
    $res = $GLOBALS['db']->selectLimit($sql, $num);
    $idx = 0;
    $goods = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        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]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $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]['original_img'] = get_image_path($row['goods_id'], $row['original_img']);
        $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
        $idx++;
    }
    return $goods;
}
Example #26
0
/**
 * 保存投票结果信息
 *
 * @access  public
 * @param   integer     $vote_id
 * @param   string      $ip_address
 * @param   string      $option_id
 * @return  void
 */
function save_vote($vote_id, $ip_address, $option_id)
{
    $sql = "INSERT INTO " . $GLOBALS['ecs']->table('vote_log') . " (vote_id, ip_address, vote_time) " . "VALUES ('{$vote_id}', '{$ip_address}', " . gmtime() . ")";
    $res = $GLOBALS['db']->query($sql);
    /* 更新投票主题的数量 */
    $sql = "UPDATE " . $GLOBALS['ecs']->table('vote') . " SET " . "vote_count = vote_count + 1 " . "WHERE vote_id = '{$vote_id}'";
    $GLOBALS['db']->query($sql);
    /* 更新投票选项的数量 */
    $sql = "UPDATE " . $GLOBALS['ecs']->table('vote_option') . " SET " . "option_count = option_count + 1 " . "WHERE " . db_create_in($option_id, 'option_id');
    $GLOBALS['db']->query($sql);
}
Example #27
0
/**
 * 将GMT时间戳格式化为用户自定义时区日期
 *
 * @param  string       $format
 * @param  integer      $time       该参数必须是一个GMT的时间戳
 *
 * @return  string
 */
function local_date($format, $time = NULL)
{
    $timezone = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : $GLOBALS['_CFG']['timezone'];
    if ($time === NULL) {
        $time = gmtime();
    } elseif ($time <= 0) {
        return '';
    }
    $time += $timezone * 3600;
    return date($format, $time);
}
Example #28
0
 /**
  * 生成支付代码
  * @param   array   $order      订单信息
  * @param   array   $payment    支付方式信息
  */
 function get_code($order, $payment)
 {
     $c_mid = trim($payment['c_mid']);
     //商户编号,在申请商户成功后即可获得,可以在申请商户成功的邮件中获取该编号
     $c_order = $order['order_sn'];
     //商户网站依照订单号规则生成的订单号,不能重复
     $c_name = "";
     //商户订单中的收货人姓名
     $c_address = "";
     //商户订单中的收货人地址
     $c_tel = "";
     //商户订单中的收货人电话
     $c_post = "";
     //商户订单中的收货人邮编
     $c_email = "";
     //商户订单中的收货人Email
     $c_orderamount = $order['order_amount'];
     //商户订单总金额
     if (!empty($order['add_time'])) {
         $c_ymd = local_date('Ymd', $order['add_time']);
     } else {
         $c_ymd = local_date('Ymd', gmtime());
     }
     //$c_ymd      = substr($order['order_sn'], 0, 8); //商户订单的产生日期,格式为"yyyymmdd",如20050102
     $c_moneytype = $payment['c_moneytype'];
     //支付币种,0为人民币
     $c_retflag = "1";
     //商户订单支付成功后是否需要返回商户指定的文件,0:不用返回 1:需要返回
     $c_paygate = empty($payment['c_paygate']) ? '' : trim($payment['c_paygate']);
     //如果在商户网站选择银行则设置该值,具体值可参见《云网支付@网技术接口手册》附录一;如果来云网支付@网选择银行此项为空值。
     $c_returl = return_url(basename(__FILE__, '.php'));
     //如果c_retflag为1时,该地址代表商户接收云网支付结果通知的页面,请提交完整文件名(对应范例文件:GetPayNotify.php)
     $c_memo1 = abs(crc32(trim($payment['c_memo1'])));
     //商户需要在支付结果通知中转发的商户参数一
     if (empty($order['order_id'])) {
         $c_memo2 = "voucher";
         //商户需要在支付结果通知中转发的商户参数二
     } else {
         $c_memo2 = '';
     }
     $c_pass = trim($payment['c_pass']);
     //支付密钥,请登录商户管理后台,在帐户信息-基本信息-安全信息中的支付密钥项
     $notifytype = "0";
     //0普通通知方式/1服务器通知方式,空值为普通通知方式
     $c_language = trim($payment['c_language']);
     //对启用了国际卡支付时,可使用该值定义消费者在银行支付时的页面语种,值为:0银行页面显示为中文/1银行页面显示为英文
     $srcStr = $c_mid . $c_order . $c_orderamount . $c_ymd . $c_moneytype . $c_retflag . $c_returl . $c_paygate . $c_memo1 . $c_memo2 . $notifytype . $c_language . $c_pass;
     //说明:如果您想指定支付方式(c_paygate)的值时,需要先让用户选择支付方式,然后再根据用户选择的结果在这里进行MD5加密,也就是说,此时,本页面应该拆分为两个页面,分为两个步骤完成。
     //--对订单信息进行MD5加密
     //商户对订单信息进行MD5签名后的字符串
     $c_signstr = md5($srcStr);
     $def_url = '<form name="payForm1" action="https://www.cncard.net/purchase/getorder.asp" method="POST" target="_blank">' . "<input type=\"hidden\" name=\"c_mid\" value=\"{$c_mid}\" />" . "<input type=\"hidden\" name=\"c_order\" value=\"{$c_order}\" />" . "<input type=\"hidden\" name=\"c_name\" value=\"{$c_name}\" />" . "<input type=\"hidden\" name=\"c_address\" value=\"{$c_address}\" />" . "<input type=\"hidden\" name=\"c_tel\" value=\"{$c_tel}\" />" . "<input type=\"hidden\" name=\"c_post\" value=\"{$c_post}\" />" . "<input type=\"hidden\" name=\"c_email\" value=\"{$c_email}\" />" . "<input type=\"hidden\" name=\"c_orderamount\" value=\"{$c_orderamount}\" />" . "<input type=\"hidden\" name=\"c_ymd\" value=\"{$c_ymd}\" />" . "<input type=\"hidden\" name=\"c_moneytype\" value=\"{$c_moneytype}\" />" . "<input type=\"hidden\" name=\"c_retflag\" value=\"{$c_retflag}\" />" . "<input type=\"hidden\" name=\"c_paygate\" value=\"{$c_paygate}\" />" . "<input type=\"hidden\" name=\"c_returl\" value=\"{$c_returl}\" />" . "<input type=\"hidden\" name=\"c_memo1\" value=\"{$c_memo1}\" />" . "<input type=\"hidden\" name=\"c_memo2\" value=\"{$c_memo2}\" />" . "<input type=\"hidden\" name=\"c_language\" value=\"{$c_language}\" />" . "<input type=\"hidden\" name=\"notifytype\" value=\"{$notifytype}\" />" . "<input type=\"hidden\" name=\"c_signstr\" value=\"{$c_signstr}\" />" . "<input type=\"submit\" name=\"submit\" value=\"" . $GLOBALS['_LANG']['cncard_button'] . "\" />" . "</form>";
     return $def_url;
 }
Example #29
0
 public function do_involved($cf_id, $type, $support, $user_id)
 {
     $find = $this->query("SELECT user_id FROM {$this->pre}crowdfunding_involved WHERE cf_id = {$cf_id} AND user_id = {$user_id} AND type = {$type}");
     if ($find) {
         return true;
     } else {
         $time = gmtime();
         $sql = "INSERT INTO {$this->pre}crowdfunding_involved (`involved_id`, `cf_id`, `user_id`, `type`, `time`, `status`) VALUES (NULL, '{$cf_id}', '{$user_id}', '{$type}', '{$time}', '{$support}'); ";
         return $this->query($sql);
     }
 }
Example #30
0
/**
 * 保存投票结果信息.
 *
 * @param int    $vote_id
 * @param string $ip_address
 * @param string $option_id
 */
function save_vote($vote_id, $ip_address, $option_id)
{
    $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('vote_log') . ' (vote_id, ip_address, vote_time) ' . "VALUES ('{$vote_id}', '{$ip_address}', " . gmtime() . ')';
    $res = $GLOBALS['db']->query($sql);
    /* 更新投票主题的数量 */
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('vote') . ' SET ' . 'vote_count = vote_count + 1 ' . "WHERE vote_id = '{$vote_id}'";
    $GLOBALS['db']->query($sql);
    /* 更新投票选项的数量 */
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('vote_option') . ' SET ' . 'option_count = option_count + 1 ' . 'WHERE ' . db_create_in($option_id, 'option_id');
    $GLOBALS['db']->query($sql);
}