Exemplo n.º 1
0
 function UploadForm($info)
 {
     $info['tab_name'] = 'Загрузка фотографий';
     $info['access_list'] = HelpFunctions::getAccessList();
     $this->setTemplate(null, 'upload_photo.tpl.php');
     $this->set($info);
 }
Exemplo n.º 2
0
 public function showErrorScreen()
 {
     echo "~~<font color='#ff0000'><b>" . $this->_errorCode . "<b></font>~~";
     echo HelpFunctions::backtrace();
     die;
     // TODO:: here can be sending information about exception to admin of site and logging
 }
Exemplo n.º 3
0
 function __construct($input)
 {
     $this->_parameters = array();
     $this->_classes = array();
     if (is_array($input)) {
         $input = HelpFunctions::Lower($input, true);
         $this->_parameters = $input;
         foreach ($this->_parameters as $key => $value) {
             if (is_array($value)) {
                 if (isset($value['class'])) {
                     $this->_classes[$key] = $value['class'];
                 }
             }
         }
     } else {
         $xml = simplexml_load_string($input);
         $buffer = array();
         foreach ($xml->attributes() as $attrName => $attrValue) {
             $this->_parameters[strtolower($attrName)] = trim((string) $attrValue);
         }
         foreach ($xml->children() as $param) {
             $buffer = array();
             $key = false;
             $class = false;
             foreach ($param->attributes() as $attrName => $attrValue) {
                 $val = trim((string) $attrValue);
                 if ($attrName == 'key') {
                     $key = strtolower($val);
                 }
                 if ($attrName == 'class') {
                     $class = $val;
                 }
                 if ($val === "true") {
                     $val = true;
                 } elseif ($val === "false") {
                     $val = false;
                 } elseif (is_numeric($val)) {
                     $val = $val;
                 }
                 $buffer[$attrName] = $val;
             }
             if ($key && (isset($buffer['enabled']) && $buffer['enabled'] == true || !isset($buffer['enabled']))) {
                 unset($buffer['key']);
                 unset($buffer['enabled']);
                 if (count($buffer) == 1) {
                     reset($buffer);
                     $buffer = current($buffer);
                 }
                 $this->_parameters[$key] = $buffer;
                 if ($class !== false) {
                     $this->_classes[$key] = $class;
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 4
0
 public function AlbumAction($edit = false, $filter = array(), $album_id = null)
 {
     $this->BaseSiteData();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $album_id = (int) $album_id > 0 ? $album_id : (int) Project::getRequest()->getKeyByNumber(0);
     $info = array();
     if ($request_user_id === $user_id && $edit === true) {
         $info['can_edit'] = true;
         $info['access_list'] = HelpFunctions::getAccessList();
     }
     if ((int) Project::getUser()->getShowedUser()->id <= 0) {
         $tabs = TabController::getMainAlbumTabs(false, false, true);
     } else {
         //	$tabs = TabController::getOwnTabs(false, true);
         $tabs = TabController::getOwnTabs(false, false, true);
     }
     $info['tab_list'] = $tabs;
     $album_model = new AlbumModel();
     $album_model->load($album_id);
     $info['thumbnail_id'] = (int) $album_model->thumbnail_id;
     $this->BaseAlbumData($info, $album_id);
     $photo_model = new PhotoModel();
     $photo_model->filter = $filter;
     $pager = new DbPager(Project::getRequest()->getKeyByNumber(1), $this->getParam('photo_per_page', self::DEFAULT_PHOTO_PER_PAGE));
     $photo_model->setPager($pager);
     $list = $photo_model->loadByAlbumUser($request_user_id, $album_id);
     $this->checkImages($list);
     $info['photo_list'] = $list;
     $info['list_pager'] = $photo_model->getPager();
     $info['list_controller'] = 'Photo';
     $info['list_action'] = 'Album';
     $info['list_user'] = null;
     $info['user_id'] = $user_id;
     $this->_view->assign('current_album_name', $album_model->name);
     $this->_view->PhotoList($info);
     $this->_view->parse();
 }
Exemplo n.º 5
0
 public function initialize(IConfigParameter $configuration)
 {
     if (get_magic_quotes_gpc()) {
         HelpFunctions::strips($_GET);
         HelpFunctions::strips($_POST);
         HelpFunctions::strips($_COOKIE);
         HelpFunctions::strips($_REQUEST);
     }
     $this->_requestMethod = $_SERVER['REQUEST_METHOD'];
     if ($this->_requestMethod == 'GET') {
         $this->_request = $_GET;
     } elseif ($this->_requestMethod == 'POST') {
         $this->_request = $_POST;
     } else {
         $this->_request = array();
     }
     $this->_username = $this->getSubDomain($configuration->get('base_host'));
     $this->_rewrite = (bool) $configuration->get('rewrite');
     if ($this->_rewrite) {
         $request_key = $configuration->get('request_key');
         $this->_param_delimiter = $configuration->get('param_delimiter');
         $this->_value_delimiter = $configuration->get('value_delimiter');
         $query = $_GET[$request_key];
         $d = explode($this->_param_delimiter, $query);
         if (isset($d[0]) && strlen($d[0])) {
             $this->_current_action = trim($d[0]);
             unset($d[0]);
             // unset controller key
             foreach ($d as $item) {
                 $tmp = explode($this->_value_delimiter, $item);
                 if (isset($tmp[0])) {
                     $v0 = trim($tmp[0]);
                     $v1 = isset($tmp[1]) ? trim($tmp[1]) : null;
                     if (strlen($v0)) {
                         $this->_request_by_number[] = $v0;
                     }
                     if (strlen($v1 !== null)) {
                         if ($this->_requestMethod == 'GET' || $this->_requestMethod == 'POST' && !isset($this->_request[$v0])) {
                             $this->_request[$v0] = $v1;
                         }
                     }
                 }
             }
         }
     } else {
         die(__METHOD__ . "::" . __LINE__ . "::Non-rewrite mode need some changes after last modification this manager!!!!");
         $this->_request_controller_key = $configuration->get('request_service_key');
         // Only for non-rewrite mode
         $this->_request_action_key = $configuration->get('request_action_key');
         // Only for non-rewrite mode
         if (!$this->_request_controller_key) {
             throw new ConfigurationException('HttpRequest, non-rewrite mode: service key at request not configured');
         }
         if (isset($this->_request[$this->_request_controller_key])) {
             $this->_current_controller = $this->_request[$this->_request_controller_key];
         }
     }
     $this->_files = $_FILES;
     Project::setRequest($this);
     $this->_common_config($configuration);
 }
Exemplo n.º 6
0
 /**
  * Вывод списка альбомов
  */
 public function ListAction()
 {
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $info = array();
     $info['tab_name'] = 'Фотоальбомы';
     if (Project::getUser()->isMyArea()) {
         $info['can_edit'] = true;
         $info['access_list'] = HelpFunctions::getAccessList();
     }
     $this->_list($info, "creation_date", "DESC", $this->getParam('album_per_page', $this->DEFAULT_ALBUM_PER_PAGE), 'List');
     $this->_view->AlbumList($info);
     $this->_view->parse();
 }
Exemplo n.º 7
0
 static function getDirSize($path)
 {
     $fileSize = 0;
     $dir = scandir($path);
     foreach ($dir as $file) {
         if ($file != '.' && $file != '..') {
             if (is_dir($path . '/' . $file)) {
                 $fileSize += HelpFunctions::getDirSize($path . '/' . $file);
             } else {
                 $fileSize += filesize($path . '/' . $file);
             }
         }
     }
     return $fileSize;
 }
Exemplo n.º 8
0
 function GTDAddFileAction()
 {
     $model = new GTDModel();
     $v_request = Project::getRequest();
     $v_session = Project::getSession();
     $request_keys = $v_request->getKeys();
     $fname = $_FILES['FileName']['tmp_name'];
     $realfname = $_FILES['FileName']['name'];
     if (HelpFunctions::isValidUploadFilename($realfname)) {
         $path = 'app' . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . $request_keys['cid'] . DIRECTORY_SEPARATOR . $request_keys['fid'] . DIRECTORY_SEPARATOR . $realfname;
         if (!file_exists('app' . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . $request_keys['cid'])) {
             mkdir('app' . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . $request_keys['cid']);
         }
         if (!file_exists('app' . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . $request_keys['cid'] . DIRECTORY_SEPARATOR . $request_keys['fid'])) {
             mkdir('app' . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . $request_keys['cid'] . DIRECTORY_SEPARATOR . $request_keys['fid']);
         }
         if (!file_exists($path)) {
             move_uploaded_file($fname, $path);
             $dbpath = '#app#user_files#' . $request_keys['cid'] . '#' . $request_keys['fid'] . '#' . $realfname;
             $model->addFolderFile($request_keys['fid'], $realfname, $dbpath, $request_keys['secure']);
         }
     }
     $files = $model->getFolderFiles($request_keys['fid']);
     $category_name = $model->getCategoryName($request_keys['cid']);
     $folder_name = $model->getFolderName($request_keys['fid']);
     $users = $model->getUserList();
     $this->_view->__set('users', $users);
     $this->_view->GTDOutputFiles($category_name, $folder_name, $request_keys['cid'], $request_keys['fid']);
     $this->_view->BuldTreeFilesView($files);
     $this->_view->parse();
 }
Exemplo n.º 9
0
 function checkEmail($email)
 {
     if (!HelpFunctions::isValidEmail($email)) {
         return array('error' => true, 'message' => 'Email неверный');
     } else {
         $user_model = new UserModel();
         $user_model->loadByEmail($email);
         if ($user_model->id > 0) {
             return array('error' => true, 'message' => 'Пользователь с таким email уже зарегистрирован на сайте');
         }
     }
     return array('error' => false, 'message' => 'Email доступен для регистрации');
 }
Exemplo n.º 10
0
 /**
  * 
  */
 public function EditBranchAction($id = null)
 {
     $request = Project::getRequest();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $this->BaseSiteData();
     $info = array();
     $this->BaseBlogData($info);
     $branch_id = $id !== null ? (int) $id : (int) $request->getKeyByNumber(0);
     $blog_model = new BlogModel();
     $blog_model->loadByUserId($user_id);
     $blog_id = (int) $blog_model->id;
     if ($blog_id <= 0) {
         Project::getResponse()->redirect($request->createUrl('Blog', 'Edit'));
     }
     $tree_model = new BlogTreeModel();
     $tree_model->load($branch_id);
     $info['user_id'] = $user_id;
     $info['request_user_id'] = $request_user_id;
     $info['branch_id'] = $tree_model->id;
     $info['branch_name'] = $tree_model->name;
     $info['branch_access'] = $tree_model->access;
     $info['blog_catalog_id'] = $tree_model->blog_catalog_id;
     $info['access_list'] = HelpFunctions::getBlogAccessList();
     $blog_banner = $blog_model->getBlogBannerById($tree_model->blog_banner_id);
     if ($blog_banner) {
         $info['blog_banner_code'] = $blog_banner['code'];
     }
     $catalog_model = new BlogCatalogModel();
     $info['catalog_list'] = $catalog_model->loadAll();
     $n = $tree_model->getNode();
     if ($n instanceof Node) {
         $child = $n->getLastChildKey();
         $parent = $n->key->getParent();
         $info['parent_key'] = $parent->__toString();
     } else {
         $child = null;
         $info['parent_key'] = null;
     }
     if ($child) {
         $info['parent_list'] = 1;
     } else {
         $info['parent_list'] = $tree_model->getParentList($blog_id, $tree_model->id);
     }
     $this->_view->BranchEdit($info);
     $this->_view->parse();
 }