public function mailAction() { $model = new MailModel(); $receiverID = Request::getUriOptions(0); $receiver = $model->getUserByID($receiverID); if (!$receiver->id or $receiver->id == Request::getParam('user')->id) { redirect(url('profile')); } if ($receiver->id < Request::getParam('user')->id) { $uid1 = $receiver->id; $uid2 = Request::getParam('user')->id; $pos = 2; } else { $uid1 = Request::getParam('user')->id; $uid2 = $receiver->id; $pos = 1; } $dialog = $model->getDialogByUsers($uid1, $uid2); if (!$dialog->id) { $data['uid1'] = $uid1; $data['uid2'] = $uid2; $did = $model->addDialog($data); } else { $did = $dialog->id; } $hash = md5($uid1 . SALT . $uid2); $arr['did'] = $did; $arr['uid1'] = $uid1; $arr['uid2'] = $uid2; $arr['pos'] = $pos; //Create session hash setSession($hash, $arr); $this->view->list = $model->getMessages($did); $this->view->name = $receiver->nickname; $this->view->receiver = $receiver->id; $this->view->hash = $hash; $this->view->did = $did; $this->view->rightList = $model->selectDialog(Request::getParam('user')->id, 0, 7); $this->view->title = $receiver->nickname; }
public function regsAction() { $model = new PageModel(); if (isPost()) { $regCode = $model->getRegCode(post('code')); if ($regCode->id or true) { // TODO забрати "OR true" $data['nickname'] = post('nickname'); if (checkLenght(post('nickname'), 3, 16) && !$model->getUserByNickname(post('nickname'))) { $data['nickname'] = post('nickname'); } else { $this->view->error = 'Incorrect "Nickname" or exist'; } if (checkEmail(post('email')) && !$model->getUserByEmail(post('email'))) { $data['email'] = post('email'); } else { $this->view->error = 'Incorrect "E-mail" or exist'; } if (checkLenght(post('password'), 6, 20)) { $data['password'] = md5(post('password')); } else { $this->view->error = 'Incorrect "Password"'; } if (checkLenght(post('password_re'), 6, 20)) { if (post('password') != post('password_re')) { $this->view->error = 'Passwords do not match'; } } else { $this->view->error = 'Incorrect "Repeat password"'; } if (post('rules') != 'yes') { $this->view->error = 'You must agree to Rules'; } if (post('terms') != 'yes') { $this->view->error = 'You must accept Terms and Conditions'; } //$data['referral'] = $regCode->uid; // TODO ref system $data['dateLast'] = time(); $data['dateReg'] = time(); if (!$this->view->error) { $uid = $model->insert('users', $data); if ($uid) { setSession('user', $uid, false); //$model->deleteRegCode($regCode->id); redirect(url($uid)); } else { $this->view->error = 'Error Registration'; } } } else { $this->view->error = 'Incorrect "Registration code"'; } } $code = Request::getUriOptions()[0]; if ($code) { $_POST['code'] = $code; } $this->view->title = Lang::translate('REG_TITLE'); }
public function matchAction() { $model = new ProfileModel(); $uriOptions = Request::getUriOptions(); $match = $model->getMatchByID($uriOptions[0]); if (!$match) { error404(); } $users = $model->getMatchUsers($match->uid, $match->pid); setSession('match_' . $match->id, $match->id); //if ($match->uid == $users[0]->id) { if (Request::getParam('user')->id == $users[0]->id) { $this->view->uid = $users[0]; $this->view->pid = $users[1]; } else { $this->view->uid = $users[1]; $this->view->pid = $users[0]; } if ($match->uid == Request::getParam('user')->id) { $this->view->ready = $match->uready; } else { $this->view->ready = $match->pready; } $this->view->match = $match; //$this->view->assets = $model->getMatchAssets(Request::getParam('user')->id, $match->id); // enable if want init users assets load $this->view->list = $model->getChatMessages($match->id); $this->view->langPars = true; $this->view->title = $users[0]->nickname . ' ' . Lang::translate('MATCH_VS') . ' ' . $users[1]->nickname; }