Esempio n. 1
0
 public static function getCode($code)
 {
     if (!$code) {
         return;
     }
     $setting = Setting::find()->where(['code' => $code])->one();
     if ($setting) {
         return $setting->value;
     } else {
         return;
     }
 }
Esempio n. 2
0
 public function actionIndex()
 {
     if (\App::$app->request->isPost) {
         $siteRoot = str_replace('\\', '/', realpath(dirname(dirname(dirname(__FILE__))) . '/')) . "/www/web/upload/";
         if (!empty($_FILES)) {
             if ($_FILES['Setting']['tmp_name']['img']) {
                 $tempPath = $_FILES['Setting']['tmp_name']['img'];
                 $filesName = uniqid() . '.' . pathinfo($_FILES['Setting']['name']['img'], PATHINFO_EXTENSION);
                 $uploadPath = $siteRoot . $filesName;
                 move_uploaded_file($tempPath, $uploadPath);
                 Setting::updateAll(['value' => $filesName], ['code' => 'img']);
             }
         }
         $setting = \App::$app->request->post('Setting');
         foreach ($setting as $key => $value) {
             Setting::updateAll(['value' => $value], ['code' => $key]);
         }
     }
     $settingParent = Setting::find()->where(['parent_id' => 0])->orderBy(['sort_order' => SORT_ASC])->all();
     return $this->render('index', ['settingParent' => $settingParent]);
 }
Esempio n. 3
0
 public function actionSignup()
 {
     //判断注册URL中是否包含邀请码参数
     if (isset($_GET['code'])) {
         $code = $_GET['code'];
         //$_code_source = UcenterMember::find()->where(['invitation_code'=>$code])->one();
         //if(count($_code_source) != 1)
         $flag = \frontend\actions\app\member::verify_code($code);
         if (!$flag) {
             header("Content-type: text/html; charset=utf-8");
             echo "<script>alert('来源链接不合法!')</script>";
             echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
             exit;
         }
     }
     $model = new SignupForm();
     //是否邀请注册
     $test_invite = 1;
     if ($model->load(Yii::$app->request->post())) {
         if ($_POST['SignupForm']['username'] && $_POST['SignupForm']['validate_code'] && $_POST['SignupForm']['password'] && $_POST['SignupForm']['password_repeat']) {
             $invite_code = $_POST["SignupForm"]['invitation_code'];
             //使用测试邀请码
             if ($test_invite) {
                 //使用测试邀请
                 $flag = \frontend\actions\app\member::verify_code($invite_code);
                 //验证码通过
                 if (!$flag) {
                     echo "<script>alert('" . '邀请码错误' . "')</script>";
                 }
             }
             $_phone = $_POST['SignupForm']['username'];
             $_code = $_POST['SignupForm']['validate_code'];
             try {
                 $result = Port::checkPhnoe($_phone, $_code);
                 if (is_bool($result)) {
                 }
             } catch (ErrorException $e) {
                 header("Content-type: text/html; charset=utf-8");
                 echo "<script>alert('" . $e->getMessage() . "')</script>";
                 echo "<script>location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
                 exit;
             }
             $user = new UcenterMember();
             $user->username = $_POST["SignupForm"]['username'];
             $user->phone = $_POST["SignupForm"]['username'];
             $user->invitation_code = $_POST["SignupForm"]['invitation_code'];
             $password = $_POST["SignupForm"]['password'];
             $user->setPassword($password);
             $user->create_ip = Yii::$app->request->userIp;
             $app_pwd = md5(sha1($password) . time());
             $user->app_pwd = $app_pwd;
             try {
                 $area = self::get_area(Yii::$app->request->userIp);
                 $user->create_area = $area;
             } catch (ErrorException $e) {
             }
             $user->generateAuthKey();
             if ($user->save()) {
                 $uid = $user['id'];
                 if ($test_invite) {
                     //使用验证码
                     $flag = \frontend\actions\app\member::verify_code($invite_code);
                     $invite_flag = \frontend\actions\app\member::use_code($flag, $uid);
                     if (!$invite_flag) {
                         $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                         return $return;
                     }
                 }
                 if (Yii::$app->getUser()->login($user)) {
                     $newModel = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
                     //$newModel->invitation_id= \yii::$app->params['invitation_id'];
                     $invitation_code = Utils::createcode();
                     $newModel->invitation_code = $invitation_code;
                     $newModel->person_face = Setting::find()->where("code='img'")->one()->value;
                     if ($_POST['url_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["url_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     } elseif ($_POST['SignupForm']['invitation_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["SignupForm"]["invitation_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     }
                     $newModel->save(false);
                     $model_asset_info = new Info();
                     $model_asset_info->member_id = yii::$app->user->id;
                     $model_asset_info->create_at = strtotime("now");
                     $model_asset_info->save(false);
                     //手机号注册领取体验金
                     $rule = Rule::find()->where(['title' => '手机号注册', 'status' => Rule::STATUS_ACTIVE])->one();
                     if ($rule) {
                         $rid = $rule->id;
                         $r_money = $rule->money;
                         $model_gold = new Gold();
                         $model_gold->rid = $rid;
                         $model_gold->money = $r_money;
                         $model_gold->uid = $code_source['id'];
                         $model_gold->created_at = strtotime("now");
                         $model_gold->save();
                     }
                     return $this->goHome();
                 }
             }
         }
     }
     return $this->render('signup', compact("model", "code"));
 }
Esempio n. 4
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\setting\Setting;
use common\models\base\activity\Card;
use yii\helpers\Url;
use kartik\file\FileInput;
$this->title = Yii::t('app', 'Setting');
$this->params['breadcrumbs'][] = $this->title;
$items = [];
foreach ($settingParent as $parent) {
    $item['label'] = Yii::t('app', $parent->code);
    $str = '';
    $children = Setting::find()->where(['parent_id' => $parent->id])->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_ASC])->all();
    foreach ($children as $child) {
        $str .= '<div class="form-group field-blogcatalog-parent_id"><label class="col-lg-2 control-label" for="blogcatalog-parent_id">' . Yii::t('app', $child->code) . '</label><div class="col-lg-3">';
        if ($child->type == 'text') {
            $str .= Html::textInput("Setting[{$child->code}]", $child->value, ["class" => "form-control"]);
        } elseif ($child->type == 'password') {
            $str .= Html::passwordInput("Setting[{$child->code}]", $child->value, ["class" => "form-control"]);
        } elseif ($child->type == 'select') {
            $options = [];
            $arrayOptions = explode(',', $child->store_range);
            foreach ($arrayOptions as $option) {
                $options[$option] = Yii::t('app', $option);
            }
            $str .= Html::dropDownList("Setting[{$child->code}]", $child->value, $options, ["class" => "form-control"]);
        } elseif ($child->type == 'checkrate') {
            $str .= Html::dropDownList("Setting[{$child->code}]", $child->value, ArrayHelper::map(Card::find()->asArray()->all(), 'id', 'title'), ["class" => "form-control"]);