示例#1
0
    public function add()
    {
        global $mysql, $langArray, $languageURL, $config, $meta;
        //昵称
        if (!isset($_POST['nickname']) || trim($_POST['nickname']) == '') {
            $error['nickname'] = $langArray['error_fill_nickname'];
        } elseif (!preg_match("/^[\\x{4e00}-\\x{9fa5}A-Za-z0-9_]{2,15}\$/u", $_POST['nickname'])) {
            $error['nickname'] = $langArray['error_not_valid_nickname'];
        }
        if (!isset($_POST['email']) || trim($_POST['email']) == '') {
            $error['email'] = $langArray['error_fill_email'];
        } elseif (!check_email($_POST['email'])) {
            $error['email'] = $langArray['error_not_valid_email'];
        } elseif ($this->isExistEmail($_POST['email'])) {
            $error['email'] = $langArray['error_exist_email'];
        }
        //if(!isset($_POST['email_confirm']) || trim($_POST['email_confirm']) == '') {
        //	$error['email_confirm'] = $langArray['error_fill_email_confirm'];
        //}
        //if(isset($_POST['email']) && isset($_POST['email_confirm']) && $_POST['email'] !== $_POST['email_confirm']) {
        //	$error['email_confirm'] = $langArray['error_emails_not_match'];
        //}
        //取消邮箱确认和不符报错
        if (!isset($_POST['username']) || trim($_POST['username']) == '') {
            $error['username'] = $langArray['error_not_set_username'];
        } elseif (!preg_match("/^[A-Za-z0-9_]{4,15}\$/u", $_POST['username'])) {
            $error['username'] = $langArray['error_not_valid_username'];
        } elseif ($this->isExistUsername($_POST['username'])) {
            $error['username'] = $langArray['error_exist_username'];
        }
        //验证码验证
        if (isset($_POST['verify'])) {
            if (empty($_POST['verify'])) {
                $error['verify'] = $langArray['error_verify_invalid_empty'];
            }
            require_once ROOT_PATH . '/classes/Verify.class.php';
            $verify = new Verify();
            $yz_verify = $verify->check($_POST['verify'], 1);
            if (!$yz_verify) {
                $error['verify'] = $langArray['error_invalid_verify'];
            }
        } else {
            return 'error_verify_invalid_empty';
        }
        if (!isset($_POST['password']) || trim($_POST['password']) == '') {
            $error['password'] = $langArray['error_fill_password'];
        }
        if (!isset($_POST['password_confirm']) || trim($_POST['password_confirm']) == '') {
            $error['password_confirm'] = $langArray['error_fill_password_confirm'];
        } elseif (isset($_POST['password']) && isset($_POST['password_confirm']) && $_POST['password'] !== $_POST['password_confirm']) {
            $error['password_confirm'] = $langArray['error_password_not_match'];
        }
        if (!isset($_POST['terms'])) {
            $error['terms'] = $langArray['error_not_agree_with_terms'];
        }
        if (isset($error)) {
            return $error;
        }
        if (!isset($_POST['status'])) {
            $_POST['status'] = 'waiting';
        }
        $groups = array();
        if (isset($_POST['groups']) && is_array($_POST['groups'])) {
            foreach ($_POST['groups'] as $k => $v) {
                $groups[$k] = $v;
            }
        }
        $activationKey = md5(rand(0, 10000) . date('HisdmY') . rand(0, 10000));
        $referalID = 0;
        if (isset($_SESSION['temp']['referal'])) {
            if ($this->isExistUsername($_SESSION['temp']['referal'])) {
                //推荐用户存在 返回用户ID
                $referalID = $mysql->fetch_array();
                $referalID = $referalID['user_id'];
            }
            unset($_SESSION['temp']['referal']);
        }
        //创建用户
        $mysql->query("\n\t\t\tINSERT INTO `users` (\n\t\t\t\t`username`,\n\t\t\t\t`password`,\n\t\t\t\t`email`,\n\t\t\t\t`nickname`,\n\t\t\t\t`register_datetime`,\n\t\t\t\t`status`,\n\t\t\t\t`groups`,\n\t\t\t\t`activate_key`,\n\t\t\t\t`referal_id`\t\t\t\t\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . sql_quote($_POST['username']) . "',\n\t\t\t\t'" . md5(md5($_POST['password'])) . "',\n\t\t\t\t'" . sql_quote($_POST['email']) . "',\n\t\t\t\t'" . sql_quote($_POST['nickname']) . "',\n\t\t\t\tNOW(),\n\t\t\t\t'" . sql_quote($_POST['status']) . "',\n\t\t\t\t'" . serialize($groups) . "',\n\t\t\t\t'" . sql_quote($activationKey) . "',\n\t\t\t\t'" . intval($referalID) . "'\n\t\t\t)\n\t\t", __FUNCTION__);
        //用户推荐人数 +1
        if ($referalID != 0) {
            $mysql->query("\n\t\t\t\tUPDATE `users`\n\t\t\t\tSET `referals` = `referals` + 1\n\t\t\t\tWHERE `user_id` = '" . intval($referalID) . "'\n\t\t\t\tLIMIT 1\n\t\t\t");
        }
        #添加邮件订阅
        if (isset($_POST['subscribed'])) {
            require_once ROOT_PATH . '/apps/bulletin/models/bulletin.class.php';
            $bulletinClass = new bulletin();
            $bulletinClass->addBulletinEmail();
        }
        //判断有无客服功能
        $have_service = false;
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/apps/service/controllers/index.php')) {
            //判断启动状态
            require_once ROOT_PATH . '/apps/app_extends/models/app_extends.class.php';
            $app_extends = new app_extends();
            $is_open = $app_extends->getStatus("客户服务管理");
            if ($is_open) {
                $have_service = true;
            }
        }
        $user_info = $this->get_user_info_by_pn($_POST['username'], $_POST['password']);
        if (!$have_service) {
            #发送激活链接
            require_once ENGINE_PATH . '/classes/email.class.php';
            $emailClass = new email();
            $emailClass->fromEmail = 'no-reply@' . $config['domain'];
            $emailClass->subject = '[' . $config['domain'] . '] ' . $langArray['email_activate_subject'];
            $emailClass->message = langMessageReplace($langArray['email_activate_text'], array('DOMAIN' => $config['domain'], 'LINK' => 'http://' . $config['domain'] . '/' . $languageURL . 'sign_in/?command=activate&user='******'username'] . '&key=' . $activationKey));
            require_once ROOT_PATH . '/apps/system/models/system.class.php';
            $system = new system();
            $smtp = $system->is_smtp();
            $smtpconf = $system->getAllKeyValue();
            if ($smtp) {
                $emailClass->email_sock($smtpconf["smtp_host"], $smtpconf["smtp_port"], 0, 'error', 10, 1, $smtpconf["smtp_user"], $smtpconf["smtp_pass"], $smtpconf["smtp_from"]);
                $emailClass->send_mail_sock($emailClass->subject, $emailClass->message, $user_info['email'], $smtpconf["smtp_from_name"]);
                unset($emailClass);
            } else {
                $emailClass->to($_POST['email']);
                $emailClass->send();
                unset($emailClass);
            }
        } else {
            #SEND ACTIVATION LINK
            require_once ENGINE_PATH . '/classes/email.class.php';
            $mail = new email();
            //获取本次收通知邮件客服邮箱
            $where = "WHERE `status`='true' AND `service_status`=1";
            $order = "time ASC";
            $limitQuery = "LIMIT 1";
            $mysql->query("\n\t\t\t\tSELECT SQL_CALC_FOUND_ROWS *\n\t\t\t\tFROM `service`\n\t\t\t\t{$where}\n\t\t\t\tORDER BY {$order}\n\t\t\t\t{$limitQuery}\n\t\t\t");
            if ($mysql->num_rows() == 0) {
                $mysql->query("\n\t\t\t\tUPDATE `service`\n\t\t\t\tSET `service_status` = '" . intval(1) . "'\n\t\t\t", __FUNCTION__);
                $mysql->query("\n\t\t\t\tSELECT SQL_CALC_FOUND_ROWS *\n\t\t\t\tFROM `service`\n\t\t\t\t{$where}\n\t\t\t\tORDER BY {$order}\n\t\t\t\t{$limitQuery}\n\t\t\t");
            }
            $theservice = $mysql->fetch_array();
            $sendtext = '用户名:' . $_POST['username'] . '<br />昵称:' . $_POST['nickname'] . '<br />邮箱:' . $_POST['email'] . '<br />手机号:' . $_POST['username'];
            $mail->to($theservice['email']);
            $mail->fromEmail = 'no-reply@' . $config['domain'];
            $mail->contentType = 'text/html';
            $mail->subject = $langArray['email_new_add_user'] . ' ' . '用户ID:' . $user_info['user_id'];
            $mail->message = $sendtext;
            $mail->send();
            unset($mail);
            //分配用户给客服
            $mysql->query("\n\t\t\tINSERT INTO `service_relation` (\n\t\t\t\t`user_id`,\n\t\t\t\t`service_user_id`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . intval($user_info['user_id']) . "',\n\t\t\t\t'" . intval($theservice['id']) . "'\n\t\t\t)\n\t\t", __FUNCTION__);
            //刷新用户服务数量
            $mysql->query("\n\t\t\t\tUPDATE `service`\n\t\t\t\tSET `service_num` = `service_num` + 1,\n\t\t\t\t`service_status` = '" . intval(0) . "'\n\t\t\t\tWHERE `id` = '" . intval($theservice['id']) . "'\n\t\t\t\tLIMIT 1\n\t\t");
            $emailClass = new email();
            $link = 'http://' . $config['domain'] . '/' . $languageURL . 'sign_in/?command=activate&user='******'username'] . '&key=' . $activationKey;
            $link = '<a href="' . $link . '" target="_blank">' . $link . '</a>';
            $emailClass->contentType = 'text/html';
            $emailClass->fromEmail = 'no-reply@' . $config['domain'];
            $emailClass->subject = '[' . $meta['meta_title'] . ']发给[' . $_POST['nickname'] . ']的注册激活邮件';
            $emailClass->message = 'Hi![' . $_POST['nickname'] . ']:<br />
								&nbsp;&nbsp;&nbsp;&nbsp;幸亏没放弃,终于等到你!想给你写信已经很久了!<br />
								&nbsp;&nbsp;&nbsp;&nbsp;这是你的登录信息,激活前处于挂起状态:<br />
								&nbsp;&nbsp;&nbsp;&nbsp;帐号:[' . $_POST['username'] . ']<br />
								&nbsp;&nbsp;&nbsp;&nbsp;密码:*********<br />
								&nbsp;&nbsp;&nbsp;&nbsp;这是你的激活连接,小编在等候你的回应:<br />
								&nbsp;&nbsp;&nbsp;&nbsp;' . $link . '<br />
								&nbsp;&nbsp;&nbsp;&nbsp;速速点击上面的激活链接来启用它们!<br />
								&nbsp;&nbsp;&nbsp;&nbsp;小编已经等不及啦!<br />
                                <br />
								&nbsp;&nbsp;&nbsp;&nbsp;专属小编:[' . $theservice['user_name'] . ']<br />
								&nbsp;&nbsp;&nbsp;&nbsp;[' . $meta['meta_title'] . ']<br />
								&nbsp;&nbsp;&nbsp;&nbsp;[' . date('Y-m-d H:i:s', time()) . ']<br />';
            require_once ROOT_PATH . '/apps/system/models/system.class.php';
            $system = new system();
            $smtp = $system->is_smtp();
            $smtpconf = $system->getAllKeyValue();
            if ($smtp) {
                $emailClass->email_sock($smtpconf["smtp_host"], $smtpconf["smtp_port"], 0, 'error', 10, 1, $smtpconf["smtp_user"], $smtpconf["smtp_pass"], $smtpconf["smtp_from"]);
                $emailClass->send_mail_sock($emailClass->subject, $emailClass->message, $user_info['email'], $smtpconf["smtp_from_name"]);
                unset($emailClass);
            } else {
                $emailClass->to($_POST['email']);
                $emailClass->send();
                unset($emailClass);
            }
        }
        $res_mail = 'http://' . $this->gotomail($user_info['email']);
        $_SESSION["THE_USER_RES_SEND_MAIL_4_M_MAIL"] = $res_mail;
        $_SESSION["THE_USER_RES_SEND_MAIL_4_M"] = $user_info['user_id'];
        return true;
    }
示例#2
0
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
_setView(__FILE__);
_setTitle($langArray['withdrawal_setTitle']);
if (!check_login_bool()) {
    $_SESSION['temp']['golink'] = '/' . $languageURL . 'withdrawal/';
    refresh('/' . $languageURL . 'sign_in/');
}
$have_service = false;
//判断有无安装客户服务
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/apps/service/controllers/index.php')) {
    //判断启动状态
    require_once ROOT_PATH . '/apps/app_extends/models/app_extends.class.php';
    $app_extends = new app_extends();
    $is_open = $app_extends->getStatus("客户服务管理");
    if ($is_open) {
        require_once ROOT_PATH . '/apps/service/models/service.class.php';
        $serviceClass = new service();
        $service = $serviceClass->getserviceByuserid($_SESSION['user']['user_id']);
        abr("service", $service);
        $have_service = true;
    }
}
abr("have_service", $have_service);
$usersClass = new users();
$user = $usersClass->get($_SESSION['user']['user_id']);
abr('user', $user);
/*
 * 查询未完成提现
 */