0, 'image_count' => 0, 'afolder' => "", 'folders' => [], ]; /** * @param $val * * @return int */ private static function get_server_limits($val) { $val = trim($val); $last = strtolower($val[strlen($val) - 1]); $kb = 1024; $mb = 1024 * $kb; $gb = 1024 * $mb; switch ($last) { case 'g': $val = (int)$val * $gb; break; case 'm': $val = (int)$val * $mb; break; case 'k': $val = (int)$val * $kb; break; } return (int)$val; } public static function max_server_upload() { //select maximum upload size $max_upload = self::get_server_limits(ini_get('upload_max_filesize')); //select post limit $max_post = self::get_server_limits(ini_get('post_max_size')); //select memory limit $memory_limit = self::get_server_limits(ini_get('memory_limit')); // return the smallest of them, this defines the real limit return min($max_upload, $max_post, $memory_limit); } public function __construct() { require_once INCLUDES."infusions_include.php"; $settings_inf = [ 'blog' => defined('BLOG_EXIST') ? get_settings('blog') : '', 'news' => defined('NEWS_EXIST') ? get_settings('news') : '', ]; self::$locale = fusion_get_locale("", LOCALE.LOCALESET."admin/image_uploads.php"); self::$settings = fusion_get_settings(); $maxed_out_settings = [ 'max_width' => 24000, 'max_height' => 24000, 'max_byte' => (self::max_server_upload() ?: 3 * 1000 * 1000 * 100) ]; $folders = [ "images" => [ 'locale' => self::$locale['422'], 'link' => IMAGES, 'count' => TRUE, 'fileinp' => $maxed_out_settings, ] ]; if (defined('ARTICLES_EXIST')) { $folders += [ "imagesa" => [ 'locale' => self::$locale['423'], 'link' => IMAGES_A, 'count' => defined('ARTICLES_EXIST'), 'fileinp' => $maxed_out_settings, ] ]; } if (defined('NEWS_EXIST')) { $folders += [ "imagesn" => [ 'locale' => self::$locale['424'], 'link' => IMAGES_N, 'count' => defined('NEWS_EXIST'), 'fileinp' => [ 'max_width' => !empty($settings_inf['news']) ? $settings_inf['news']['news_photo_max_w'] : 0, 'max_height' => !empty($settings_inf['news']) ? $settings_inf['news']['news_photo_max_h'] : 0, 'max_byte' => !empty($settings_inf['news']) ? $settings_inf['news']['news_photo_max_b'] : 0, ], ], "imagesnc" => [ 'locale' => self::$locale['427'], 'link' => IMAGES_NC, 'count' => defined('NEWS_EXIST'), 'fileinp' => [ 'max_width' => !empty($settings_inf['news']) ? $settings_inf['news']['news_photo_max_w'] : 0, 'max_height' => !empty($settings_inf['news']) ? $settings_inf['news']['news_photo_max_h'] : 0, 'max_byte' => !empty($settings_inf['news']) ? $settings_inf['news']['news_photo_max_b'] : 0, ], ] ]; } if (defined('BLOG_EXIST')) { $folders += [ "imagesb" => [ 'locale' => self::$locale['428'], 'link' => IMAGES_B, 'count' => defined('BLOG_EXIST'), 'fileinp' => [ 'max_width' => !empty($settings_inf['blog']) ? $settings_inf['blog']['blog_photo_max_w'] : 0, 'max_height' => !empty($settings_inf['blog']) ? $settings_inf['blog']['blog_photo_max_h'] : 0, 'max_byte' => !empty($settings_inf['blog']) ? $settings_inf['blog']['blog_photo_max_b'] : 0, ], ], "imagesbc" => [ 'locale' => self::$locale['429'], 'link' => IMAGES_BC, 'count' => defined('BLOG_EXIST'), 'fileinp' => [ 'max_width' => !empty($settings_inf['blog']) ? $settings_inf['blog']['blog_photo_max_w'] : 0, 'max_height' => !empty($settings_inf['blog']) ? $settings_inf['blog']['blog_photo_max_h'] : 0, 'max_byte' => !empty($settings_inf['blog']) ? $settings_inf['blog']['blog_photo_max_b'] : 0, ], ], ]; } $this->data['folders'] = $folders; if (isset($_GET['ifolder']) && ctype_alnum($_GET['ifolder']) == 1 && isset($folders[$_GET['ifolder']]['link'])) { $_GET['ifolder'] = stripinput($_GET['ifolder']); $this->data['afolder'] = $folders[$_GET['ifolder']]['link']; } else { $_GET['ifolder'] = "images"; $this->data['afolder'] = IMAGES; } $_GET['action'] = isset($_GET['action']) ? $_GET['action'] : ''; switch ($_GET['action']) { case 'delete': self::delete_images($_GET['view']); break; case 'update': include INCLUDES."buildlist.php"; break; default: break; } $this->data['image_list'] = makefilelist($this->data['afolder'], ".|..", TRUE, "files", "php|js|ico|DS_Store|SVN"); if ($this->data['image_list']) { $this->data['image_count'] = count($this->data['image_list']); } BreadCrumbs::getInstance()->addBreadCrumb(['link' => ADMIN.'images.php'.fusion_get_aidlink(), 'title' => self::$locale['460']]); } public static function getInstance($key = 'default') { if (!isset(self::$instances[$key])) { self::$instances[$key] = new static(); } return self::$instances[$key]; } private function delete_images($id) { unlink($this->data['afolder'].stripinput($id)); if (self::$settings['tinymce_enabled'] == 1) { include INCLUDES."buildlist.php"; } addNotice('warning', self::$locale['401']); redirect(clean_request("", ["section", "action", "view"], FALSE)); } public function display_admin() { opentable(self::$locale['460']); $allowed_section = ["list", "upload", 'edit']; if (isset($_GET['section']) && $_GET['section'] == "back") { redirect(clean_request("", ["section", "action", "view"], FALSE)); } $_GET['section'] = isset($_GET['section']) && in_array($_GET['section'], $allowed_section) ? $_GET['section'] : 'list'; $edit = (isset($_GET['action']) && $_GET['action'] == 'edit') ? $_GET['ifolder'] : ''; if ($edit) { $tab_title['title'][] = self::$locale['back']; $tab_title['id'][] = "back"; $tab_title['icon'][] = "fa fa-fw fa-arrow-left"; } $tab_title['title'][] = $edit ? self::$locale['440'] : self::$locale['460']; $tab_title['id'][] = $edit ? 'edit' : 'list'; $tab_title['icon'][] = $edit ? 'fa fa-eye' : 'fa fa-picture-o'; $tab_title['title'][] = self::$locale['420']; $tab_title['id'][] = 'upload'; $tab_title['icon'][] = 'fa fa-plus'; echo opentab($tab_title, $_GET['section'], 'list', TRUE); switch ($_GET['section']) { case "upload": $this->add_image_form(); break; case "edit": $this->edit_image(); break; default: $this->image_list(); break; } echo closetab(); closetable(); } public function edit_image() { if (isset($_GET['view']) && in_array($_GET['view'], $this->data['image_list'])) { echo "
".$this->data['image_list'][$i]." | \n"; echo "\n"; echo "".self::$locale['461']." -\n"; echo "".self::$locale['delete']." | \n"; echo "