public function dump()
 {
     $time = gmtTime();
     $name = empty($_REQUEST['sql_file_name']) ? toDate($time, 'YmdHis') : $_REQUEST['sql_file_name'];
     $tables = $this->getAllTable();
     $_SESSION['dump_table_data'] = array('file_dir' => $name, 'tables' => $tables, 'perfix' => C('DB_PREFIX'), 'time' => $time);
     $this->redirect('DataBase/dumptable');
 }
 public function order()
 {
     $goods_id = isset($_POST['goods_id']) && intval($_POST['goods_id']) ? $_POST['goods_id'] : 0;
     $uid = isset($_COOKIE['user']['id']) ? $_COOKIE['user']['id'] : '';
     $user_rel = $this->user_mod->where('id=' . $uid . '')->find();
     $ex_goods_mod = D('exchange_goods');
     $ex_goods_rel = $ex_goods_mod->where('id=' . $goods_id . '')->find();
     //		//查询order表里面,用户购买商品的次数
     $ex_order_mod = D('exchange_order');
     $info_data = array();
     $info_data['address'] = isset($_POST['address']) ? $_POST['address'] : '';
     $info_data['zip'] = isset($_POST['zip']) ? $_POST['zip'] : '';
     $info_data['consignee'] = isset($_POST['consignee']) ? $_POST['consignee'] : '';
     $info_data['mobile_phone'] = isset($_POST['mobile_phone']) ? $_POST['mobile_phone'] : '';
     $info_data['fax_phone'] = isset($_POST['fax_phone']) ? $_POST['fax_phone'] : '';
     $info_data['email'] = isset($_POST['email']) ? $_POST['email'] : '';
     $info_data['qq'] = isset($_POST['qq']) ? $_POST['qq'] : '';
     $info_data['create_time'] = time();
     $info_data['uid'] = $uid;
     //更新收货人表
     if (!empty($info_data['address'])) {
         $consignee_mod = D('user_consignee');
         //收货人
         $consignee_rel = $consignee_mod->where('uid=' . $uid . '')->find();
         if (count($consignee_rel) > 0) {
             //执行更新操作
             $consignee_mod->where('uid=' . $uid . '')->save($info_data);
         } else {
             $consignee_mod->add($info_data);
             //入库操作
         }
     }
     //订单表入库
     $info_data['remark'] = isset($_POST['remark']) ? $_POST['remark'] : '';
     $info_data['data_name'] = $ex_goods_rel['name'];
     $info_data['sn'] = gmtTime() . mt_rand(0, 1000);
     $info_data['goods_status'] = 0;
     $info_data['order_score'] = $ex_goods_rel['integral'];
     $info_data['data_num'] = 1;
     $info_data['user_name'] = $user_rel['name'];
     $info_data['goods_id'] = $goods_id;
     $info_data['create_time'] = time();
     $info_data['update_time'] = time();
     $ex_last_id = $ex_order_mod->add($info_data);
     //增加订单
     //更新exchange_goods 以及user_info表
     if ($ex_last_id) {
         $ex_goods_mod->where('id=' . $goods_id . '')->setInc('buy_count', 1);
         $this->user_info->where('uid=' . $uid . '')->setDec('integral', $info_data['order_score']);
         //更新用户兑换记录
         $user_info['exchange_num'] = $ex_order_mod->field('uid')->where('uid=' . $uid . '')->count();
         $this->user_info->where('uid=' . $uid . '')->save($user_info);
     }
     exit('success');
 }
Example #3
0
<?php

/**
 *
 * Time Server
 *
 */
function gmtTime()
{
    return gmdate("F, d Y H:i:s");
}
$server = new IXR_Server(array('time.getGMTTime' => gmtTime()));
 public function export()
 {
     $word_file = 'word.txt';
     $word_content = '';
     $words = D('Word')->where("status = 1")->findAll();
     foreach ($words as $word) {
         switch ($word['type']) {
             case 1:
                 $word_content .= $word['word'] . "|" . $word['type'] . "\n";
                 break;
             case 2:
                 $word_content .= $word['word'] . "|" . $word['type'] . "|" . $word['replacement'] . "\n";
                 break;
         }
     }
     $word_content = trim($word_content);
     $time = gmtTime();
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $time) . ' GMT');
     header('Cache-control: no-cache');
     header('Content-Encoding: none');
     header('Content-Disposition: attachment; filename="' . $word_file . '"');
     header('Content-type: txt');
     header('Content-Length: ' . strlen($word_content));
     echo $word_content;
     exit;
 }
Example #5
0
function tomorrow($tzOffset = 0)
{
    $localTime = gmtTime($tzOffset);
    //return date('Y-m-d', mktime(0, 0, 0, date("m")  , date("d")+1, date("Y")));
    return date('Y-m-d', mktime(0, 0, 0, date("m", gmtTime($tzOffset)), date("d", gmtTime($tzOffset)) + 1, date("Y", gmtTime($tzOffset))));
}
Example #6
0
function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0)
{
    $ckey_length = 4;
    $key = md5($key ? $key : UC_KEY);
    $keya = md5(substr($key, 0, 16));
    $keyb = md5(substr($key, 16, 16));
    $keyc = $ckey_length ? $operation == 'DECODE' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length) : '';
    $cryptkey = $keya . md5($keya . $keyc);
    $key_length = strlen($cryptkey);
    $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + gmtTime() : 0) . substr(md5($string . $keyb), 0, 16) . $string;
    $string_length = strlen($string);
    $result = '';
    $box = range(0, 255);
    $rndkey = array();
    for ($i = 0; $i <= 255; $i++) {
        $rndkey[$i] = ord($cryptkey[$i % $key_length]);
    }
    for ($j = $i = 0; $i < 256; $i++) {
        $j = ($j + $box[$i] + $rndkey[$i]) % 256;
        $tmp = $box[$i];
        $box[$i] = $box[$j];
        $box[$j] = $tmp;
    }
    for ($a = $j = $i = 0; $i < $string_length; $i++) {
        $a = ($a + 1) % 256;
        $j = ($j + $box[$a]) % 256;
        $tmp = $box[$a];
        $box[$a] = $box[$j];
        $box[$j] = $tmp;
        $result .= chr(ord($string[$i]) ^ $box[($box[$a] + $box[$j]) % 256]);
    }
    if ($operation == 'DECODE') {
        if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) {
            return substr($result, 26);
        } else {
            return '';
        }
    } else {
        return $keyc . str_replace('=', '', base64_encode($result));
    }
}
 /**
 +----------------------------------------------------------
 * 获取子目录的名称
 +----------------------------------------------------------
 * @access private
 +----------------------------------------------------------
 * @param array $file  上传的文件信息
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 private function getSubName($file)
 {
     switch ($this->subType) {
         case 'date':
             $dir = toDate(gmtTime(), $this->dateFormat);
             break;
         case 'hash':
         default:
             $name = md5($file['savename']);
             $dir = '';
             for ($i = 0; $i < $this->hashLevel; $i++) {
                 $dir .= $name[0] . '/';
             }
             break;
     }
     if (!is_dir($file['savepath'] . $dir)) {
         mk_dir($file['savepath'] . $dir);
     }
     return $dir;
 }
 /**
      +----------------------------------------------------------
 * 登录检测
      +----------------------------------------------------------
 */
 public function checkLogin()
 {
     if (empty($_POST['admin_name'])) {
         $this->error(L('ADMIN_NAME_REQUIRE'));
     } elseif (empty($_POST['admin_pwd'])) {
         $this->error(L('ADMIN_PWD_REQUIRE'));
     } elseif (empty($_POST['verify'])) {
         $this->error(L('VERIFY_REQUIRE'));
     }
     //生成认证条件
     $map = array();
     // 支持使用绑定帐号登录
     $map['admin_name'] = $_POST['admin_name'];
     $map["status"] = array('gt', 0);
     if ($_SESSION['verify'] != md5($_POST['verify'])) {
         $this->error(L('VERIFY_ERROR'));
     }
     import('@.ORG.RBAC');
     $auth_info = RBAC::authenticate($map);
     //使用用户名、密码和状态的方式进行认证
     if (false === $auth_info) {
         $this->saveLog(0, 0);
         $this->error(L('ADMIN_NAME_NOT_EXIST'));
     } else {
         if ($auth_info['admin_pwd'] != md5($_POST['admin_pwd'])) {
             $this->saveLog(0, 0);
             $this->error(L('ADMIN_PWD_ERROR'));
         }
         Session::setExpire(time() + fanweC("EXPIRED_TIME") * 60);
         $_SESSION[C('USER_AUTH_KEY')] = $auth_info['id'];
         $_SESSION['admin_name'] = $auth_info['admin_name'];
         $_SESSION['last_time'] = $auth_info['last_time'];
         $_SESSION['login_count'] = $auth_info['login_count'];
         if ($auth_info['admin_name'] == fanweC('SYS_ADMIN')) {
             $_SESSION[C('ADMIN_AUTH_KEY')] = true;
         }
         //保存登录信息
         $admin = M(C('USER_AUTH_MODEL'));
         $ip = getClientIp();
         $time = gmtTime();
         $data = array();
         $data['id'] = $auth_info['id'];
         $data['last_login_time'] = $time;
         $data['login_count'] = array('exp', 'login_count + 1');
         $data['last_login_ip'] = $ip;
         $admin->save($data);
         // 缓存访问权限
         RBAC::saveAccessList();
         $this->saveLog(1, 0);
         $this->success(L('LOGIN_SUCCESS'));
     }
 }
Example #9
0
 protected function saveLog($result = '1', $data_id = 0, $msg = '')
 {
     if (fanweC("APP_LOG") == 0) {
         return;
     }
     $log_app = unserialize(fanweC("LOG_APP"));
     $log_module = MODULE_NAME;
     $log_action = ACTION_NAME;
     if (in_array(strtolower($log_action), $log_app[strtolower($log_module)])) {
         $log_data = array();
         $log_data['log_module'] = $log_module;
         $log_data['log_action'] = $log_action;
         if (!$data_id) {
             $pk = M(MODULE_NAME)->getPk();
             $data_id = intval($_REQUEST[$pk]);
         }
         $log_data['data_id'] = $data_id;
         $log_data['log_time'] = gmtTime();
         $log_data['admin_id'] = intval($_SESSION[C("USER_AUTH_KEY")]);
         $log_data['ip'] = getClientIp();
         $log_data['log_result'] = $result;
         $log_data['log_msg'] = $msg;
         $log_data['log_request'] = print_r($_REQUEST, true);
         D("AdminLog")->add($log_data);
     }
 }
 public function updateSend()
 {
     $mid = intval($_REQUEST['mid']);
     $msg = array();
     $msg['title'] = trim($_REQUEST['title']);
     $msg['message'] = trim($_REQUEST['message']);
     $msg['create_time'] = gmtTime();
     $end_time = trim($_REQUEST['end_time']);
     if (empty($end_time)) {
         $msg['end_time'] = 0;
     } else {
         $msg['end_time'] = strZTime($end_time);
     }
     D('SysMsg')->where("mid = '{$mid}'")->save($msg);
     D('SysMsgUserGroup')->where("mid = '{$mid}'")->delete();
     $user_group = trim($_REQUEST['user_group']);
     if (!empty($user_group)) {
         $user_group = explode(',', $user_group);
         foreach ($user_group as $gid) {
             $data = array();
             $data['mid'] = $mid;
             $data['gid'] = $gid;
             D('SysMsgUserGroup')->add($data);
         }
     }
     D('SysMsgUserYes')->where("mid = '{$mid}'")->delete();
     $user_yes = trim($_REQUEST['user_yes']);
     if (!empty($user_yes)) {
         $user_yes = explode(',', $user_yes);
         $user_yes = array_unique($user_yes);
         foreach ($user_yes as $uname) {
             $data = array();
             $data['mid'] = $mid;
             $data['uid'] = D('User')->where("user_name = '{$uname}'")->getField('uid');
             if ($data['uid'] > 0) {
                 D('SysMsgUserYes')->add($data);
             }
         }
     }
     D('SysMsgUserNo')->where("mid = '{$mid}'")->delete();
     $user_no = trim($_REQUEST['user_no']);
     if (!empty($user_no)) {
         $user_no = explode(',', $user_no);
         $user_no = array_unique($user_no);
         foreach ($user_no as $uname) {
             $data = array();
             $data['mid'] = $mid;
             $data['uid'] = D('User')->where("user_name = '{$uname}'")->getField('uid');
             if ($data['uid'] > 0) {
                 D('SysMsgUserNo')->add($data);
             }
         }
     }
     $this->assign('jumpUrl', U('UserMsg/groupList'));
     $this->success(L('EDIT_SUCCESS'));
 }
Example #11
0
 public function insert()
 {
     $_POST['create_time'] = gmtTime();
     $_POST['status'] = 1;
     parent::insert();
 }