first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Controller;
use Joomunited\WPFramework\v1_0_4\Utilities;
use Joomunited\WPFramework\v1_0_4\Filesystem;
defined( 'ABSPATH' ) || die();
class wpfdControllerCategory extends Controller {
/**
* Save file params
*/
public function saveparams(){
$modelRoles = $this->getModel('roles');
$params = Utilities::getInput('params','POST','none');
$id = Utilities::getInput('id','GET','int');
$roles = isset($params['roles']) ? $params['roles'] : array();
if(!$modelRoles->save($id, $params['visibility'],$roles)){
$this->exitStatus(false,'error while saving');
}
$model = $this->getModel();
if(!$model->saveParams($id,$params)) {
$this->exitStatus(false,'error while saving params');
}
$this->exitStatus(true);
}
public function listdir(){
if(!is_admin()){
return json_encode(array());
}
$modelConfig = $this->getModel('config');
$config = $modelConfig->getConfig();
$allowed_ext = explode(',', $config['allowedext']);
foreach ($allowed_ext as $key => $value) {
$allowed_ext[$key] = strtolower(trim($allowed_ext[$key]));
if($allowed_ext[$key]==''){
unset($allowed_ext[$key]);
}
}
$path = get_home_path(). DIRECTORY_SEPARATOR;
$dir = Utilities::getInput('dir', 'GET', 'none');
$return = $dirs = $fi = array();
if( file_exists($path.$dir) ) {
$files = scandir($path.$dir);
natcasesort($files);
if( count($files) > 2 ) {
// All dirs
foreach( $files as $file ) {
if( file_exists($path . $dir . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..' && is_dir($path . $dir. DIRECTORY_SEPARATOR . $file) ) {
$dirs[] = array('type'=>'dir','dir'=>$dir,'file'=>$file);
}elseif( file_exists($path . $dir . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..' && !is_dir($path . $dir . DIRECTORY_SEPARATOR . $file) && in_array(wpfd_getext($file), $allowed_ext) ) {
$fi[] = array('type'=>'file','dir'=>$dir,'file'=>$file,'ext'=>strtolower(wpfd_getext($file)));
}
}
$return = array_merge($dirs,$fi);
}
}
echo json_encode( $return );
wp_die();
}
}
?>

View File

@@ -0,0 +1,85 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Controller;
use Joomunited\WPFramework\v1_0_4\Form;
use Joomunited\WPFramework\v1_0_4\Utilities;
use Joomunited\WPFramework\v1_0_4\Factory;
use Joomunited\WPFramework\v1_0_4\Application;
defined( 'ABSPATH' ) || die();
class wpfdControllerConfig extends Controller {
/**
* Save file params
*/
public function savetfileparams(){
$model = $this->getModel();
$form = new Form();
$formfile = Application::getInstance('wpfd')->getPath().DIRECTORY_SEPARATOR. 'admin'.DIRECTORY_SEPARATOR.'forms'.DIRECTORY_SEPARATOR.'file_config.xml';
if(!$form->load($formfile)){
$this->redirect('admin.php?page=wpfd-config&error=1');
}
if(!$form->validate()){
$this->redirect('admin.php?page=wpfd-config&error=2');
}
$datas = $form->sanitize();
if(!$model->saveFileParams($datas)){
$this->redirect('admin.php?page=wpfd-config&error=3');
}
$this->redirect('admin.php?page=wpfd-config');
}
/**
* Save config
*/
public function saveconfig(){
$model = $this->getModel();
$form = new Form();
if(!$form->load('config')){
$this->redirect('admin.php?page=wpfd-config&error=1');
}
if(!$form->validate()){
$this->redirect('admin.php?page=wpfd-config&error=2');
}
$datas = $form->sanitize();
if(!$model->save($datas)){
$this->redirect('admin.php?page=wpfd-config&error=3');
}
$this->redirect('admin.php?page=wpfd-config');
}
public function getTokenKey(){
$dropAuthor = Utilities::getInput('dropAuthor', 'POST','string');
$app = Application::getInstance('wpfdAddon');
require_once $app->getPath().DIRECTORY_SEPARATOR.$app->getType().DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'wpfdAddonDropbox.php';
$Dropbox = new wpfdAddonDropbox();
if(!empty($dropAuthor)){
//convert code authorCOde to Token
$list = $Dropbox->convertAuthorizationCode($dropAuthor);
}
if($list['accessToken']){
$app = Application::getInstance('wpfdAddon');
require_once $app->getPath().DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'wpfdHelper.php';
//save accessToken to database
$saveParams = new wpfdAddonHelper();
$params = $saveParams->getAllDropboxConfigs();
$params['dropboxToken'] = $list['accessToken'];
$saveParams->saveDropboxConfigs($params);
}
$this->exitStatus(true,$list);
}
}
?>

View File

@@ -0,0 +1,251 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Controller;
use Joomunited\WPFramework\v1_0_4\Form;
use Joomunited\WPFramework\v1_0_4\Utilities;
defined('ABSPATH') || die();
class wpfdControllerFile extends Controller
{
/**
* Download file
*/
public function download()
{
$model = $this->getModel();
$id = Utilities::getInt('id');
$version = Utilities::getInput('version', 'GET', 'string');
$catid = Utilities::getInt('catid');
if (apply_filters('wpfdAddonCategoryFrom', $catid) == 'dropbox') {
$id_file = Utilities::getInput('id', 'GET', 'string');
$vid = Utilities::getInput('vid', 'GET', 'string');
if ($version) {
apply_filters('wpfdAddonDownloadVersion', $id_file, $vid);
}
exit();
} else {
$file = $model->getFile($id);
$remote_url = false;
if (!$version) {
$file = $model->getFile($id);
$file_meta = get_post_meta($id, '_wpfd_file_metadata', true);
$remote_url = isset($file_meta['remote_url']) ? $file_meta['remote_url'] : false;
$url = $file_meta['file'];
} else {
$vid = Utilities::getInt('vid');
$version = $model->getVersion($vid);
if ($version) {
$file = array_merge($file, $version);
if ($version['remote_url']) {
$remote_url = true;
$url = $version['file'];
}
}
}
//todo : verifier les droits d'acces à la catéorgie du fichier
if (!empty($file) && $file['ID']) {
$filename = preg_replace('/[^a-zA-Z0-9-_\.]/', '', $file['title']);
if ($filename == '') {
$filename = 'download';
}
if ($remote_url) {
header("Location: $url");
} else {
$contenType = 'application/octet-stream';
$sysfile = wpfdBase::getFilesPath($file['catid']) . '/' . $file['file'];
if (file_exists($sysfile)) {
@ob_end_clean();
ob_start();
header('Content-Description: File Transfer');
header('Content-Type: ' . $contenType);
header('Content-Disposition: attachment; filename=' . basename($filename . '.' . $file['ext']));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($sysfile));
ob_clean();
flush();
readfile($sysfile);
}
}
}
exit();
}
}
/**
* Restore file
*/
public function restore()
{
$id_file = Utilities::getInt('id');
$vid = Utilities::getInt('vid');
$catid = Utilities::getInt('catid');
if (apply_filters('wpfdAddonCategoryFrom', $catid) == 'dropbox') {
$id_file = Utilities::getInput('id', 'GET', 'string');
$vid = Utilities::getInput('vid', 'GET', 'string');
$version = apply_filters('wpfdAddonRestoreVersion', $id_file, $vid);
$this->exitStatus($version);
} else {
$model = $this->getModel();
$file = $model->getFile($id_file);
$version = $model->getVersion($vid);
$result = false;
if ($version) {
$result = $model->updateFile($id_file, array(
'title' => $file['title'],
'file' => $version['file'],
'ext' => $version['ext'],
'size' => $version['size'],
'version' => $version['version'],
'remote_url' => $version['remote_url']
));
$result = (bool)$model->deleteVersion($vid);
$this->exitStatus(true);
}
$this->exitStatus(false);
}
}
/**
* Delete file version
*/
public function deleteVersion()
{
$idCategory = Utilities::getInt('catid');
if (apply_filters('wpfdAddonCategoryFrom', $idCategory) == 'googleDrive') {
$id_file = Utilities::getInput('id_file', 'GET', 'none');
$vid = Utilities::getInput('vid', 'GET', 'none');
if (apply_filters('wpfdAddonDeleteVersion', $idCategory, $id_file, $vid)) {
$this->exitStatus(true, array());
} else {
$this->exitStatus('error validating');
}
} else {
$vid = Utilities::getInt('vid');
$model = $this->getModel();
$id_file = Utilities::getInput('id_file', 'GET', 'none');
$file = $model->getFile($id_file);
$version = $model->getVersion($vid);
$file_dir = wpfdBase::getFilesPath($file['catid']) . '/' . $version['file'];
$result = (bool)$model->deleteVersion($vid);
if ($result) {
if (file_exists($file_dir)) {
unlink($file_dir);
}
}
$this->exitStatus($result);
}
}
/**
* Save file
*/
public function save()
{
$model = $this->getModel();
$form = new Form();
if (!$form->load('file')) {
$this->exitStatus('error');
}
// if (!$form->validate()) {
// $this->exitStatus('error validating');
// }
$idCategory = Utilities::getInt('idCategory');
if (apply_filters('wpfdAddonCategoryFrom', $idCategory) == 'googleDrive') {
$data = $form->sanitize();
$fileId = Utilities::getInput('id', 'Get', 'none');
$data['id'] = $fileId;
if (apply_filters('wpfdAddonSaveFileInfo', $data)) {
$this->exitStatus(true);
} else {
$this->exitStatus('error saving');
}
} elseif (apply_filters('wpfdAddonCategoryFrom', $idCategory) == 'dropbox') {
$data = $form->sanitize();
$fileId = Utilities::getInput('id', 'Get', 'none');
$data['id'] = $fileId;
$new_id = apply_filters('wpfdAddonSaveDropboxFileInfo', $data, $idCategory);
if (!empty($new_id)) {
$this->exitStatus(true, array('new_id' => $new_id));
} else {
$this->exitStatus('error saving');
}
} else {
$datas = $form->sanitize();
$datas['id'] = Utilities::getInt('id');
$datas['description'] = $_POST['description'];
if (!$model->save($datas)) {
$this->exitStatus('error saving');
}
$this->exitStatus(true);
}
}
/**
* Delete file
*/
public function delete()
{
$idCategory = Utilities::getInt('id_category');
$whereDelete = apply_filters('wpfdAddonCategoryFrom', $idCategory);
if ($whereDelete === 'googleDrive') {
$id_file = Utilities::getInput('id_file', 'GET', 'string');
do_action("wpfdAddonDeleteGoogleCloudFiles", $idCategory, $id_file);
} elseif ($whereDelete === 'dropbox') {
$id_file = Utilities::getInput('id_file', 'GET', 'string');
do_action("wpfdAddonDeleteDropboxFiles", $idCategory, $id_file);
} else {
$id_file = Utilities::getInt('id_file');
$model = $this->getModel();
$versions = $model->getVersions($id_file,$idCategory);
$file = $model->getFile($id_file);
if (!empty($versions)) {
foreach ($versions as $key => $value) {
$version = $model->getVersion($value['meta_id']);
$file_dir = wpfdBase::getFilesPath($file['catid']) . '/' . $version['file'];
$result = (bool)$model->deleteVersion($value['meta_id']);
if ($result) {
if (file_exists($file_dir)) {
unlink($file_dir);
}
}
}
}
if (!empty($file)) {
if ($model->delete($id_file)) {
$file_dir = wpfdBase::getFilesPath($file['catid']);
if (file_exists($file_dir . $file['file'])) {
unlink($file_dir . $file['file']);
$this->exitStatus(true);
}
}
$this->exitStatus('error while deleting');
}
}
}
}
?>

View File

@@ -0,0 +1,373 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Controller;
use Joomunited\WPFramework\v1_0_4\Utilities;
defined('ABSPATH') || die();
class wpfdControllerFiles extends Controller
{
private $allowed_ext = array('jpg', 'jpeg', 'png', 'gif', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'zip', 'tar', 'rar', 'odt', 'ppt', 'pps', 'txt');
/**
* Upload a file
*/
public function upload()
{
$id_category = Utilities::getInt('id_category', 'POST');
if ($id_category <= 0) {
$this->exitStatus(__('Wrong Category', 'wp-smart-editor'));
}
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post') {
$this->exitStatus(__('Wrong http response', 'wp-smart-editor'));
}
$configModel = $this->getModel('config');
$allowed = $configModel->getAllowedExt();
if (!empty($allowed)) {
$this->allowed_ext = $allowed;
}
$pic = $_FILES['pic'];
$ext = strtolower(pathinfo($pic['name'], PATHINFO_EXTENSION));
if (!in_array($ext, $this->allowed_ext)) {
$this->exitStatus(__('This type of file is not allowed to be uploaded. You can add new file types in the plugin configuration', 'wp-smart-editor'), array('allowed ' => $this->allowed_ext));
}
$placeUpload = apply_filters('wpfdAddonCategoryFrom', $id_category);
if ($placeUpload == 'googleDrive') {
$dataReturn = apply_filters('wpfdAddonGoogleDriveUpload', $id_category, $_FILES);
$this->exitStatus($dataReturn['status'], $dataReturn['data']);
} elseif ($placeUpload == 'dropbox') {
$dataReturn = apply_filters('wpfdAddonDropboxUpload', $id_category, $_FILES);
$this->exitStatus($dataReturn['status'], $dataReturn['data']);
} else {
//todo: vérifier les erreurs de création de fichier
$file_dir = wpfdBase::getFilesPath($id_category);
if (!file_exists($file_dir)) {
mkdir($file_dir, 0777, true);
$data = '<html><body bgcolor="#FFFFFF"></body></html>';
$file = fopen($file_dir . 'index.html', 'w');
fwrite($file, $data);
fclose($file);
$data = 'deny from all';
$file = fopen($file_dir . '.htaccess', 'w');
fwrite($file, $data);
fclose($file);
}
if (array_key_exists('pic', $_FILES) && $_FILES['pic']['error'] == 0) {
$newname = uniqid() . '.' . $ext;
if (!move_uploaded_file($pic['tmp_name'], $file_dir . $newname)) {
$this->exitStatus(__('Cant move uploaded file', 'wp-smart-editor'));
}
chmod($file_dir . $newname, 0777);
//Insert new image into databse
$model = $this->getModel();
$file_title = pathinfo($pic['name'], PATHINFO_FILENAME);
$file_title = str_replace("|","/",$file_title);
$id_file = $model->addFile(array(
'title' => base64_decode( $file_title),
'id_category' => (int)$id_category,
'file' => $newname,
'ext' => $ext,
'size' => filesize($file_dir . $newname)
));
if (!$id_file) {
unlink($file_dir . $newname);
$this->exitStatus(__('Cant save to database', 'wp-smart-editor'));
}
$this->exitStatus(true, array('id_file' => $id_file, 'name' => $newname));
}
$this->exitStatus(__('Error while uploading', 'wp-smart-editor')); //todo : translate
}
}
/**
* Reorder category
*/
public function reorder()
{
$files = Utilities::getInput('order', 'GET', 'string');
$files = json_decode(stripslashes_deep($files));
$model = $this->getModel();
if ($model->reorder($files)) {
$return = true;
} else {
$return = false;
}
$return = json_encode($return);
$this->exitStatus($return);
}
/**
* Get version for file
*/
public function version()
{
$idCategory = Utilities::getInt('id_category', 'POST');
if (apply_filters('wpfdAddonCategoryFrom', $idCategory) == 'googleDrive') {
$id_file = Utilities::getInput('id_file', 'POST', 'none');
if (!$id_file) {
$this->exitStatus(__('Wrong file', 'wp-smart-editor'));
}
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post') {
$this->exitStatus(__('Wrong http response', 'wp-smart-editor'));
}
if (array_key_exists('pic', $_FILES) && $_FILES['pic']['error'] == 0) {
$pic = $_FILES['pic'];
$ext = strtolower(pathinfo($pic['name'], PATHINFO_EXTENSION));
if (!in_array(strtolower($ext), $this->allowed_ext)) {
$this->exitStatus(__('This type of file is not allowed to be uploaded. You can add new file types in the plugin configuration', 'wp-smart-editor'), array('allowed ' => $this->allowed_ext));
}
$fileContent = file_get_contents($pic['tmp_name']);
if (apply_filters(
'wpfdAddonUploadVersion',
array('id' => $id_file,
'newRevision' => true,
'title' => $pic['name'],
'data' => $fileContent,
'ext' => strtolower(($pic['name']))),
$idCategory
)) {
$this->exitStatus(true, array('id_file' => $id_file, 'name' => $pic['name']));
} else {
$this->exitStatus(__('Can\'t upload to google Drive', 'wp-smart-editor'));
}
}
} elseif (apply_filters('wpfdAddonCategoryFrom', $idCategory) == 'dropbox') {
$id_file = Utilities::getInput('id_file', 'POST', 'none');
if (!$id_file) {
$this->exitStatus(__('Wrong file', 'wp-smart-editor'));
}
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post') {
$this->exitStatus(__('Wrong http response', 'wp-smart-editor'));
}
if (array_key_exists('pic', $_FILES) && $_FILES['pic']['error'] == 0) {
$pic = $_FILES['pic'];
$ext = strtolower(pathinfo($pic['name'], PATHINFO_EXTENSION));
if (!in_array(strtolower($ext), $this->allowed_ext)) {
$this->exitStatus(__('This type of file is not allowed to be uploaded. You can add new file types in the plugin configuration', 'wp-smart-editor'), array('allowed ' => $this->allowed_ext));
}
$fileInfo = apply_filters('wpfdAddonDropboxGetFileInfo', $id_file, $idCategory);
if (strpos($pic['name'], $fileInfo['ext'])) {
if (apply_filters(
'wpfdAddonUploadDropboxVersion',
array('newRevision' => true,
'old_file' => $id_file,
'new_file_name' => $pic['name'],
'new_file_size' => $pic['size'],
'new_tmp_name' => $pic['tmp_name']
),
$idCategory
)) {
$this->exitStatus(true, array('id_file' => $id_file, 'name' => $pic['name']));
} else {
$this->exitStatus(__('can\'t upload to Dropbox', 'wp-smart-editor'));
}
} else {
$this->exitStatus(__('You need to upload a file which has same file type with current file. Dropbox only allow same file type for new version.', 'wp-smart-editor'));
}
}
} else {
$id_file = Utilities::getInt('id_file', 'POST');
if ($id_file <= 0) {
$this->exitStatus(__('Wrong file', 'wp-smart-editor'));
}
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post') {
$this->exitStatus(__('Wrong http response', 'wp-smart-editor'));
}
if (array_key_exists('pic', $_FILES) && $_FILES['pic']['error'] == 0) {
$pic = $_FILES['pic'];
$ext = strtolower(pathinfo($pic['name'], PATHINFO_EXTENSION));
if (!in_array(strtolower($ext), $this->allowed_ext)) {
$this->exitStatus(__('This type of file is not allowed to be uploaded. You can add new file types in the plugin configuration', 'wp-smart-editor'), array('allowed ' => $this->allowed_ext));
}
$model = $this->getModel('file');
$file = $model->getFile($id_file);
if (file_exists(wpfdBase::getFilesPath($file['catid']) . $file['file'])) {
// unlink(wpfdBase::getFilesPath($file['catid']).$file['file']);
}
$newname = uniqid() . '.' . strtolower($ext);
if (!move_uploaded_file($pic['tmp_name'], wpfdBase::getFilesPath($file['catid']) . $newname)) {
$this->exitStatus(__('Cant move uploaded file', 'wp-smart-editor'));
}
chmod(wpfdBase::getFilesPath($file['catid']) . $newname, 0777);
$result = $model->updateFile($id_file, array(
'title' => $file['title'],
'file' => $newname,
'ext' => $ext,
'size' => filesize(wpfdBase::getFilesPath($file['catid']) . $newname)
));
if (!$result) {
unlink(wpfdBase::getFilesPath($file['catid']) . $newname);
$this->exitStatus(__('Cant save to database', 'wp-smart-editor'));
}
//add old file into version history
$model->addVersion($file);
$this->exitStatus(true, array('id_file' => $id_file, 'name' => $newname));
}
}
}
/**
* Import files
*/
public function import()
{
if (!is_admin()) {
$this->exitStatus(__('You don\'t have the sufficient permissions', 'wp-smart-editor'));
}
$id_category = Utilities::getInt('id_category');
if ($id_category <= 0) {
$this->exitStatus(__('Category not found', 'wp-smart-editor'));
}
$modelCat = $this->getModel('category');
$category = $modelCat->getCategory($id_category);
$file_dir = wpfdBase::getFilesPath($id_category);
if (!file_exists($file_dir)) {
if (!file_exists($file_dir)) {
mkdir($file_dir, 0777, true);
$data = '<html><body bgcolor="#FFFFFF"></body></html>';
$file = fopen($file_dir . 'index.html', 'w');
fwrite($file, $data);
fclose($file);
$data = 'deny from all';
$file = fopen($file_dir . '.htaccess', 'w');
fwrite($file, $data);
fclose($file);
}
}
$files = Utilities::getInput('files', 'GET', 'none');
if (!empty($files)) {
$count = 0;
$configModel = $this->getModel('config');
$allowed = $configModel->getAllowedExt();
if (!empty($allowed)) {
$this->allowed_ext = $allowed;
}
foreach ($files as $file) {
$file = get_home_path() . $file;
if (!in_array(wpfd_getext($file), $this->allowed_ext)) {
$this->exitStatus(__('This type of file is not allowed to be uploaded. You can add new file types in the plugin configuration', 'wp-smart-editor'), array('allowed ' => $this->allowed_ext));
}
$newname = uniqid() . '.' . strtolower(wpfd_getext($file));
if (!copy($file, $file_dir . $newname)) {
$this->exitStatus(__('Cant move uploaded file', 'wp-smart-editor'));
}
chmod($file_dir . $newname, 0777);
//Insert new image into databse
$model = $this->getModel();
$id_file = $model->addFile(array(
'title' => preg_replace('#\.[^.]*$#', '', basename($file)),
'id_category' => $id_category,
'file' => $newname,
'ext' => strtolower(wpfd_getext($file)),
'size' => filesize($file_dir . $newname)
));
if (!$id_file) {
unlink($file_dir . $newname);
$this->exitStatus(__('Cannot save file to DB', 'wp-smart-editor'));
}
$count++;
}
$this->exitStatus(true, array('nb' => $count));
}
$this->exitStatus(__('Error while importing', 'wp-smart-editor'));
}
/**
* Add a remote file url
*/
public function addremoteurl()
{
$id_category = Utilities::getInt('id_category', 'GET');
if ($id_category <= 0) {
$this->exitStatus(__('Wrong Category', 'wp-smart-editor'));
}
$remote_title = Utilities::getInput('remote_title', 'POST', 'string');
$remote_url = Utilities::getInput('remote_url', 'POST', 'none');
$remote_type = Utilities::getInput('remote_type', 'POST', 'none');
if ($remote_title == null) {
$this->exitStatus(__('Enter title', 'wp-smart-editor'));
} else if ($remote_type == null) {
$this->exitStatus(__('Enter type', 'wp-smart-editor'));
} else if ($remote_url == null) {
$this->exitStatus(__('Enter url', 'wp-smart-editor'));
} else {
if (!preg_match("(http://|https://)", $remote_url)) {
$this->exitStatus(__($remote_url . " is not a valid URL"));
}
}
//Insert new image into databse
$model = $this->getModel();
$id_file = $model->addFile(array(
'title' => $remote_title,
'id_category' => (int)$id_category,
'file' => $remote_url,
'ext' => $remote_type,
'size' => wpfd_remote_file_size($remote_url)
), true);
if (!$id_file) {
$this->exitStatus(__('Cant save to database', 'wp-smart-editor'));
}
$this->exitStatus(true, array('id_file' => $id_file, 'name' => $remote_url));
}
public function showcolumn(){
$check = Utilities::getInput('check','POST','none');
$lists = Utilities::getInput('column_show','POST','none') != null ? Utilities::getInput('column_show','POST','none') : array();
$string_lists = implode(',',$lists);
setcookie('wpfd_show_columns', $string_lists, time() + (86400 * 30), "/");
wp_send_json(true);
}
}
?>

View File

@@ -0,0 +1,18 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Controller;
defined( 'ABSPATH' ) || die();
class wpfdControllerWpfd extends Controller {
}
?>