Exemplo n.º 1
0
 public function actionLogon()
 {
     $result = array('status' => -1, 'access_token' => -1, 'userid' => 0, 'message' => '');
     $paras = Yii::$app->request->post();
     //$query->
     if (!isset($paras['password'], $paras['name'], $paras['email'], $paras['firstname'], $paras['lastname'], $paras['sex'], $paras['phone'], $paras['code'])) {
         $result['message'] = 'lack of parameters';
         return $result;
     }
     if (!$this->checkInvitation($paras['code'])) {
         $result['message'] = 'wrong invitation code';
         $result['status'] = '2';
         return $result;
     }
     $user = new \app\models\User();
     $user->password = md5($paras['password'], false);
     $user->name = $paras['name'];
     $user->email = $paras['email'];
     $user->firstname = $paras['firstname'];
     $user->lastname = $paras['lastname'];
     $user->sex = $paras['sex'];
     $user->phone = $paras['phone'];
     $user->access_token = $user->password;
     if ($user->validate()) {
         $user->save();
         $result['access_token'] = $user->access_token;
         $result['status'] = 1;
         $result['userid'] = $user->id;
         $result['message'] = 'registered succesfully';
     } else {
         $result['message'] = 'registered failed';
         $result['status'] = 0;
     }
     return $result;
 }
 public function up()
 {
     $user = new app\models\User();
     $user->email = 'admin';
     $user->password = '******';
     $user->save();
 }
Exemplo n.º 3
0
 public function actionSignUp()
 {
     $model = new \app\models\User();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('/personal');
     }
     return $this->render('sign-up', ['model' => $model]);
 }
Exemplo n.º 4
0
 public function up()
 {
     $result = $this->createTable('{{%users}}', ['id' => Schema::TYPE_PK, 'username' => Schema::TYPE_STRING . ' NOT NULL COMMENT "Логин"', 'email' => Schema::TYPE_STRING . ' NOT NULL COMMENT "Email"', 'password' => Schema::TYPE_STRING . ' NOT NULL COMMENT "Пароль"', 'authKey' => Schema::TYPE_STRING . ' NOT NULL COMMENT "Токен"']);
     foreach ($this->_data as $item) {
         $model = new \app\models\User();
         $model->attributes = $item;
         $model->save();
     }
     return $result;
 }
 public function run()
 {
     $data = cache_remember('user.inactive.' . auth('id'), function () {
         $user = new \app\models\User();
         return $user->getActiveData(auth('id'));
     });
     if ($data['active'] === '1') {
         $_SESSION['auth']['active'] = '1';
         cache_forgot('user.inactive.' . auth('id'));
         echo '<div class="alert alert-success">คุณได้รับการยืนยันแล้วว่า ข้อมูลถูกต้องและเป็นสมาชิกของสาขานี้ กรุณา reload page</div>';
     }
 }
Exemplo n.º 6
0
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%user}}', ['id' => Schema::TYPE_PK, 'username' => Schema::TYPE_STRING . ' NOT NULL ', 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', 'password_hash' => Schema::TYPE_STRING . ' NOT NULL', 'password_reset_token' => Schema::TYPE_STRING, 'email' => Schema::TYPE_STRING . ' NOT NULL', 'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', 'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL'], $tableOptions);
     $user = new \app\models\User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->generateAuthKey();
     $user->setPassword('demo');
     return $user->insert();
 }
Exemplo n.º 7
0
 public function store(Request $request, Response $response, Hash $hash)
 {
     $rules = ['email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:8'];
     $validator = app('validation')->make($request->all(), $rules);
     if ($validator->fails()) {
         $request->session->add(['errors' => $validator->errors()->all()]);
         return app('twig')->render('user/signup.htm', ['oldInputs' => $request->all()]);
     }
     $user = new \app\models\User();
     $user->email = $request->body->get('email');
     $user->password = $hash->make($request->body->get('password'));
     $user->save();
     $request->session->add(['success' => "Welcome to Notejam, you can now log in."]);
     return $response->redirect('/signin');
 }
 public function getJson()
 {
     $news = cache_remember('p.getJson.news.' . user('major'), function () {
         $news = new \app\models\News();
         return json_encode($news->getNewsList());
     });
     $user = cache_remember('user.get.members.' . user('major'), function () {
         $user = new \app\models\User();
         return json_encode($user->getMembers(true));
     });
     $gbnews = cache_remember('home.gbnews', function () {
         $gbnews = new \app\models\GbNews();
         return json_encode($gbnews->lists(6));
     });
     echo '{ "news":' . $news . ', "users":' . $user . ', "gbnews":' . $gbnews . ' }';
 }
Exemplo n.º 9
0
 public function actionList()
 {
     if (isset($_GET['ajax'])) {
         $page = isset($_POST['page']) ? $_POST['page'] : 1;
         $rows = isset($_POST['rows']) ? $_POST['rows'] : 10;
         $user_obj = new \app\models\User();
         $data = $user_obj->get_list([], $page, $rows);
         if (!$data) {
             echo '查询失败';
             exit;
         }
         echo json_encode($data);
     } else {
         return $this->render('list');
     }
 }
Exemplo n.º 10
0
 public function login()
 {
     $proffstore = new ProffstoreCURL();
     $proffstore->auth($this->password, $this->email);
     if ($proffstore->accesToken) {
         $user = \app\models\User::findOne(['email' => $this->email]);
         if ($user) {
             $user->setAttribute('tocken', $proffstore->accesToken);
             $user->update(false);
         } else {
             $user = new \app\models\User();
             $user->setAttributes(['email' => $this->email, 'pass' => $this->password, 'tocken' => $proffstore->accesToken]);
             $user->setAttribute('tocken', $proffstore->accesToken);
             $user->save(false);
         }
         \Yii::$app->user->login($user, 3600 * 24 * 3);
         return $proffstore->accesToken;
     } else {
         return null;
     }
 }
Exemplo n.º 11
0
" data-essay-status="<?php 
        echo $essay['status'];
        ?>
">
                                        <p style="font-size:24px;">
                                            <b style="font-size:24px;"><?php 
        echo $essay['firstname'];
        ?>
, </b>
                                            <b style="font-size:16px;">
                                                <?php 
        echo $essay['city'];
        ?>
, 
                                                <?php 
        echo app\models\User::getYearsOld($essay['birth_date']);
        ?>
 года
                                            </b>
                                        </p>
                                        <p>
                                            <?php 
        echo Essays::getPhoto($essay['photo_path']) ? "<img src=" . Essays::getPhoto($essay['photo_path']) . ">" : "";
        ?>
                                            <?php 
        echo $essay['text'];
        ?>
                                        </p>
                                    </div>
                                <?php 
    }
Exemplo n.º 12
0
 /**
  * Ruturn user-setup page if application no-user found.
  * @return mixed
  */
 public function actionUserSetup()
 {
     $chkUserTbl = \app\models\User::find()->exists();
     if ($chkUserTbl) {
         return $this->redirect(['setup-completed']);
     }
     $model = new \app\models\User();
     $model->scenario = 'firstTime';
     $chkUserTbl = \app\models\User::find()->exists();
     if ($chkUserTbl) {
         return $this->redirect(['site/login']);
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->created_by = 1;
         $model->created_at = new \yii\db\Expression('NOW()');
         $model->user_login_id = $model->admin_user;
         $model->user_password = MD5($model->create_password . $model->create_password);
         $model->user_type = 'A';
         if ($model->save()) {
             $auth_assign = new \app\models\AuthAssignment();
             $auth_assign->item_name = 'SuperAdmin';
             $auth_assign->user_id = $model->user_id;
             $auth_assign->created_at = date_format(date_create(), 'U');
             if ($auth_assign->save(false)) {
                 return $this->redirect(['setup-completed']);
             }
         }
     }
     return $this->render('user-setup', ['model' => $model]);
 }
Exemplo n.º 13
0
    <section class="col-lg-9 connectedSortable ui-sortable">

        <!-- Chat box -->
        <?php 
echo \sintret\chat\ChatRoom::widget(['url' => \yii\helpers\Url::to(['/ajax/send-chat']), 'userModel' => \app\models\User::className(), 'userField' => 'avatarImage']);
?>
        <!-- To Do List -->
        <?php 
echo \sintret\todolist\ListView::widget(['url' => \yii\helpers\Url::to(['/ajax/todolist']), 'relations' => app\models\User::className()]);
?>

    </section><!-- /.Left col -->
    <div class="col-md-3">
        <?php 
$phone = [];
$users = app\models\User::find()->where(['status' => app\models\User::STATUS_ACTIVE])->all();
if ($users) {
    foreach ($users as $user) {
        if ($user->phone) {
            $invite[] = "{ id : '{$user->phone}', invite_type : 'PHONE' }";
        }
        $invite[] = "{ id : '{$user->email}', invite_type : 'EMAIL' }";
    }
}
$invites = implode(",", $invite);
//echo $invites;
?>


        <div class="col-md-12">
            <div class="box box-solid">
Exemplo n.º 14
0
 <?php 
$this->params["menu"] = array();
app\widgets\MiniForm::begin(array('header' => Yii::t('app', "Bankbooks")));
?>
 

<?php 
$dateisOn = kartik\datecontrol\DateControl::widget(['model' => $model, 'attribute' => 'date_from', 'type' => 'date']) . kartik\datecontrol\DateControl::widget(['model' => $model, 'attribute' => 'date_to', 'type' => 'date']);
?>

 <?php 
echo app\widgets\GridView::widget(array('id' => 'transaction-grid', 'dataProvider' => $model->dp(), 'columns' => array('id', array('attribute' => 'account_id', 'filter' => \yii\helpers\ArrayHelper::map(app\models\Accounts::find()->where(['type' => 7])->All(), 'id', 'name'), 'value' => function ($data) {
    return $data->getAccountName();
}), array('value' => function ($data) {
    return $this->render('_bank', array('cdata' => $data, 'intType' => 0));
}, 'format' => 'raw'), array('value' => function ($data) {
    return $this->render('_trans', array('cdata' => $data, 'intType' => 0));
}, 'format' => 'raw'), array('attribute' => 'date', 'filter' => $dateisOn, 'value' => function ($data) {
    return $data->date;
}), array('attribute' => 'owner', 'filter' => \yii\helpers\ArrayHelper::map(app\models\User::find()->All(), 'id', 'username')), array('class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => array()))));
?>


<?php 
app\widgets\MiniForm::end();
Exemplo n.º 15
0
 function get_index()
 {
     $user = new \app\models\User(\app\inc\Input::getPath()->part(4));
     return $user->getData();
 }
Exemplo n.º 16
0
            // echo '<img src="'.Yii::$app->params['imgUrl'].$value.'?imageView2/1/w/500/q/50" />';
        }
    }
    ?>
    </ul>
    </div>
  </div>
 <?php 
}
?>
    <?php 
echo LinkPager::widget(['pagination' => $pages]);
?>

<?php 
if (app\models\User::isGuest()) {
    ?>
    <a href="/user/login" class="am-btn am-btn-default">登陆后评论</a>
    <?php 
} else {
    ?>
<form class="am-form" action='/comment/create' method="post">
  <!-- <fieldset disabled> -->
    <div class="am-form-group">
    <input type="hidden" name="data[post_id]" value="<?php 
    echo $_GET['id'];
    ?>
">
        <input type="hidden" value="<?php 
    echo Yii::$app->getRequest()->getCsrfToken();
    ?>
Exemplo n.º 17
0
$app->configureMode('production', function () use($app) {
    $app->config(array('log.enable' => true, 'log.level' => \Slim\Log::ERROR, 'debug' => false));
});
// Only invoked if mode is "development"
$app->configureMode('development', function () use($app) {
    $app->config(array('log.enable' => true, 'log.level' => \Slim\Log::DEBUG, 'debug' => true));
});
$app->group('/gateway', function () use($app) {
    $app->post('/register', function () use($app) {
        $json = $app->request->getBody();
        $data = json_decode($json, false);
        // TODO: Send email for confirmation
        $pass = \app\utilities\PasswordUtility::GenerateSalt();
        $now = date("Y-m-d H:i:s");
        $hash = password_hash($data->Email . $now, PASSWORD_DEFAULT);
        $user = new \app\models\User(array('username' => $data->Email, 'password' => password_hash($pass, PASSWORD_DEFAULT), 'email' => $data->Email, 'confirmation' => $now));
        $user->save();
        $apiId = \app\utilities\PasswordUtility::GenerateSalt();
        $apiKey = \app\utilities\PasswordUtility::GenerateSalt();
        $userAuthorization = new \app\models\UserAuthorization(array('user_id' => $user->id, 'api_id' => $apiId, 'api_key' => password_hash($apiKey, PASSWORD_DEFAULT)));
        $userAuthorization->save();
        echo json_encode(array('ResponseCode' => \config\Constants::$success, 'APIId' => $apiId, 'APIKey' => $apiKey));
    });
});
// API group
$app->group('/api', function () use($app) {
    $app->get('/turbulencedata/:latitude/:longitude(/:radius(/:hoursUntilStale))', function ($latitude, $longitude, $radius = 1, $hoursUntilStale = 2) {
        $controller = new \app\controllers\TurbulenceStatisticController();
        $finalResults = $controller->getTurbulenceData($latitude, $longitude, $radius, $hoursUntilStale);
        echo json_encode(array('ResponseCode' => \config\Constants::$success, 'Results' => $finalResults));
    });
Exemplo n.º 18
0
 /**
  * Page that is used for new users to register on this website. There is also a similar page on admin module called
  * admin/users/create where admins can create a new user. When an admin create an user then the password is generated
  * automatically and sent to user email address. So not even the admin can see it, just the new user.
  */
 public function actionRegister()
 {
     if (WebApp::get()->user()->isConnected()) {
         // can't register if is already connected
         WebApp::get()->request()->goToPage('home');
     }
     $user = new \app\models\User();
     $user->setAction('register');
     if (isset($_POST['register']) && $user->setAttributes($_POST['User'])->validate()) {
         if ($user->register()) {
             Messages::get()->success('Account created!');
             WebApp::get()->request()->goToPage('home');
         }
     }
     $this->assign('user', $user);
 }
Exemplo n.º 19
0
<?php

$this->params["menu"] = array();
app\widgets\MiniForm::begin(array('header' => Yii::t('app', "Bankbooks")));
?>
 

<?php 
$dateisOn = kartik\datecontrol\DateControl::widget(['model' => $model, 'attribute' => 'date_from', 'type' => 'date']) . kartik\datecontrol\DateControl::widget(['model' => $model, 'attribute' => 'date_to', 'type' => 'date']);
?>

<?php 
echo app\widgets\GridView::widget(array('id' => 'transaction-grid', 'dataProvider' => $model->dp(), 'columns' => array('id', array('attribute' => 'account_id', 'filter' => \yii\helpers\ArrayHelper::map(app\models\Accounts::find()->where(['type' => 7])->all(), 'id', 'name'), 'value' => function ($data) {
    return $data->getAccountName();
}), array('value' => function ($data) {
    return $this->render('_trans', array('cdata' => $data, 'intType' => 1));
}, 'format' => 'raw'), array('value' => function ($data) {
    return $this->render('_trans', array('cdata' => $data, 'intType' => 0));
}, 'format' => 'raw'), array('attribute' => 'date', 'filter' => $dateisOn), array('attribute' => 'owner', 'filter' => \yii\helpers\ArrayHelper::map(app\models\User::find()->All(), 'id', 'username')), array('class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) {
    //if ($model->docStatus->looked == 1) return '';
    $url = yii\helpers\BaseUrl::base() . '/match/matchdelete/' . $model->id;
    return \yii\helpers\Html::a('<i class="glyphicon glyphicon-remove"></i>', $url);
    //'label' => '<i class="glyphicon glyphicon-remove"></i>',
}]))));
?>


<?php 
app\widgets\MiniForm::end();
Exemplo n.º 20
0
            ?>
">
                            <div class="item-gallery">
                                <div class="content-esse">
                                    <div class="title-esse">
                                        <p><strong><?php 
            echo $essay['firstname'];
            ?>
</strong> / <?php 
            echo $essay['city'];
            ?>
 / <?php 
            echo app\models\User::getYearsOld($essay['birth_date']);
            ?>
 <?php 
            echo app\components\ShellHelper::YearTextArg(app\models\User::getYearsOld($essay['birth_date']));
            ?>
 <?php 
            echo $essay['c_votes'] > 0 ? '<span style="float:right">Количество голосов: <span class="count_votes">' . $essay['c_votes'] . '</span></span>' : '';
            ?>
</p>
                                    </div>
                                    <div class="text-esse <?php 
            echo Essays::getPhoto($essay['photo_path']) ? '' : 'without-foto';
            ?>
">
                                        <div class="fleft">
                                            <p><?php 
            echo $essay['text'];
            ?>
</p>