Exemplo n.º 1
0
    $data .= "\n";
    foreach ($pay_res as $val) {
        $data .= $val['order_num'] . "\t";
    }
    /* 配送方式 */
    $sql = 'SELECT sp.shipping_id, sp.shipping_name AS ship_name, COUNT(i.order_id) AS order_num ' . 'FROM ' . $hhs->table('shipping') . ' AS sp, ' . $hhs->table('order_info') . ' AS i ' . 'WHERE sp.shipping_id = i.shipping_id ' . order_query_sql('finished') . "AND i.add_time >= '{$start_date}' AND i.add_time <= '{$end_date}' " . "GROUP BY i.shipping_id ORDER BY order_num DESC";
    $ship_res = $db->getAll($sql);
    $data .= "\n{$_LANG['shipping_method']}\n";
    foreach ($ship_res as $val) {
        $data .= $val['ship_name'] . "\t";
    }
    $data .= "\n";
    foreach ($ship_res as $val) {
        $data .= $val['order_num'] . "\t";
    }
    echo hhs_iconv(EC_CHARSET, 'GB2312', $data) . "\t";
    exit;
}
/*------------------------------------------------------ */
//--订单统计需要的函数
/*------------------------------------------------------ */
/**
 * 取得订单概况数据(包括订单的几种状态)
 * @param       $start_date    开始查询的日期
 * @param       $end_date      查询的结束日期
 * @return      $order_info    订单概况数据
 */
function get_orderinfo($start_date, $end_date)
{
    $order_info = array();
    /* 未确认订单数 */
Exemplo n.º 2
0
    $smarty->assign('data_count_name', $_LANG['order_count_trend']);
    $smarty->assign('data_amount_name', $_LANG['order_amount_trend']);
    /* 根据查询类型生成文件名 */
    if ($query_type == 'year') {
        $filename = date('Y', $start_time) . "_" . date('Y', $end_time) . '_report';
    } else {
        $filename = date('Ym', $start_time) . "_" . date('Ym', $end_time) . '_report';
    }
    $smarty->assign('action_link', array('text' => $_LANG['down_sales_stats'], 'href' => 'sale_general.php?act=download&filename=' . $filename . '&query_type=' . $query_type . '&start_time=' . $start_time . '&end_time=' . $end_time));
    /* 显示模板 */
    $smarty->assign('ur_here', $_LANG['report_sell']);
    assign_query_info();
    $smarty->display('sale_general.htm');
} elseif ($_REQUEST['act'] == 'download') {
    /* 文件名 */
    $filename = !empty($_REQUEST['filename']) ? trim($_REQUEST['filename']) : '';
    header("Content-type: application/vnd.ms-excel; charset=utf-8");
    header("Content-Disposition: attachment; filename={$filename}.xls");
    /* 文件标题 */
    echo hhs_iconv(EC_CHARSET, 'GB2312', $filename . $_LANG['sales_statistics']) . "\t\n";
    /* 订单数量, 销售出商品数量, 销售金额 */
    echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['period']) . "\t";
    echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_count_trend']) . "\t";
    echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_amount_trend']) . "\t\n";
    foreach ($data_list as $data) {
        echo hhs_iconv(EC_CHARSET, 'GB2312', $data['period']) . "\t";
        echo hhs_iconv(EC_CHARSET, 'GB2312', $data['order_count']) . "\t";
        echo hhs_iconv(EC_CHARSET, 'GB2312', $data['order_amount']) . "\t";
        echo "\n";
    }
}
Exemplo n.º 3
0
 function fsockRequest($url, $method, $postfields = NULL, $headers = array())
 {
     $urlarr = parse_url($url);
     $errno = '';
     $errstr = '';
     $transports = '';
     $responseText = '';
     if ($urlarr['scheme'] == 'https') {
         $transports = 'ssl://';
         $urlarr['port'] = '443';
     } else {
         $transports = 'tcp://';
         $urlarr['port'] = '80';
     }
     $fp = @fsockopen($transports . $urlarr['host'], $urlarr['port'], $errno, $errstr, $this->timeout);
     if (!$fp) {
         die("ERROR: {$errno} - " . hhs_iconv('GBK', 'UTF8', $errstr) . "<br />\r\n");
         return false;
     } else {
         if (!empty($urlarr['query'])) {
             $urlarr['path'] .= '?' . $urlarr['query'];
         }
         $urlarr['method'] = $method;
         //print_r($urlarr);
         $header = $method . ' ' . $urlarr['path'] . " HTTP/1.1\r\n";
         //fputs($fp, $method.' '. $urlarr['path'] ." HTTP/1.1\r\n");
         //fputs($fp, "Referer: " . $url ."\r\n");
         if ($method == 'POST') {
             $header .= "Content-type: application/x-www-form-urlencoded\r\n";
             $header .= "Content-length: " . strlen($postfields) . "\r\n";
         }
         $header .= "Host: " . $urlarr['host'] . "\r\n";
         $header .= "Connection: close\r\n\r\n";
         fputs($fp, $header);
         if ($method == 'POST') {
             fputs($fp, $postfields . "\r\n\r\n");
         }
         while (!feof($fp)) {
             $responseText .= @fgets($fp, 1024);
         }
         fclose($fp);
         $len = 0;
         $pos = strpos($responseText, 'Content-Length:');
         if ($pos > 0) {
             $pos += 15;
             $len = intval(substr($responseText, $pos, stripos($responseText, "\r\n", $pos) - $pos));
         }
         $responseText = trim(stristr($responseText, "\r\n\r\n"), "\r\n");
         if ($len > 0) {
             if (strlen($responseText) != $len) {
                 $nowH = substr($responseText, 0, strpos($responseText, "\r\n"));
                 if (strlen($responseText) - strlen($nowH) + 2 == $len) {
                     $responseText = substr($responseText, strpos($responseText, "\r\n") + 2);
                 }
             }
         } else {
             $responseText = trim(substr($responseText, strpos($responseText, "\r\n") + 2), "\r\n");
             $responseText = substr($responseText, 0, strrpos($responseText, "\r\n"));
         }
         return $responseText;
     }
 }
Exemplo n.º 4
0
             }
         } else {
             $user_db_charset = $_POST['cfg']['db_charset'] == 'GB2312' ? 'GBK' : $_POST['cfg']['db_charset'];
             if (!empty($_POST['cfg']['is_latin1'])) {
                 sys_msg($_LANG['error_not_latin1'], null, null, false);
             }
             if ($user_db_charset != strtoupper($db_charset)) {
                 sys_msg(sprintf($_LANG['invalid_db_charset'], strtoupper($db_charset), $user_db_charset), null, null, false);
             }
         }
     }
 }
 /* 中文检测 */
 $test_str = '测试中文字符';
 if ($_POST['cfg']['db_charset'] != 'UTF8') {
     $test_str = hhs_iconv('UTF8', $_POST['cfg']['db_charset']);
 }
 $sql = "SELECT " . $cls_user->field_name . " FROM " . $cls_user->table($cls_user->user_table) . " WHERE " . $cls_user->field_name . " = '{$test_str}'";
 $test = $cls_user->db->query($sql, 'SILENT');
 if (!$test) {
     sys_msg($_LANG['error_latin1'], null, null, false);
 }
 if (!empty($_POST['save'])) {
     /* 直接保存修改 */
     if (save_integrate_config($code, $_POST['cfg'])) {
         sys_msg($_LANG['save_ok'], 0, array(array('text' => $_LANG['06_list_integrate'], 'href' => 'integrate.php?act=list')));
     } else {
         sys_msg($_LANG['save_error'], 0, array(array('text' => $_LANG['06_list_integrate'], 'href' => 'integrate.php?act=list')));
     }
 }
 $sql = "SELECT COUNT(*) FROM " . $hhs->table('users');
Exemplo n.º 5
0
 }
 $pos = strrpos($file["name"], ".");
 $ext = substr($file["name"], $pos + 1);
 if ($ext != 'csv') {
     $links[] = array('text' => '重新上传', 'href' => 'order.php?act=import');
     sys_msg("请使用csv格式的文件", 1, $links);
 }
 $filename = $file['name'];
 $newpath = $file['tmp_name'];
 /*
         $field="(order_id,total_fee,team_sign,order_sn,team_first,formated_pay_time,goods_sn
         ,province,city,district,address,mobile,consignee,formated_add_time,
         shipping_id,shipping_name,invoice_no)";*/
 if (is_file($newpath)) {
     $tmp = file_get_contents($newpath);
     $tmp = hhs_iconv('gb2310', EC_CHARSET, $tmp);
     $list = explode("\n", $tmp);
     unset($list[0]);
     $total_num = 0;
     foreach ($list as $k => $v) {
         $t = explode(',', $v);
         foreach ($t as $k1 => $v1) {
             //$t[$k1]=preg_replace("/\"/",'',$v1);
             $t[$k1] = $v1 = str_replace("\"", "", $v1);
             $t[$k1] = $v1 = str_replace("'", "", $v1);
             $t[$k1] = $v1 = trim($v1);
         }
         $list[$k] = $t;
         if (empty($t[0])) {
             unset($list[$k]);
             continue;
Exemplo n.º 6
0
 /**
  *  检查指定用户是否存在及密码是否正确(重载基类check_user函数,支持zc加密方法)
  *
  * @access  public
  * @param   string  $username   用户名
  *
  * @return  int
  */
 function check_user($username, $password = null)
 {
     if ($this->charset != 'UTF8') {
         $post_username = hhs_iconv('UTF8', $this->charset, $username);
     } else {
         $post_username = $username;
     }
     if ($password === null) {
         $sql = "SELECT " . $this->field_id . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='" . $post_username . "'";
         return $this->db->getOne($sql);
     } else {
         $sql = "SELECT user_id, password, salt,ec_salt " . " FROM " . $this->table($this->user_table) . " WHERE user_name='{$post_username}'";
         $row = $this->db->getRow($sql);
         $ec_salt = $row['ec_salt'];
         if (empty($row)) {
             return 0;
         }
         if (empty($row['salt'])) {
             if ($row['password'] != $this->compile_password(array('password' => $password, 'ec_salt' => $ec_salt))) {
                 return 0;
             } else {
                 if (empty($ec_salt)) {
                     $ec_salt = rand(1, 9999);
                     $new_password = md5(md5($password) . $ec_salt);
                     $sql = "UPDATE " . $this->table($this->user_table) . "SET password= '" . $new_password . "',ec_salt='" . $ec_salt . "'" . " WHERE user_name='{$post_username}'";
                     $this->db->query($sql);
                 }
                 return $row['user_id'];
             }
         } else {
             /* 如果salt存在,使用salt方式加密验证,验证通过洗白用户密码 */
             $encrypt_type = substr($row['salt'], 0, 1);
             $encrypt_salt = substr($row['salt'], 1);
             /* 计算加密后密码 */
             $encrypt_password = '';
             switch ($encrypt_type) {
                 case ENCRYPT_ZC:
                     $encrypt_password = md5($encrypt_salt . $password);
                     break;
                     /* 如果还有其他加密方式添加到这里  */
                     //case other :
                     //  ----------------------------------
                     //  break;
                 /* 如果还有其他加密方式添加到这里  */
                 //case other :
                 //  ----------------------------------
                 //  break;
                 case ENCRYPT_UC:
                     $encrypt_password = md5(md5($password) . $encrypt_salt);
                     break;
                 default:
                     $encrypt_password = '';
             }
             if ($row['password'] != $encrypt_password) {
                 return 0;
             }
             $sql = "UPDATE " . $this->table($this->user_table) . " SET password = '" . $this->compile_password(array('password' => $password)) . "', salt=''" . " WHERE user_id = '{$row['user_id']}'";
             $this->db->query($sql);
             return $row['user_id'];
         }
     }
 }
Exemplo n.º 7
0
        header("Content-type: application/vnd.ms-excel; charset=utf-8");
        header("Content-Disposition: attachment; filename={$file_name}.xls");
        /* 文件标题 */
        echo hhs_iconv(EC_CHARSET, 'GB2312', $_REQUEST['start_date'] . $_LANG['to'] . $_REQUEST['end_date'] . $_LANG['sales_list']) . "\t\n";
        /* 商品名称,订单号,商品数量,销售价格,销售日期 */
        echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['goods_name']) . "\t";
        echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_sn']) . "\t";
        echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['amount']) . "\t";
        echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['sell_price']) . "\t";
        echo hhs_iconv(EC_CHARSET, 'GB2312', $_LANG['sell_date']) . "\t\n";
        foreach ($goods_sales_list['sale_list_data'] as $key => $value) {
            echo hhs_iconv(EC_CHARSET, 'GB2312', $value['goods_name']) . "\t";
            echo hhs_iconv(EC_CHARSET, 'GB2312', '[ ' . $value['order_sn'] . ' ]') . "\t";
            echo hhs_iconv(EC_CHARSET, 'GB2312', $value['goods_num']) . "\t";
            echo hhs_iconv(EC_CHARSET, 'GB2312', $value['sales_price']) . "\t";
            echo hhs_iconv(EC_CHARSET, 'GB2312', $value['sales_time']) . "\t";
            echo "\n";
        }
        exit;
    }
    $sale_list_data = get_sale_list();
    $smarty->assign('goods_sales_list', $sale_list_data['sale_list_data']);
    $smarty->assign('filter', $sale_list_data['filter']);
    $smarty->assign('record_count', $sale_list_data['record_count']);
    $smarty->assign('page_count', $sale_list_data['page_count']);
    make_json_result($smarty->fetch('sale_list.htm'), '', array('filter' => $sale_list_data['filter'], 'page_count' => $sale_list_data['page_count']));
} else {
    /* 权限判断 */
    admin_priv('sale_order_stats');
    /* 时间参数 */
    if (!isset($_REQUEST['start_date'])) {
Exemplo n.º 8
0
/**
 * 保存搜索引擎关键字
 *
 * @access  public
 * @return  void
 */
function save_searchengine_keyword($domain, $path)
{
    if (strpos($domain, 'google.com.tw') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'GOOGLE TAIWAN';
        $keywords = urldecode($regs[1]);
        // google taiwan
    }
    if (strpos($domain, 'google.cn') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'GOOGLE CHINA';
        $keywords = urldecode($regs[1]);
        // google china
    }
    if (strpos($domain, 'google.com') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'GOOGLE';
        $keywords = urldecode($regs[1]);
        // google
    } elseif (strpos($domain, 'baidu.') !== false && preg_match('/wd=([^&]*)/i', $path, $regs)) {
        $searchengine = 'BAIDU';
        $keywords = urldecode($regs[1]);
        // baidu
    } elseif (strpos($domain, 'baidu.') !== false && preg_match('/word=([^&]*)/i', $path, $regs)) {
        $searchengine = 'BAIDU';
        $keywords = urldecode($regs[1]);
        // baidu
    } elseif (strpos($domain, '114.vnet.cn') !== false && preg_match('/kw=([^&]*)/i', $path, $regs)) {
        $searchengine = 'CT114';
        $keywords = urldecode($regs[1]);
        // ct114
    } elseif (strpos($domain, 'iask.com') !== false && preg_match('/k=([^&]*)/i', $path, $regs)) {
        $searchengine = 'IASK';
        $keywords = urldecode($regs[1]);
        // iask
    } elseif (strpos($domain, 'soso.com') !== false && preg_match('/w=([^&]*)/i', $path, $regs)) {
        $searchengine = 'SOSO';
        $keywords = urldecode($regs[1]);
        // soso
    } elseif (strpos($domain, 'sogou.com') !== false && preg_match('/query=([^&]*)/i', $path, $regs)) {
        $searchengine = 'SOGOU';
        $keywords = urldecode($regs[1]);
        // sogou
    } elseif (strpos($domain, 'so.163.com') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'NETEASE';
        $keywords = urldecode($regs[1]);
        // netease
    } elseif (strpos($domain, 'yodao.com') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'YODAO';
        $keywords = urldecode($regs[1]);
        // yodao
    } elseif (strpos($domain, 'zhongsou.com') !== false && preg_match('/word=([^&]*)/i', $path, $regs)) {
        $searchengine = 'ZHONGSOU';
        $keywords = urldecode($regs[1]);
        // zhongsou
    } elseif (strpos($domain, 'search.tom.com') !== false && preg_match('/w=([^&]*)/i', $path, $regs)) {
        $searchengine = 'TOM';
        $keywords = urldecode($regs[1]);
        // tom
    } elseif (strpos($domain, 'live.com') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'MSLIVE';
        $keywords = urldecode($regs[1]);
        // MSLIVE
    } elseif (strpos($domain, 'tw.search.yahoo.com') !== false && preg_match('/p=([^&]*)/i', $path, $regs)) {
        $searchengine = 'YAHOO TAIWAN';
        $keywords = urldecode($regs[1]);
        // yahoo taiwan
    } elseif (strpos($domain, 'cn.yahoo.') !== false && preg_match('/p=([^&]*)/i', $path, $regs)) {
        $searchengine = 'YAHOO CHINA';
        $keywords = urldecode($regs[1]);
        // yahoo china
    } elseif (strpos($domain, 'yahoo.') !== false && preg_match('/p=([^&]*)/i', $path, $regs)) {
        $searchengine = 'YAHOO';
        $keywords = urldecode($regs[1]);
        // yahoo
    } elseif (strpos($domain, 'msn.com.tw') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'MSN TAIWAN';
        $keywords = urldecode($regs[1]);
        // msn taiwan
    } elseif (strpos($domain, 'msn.com.cn') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'MSN CHINA';
        $keywords = urldecode($regs[1]);
        // msn china
    } elseif (strpos($domain, 'msn.com') !== false && preg_match('/q=([^&]*)/i', $path, $regs)) {
        $searchengine = 'MSN';
        $keywords = urldecode($regs[1]);
        // msn
    }
    if (!empty($keywords)) {
        $gb_search = array('YAHOO CHINA', 'TOM', 'ZHONGSOU', 'NETEASE', 'SOGOU', 'SOSO', 'IASK', 'CT114', 'BAIDU');
        if (EC_CHARSET == 'utf-8' && in_array($searchengine, $gb_search)) {
            $keywords = hhs_iconv('GBK', 'UTF8', $keywords);
        }
        if (EC_CHARSET == 'gbk' && !in_array($searchengine, $gb_search)) {
            $keywords = hhs_iconv('UTF8', 'GBK', $keywords);
        }
        $GLOBALS['db']->autoReplace($GLOBALS['hhs']->table('keywords'), array('date' => local_date('Y-m-d'), 'searchengine' => $searchengine, 'keyword' => addslashes($keywords), 'count' => 1), array('count' => 1));
    }
}