Ejemplo n.º 1
0
 static function set_config($name, $value)
 {
     $one = DB::one('core_config', array('where' => array('slug' => $name)));
     if ($one) {
         DB::update('core_config', array('body' => $value), 'slug=:slug', array(':slug' => $name));
     } else {
         DB::insert('core_config', array('slug' => $name, 'body' => $value));
     }
 }
Ejemplo n.º 2
0
 /**
  * 返回用户信息
  *
  */
 static function get_member($id)
 {
     $cacheId = 'get_member_' . $id;
     $one = \Yii::$app->cache->get($cacheId);
     if (!$one) {
         $one = DB::one('oauth_users', array('where' => array('id' => $id)));
         $one = (object) $one;
         \Yii::$app->cache->set($cacheId, $one, 86400 * 360 * 360);
     }
     return $one;
 }
Ejemplo n.º 3
0
 function actionDisplay($id, $form)
 {
     $id = (int) $id;
     if ($id < 1) {
         exit;
     }
     $one = DB::one('comment', array('where' => array('id' => $id)));
     $display = $one['display'] == 1 ? 0 : 1;
     DB::update('comment', array('display' => $display), 'id=:id', array(':id' => $id));
     flash('success', __('sucessful'));
     $this->redirect(url('comment/site/index', array('form' => $form)));
 }
Ejemplo n.º 4
0
 /**
  * 保存 body
  */
 static function body($body)
 {
     $slug = md5(trim($body));
     $cacheId = 'database#comment_body_slug_' . $slug;
     $one = cache($cacheId);
     if (!$one) {
         $one = DB::one('comment_body', array('where' => array('slug' => $slug)));
         cache($cacheId, $one);
     }
     if ($one) {
         return $one['id'];
     }
     DB::insert('comment_body', array('slug' => $slug, 'body' => $body));
     return DB::id();
 }
Ejemplo n.º 5
0
 function member_get_third_set_user($me, $oauth_id, $token)
 {
     $me['email'] = $me['email'] ?: 'info';
     $uniqid = md5(uniqid(microtime()));
     if (!$me['id']) {
         flash('error', __('login failed'));
         $this->redirect(return_url());
     }
     $one = DB::one('oauth_users', array('where' => array('uid' => $me['id'], 'oauth_id' => $oauth_id)));
     if ($one) {
         DB::update('oauth_users', array('name' => $me['name'], 'email' => $me['email'], 'token' => $token, 'uuid' => $uniqid), "id=:id", array(':id' => $one['id']));
     } else {
         DB::insert('oauth_users', array('uid' => $me['id'], 'name' => $me['name'], 'email' => $me['email'], 'oauth_id' => $oauth_id, 'token' => $token, 'uuid' => $uniqid));
     }
     $one = DB::one('oauth_users', array('where' => array('uuid' => $uniqid, 'oauth_id' => $oauth_id)));
     if ($one) {
         $value = array('id' => $one['id'], 'name' => $one['name'], 'email' => $one['email'], 'oauth' => true);
         cookie('user', json_encode($value), 0);
     }
 }