public static function before() { if (Request::get('lang')) { $langList = array_map(function ($a) { return $a['iso']; }, Language::getList()); $lang = strtolower(Request::get('lang')); if (in_array($lang, $langList)) { Request::cookie(self::$langKeyCookie, $lang); } Request::redirect(Request::url(array('lang' => ''))); } if (Request::get('confirm_email')) { connectionUserModel::create()->confirmationEmailLink(Request::get('confirm_email')); Request::get('email_confirm', true); } if (ConnectionHelper::isLogin() && Request::get('status') && Request::get('status') == connectionUserModel::STATUS_MODERATE) { $userLogin = ConnectionHelper::userLogin(); connectionUserModel::create()->changeStatus($userLogin['id'], connectionUserModel::STATUS_MODERATE, 'Пользователь отправил профиль на проверку.'); Request::redirect('/profile/'); } if (Request::get('auth') && !ConnectionHelper::isLogin()) { Request::redirect('/login/'); } if (ConnectionHelper::isLogin()) { ConnectionHelper::updateUserActive(); } }
function execute() { $model = new connectionUserModel(); $user = ConnectionHelper::userLogin(); $model->addFavorite((int) $user['id'], (int) Request::post('user')); return true; }
function execute() { if (Request::post('step')) { return $this->stepPurse(Request::post('step')); } return array('user' => ConnectionHelper::userLogin()); }
function getPhotoByID($photo_id) { $result = $this->where(array('id' => (int) $photo_id))->fetchAll(); if (sizeof($result) == 0) { return false; } $photo = $result[0]; $photo['blocked'] = false; if ($photo['avatar']) { return $photo; } if (ConnectionHelper::isLogin()) { $user = ConnectionHelper::userLogin(); if ($user['id'] == $photo['user_id']) { return $photo; } } if (Request::get('backend')) { return $photo; } $index = sizeof($this->where(array('id' => array('$gt' => $photo['id']), 'user_id' => $photo['user_id'], 'published' => true))->sort('id', -1)->fetchAll()) + 1; if ($index > $this->showIndex) { $photo['file'] = $this->blockedImage; $photo['blocked'] = true; } return $photo; }
function execute() { $model = new connectionUserPhotoModel(); $user = ConnectionHelper::userLogin(); $photo = $model->getPhoto($user['id']); return array('photos' => $photo); }
function execute() { $user = ConnectionHelper::userLogin(); $model = new connectionFeedbackModel(); $list = $model->where(array('contact' => (int) $user['id']))->sort('date', -1)->fetchAll(); return array('list' => $list); }
function execute() { $user_id = (int) Request::post('id'); $login = ConnectionHelper::userLogin(); connectionUserContactModel::create()->addUser($login['id'], $user_id); connectionUserEventModel::create()->add(array('type' => connectionUserEventModel::TYPE_INVITE_CHAT, 'user' => (int) $user_id, 'from' => (int) $login['id'])); return 'success'; }
function execute() { $user = ConnectionHelper::userLogin(); $model = new connectionUserModel(); $model->updateInfo($_POST, (int) $user['id'], $_FILES); Request::redirect('/profile/'); return 'success'; }
function execute() { $user = ConnectionHelper::userLogin(); $model = connectionUserModel::create(); $favorite = array(); foreach ($user['favorite'] as $userID) { $favorite[] = $model->getInfo($userID); } return array('favorite' => $favorite); }
function send($to, $text, $attachment = array()) { $user = ConnectionHelper::userLogin(); $model = new connectionMessageModel(); $date = (int) strtotime('now'); $data = array('from' => (int) $user['id'], 'to' => (int) $to, 'text' => Validator::clearValue($text), 'state' => 'unread', 'attachment' => $attachment, 'date' => $date); $message_id = (int) $model->insert($data); $this->insert(array('user_id' => (int) $user['id'], 'message_id' => $message_id, 'type' => 'sent', 'date' => $date)); $this->insert(array('user_id' => (int) $to, 'message_id' => $message_id, 'type' => 'inbox', 'date' => $date)); return $message_id; }
function execute() { $model = new connectionUserMessageModel(); $user = ConnectionHelper::userLogin(); $message = $model->getUserMessage($user['id'], Request::post('id')); if ($message) { $model->setState($message['id'], 'unread'); return 'success'; } return 'error'; }
function execute() { $model = new connectionUserModel(); $login = ConnectionHelper::userLogin(); $user = array_map(function ($a) use($model) { $data = $model->getInfo($a['id']); return array('id' => $data['id'], 'key' => $data['id'], 'name' => $data['first_name'], 'status' => $data['online'] ? 'online' : 'offline', 'avatar' => '/photo/thumb/' . $data['avatar']['id'], 'nickname' => $data['first_name'], 'camera' => isset($data['camera']) && $data['camera'] == 1 ? $data['stream'] : false); }, $model->getContact($login['id'])); echo json_encode(array('contact' => $user)); exit; }
function execute() { $user = ConnectionHelper::userLogin(); $model = new connectionFeedbackAnswerModel(); $data = Request::post('answer'); $data['user'] = $user['id']; $result = $model->add($data); if (!Request::isAjax()) { Request::redirect('/profile/support/' . $data['ticket'] . '/'); } return $result ? 'success' : 'error'; }
function execute() { $user = ConnectionHelper::userLogin(); $model = new connectionUserVideoModel(); if (Request::post('id') && Request::post('title')) { $video = (int) Request::post('id'); $title = Request::post('title'); if (!empty($title)) { $model->where(array('id' => $video))->update(array('title' => htmlspecialchars(Request::post('title')))); } } return array('video' => $model->where(array('user' => (int) $user['id']))->sort('date', -1)->fetchAll()); }
function execute() { $photo_id = (int) Request::post('photo'); if ($photo_id == 0) { return false; } $model = new connectionUserPhotoModel(); $photo = $model->getPhotoByID($photo_id); $user = ConnectionHelper::userLogin(); if (!$photo || isset($photo['avatar']) && $photo['avatar'] || $photo['user_id'] != $user['id']) { return false; } return $model->deletePhoto($photo_id); }
function execute() { $model = new connectionUserMessageModel(); $user = ConnectionHelper::userLogin(); $message = $model->getUserMessage($user['id'], Request::get('message_id')); if (!$message) { $this->showNotFound(); return; } if ($message['type'] == 'inbox') { $model->setState($message['id'], 'readed'); } return array('message' => $message); }
function execute() { $videoID = (int) Request::post('id'); $model = new connectionUserVideoModel(); $video = $model->where(array('id' => $videoID))->fetchOne(); if (!$video) { return array('status' => 'error'); } $user = ConnectionHelper::userLogin(); if ($video['user'] != $user['id']) { return array('status' => 'error'); } $model->where(array('id' => $videoID))->delete(); return array('status' => 'success'); }
function execute() { $id = Request::post('id'); $model = new connectionUserAttachmentModel(); $login = ConnectionHelper::userLogin(); $result = array('code' => $id); $file = Request::files('attach'); if (sizeof($file) > 0) { $id = $model->addFile($file[0], $login['id']); if ($id) { $result['id'] = $id; $result['url'] = '/attachment/size-50/' . $id; } } return $result; }
function execute() { $user = ConnectionHelper::userLogin(); $id = Request::params('video_id'); if (!$id) { return array('status' => 'error', 'message' => '[`Title error view video not found`]'); } $video = connectionUserVideoModel::create()->where(array('id' => (int) $id))->fetchOne(); if (!$video) { return array('status' => 'error', 'message' => '[`Title error view video not found`]'); } if ($video['status'] != 'published' && $video['user'] != $user['id']) { return array('status' => 'error', 'message' => '[`Title error view video not permission`]'); } $file = '/me-uploads/connection/user_video/user' . $video['user'] . '/' . $video['id'] . '/video.flv'; return array('status' => 'success', 'file' => $file, 'title' => $video['title']); }
function execute() { if (Request::get('delete_attach') && Request::get('file')) { $user = ConnectionHelper::userLogin(); $key = 'field_' . (int) Request::get('delete_attach'); if (isset($user[$key])) { foreach ($user[$key] as $index => $value) { if ($value['file'] == Request::get('file')) { unset($user[$key][$index]); } } connectionUserModel::create()->where(array('id' => (int) $user['id']))->update(array($key => array_values($user[$key]))); } } $model = new connectionFieldsModel(); return array('fields' => $model->getGroupLocale('info', Language::getActiveLanguageISO())); }
function execute() { $user = ConnectionHelper::userLogin(); $response = array('result' => '[`Title profile change password success`]'); if (!$user || !Request::post('old_password') || !Request::post('new_password') || !Request::post('repeat_password')) { return array('result' => '[`Title profile change password error`]'); } if (md5(Request::post('old_password')) != $user['password'] || Request::post('new_password') != Request::post('repeat_password')) { return array('result' => '[`Title profile change password error`]'); } $model = new connectionUserModel(); $password = Request::post('new_password'); if (!Validator::Field($password, $model->regFields['password'])) { return array('result' => '[`Title profile change password error`]'); } $model->changePassword($user['id'], $password); return $response; }
function execute() { $video = new ConnectionVideo(); if (!Request::files('Filedata')) { return array('status' => 'error'); } $result = $video->download('Filedata'); if (!$result) { return array('status' => 'error'); } $file = Request::files('Filedata'); $model = new connectionUserVideoModel(); $user = ConnectionHelper::userLogin(); $userModel = new connectionUserModel(); $videoID = $model->insert(array('file' => $result, 'status' => 'upload', 'user' => (int) $user['id'], 'date' => strtotime('now'), 'title' => htmlspecialchars($file[0]['name']))); $userModel->addHistory($user['id'], connectionUserModel::HISTORY_ADD_VIDEO, '', array('video' => (int) $videoID)); Route::exec('php ' . MAIN_DIR . DS . 'cli.php connection ConvertVideo cli ' . $videoID); return array('status' => 'success'); }
function execute() { $files = Request::files('photo'); if (!$files || sizeof($files) == 0) { return; } $user = ConnectionHelper::userLogin(); $uploadDir = ConnectionHelper::getPhotoDir($user['id']); $model = new connectionUserPhotoModel(); File::mkdir($uploadDir); foreach ($files as $file) { $file_info = pathinfo($file['name']); if (!in_array(strtolower($file_info['extension']), array('png', 'jpeg', 'jpg', 'gif'))) { continue; } $file_name = uniqid() . strtotime('now') . md5(rand()) . '.' . $file_info['extension']; File::upload($file, $uploadDir, $file_name); $model->addPhoto($user['id'], $file_name); } }
function execute() { $user = ConnectionHelper::userLogin(); $mail = Request::post('mail'); if (!$mail || !isset($mail['to']) || !isset($mail['text']) || empty($mail['text'])) { return array('status' => 'error', 'message' => '[`Title error private message send`]'); } $model = new connectionUserMessageModel(); $count = connectionMessageModel::create()->getDialogMessageCount($user['id'], $mail['to']); if ($count > 0) { $result = connectionUserBalanceModel::create()->operation((int) $user['id'], -(double) Settings::getValue('price_message', 'connection'), connectionUserBalanceModel::OPERATION_REASON_PRIVATE_MESSAGE); if (!$result) { return array('status' => 'error', 'message' => '[`Title error private message send balance`]'); } } $message = $model->send($mail['to'], $mail['text'], isset($mail['attachment']) && is_array($mail['attachment']) ? array_unique($mail['attachment']) : array()); if ($count > 0) { connectionUserBalanceModel::create()->where(array('id' => (int) $result))->update(array('param' => array('message' => (int) $message))); } return array('status' => 'success', 'message' => '[`Title success private message send`]'); }
function execute() { $search = Request::post('search'); $searchUser = ConnectionSearchUser::create(); $saveTemp = false; $user = ConnectionHelper::userLogin(); if (ConnectionHelper::isLogin() && !$search) { $saveTemp = Temp::get('user_' . $user['id'] . '_advanced_filter'); $saveTemp = $saveTemp ? unserialize($saveTemp) : false; } if (!$saveTemp) { $saveTemp = array('query' => $search, 'filter' => $searchUser->filterSearchField($search)); if (ConnectionHelper::isLogin()) { Temp::set('user_' . $user['id'] . '_advanced_filter', serialize($saveTemp)); } } $this->setSeoPage('advanced_search'); if ($search || true) { print_r($saveTemp); } }
public function create($payment, $price) { $model = new connectionUserBalanceModel(); $user = ConnectionHelper::userLogin(); return $model->operation($user['id'], $price, 'Updating user account', $payment, array(), connectionUserBalanceModel::STATUS_OPERATE); }
public function add($feedback) { $from = null; $data = array(); if (ConnectionHelper::isLogin()) { $user = ConnectionHelper::userLogin(); $from = (int) $user['id']; } else { $ticket = array('subject' => htmlspecialchars($feedback['subject']), 'message' => nl2br(htmlspecialchars($feedback['message']))); connectionNotificationModel::run(connectionNotificationModel::EVENT_NEW_FEEDBACK_ANONIMUS, array('user' => array('name' => htmlspecialchars($feedback['name']), 'email' => htmlspecialchars($feedback['email'])), 'ticket' => $ticket), Language::getActiveLanguageISO()); return $ticket; } foreach ($this->field as $field) { if (!isset($feedback) || empty($feedback)) { return false; } else { $data[$field] = htmlspecialchars($feedback[$field]); } } $data['message'] = nl2br($data['message']); if (is_null($from)) { if (!isset($feedback['email']) || empty($feedback['email']) || !filter_var($feedback['email'], FILTER_VALIDATE_EMAIL)) { return false; } if (!isset($feedback['name']) || empty($feedback['name'])) { return false; } $data['contact'] = array('email' => htmlspecialchars($feedback['email']), 'name' => htmlspecialchars($feedback['name'])); } else { $data['contact'] = $from; } $data['status'] = self::FEEDBACK_STATUS_NEW; $data['date'] = strtotime('now'); $data['url'] = md5($data['date'] . $data['subject'] . uniqid()); $data['last_action'] = 'user'; if (isset($feedback['attachment']) && is_array($feedback['attachment'])) { $data['attachment'] = $feedback['attachment']; } $id = $this->insert($data); $data['id'] = $id; connectionNotificationModel::run(connectionNotificationModel::EVENT_NEW_FEEDBACK, array('user' => ConnectionHelper::userLogin(), 'ticket' => $data), Language::getActiveLanguageISO()); return $id; }
function execute() { $model = new connectionUserMessageModel(); $user = ConnectionHelper::userLogin(); return array('messages' => $model->getMessages($user['id'], 'sent')); }
public function getOppositeSex() { if (!ConnectionHelper::isLogin()) { $sex = 'female'; } else { $user = ConnectionHelper::userLogin(); if ($user['sex'] == 'female') { $sex = 'male'; } else { $sex = 'female'; } } return $sex; }