public static function Instance() { if (self::$instance == null) { self::$instance = new self(); } return self::$instance; }
public function action_ckupload() { if (M_Users::Instance()->Get() == null) { die; } if (!isset($_FILES['upload'])) { die; } $callback = $_REQUEST['CKEditorFuncNum']; //$callback = 3; $mFiles = M_Files::Instance()->set_type('image'); //$mMediaFiles = M_MediaFiles::Instance(); if ($this->ck_sort_img_folder === true && isset($_GET['pid'])) { $pid = strip_tags($_GET['pid']); $destination = $this->ckupload_dir . $pid; if ($pid == 'post_0') { $destination .= '_' . $this->ck_temp_prefix . '/'; $_SESSION['destination'] = $destination; } else { $destination .= '/'; } } else { $destination = $this->ckupload_dir; } if (!is_dir($destination)) { mkdir($destination); } $file = $mFiles->upload_file($_FILES['upload'], $destination); if ($file) { $http_path = $destination . $file['name']; $message = 'Файл загружен'; } else { $http_path = ''; $message = $mFiles->error(); } echo "<script>window.parent.CKEDITOR.tools.callFunction({$callback}, \"" . $http_path . "\",\"" . $message . "\");</script>"; }
private function move_upload_base64($file, $name) { // Выделим данные $data = explode(',', $file); // Декодируем данные, закодированные алгоритмом MIME base64 $encodedData = str_replace(' ', '+', $data[1]); $decodedData = base64_decode($encodedData); // Создаем изображение на сервере if (file_put_contents($this->imgDir . $name, $decodedData)) { M_Files::Instance()->resize_img($this->imgDir . $name, $this->imgSmallDir . $name, $this->imgSmallWidht); return true; } return false; }
public function delete_mail($listid, $mail_id) { $dir = SITE_ROOT . '/' . MAILING_DIR . (int) $listid . '/' . (int) $mail_id . '/'; parent::delete($mail_id); if (file_exists($dir)) { M_Files::Instance()->remove_directory($dir); } return true; }