Example #1
0
 function putcomment($item, $name)
 {
     // $s = '';
     // foreach($item as $k => $v) {
     // $s .= "$k=>$v\n";
     // }
     // $s .= "\n" . Getter::getcidfromname($name) . "\n\n";
     // 返回0表示要求断开链接
     if (strlen($item['message']) == 0) {
         return 2;
     }
     if ($item['playTime'] + 0 == 0) {
         return 3;
     }
     if (strlen($item['message']) > MAX_LEN) {
         $item['message'] = substr($item['message'], 0, MAX_LEN);
     }
     $cid = Getter::getcidfromname($name);
     $cmtdb = new CmtDB($cid);
     if ($cmtdb) {
         $cmtdb->insert_cmt($item);
         return 1;
     }
     return 0;
 }
Example #2
0
 function render()
 {
     switch ($this->vars['page']) {
         case 'messages':
             $getter = new Getter();
             $user = $getter->getCurrentUser();
             $messages = $getter->getMessages();
             include './templates/header.php';
             include './templates/messages.php';
             include './templates/footer.php';
             break;
         case 'message':
             $getter = new Getter();
             $user = $getter->getCurrentUser();
             $message = $getter->getMessageById(array('messageId' => $this->vars['messageId']));
             include './templates/header.php';
             include './templates/message.php';
             include './templates/footer.php';
             break;
         case 'profile':
             $getter = new Getter();
             $user = $getter->getCurrentUser();
             include './templates/header.php';
             include './templates/profile.php';
             include './templates/footer.php';
             break;
         case 'foreignProfile':
             $getter = new Getter();
             $user = $getter->getCurrentUser();
             $foreignProfile = $getter->getUserById(array('userId' => $this->vars['userId']));
             include './templates/header.php';
             include './templates/foreignProfile.php';
             include './templates/footer.php';
             break;
         case 'vision':
             include './templates/vision.php';
             break;
     }
 }
Example #3
0
 function updateProfile()
 {
     $user = $_SESSION['user'];
     $userUpdate = new User(array('email' => $_POST['email'], 'password' => $_POST['password'], 'name' => $_POST['name'], 'avatar' => pathinfo($_FILES['avatar']['name'])));
     $userVars = get_object_vars($userUpdate);
     foreach ($userVars as $i => $v) {
         if (!empty($v)) {
             if ($i == 'avatar') {
                 $avatarInfo = pathinfo($_FILES['avatar']['name']);
                 $avatarPath = "./files/images/avatars/{$user->id}.{$avatarInfo['extension']}";
                 move_uploaded_file($_FILES['avatar']['tmp_name'], $avatarPath);
                 try {
                     $this->dbh->query("\n                                update users\n                                set avatar = '{$avatarPath}'\n                                where id = {$user->id}\n                            ");
                 } catch (PDOException $e) {
                     echo $e->getMessage();
                     file_put_contents('./errors.txt', date('jS F Y H:i:s') . ' # ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
                 }
             } else {
                 try {
                     $this->dbh->query("\n                                update users\n                                set {$i} = '{$v}'\n                                where id = {$user->id}\n                            ");
                 } catch (PDOException $e) {
                     echo $e->getMessage();
                     file_put_contents('./errors.txt', date('jS F Y H:i:s') . ' # ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
                 }
             }
         }
     }
     $getter = new Getter();
     $_SESSION['user'] = $getter->getUserById(array('userId' => $user->id));
     header("location: index.php?page=profile");
 }
Example #4
0
 public function testHasCorrectShortName()
 {
     $getter = new Getter([]);
     $this->assertSame('Getter', $getter->getShortName());
 }
Example #5
0
 private function update()
 {
     Getter::set(Request::get('table'));
 }
Example #6
0
 /**
  * @param $object
  *
  * @return mixed The field value from $object
  */
 public function get($object)
 {
     return $this->getter->get($object);
 }
Example #7
0
 /**
  * @param $key
  * @return \BitrixHelperLib\Classes\Block\Getter
  */
 public function getRelatedGetter($key)
 {
     $prop = $this->getProp($key);
     $retval = false;
     if (!empty_array($prop['VALUE']) || !empty($prop['VALUE'])) {
         $retval = Getter::instance()->setFilter(array('ID' => $prop['VALUE']));
     }
     return $retval;
 }