public function IndexAction() { if (!Request::isPosted('email')) { $this->Render(); } else { $email = Request::post('email', '', 'mail'); $pass1 = Request::post('pass1', '', 'safe'); $pass2 = Request::post('pass2', '', 'safe'); if ($email == '') { Site::Message('Вы не указали Ваш e-mail, или такого адреса не существует'); $this->Render(); } elseif (UserModel::isExists($email, 'login')) { Site::Message('Похоже пользователь с таким почтовым ящиком уже существует.<br>Возможно Вы регистрировались раньше, если вы забыли пароль, Вы можете восстановить его.'); $this->Render(); } elseif ($pass1 == '') { Site::Message('Вы забыли придумать пароль'); $this->Render(); } elseif (strlen($pass1) < 6) { Site::Message('Пароль короче 6-ти символов =('); $this->Render(); } elseif ($pass1 != $pass2) { Site::Message('Введенные Вами пароли не совпадают, где-то ошиблись, попробуйте ещё раз'); $this->Render(); } else { UserModel::Registration($email, $pass1); User::LoginByPass($email, $pass1); Site::Message('Ваш профиль успешно создан!'); $this->Route('newcompany'); } } }
public function SaveFile($name) { if (move_uploaded_file($_FILES[$this->filename]["tmp_name"], ROOT . 'web/files/' . $name)) { Site::Message('Файл Успешно загружен'); } else { Site::Error('Ошибка загрузки файла'); } }
public function DeleteAction() { $id = intval(Request::GetPart(3)); $contact = ContactsModel::GetObj()->where('id = ? AND company_id = ?', [0 => $id, 1 => $this->company->id]); if ($contact->id > 0) { ContactsModel::delete()->id($contact->id); } Site::Message('Контакт успешно удалён'); $this->route('profile'); }
public function Route($newcontroller = default_page, $action = 'index') { $newcontroller = mb_convert_case($newcontroller, MB_CASE_TITLE, "UTF-8") . 'Controller'; if (class_exists($newcontroller)) { $this->HTML = (new $newcontroller($action))->HTML; } else { Site::Message('404 Страница не найдена (ошибка цепочки вызовов)'); } $this->finished = true; }
public function NewrateAction() { $id = Request::GetPart(2, 0); $rate = intval(Request::post('rate', 0)); if ($id > 0) { $company = CompanyModel::GetObj()->id($id); $company->rate = $rate; $company->save(); Site::Message('Рейтинг компании ' . $company->name . ' успешно изменён'); $this->route(); } }
public function DeletemyaccountAction() { if (!UserModel::CheckPassword(User::GetID(), Request::post('oldpass'))) { Site::Message('Пароль указан не верно'); $this->Render('index', ['company' => $this->company]); } else { GroupModel::Dec($this->company->group_id); CompanyModel::DeleteCompany($this->company->id); Site::Message('Ваш профиль был полностью удалён с сайта, мы очень сожалеем =( '); $this->route(); } }
public function FavoriteSet($id) { if ($id > 0 and $id != User::company()) { $cnt = SQL::Query('SELECT count(*) as cnt FROM `favorites` WHERE host_id = ? AND fav_id = ?', [0 => User::company(), 1 => $id])->fetch(PDO::FETCH_OBJ)->cnt; if ($cnt > 0) { Site::Message('Компания удалена из избранного'); FavoriteModel::drop($id); } else { Site::Message('Компаниия добавлена в избранное'); FavoriteModel::add($id); } } }
public function UpdateAction() { Site::Message('Обновление файла sitemap.xml'); $companys = SQL::Query('SELECT id FROM `companys` ORDER BY id;')->FetchAll(PDO::FETCH_OBJ); $sitelink = Site::link(); $this->sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n"; $this->addurl($sitelink); $this->addurl($sitelink . 'list'); $this->addurl($sitelink . 'list/setgroup'); $this->addurl($sitelink . 'feedback'); foreach ($companys as $company) { $this->addurl($sitelink . $company->id); } $this->sitemap .= '</urlset>'; file_put_contents('./sitemap.xml', $this->sitemap); }
public function SendAction() { $company = Request::post('company_name', ''); $adress = Request::post('adress', ''); $message = Request::post('message', ''); if ($message == '') { Site::Message('Текст сообщения не может быть пустым'); $this->render('index', ['company' => $company, 'adress' => $adress]); } elseif ($company == '') { Site::Message('Поле "Отправитель" не может быть пустым'); $this->render('index', ['company' => '', 'adress' => $adress]); } else { Site::Message('Ваше сообщение отправлено'); $this->sendemail($company, $message, $adress); $this->route(); } }
public function MeAction() { Site::Message('Вы в списке избранного у следующих компаний'); $favorits = FavoriteModel::GetAll('host_id')->where('fav_id = ?', [0 => $this->company->id]); foreach ($favorits as $fav) { $add = ', '; if ($list == '') { $add = ''; } $list .= $add . $fav->host_id; } if ($list != '') { $this->ShowList($list); } else { $this->Render('empty', ['company' => $this->company]); } }
public function setpasswordAction() { $pass1 = Request::post('pass1', '', 'safe'); $pass2 = Request::post('pass2', '', 'safe'); if (User::isLogged()) { if ($pass1 != $pass2) { Site::Message('Введенные пароли не совпадают'); $this->Render('setpass'); } elseif (strlen($pass1) < 6) { Site::Message('Введенный новый пароль, короче шести символов'); $this->Render('setpass'); } else { UserModel::SetPassword(User::GetID(), $pass1); Site::Message('Пароль успешно изменен'); $this->Route(); } } else { Site::Message('Неверная ссылка'); $this->Route(); } }
public function IndexAction() { if (User::isLogged()) { Site::Message('Вы уже вошли в систему'); $this->Route(); } elseif (Request::isPosted('loguser')) { User::LoginByPass(Request::post('loguser', '', 'mail'), Request::post('logpass', '', 'safe')); if (!User::isLogged()) { Site::Error('Неверный логин или пароль'); $this->Render(); } else { Site::Message('Вы успешно вошли в систему'); if (!User::admin()) { $this->Route('profile'); } else { $this->Route(); } } } else { $this->Render(); } }
public function start() { User::logout(); Site::Message('Вы успешно вышли из системы'); $this->Route(); }
public function SetlogoAction() { $file = new File('logo', 7); if ($file->isLoaded()) { if (!$file->checktype(['jpg', 'jpeg', 'bmp', 'gif', 'png'])) { Site::Error('Неверный тип файла'); $this->IndexAction(); } else { $new_name = $file->getnewname(); $file->SaveResizedImage($new_name, 200, 0); $file->SaveResizedImage('s_' . $new_name, 100, 0); if (file_exists(ROOT . '/web/files/' . $this->company->logo) and $this->company->logo != '') { unlink(ROOT . '/web/files/' . $this->company->logo); unlink(ROOT . '/web/files/s_' . $this->company->logo); } $this->company->logo = $new_name; $this->company->save(); $this->IndexAction(); } } else { Site::Message('Ошибка загрузки файла, попробуйте ещё раз'); $this->IndexAction(); } }
private function search($search) { $res = CompanyModel::Search($search, $this->region_id, $this->group_id, $this->result_per_page, ($this->page - 1) * $this->result_per_page); if (SQL::Count() == 0 and $this->group_id + $this->region_id > 0 and $search != '') { $this->region_id = 0; $this->group_id = 0; $res = CompanyModel::search($search, 0, 0, $this->page, ($this->page - 1) * $this->result_per_page); if (SQL::Count() > 0) { Site::Message('Мы не нашли ничего в выбранных вами группах, но похоже что-то нашлось тут.'); } } if (SQL::Count() == 0) { return $this->filter($search); } return $res; }
public function SetlogoAction() { $file = new File('logo', 7); if ($file->isLoaded()) { if (!$file->checktype(['jpg', 'jpeg', 'bmp', 'gif', 'png'])) { Site::Error('Неверный тип файла'); $this->render('logo'); } else { $new_name = $file->getnewname(); $file->SaveResizedImage($new_name, 200, 200); $file->SaveResizedImage('s_' . $new_name, 100, 100); //Если файл лого уже существует $company = CompanyModel::GetObj()->id(User::company()); if (file_exists(ROOT . '/web/files/' . $company->logo) and $company->logo != '') { unlink(ROOT . '/web/files/' . $company->logo); unlink(ROOT . '/web/files/s_' . $company->logo); } $this->company->logo = $new_name; $this->company->save(); $this->ConfirmlogoAction(); } } else { Site::Message('Ошибка загрузки файла, попробуйте ещё раз'); $this->render('logo'); } }
public function DeleteAction() { $id = intval(Request::GetPart(3)); $product = ProductModel::GetObj()->where('id = ? AND company_id = ?', [0 => $id, 1 => $this->company->id]); if ($product->id > 0) { ProductModel::delete()->id($product->id); } if ($product->pic != '') { if (file_exists(ROOT . '/web/files/' . $product->pic)) { unlink(ROOT . '/web/files/' . $product->pic); } if (file_exists(ROOT . '/web/files/s_' . $product->pic)) { unlink(ROOT . '/web/files/s_' . $product->pic); } } Site::Message('Продукт успешно удалён'); $this->route('profile'); }