function registrationAction() { $v_params['logined'] = LoginChecker::isLogined(); $v_params['sys_name'] = SysPropertiesUtil::getPropertyValue("sys_name"); $v_params['sys_slog'] = SysPropertiesUtil::getPropertyValue("sys_slog"); $v_params['reg']['main'] = TRUE; if (0 < count($_POST)) { // Передача формы $containErrors = FALSE; if (isset($_POST['email'])) { $email = $_POST['email']; if (0 == strcmp("", $email)) { $v_params['errors'][] = "Email не может быть пустым"; $containErrors = TRUE; } else { if (!preg_match("/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}\$/", $email)) { $v_params['errors'][] = "Скорее всего вы ввели email не правильно"; $containErrors = TRUE; } else { $imgAccount = ImgAccountUtil::getImgAccountByEmail($email); if ($imgAccount) { $v_params['errors'][] = "Такой Email уже зарегистрирован"; $containErrors = TRUE; } } } } if (isset($_POST['password1'])) { $password1 = $_POST['password1']; if ("" == $password1) { $v_params['errors'][] = "Пароль не может быть пустым <br/>"; $containErrors = TRUE; } else { if (9 > strlen($password1)) { $v_params['errors'][] = "Длина пароля должна быть от 9 символов"; $containErrors = TRUE; } } } if (0 != strcmp($_POST['password1'], $_POST['password2'])) { $v_params['errors'][] = "Пароль и его подтверждение не совпадают"; $containErrors = TRUE; } if (isset($_POST['name'])) { $name = $_POST['name']; if ("" == $name) { $v_params['errors'][] = "Введите название торгового стенда (позднее вы сможете его изменить)"; $containErrors = TRUE; } } $resp = recaptcha_check_answer(RECAPCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $v_params['errors'][] = "Защита от роботов введена не верно"; $containErrors = TRUE; } // Обработка if ($containErrors) { // Есть ошибки $v_params['addr_regions'] = AddrRegionUtil::getRegions(); Application::fastView('main/sys_registration', $v_params); } else { // Нет ошибок, создаем аккаунт $imgAccount['email'] = $_POST['email']; $imgAccount['hashpass'] = Hasher::getHash($_POST['password1']); $imgAccount['show_email'] = 0; $imgAccount['active'] = 0; $imgAccount['img_name'] = $_POST['name']; $imgAccount['img_slog'] = $_POST['slog']; if (isset($_POST['region']) && "" != $_POST['region']) { $addrRegion = AddrRegionUtil::getRegionByCode($_POST['region']); $imgAddress['region_id'] = $addrRegion['id']; } $imgAddressId = ImgAddressUtil::insertImgAddress($imgAddress); $imgAccount['img_address_id'] = $imgAddressId; $imgAccount['show_address'] = 1; $activation_code = UUIDGenerator::generate(); $imgAccount['check_code'] = $activation_code; $imgAccountId = ImgAccountUtil::createImgAccount($imgAccount); $mail_values['__root_url__'] = "http://" . $_SERVER["HTTP_HOST"]; $mail_values['__act_url__'] = "http://" . $_SERVER["HTTP_HOST"] . "/activation?imgID=" . $imgAccountId . "&acode=" . $activation_code; MailWork::sendMailByTemplate($imgAccount['email'], "Завершение регистрации на сайте " . $_SERVER["HTTP_HOST"], "end_reg.html", $mail_values); $v_params['message'] = "На указаный email выслано письмо с подтверждением регистрации"; $v_params['message_descr'] = "Проверьте свой почтовый ящик, там будет письмо с сылкой для активации созданного аккаунта, после чего вы сможете работать со своим торговым стендом"; Application::fastView('main/sys_message', $v_params); } } else { $v_params['addr_regions'] = AddrRegionUtil::getRegions(); Application::fastView('main/sys_registration', $v_params); } }
function albumAction() { $img_id = $_SESSION['imag_id']; $imgAccount = ImgAccountUtil::getImgAccountById($img_id, TRUE); $v_params['sys_name'] = SysPropertiesUtil::getPropertyValue("sys_name"); $v_params['sys_slog'] = SysPropertiesUtil::getPropertyValue("sys_slog"); if (NULL != $imgAccount) { $v_params['logined'] = LoginChecker::isLogined(); if ($v_params['logined'] == $img_id) { $v_params['img_name'] = $imgAccount['img_name']; $v_params['mysc']['main'] = TRUE; $v_params['img_all_gds_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR; $v_params['img_all_blog_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR; $v_params['img_gds_cats_HTML'] = ImgGdsCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR . "?" . PROD_CAT_PARAM_NAME . "="); $v_params['img_blog_cats_HTML'] = ImgBlogCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR . "?" . ART_CAT_PARAM_NAME . "="); if (isset($_GET['act'])) { $action = $_GET['act']; if (0 == strcmp("add", $action)) { // Создать новый альбом $v_params['action_name'] = "Создать альбом"; if (isset($_POST['img_album_name'])) { $img_album_name = trim($_POST['img_album_name']); if (0 == strcmp("", $img_album_name)) { $v_params['messages'][] = "Имя альбома не может быть пустым"; } else { $imgAlbum['account_id'] = $imgAccount['id']; $imgAlbum['name'] = $img_album_name; $imgAlbum['description'] = $_POST['img_album_desc']; ImgAlbumUtil::insertImgAlbum($imgAlbum); $albumsURL = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/albums"; header("Location: {$albumsURL}"); } } Application::fastView('imag-admin/albums/img_admin_album_au', $v_params); exit; } else { if (0 == strcmp("upd", $action)) { // Переименовать альбом $v_params['action_name'] = "Переименовать альбом"; if (isset($_GET['alb_id'])) { $imgAlbumId = $_GET['alb_id']; $imgAlbum = ImgAlbumUtil::getImgAlbumByID($imgAlbumId, $imgAccount['id']); if (NULL != $imgAlbum) { $v_params['img_album_name'] = $imgAlbum['name']; $v_params['img_album_desc'] = $imgAlbum['description']; } } else { $albumsURL = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/albums"; header("Location: {$albumsURL}"); } if (isset($_POST['img_album_name'])) { $img_album_name = trim($_POST['img_album_name']); if (0 == strcmp("", $img_album_name)) { $v_params['messages'][] = "Имя альбома не может быть пустым"; } else { $imgAlbum['id'] = $imgAlbumId; $imgAlbum['account_id'] = $imgAccount['id']; $imgAlbum['name'] = $img_album_name; $imgAlbum['description'] = $_POST['img_album_desc']; ImgAlbumUtil::updateImgAlbum($imgAlbum); $albumsURL = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/albums"; header("Location: {$albumsURL}"); } } Application::fastView('imag-admin/albums/img_admin_album_au', $v_params); exit; } else { if (0 == strcmp("del", $action)) { // Удалить альбом $v_params['action_name'] = "Удалить альбом"; if (isset($_GET['alb_id'])) { $imgAlbumId = $_GET['alb_id']; $imgAlbum = ImgAlbumUtil::getImgAlbumByID($imgAlbumId, $imgAccount['id']); if (NULL != $imgAlbum) { $v_params['img_album_name'] = $imgAlbum['name']; $v_params['img_album_desc'] = $imgAlbum['description']; $v_params['img_album_pict_count'] = ImgPictureUtil::countImgPicturesByAlbumId($imgAlbumId); } } else { $albumsURL = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/albums"; header("Location: {$albumsURL}"); } if ($_POST['album_del_form']) { if ($_POST['with_pict']) { $img_pictures = ImgPictureUtil::getImgPicturesByAlbumId($imgAlbumId, $imgAccount['id']); if (count($img_pictures)) { foreach ($img_pictures as $img_pucture) { $file_path = dirname(__FILE__) . "/../../../application_data" . $img_pucture['path']; unlink($file_path); $path_blocks = explode("/", $img_pucture['path']); $last = count($path_blocks) - 1; $path_blocks[$last] = SMAL_PICT_PREFIX . $path_blocks[$last]; $path_small = implode("/", $path_blocks); $smal_file_path = dirname(__FILE__) . "/../../../application_data" . $path_small; unlink($smal_file_path); } } ImgAlbumUtil::deleteImgAlbumByID($imgAlbumId, TRUE); } else { ImgAlbumUtil::deleteImgAlbumByID($imgAlbumId, FALSE); } $albumsURL = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/albums"; header("Location: {$albumsURL}"); } else { Application::fastView('imag-admin/albums/img_admin_album_del', $v_params); exit; } } else { if (0 == strcmp("show", $action)) { // Показать содержимое $v_params['action_name'] = "Содержимое альбома"; $alb_id = $_GET['alb_id']; $v_params['pict_control_url'] = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/picture"; $v_params['img_album'] = ImgAlbumUtil::getImgAlbumByID($alb_id, $imgAccount['id']); if (NULL == $v_params['img_album']) { $v_params['img_album_name'] = "Картинки без альбома"; } else { $v_params['img_album_name'] = $v_params['img_album']['name']; } // Загрузка файлов if (NULL != $alb_id && NULL != $v_params['img_album'] || NULL == $alb_id) { if (isset($_FILES) && NULL != $_FILES['file']) { // директория для изображений $images_dir = dirname(__FILE__) . "/../../../application_data/images/"; foreach ($_FILES['file']['name'] as $k => $f) { if (!$_FILES['file']['error'][$k]) { if (is_uploaded_file($_FILES['file']['tmp_name'][$k])) { $fn = UUIDGenerator::generate(); $dir_path = $images_dir . "acc" . $imgAccount['id'] . "/"; $file_path = $dir_path . $fn; $rel_file_path = "/images/acc" . $imgAccount['id'] . "/" . $fn; @mkdir($dir_path, 0766); @ImageUtil::create_small($_FILES['file']['tmp_name'][$k], $file_path, SIZE_BIG_PICT, SIZE_BIG_PICT); @ImageUtil::create_small($file_path, $dir_path . SMAL_PICT_PREFIX . $fn, SIZE_SMAL_PICT, SIZE_SMAL_PICT); unlink($_FILES['file']['tmp_name'][$k]); $imgPicture['account_id'] = $imgAccount['id']; $imgPicture['album_id'] = $alb_id; $imgPicture['name'] = $_FILES['file']['name'][$k]; $imgPicture['path'] = $rel_file_path; ImgPictureUtil::createImgPicture($imgPicture); } } } } if (NULL == $alb_id) { $v_params['alb_pictures'] = ImgPictureUtil::getImgPicturesNoAlbum($imgAccount['id']); } else { $v_params['alb_pictures'] = ImgPictureUtil::getImgPicturesByAlbumId($alb_id, $imgAccount['id']); } Application::fastView('imag-admin/albums/img_admin_album_show', $v_params); return; } } } } } } } } Application::fastView('main/sys_error', $v_params); }
function albumAction() { $v_params['sys_name'] = SysPropertiesUtil::getPropertyValue("sys_name"); $v_params['sys_slog'] = SysPropertiesUtil::getPropertyValue("sys_slog"); if (LoginChecker::isAdmin()) { if (isset($_GET['act'])) { $action = $_GET['act']; if (0 == strcmp("add", $action)) { // Создать новый альбом $v_params['action_name'] = "Создать альбом"; if (isset($_POST['img_album_name'])) { $img_album_name = trim($_POST['img_album_name']); if (0 == strcmp("", $img_album_name)) { $v_params['messages'][] = "Имя альбома не может быть пустым"; } else { $imgAlbum['account_id'] = 0; $imgAlbum['name'] = $img_album_name; $imgAlbum['description'] = $_POST['img_album_desc']; ImgAlbumUtil::insertImgAlbum($imgAlbum); header("Location: /superAdmin/albums"); } } Application::fastView('super-admin/albums/album_au', $v_params); exit; } else { if (0 == strcmp("upd", $action)) { // Переименовать альбом $v_params['action_name'] = "Переименовать альбом"; if (isset($_GET['alb_id'])) { $imgAlbumId = $_GET['alb_id']; $imgAlbum = ImgAlbumUtil::getImgAlbumByID($imgAlbumId, 0); if (NULL != $imgAlbum) { $v_params['img_album_name'] = $imgAlbum['name']; $v_params['img_album_desc'] = $imgAlbum['description']; } } else { header("Location: /superAdmin/albums"); } if (isset($_POST['img_album_name'])) { $img_album_name = trim($_POST['img_album_name']); if (0 == strcmp("", $img_album_name)) { $v_params['messages'][] = "Имя альбома не может быть пустым"; } else { $imgAlbum['id'] = $imgAlbumId; $imgAlbum['account_id'] = 0; $imgAlbum['name'] = $img_album_name; $imgAlbum['description'] = $_POST['img_album_desc']; ImgAlbumUtil::updateImgAlbum($imgAlbum); header("Location: /superAdmin/albums"); } } Application::fastView('super-admin/albums/album_au', $v_params); exit; } else { if (0 == strcmp("del", $action)) { // Удалить альбом $v_params['action_name'] = "Удалить альбом"; if (isset($_GET['alb_id'])) { $imgAlbumId = $_GET['alb_id']; $imgAlbum = ImgAlbumUtil::getImgAlbumByID($imgAlbumId, 0); if (NULL != $imgAlbum) { $v_params['img_album_name'] = $imgAlbum['name']; $v_params['img_album_desc'] = $imgAlbum['description']; $v_params['img_album_pict_count'] = ImgPictureUtil::countImgPicturesByAlbumId($imgAlbumId); } } else { header("Location: /superAdmin/albums"); } if ($_POST['album_del_form']) { if ($_POST['with_pict']) { $img_pictures = ImgPictureUtil::getImgPicturesByAlbumId($imgAlbumId, 0); if (count($img_pictures)) { foreach ($img_pictures as $img_pucture) { $file_path = dirname(__FILE__) . "/../../application_data" . $img_pucture['path']; unlink($file_path); $path_blocks = explode("/", $img_pucture['path']); $last = count($path_blocks) - 1; $path_blocks[$last] = SMAL_PICT_PREFIX . $path_blocks[$last]; $path_small = implode("/", $path_blocks); $smal_file_path = dirname(__FILE__) . "/../../application_data" . $path_small; unlink($smal_file_path); } } ImgAlbumUtil::deleteImgAlbumByID($imgAlbumId, TRUE); } else { ImgAlbumUtil::deleteImgAlbumByID($imgAlbumId, FALSE); } header("Location: /superAdmin/albums"); } else { Application::fastView('super-admin/albums/album_del', $v_params); exit; } } else { if (0 == strcmp("show", $action)) { $v_params['action_name'] = "Содержимое альбома"; $alb_id = (int) $_GET['alb_id']; $v_params['pict_control_url'] = "/superAdmin/picture"; $v_params['img_album'] = ImgAlbumUtil::getImgAlbumByID($alb_id, 0); if (NULL == $v_params['img_album']) { $v_params['img_album_name'] = "Картинки без альбома"; } else { $v_params['img_album_name'] = $v_params['img_album']['name']; } // Загрузка файлов if (NULL != $alb_id && NULL != $v_params['img_album'] || NULL == $alb_id) { if (isset($_FILES) && NULL != $_FILES['file']) { // директория для изображений $images_dir = dirname(__FILE__) . "/../../application_data/images/"; foreach ($_FILES['file']['name'] as $k => $f) { if (!$_FILES['file']['error'][$k]) { if (is_uploaded_file($_FILES['file']['tmp_name'][$k])) { $fn = UUIDGenerator::generate(); $dir_path = $images_dir . "acc0/"; $file_path = $dir_path . $fn; $rel_file_path = "/images/acc0/" . $fn; @mkdir($dir_path, 0766); @ImageUtil::create_small($_FILES['file']['tmp_name'][$k], $file_path, SIZE_BIG_PICT, SIZE_BIG_PICT); @ImageUtil::create_small($file_path, $dir_path . SMAL_PICT_PREFIX . $fn, SIZE_SMAL_PICT, SIZE_SMAL_PICT); unlink($_FILES['file']['tmp_name'][$k]); $imgPicture['account_id'] = 0; $imgPicture['album_id'] = $alb_id; $imgPicture['name'] = $_FILES['file']['name'][$k]; $imgPicture['path'] = $rel_file_path; ImgPictureUtil::createImgPicture($imgPicture); } } } } if (NULL == $alb_id) { $v_params['alb_pictures'] = ImgPictureUtil::getImgPicturesNoAlbum(0); } else { $v_params['alb_pictures'] = ImgPictureUtil::getImgPicturesByAlbumId($alb_id, 0); } Application::fastView('super-admin/albums/album_show', $v_params); exit; } } } } } } } else { header("Location: /superAdmin/login"); } }