mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Submitnews Image import fix. Upload page now using e_upload.php. Upload admin area still needs work.
This commit is contained in:
@@ -96,6 +96,12 @@ class news_admin extends e_admin_dispatcher
|
||||
{
|
||||
|
||||
|
||||
if(!empty($_GET['sub']) && $_GET['action'] == 'create')
|
||||
{
|
||||
$this->adminMenu['sub/list']['selected'] = true;
|
||||
$this->getResponse()->setTitle(NWSLAN_47);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -291,7 +297,9 @@ class news_sub_form_ui extends e_admin_form_ui
|
||||
|
||||
$text .= '
|
||||
|
||||
<div id="submitted_'.$submitnews_id.'" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div id="submitted_'.$submitnews_id.'" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4>'.$tp->toHtml($submitnews_title,false,'TITLE').'</h4>
|
||||
@@ -321,7 +329,8 @@ class news_sub_form_ui extends e_admin_form_ui
|
||||
<div class="modal-footer">
|
||||
<a href="#" data-dismiss="modal" class="btn btn-primary">'.LAN_NEWS_67.'</a>
|
||||
</div>
|
||||
</div>';
|
||||
</div>
|
||||
</div></div>';
|
||||
|
||||
return $text;
|
||||
|
||||
@@ -337,10 +346,27 @@ class news_sub_form_ui extends e_admin_form_ui
|
||||
{
|
||||
$text = "<div class='btn-group'>";
|
||||
$approved = $this->getController()->getListModel()->get('submitnews_auth'); // approved;
|
||||
|
||||
|
||||
$row = $this->getController()->getListModel();
|
||||
|
||||
$submitnews_id = $row->get('submitnews_id');
|
||||
$submitnews_title = $row->get('submitnews_title');
|
||||
$submitnews_file = $row->get('submitnews_file');
|
||||
$submitnews_item = $row->get('submitnews_item');
|
||||
|
||||
// $text .= "<a href='#submitted_".$submitnews_id."' class='e-modal' >";
|
||||
|
||||
|
||||
$text = "<a class='btn btn-default btn-large' data-toggle='modal' href='#submitted_".$submitnews_id."' data-cache='false' data-target='#submitted_".$submitnews_id."' title='".LAN_PREVIEW."'>".ADMIN_VIEW_ICON."</a>";
|
||||
|
||||
|
||||
|
||||
|
||||
if($approved == 0)
|
||||
{
|
||||
//$text = $this->submit_image('submitnews['.$id.']', 1, 'execute', NWSLAN_58);
|
||||
$text = "<a class='btn btn-large' href='".e_SELF."?mode=main&action=create&sub={$id}'>".ADMIN_EXECUTE_ICON."</a>";
|
||||
$text .= "<a class='btn btn-default btn-large' href='".e_SELF."?mode=main&action=create&sub={$id}'>".ADMIN_EXECUTE_ICON."</a>";
|
||||
// NWSLAN_103;
|
||||
}
|
||||
else // Already submitted;
|
||||
@@ -348,7 +374,7 @@ class news_sub_form_ui extends e_admin_form_ui
|
||||
|
||||
}
|
||||
|
||||
$text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'btn btn-large action delete'));
|
||||
$text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'btn btn-default btn-large action delete'));
|
||||
$text .= "</div>";
|
||||
return $text;
|
||||
}
|
||||
@@ -452,6 +478,12 @@ class news_admin_ui extends e_admin_ui
|
||||
|
||||
public function beforeCreate($new_data)
|
||||
{
|
||||
if(!empty($new_data['news_thumbnail']) && !empty($_GET['sub'])) // From SubmitNews.
|
||||
{
|
||||
$new_data['news_thumbnail'] = $this->processSubNewsImages($new_data['news_thumbnail']);
|
||||
}
|
||||
|
||||
|
||||
$new_data['news_thumbnail'] = $this->processThumbs($new_data['news_thumbnail']);
|
||||
|
||||
if(empty($new_data['news_datestamp']))
|
||||
@@ -459,6 +491,8 @@ class news_admin_ui extends e_admin_ui
|
||||
$new_data['news_datestamp'] = time();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$new_data['news_sef'] = empty($new_data['news_sef']) ? eHelper::title2sef($new_data['news_title']) : eHelper::secureSef($new_data['news_sef']);
|
||||
|
||||
$tmp = explode(chr(35), $new_data['news_author']);
|
||||
@@ -472,6 +506,43 @@ class news_admin_ui extends e_admin_ui
|
||||
return $new_data;
|
||||
}
|
||||
|
||||
private function processSubNewsImages($row)
|
||||
{
|
||||
$new = array();
|
||||
foreach($row as $k=>$v)
|
||||
{
|
||||
$tmp = urldecode($v);
|
||||
if(strpos($tmp,'{e_UPLOAD}')!==false)
|
||||
{
|
||||
list($root,$qry) = explode("?",$tmp);
|
||||
parse_str($qry,$opt);
|
||||
if(!empty($opt['src']))
|
||||
{
|
||||
|
||||
$f = str_replace('{e_UPLOAD}','',$opt['src']);
|
||||
// e107::getMessage()->addInfo("<h3>Importing File</h3>".print_a($f,true));
|
||||
if($bbpath = e107::getMedia()->importFile($f,'news', e_UPLOAD.$f))
|
||||
{
|
||||
$new[] = $bbpath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
elseif(!empty($v))
|
||||
{
|
||||
$new[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
// e107::getMessage()->addInfo("<h3>Process SubNews Images</h3>".print_a($new,true));
|
||||
|
||||
return implode(",",$new);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function beforeUpdate($new_data, $old_data, $id)
|
||||
{
|
||||
@@ -1190,7 +1261,7 @@ class news_admin_ui extends e_admin_ui
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
if ($sql->select("submitnews", "*", "submitnews_id=".intval($id)))
|
||||
{
|
||||
$row = $sql->fetch();
|
||||
@@ -1198,23 +1269,9 @@ class news_admin_ui extends e_admin_ui
|
||||
$data['news_body'] = $row['submitnews_item'];
|
||||
$data['news_category'] = intval( $row['submitnews_category']);
|
||||
$data['news_body'] .= "\n[[b]".NWSLAN_49." {$row['submitnews_name']}[/b]]";
|
||||
$thumbs = array();
|
||||
|
||||
if($row['submitnews_file'])
|
||||
{
|
||||
$files = explode(",",$row['submitnews_file']);
|
||||
foreach($files as $f)
|
||||
{
|
||||
if($bbpath = e107::getMedia()->importFile($f,'news'))
|
||||
{
|
||||
$thumbs[] = $bbpath;
|
||||
// $data['news_body'] .= "\n\n[img]".$bbpath."[/img]";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$data['news_thumbnail'] = implode(",",$thumbs);
|
||||
$data['news_thumbnail'] = $row['submitnews_file']; // implode(",",$thumbs);
|
||||
$data['news_sef'] = eHelper::dasherize($data['news_title']);
|
||||
$data['submitted_id'] = $id;
|
||||
|
||||
foreach($data as $k=>$v)
|
||||
@@ -1437,6 +1494,20 @@ class news_form_ui extends e_admin_form_ui
|
||||
|
||||
if($mode == 'write')
|
||||
{
|
||||
if(!empty($_GET['sub']))
|
||||
{
|
||||
$thumbTmp = explode(",",$curval);
|
||||
$paths = array();
|
||||
foreach($thumbTmp as $key=>$path)
|
||||
{
|
||||
$paths[] = e107::getParser()->thumbUrl(e_TEMP.$path,'aw=800'); ;
|
||||
}
|
||||
|
||||
$curval = implode(",", $paths);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$tp = e107::getParser();
|
||||
$frm = e107::getForm();
|
||||
|
||||
@@ -1447,7 +1518,7 @@ class news_form_ui extends e_admin_form_ui
|
||||
{
|
||||
if(!empty($path) && (strpos($path, ",") == false) && $path[0] != "{" && $tp->isVideo($path) === false )//BC compat
|
||||
{
|
||||
$thumbTmp[$key] = "{e_IMAGE}newspost_images/".$path;
|
||||
// $thumbTmp[$key] = "{e_IMAGE}newspost_images/".$path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -42,6 +42,7 @@ class upload_admin extends e_admin_dispatcher
|
||||
protected $adminMenu = array(
|
||||
|
||||
'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'V'),
|
||||
// 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'V'),
|
||||
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'V'),
|
||||
|
||||
/*
|
||||
@@ -75,7 +76,7 @@ class upload_ui extends e_admin_ui
|
||||
'checkboxes' => array ( 'title' => '', 'type' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => true, 'class' => 'center', 'toggle' => 'e-multiselect', ),
|
||||
'upload_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'upload_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'upload_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', 'validate' => true, 'inline' => true),
|
||||
'upload_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', 'validate' => true, 'inline' => true),
|
||||
'upload_poster' => array ( 'title' => UPLLAN_5, 'type' => 'user', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'upload_email' => array ( 'title' => LAN_EMAIL, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'upload_website' => array ( 'title' => LAN_URL, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
@@ -86,19 +87,25 @@ class upload_ui extends e_admin_ui
|
||||
'upload_demo' => array ( 'title' => UPLLAN_14, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'upload_filesize' => array ( 'title' => LAN_SIZE, 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'upload_active' => array ( 'title' => LAN_STATUS, 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('singleOption' => true), 'class' => 'center', 'thclass' => 'center', 'batch' => true),
|
||||
'upload_category' => array ( 'title' => LAN_CATEGORY, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => array(), 'writeParms' => array(), 'class' => 'left', 'thclass' => 'left', 'validate' => true ),
|
||||
'upload_category' => array ( 'title' => LAN_CATEGORY, 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => array(), 'writeParms' => array(), 'class' => 'left', 'thclass' => 'left', 'validate' => true ),
|
||||
'upload_owner' => array ( 'title' => LAN_OWNER, 'type' => 'text', 'readonly'=>true, 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
|
||||
'options' => array ( 'title' => LAN_OPTIONS, 'type' => '', 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
|
||||
);
|
||||
|
||||
protected $fieldpref = array('checkboxes', 'upload_datestamp', 'upload_name', 'upload_category', 'options');
|
||||
protected $fieldpref = array('checkboxes', 'upload_datestamp', 'upload_poster','upload_name', 'upload_category', 'upload_owner', 'options');
|
||||
|
||||
|
||||
|
||||
public $categories = array();
|
||||
|
||||
// optional
|
||||
public function init()
|
||||
{
|
||||
$qry = "
|
||||
|
||||
$this->categories = e107::getAddonConfig('e_upload','','category');
|
||||
|
||||
|
||||
/* $qry = "
|
||||
SELECT dc.download_category_name, dc.download_category_id
|
||||
FROM #download_category AS dc
|
||||
WHERE dc.download_category_parent = 0
|
||||
@@ -127,7 +134,7 @@ class upload_ui extends e_admin_ui
|
||||
$parent = $cats[$id];
|
||||
$label = e107::getParser()->toHTML($parent['download_category_name'], false, 'TITLE');
|
||||
$this->addSubcategories($id, $cats, $subIndex, $label);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@@ -299,6 +306,60 @@ class upload_ui extends e_admin_ui
|
||||
|
||||
class upload_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
public function upload_category($value, $type, $options = array())
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
|
||||
|
||||
case 'read':
|
||||
|
||||
|
||||
$owner = $this->getController()->getListModel()->get('upload_owner');
|
||||
|
||||
$opts = $this->getController()->categories[$owner];
|
||||
|
||||
return print_a($opts,true);
|
||||
|
||||
foreach($opts as $k=>$v)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return $value."-- ".$owner; // $this->radio_switch('upload_active', $va
|
||||
return $value ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON;
|
||||
break;
|
||||
|
||||
case 'write':
|
||||
$owner = $this->getController()->getModel()->get('upload_owner');
|
||||
return $value."-- ".$owner; // $this->radio_switch('upload_active', $value, LAN_ACCEPT, LAN_PENDING, $options);
|
||||
break;
|
||||
|
||||
case 'batch':
|
||||
|
||||
//TODO move all 'downloads' specific code into e_upload.php .
|
||||
/*
|
||||
$pref = e107::pref('core', 'e_upload_list');
|
||||
foreach($pref as $k=>$v)
|
||||
{
|
||||
$def = 'LAN_PLUGIN_'.strtoupper($v).'_NAME';
|
||||
$text = $this->option('Send to '.defset($def,$v), 'send_to_'.$k, false, array('other' => 'style="padding-left: 15px"'));
|
||||
}
|
||||
*/
|
||||
|
||||
// $text = $this->option(LAN_ACCEPT, 'upload_active', false, array('other' => 'style="padding-left: 15px"'));
|
||||
|
||||
|
||||
// return $text; // $this->option('Accept', 'upload_active', false, array('other' => 'style="padding-left: 15px"'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function upload_active($value, $type, $options = array())
|
||||
{
|
||||
switch($type)
|
||||
|
@@ -503,13 +503,14 @@ CREATE TABLE upload (
|
||||
upload_datestamp int(10) unsigned NOT NULL default '0',
|
||||
upload_name varchar(100) NOT NULL default '',
|
||||
upload_version varchar(10) NOT NULL default '',
|
||||
upload_file varchar(100) NOT NULL default '',
|
||||
upload_file varchar(180) NOT NULL default '',
|
||||
upload_ss varchar(100) NOT NULL default '',
|
||||
upload_description text NOT NULL,
|
||||
upload_demo varchar(100) NOT NULL default '',
|
||||
upload_filesize int(10) unsigned NOT NULL default '0',
|
||||
upload_active tinyint(3) unsigned NOT NULL default '0',
|
||||
upload_category tinyint(3) unsigned NOT NULL default '0',
|
||||
upload_owner varchar(50) NOT NULL default '',
|
||||
PRIMARY KEY (upload_id),
|
||||
KEY upload_active (upload_active)
|
||||
) ENGINE=MyISAM;
|
||||
|
@@ -596,8 +596,16 @@ class e_form
|
||||
{
|
||||
$url .= "&video=1";
|
||||
}
|
||||
|
||||
$title = "Media Manager : ".$category;
|
||||
|
||||
if(E107_DBG_BASIC)
|
||||
{
|
||||
|
||||
$title = "Media Manager : ".$category;
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = LAN_EDIT;
|
||||
}
|
||||
|
||||
// $ret = "<a title=\"{$title}\" rel='external' class='e-dialog' href='".$url."'>".$label."</a>"; // using colorXXXbox.
|
||||
$ret = "<a title=\"{$title}\" class='e-modal' data-modal-caption='Media Manager' data-cache='false' data-target='#uiModal' href='".$url."'>".$label."</a>"; // using bootstrap.
|
||||
@@ -842,7 +850,7 @@ class e_form
|
||||
$width = vartrue($sc_parameters['w'], 120);
|
||||
$height = vartrue($sc_parameters['h'], 100);
|
||||
|
||||
$ret = "<div class='imgselector-container e-tip' {$title} style='margin-right:25px; display:inline-block; width:".$width."px;min-height:".$height."px;'>";
|
||||
$ret = "<div class='imgselector-container e-tip' {$title} style='vertical-align:top;margin-right:25px; display:inline-block; width:".$width."px;min-height:".$height."px;'>";
|
||||
$att = 'aw='.$width."'&ah=".$height."'";
|
||||
$thpath = isset($sc_parameters['nothumb']) || vartrue($hide) ? $default : $tp->thumbUrl($default_thumb, $att, true);
|
||||
|
||||
@@ -853,10 +861,17 @@ class e_form
|
||||
{
|
||||
$cat = $cat . "_image";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$ret .= $this->mediaUrl($cat, $label,$name_id,$sc_parameters);
|
||||
|
||||
if($cat != '_icon' && $blank == false) // ICONS
|
||||
{
|
||||
$ret .= "<div class='text-right'><a title='".LAN_PREVIEW."' class='btn btn-sm btn-default btn-block e-modal' data-modal-caption='".LAN_PREVIEW."' href='".$default_url."'>".$tp->toGlyph('fa-search')."</a></div>";
|
||||
}
|
||||
$ret .= "</div>\n";
|
||||
$ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' />";
|
||||
$ret .= "<input type='hidden' name='mediameta_{$name}' id='{$meta_id}' value='' />";
|
||||
|
@@ -616,8 +616,10 @@ class userlogin
|
||||
// $text = e107::getParser()->toDB($text);
|
||||
// $text = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS_);
|
||||
|
||||
$debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2);
|
||||
$debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,4);
|
||||
|
||||
// unset($debug[0]);
|
||||
$debug[0] = e_REQUEST_URI;
|
||||
|
||||
// $array = debug_backtrace();
|
||||
// e107::getLog()->e_log_event(4, $array, "LOGIN", $title, $text, FALSE, LOG_TO_ROLLING);
|
||||
|
@@ -42,6 +42,16 @@ class e_media
|
||||
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_image.php');
|
||||
}
|
||||
|
||||
|
||||
public function debug($val)
|
||||
{
|
||||
|
||||
$this->logging = intval($val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Import files from specified path into media database.
|
||||
* @param string $cat Category nickname
|
||||
@@ -804,8 +814,12 @@ class e_media
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkDupe($oldpath,$newpath)
|
||||
/**
|
||||
* @param string $oldpath - path to pre-moved file (no e107 constants)
|
||||
* @param string $newpath - new path to move file to (no e107 constants)
|
||||
* @return bool|string returns false if duplciate entry found otherwise return new path.
|
||||
*/
|
||||
function checkDupe($oldpath, $newpath)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$tp = e107::getParser();
|
||||
@@ -823,9 +837,11 @@ class e_media
|
||||
if($sql->select("core_media","media_url","media_url LIKE '%".$tp->createConstants($newpath,'rel')."' LIMIT 1"))
|
||||
{
|
||||
// $mes->addWarning($newpath." detected in media-manager.");
|
||||
$this->log("Import not performed. ".$newpath." detected in media table already.");
|
||||
$row = $sql->fetch();
|
||||
$newpath = $row['media_url'];
|
||||
$this->log("Import not performed. ".$newpath." detected in media table already.");
|
||||
|
||||
return false;
|
||||
//$row = $sql->fetch();
|
||||
//$newpath = $row['media_url']; // causes trouble with importFile() if {e_MEDIA_CONSTANT} returned.
|
||||
}
|
||||
|
||||
return $newpath;
|
||||
@@ -1022,7 +1038,7 @@ class e_media
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
|
||||
if(!$oldpath) $oldpath = e_IMPORT.$file;
|
||||
if(empty($oldpath)) $oldpath = e_IMPORT.$file;
|
||||
|
||||
if(!file_exists($oldpath))
|
||||
{
|
||||
@@ -1045,10 +1061,15 @@ class e_media
|
||||
$mes->addError("Couldn't generate path from file info:".$oldpath);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$newpath = $this->checkDupe($oldpath,$typePath.'/'.$file);
|
||||
|
||||
|
||||
if(!$newpath = $this->checkDupe($oldpath,$typePath.'/'.$file))
|
||||
{
|
||||
return $tp->createConstants($typePath.'/'.$file,'rel');
|
||||
}
|
||||
|
||||
$newpath = $this->checkFileExtension($newpath, $img_data['media_type']);
|
||||
|
||||
|
||||
if(!rename($oldpath, $newpath)) // e_MEDIA.$newpath was working before.
|
||||
{
|
||||
$this->log("Couldn't move file from ".realpath($oldpath)." to ".e_MEDIA.$newpath);
|
||||
|
@@ -122,6 +122,7 @@ define("LAN_PWD_REQUIRED", "Password is required"); // admin php hover field adm
|
||||
define("LAN_SHOW", "Show");
|
||||
define("LAN_GENERATE", "Generate");
|
||||
define("LAN_SUMMARY", "Summary"); // TODO more files use summary replace
|
||||
define("LAN_REQUIRED_BLANK", "Required field(s) were left blank.");
|
||||
|
||||
|
||||
?>
|
@@ -240,7 +240,7 @@ define("LAN_CREATED_FAILED","Creation Unsuccessful");
|
||||
define("LAN_DELETED_FAILED","Deletion Unsuccessful");
|
||||
define("LAN_UPDATED_FAILED","Update Unsuccessful");
|
||||
define("LAN_NO_CHANGE","Nothing updated as no changes were made.");
|
||||
define("LAN_REQUIRED_BLANK", "Required field(s) left blank.");
|
||||
|
||||
define("LAN_TRY_AGAIN","Please try again.");
|
||||
define("LAN_NEVER", "Never");
|
||||
define("LAN_PRUNE", "Prune");
|
||||
|
@@ -85,13 +85,13 @@ class download_upload
|
||||
foreach($v['download_category_sub'] as $row)
|
||||
{
|
||||
$id2 = $row['download_category_name'];
|
||||
$arr[$id] = array($row['download_category_id']=>$id2);
|
||||
$arr[$id] = array('download__'.$row['download_category_id']=>$id2);
|
||||
if(!empty($row['download_category_sub']))
|
||||
{
|
||||
foreach($row['download_category_sub'] as $key=>$val)
|
||||
{
|
||||
$subid = $val['download_category_name'];
|
||||
$arr[$id][$subid] = array($val['download_category_id']=>$subid);
|
||||
$arr[$id][$subid] = array('download__'.$val['download_category_id']=>$subid);
|
||||
}
|
||||
}
|
||||
|
||||
|
88
upload.php
88
upload.php
@@ -102,20 +102,24 @@ class userUpload
|
||||
$mes = e107::getMessage();
|
||||
$tp = e107::getParser();
|
||||
|
||||
$error = false;
|
||||
$postemail ='';
|
||||
$error = false;
|
||||
$postemail ='';
|
||||
$catID = null;
|
||||
$catOwner = null;
|
||||
$file = null;
|
||||
$image = null;
|
||||
$filesize = 0;
|
||||
|
||||
|
||||
if (($_POST['file_email'] || USER == TRUE) && $_POST['file_name'] && $_POST['file_description'] && $_POST['download_category'])
|
||||
if ((!empty($_POST['file_email']) || USER == true) && !empty($_POST['file_name']) && !empty($_POST['file_description']) && !empty($_POST['category']))
|
||||
{
|
||||
|
||||
// $uploaded = file_upload(e_FILE."public/", "unique");
|
||||
$fl = e107::getFile();
|
||||
$uploaded = $fl->getUploaded(e_UPLOAD, "unique", array('max_file_count' => 2, 'extra_file_types' => TRUE));
|
||||
|
||||
// $uploaded = process_uploaded_files(e_UPLOAD, "unique", array('max_file_count' => 2, 'extra_file_types' => TRUE));
|
||||
|
||||
// First, see what errors the upload handler picked up
|
||||
if ($uploaded === FALSE)
|
||||
if ($uploaded === false)
|
||||
{
|
||||
$error = true;
|
||||
$mes->addError(LAN_UL_021);
|
||||
@@ -151,13 +155,17 @@ class userUpload
|
||||
}
|
||||
|
||||
// The upload handler checks max file size
|
||||
$downloadCategory = intval($_POST['download_category']);
|
||||
if (!$downloadCategory)
|
||||
{
|
||||
$error = true;
|
||||
|
||||
if(!empty($_POST['category']))
|
||||
{
|
||||
list($catOwner, $catID) = explode("__",$_POST['category'],2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
$mes->addError(LAN_UL_037);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// an error - delete the files to keep things tidy
|
||||
if ($error)
|
||||
{
|
||||
@@ -196,11 +204,33 @@ class userUpload
|
||||
$_POST['file_description'] = $tp->toDB($_POST['file_description']);
|
||||
|
||||
$file_time = time();
|
||||
|
||||
$sql->insert("upload", "0, '".$poster."', '".$postemail."', '".$tp -> toDB($_POST['file_website'])."', '".$file_time."', '".$tp -> toDB($_POST['file_name'])."', '".$tp -> toDB($_POST['file_version'])."', '".$file."', '".$image."', '".$tp -> toDB($_POST['file_description'])."', '".$tp -> toDB($_POST['file_demo'])."', '".$filesize."', 0, '".$downloadCategory."'");
|
||||
|
||||
$edata_fu = array("upload_user" => $poster, "upload_email" => $postemail, "upload_name" => $tp -> toDB($_POST['file_name']),"upload_file" => $file, "upload_version" => $_POST['file_version'], "upload_description" => $tp -> toDB($_POST['file_description']), "upload_size" => $filesize, "upload_category" => $downloadCategory, "upload_website" => $tp -> toDB($_POST['file_website']), "upload_image" => $image, "upload_demo" => $tp -> toDB($_POST['file_demo']), "upload_time" => $file_time);
|
||||
|
||||
$insertQry = array(
|
||||
'upload_id' => 0,
|
||||
'upload_poster' => $poster,
|
||||
'upload_email' => $postemail,
|
||||
'upload_website' => $tp->toDB($_POST['file_website']),
|
||||
'upload_datestamp' => $file_time,
|
||||
'upload_name' => $tp->toDB($_POST['file_name']),
|
||||
'upload_version' => $tp->toDB($_POST['file_version']),
|
||||
'upload_file' => $file,
|
||||
'upload_ss' => $image,
|
||||
'upload_description' => $tp->toDB($_POST['file_description']),
|
||||
'upload_demo' => $tp->toDB($_POST['file_demo']),
|
||||
'upload_filesize' => $filesize,
|
||||
'upload_active' => 0,
|
||||
'upload_category' => intval($catID),
|
||||
'upload_owner' => $catOwner
|
||||
);
|
||||
|
||||
|
||||
$sql->insert("upload", $insertQry);
|
||||
|
||||
$edata_fu = $insertQry;
|
||||
$edata_fu["upload_user"] = $poster;
|
||||
$edata_fu["upload_time"] = $file_time;
|
||||
|
||||
|
||||
e107::getEvent()->trigger("fileupload", $edata_fu); // BC
|
||||
e107::getEvent()->trigger("user_file_upload", $edata_fu);
|
||||
|
||||
@@ -210,7 +240,7 @@ class userUpload
|
||||
}
|
||||
else
|
||||
{ // Error - missing data
|
||||
$mes->addError(LAN_ERROR_29);
|
||||
$mes->addError(LAN_REQUIRED_BLANK);
|
||||
}
|
||||
|
||||
echo e107::getMessage()->render();
|
||||
@@ -237,7 +267,7 @@ class userUpload
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
|
||||
$text = "<div style='text-align:center'>
|
||||
$text = "<div>
|
||||
<form enctype='multipart/form-data' method='post' onsubmit='return frmVerify()' action='".e_SELF."'>
|
||||
<table style='".USER_WIDTH."' class='table fborder'>
|
||||
<colgroup>
|
||||
@@ -261,7 +291,7 @@ class userUpload
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style='text-align:center' class='forumheader3'>".LAN_419."</td>
|
||||
<td class='forumheader3'>".LAN_419."</td>
|
||||
<td class='forumheader3'>";
|
||||
|
||||
// $text .= "<b>".LAN_406."</b><br />".LAN_419.":";
|
||||
@@ -308,56 +338,56 @@ class userUpload
|
||||
|
||||
$text .= "</td></tr>";
|
||||
|
||||
//TODO Replcae all form inputs with $frm methods.
|
||||
$frm = e107::getForm();
|
||||
|
||||
if (!USER) // Prompt for name, email
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td class='forumheader3'>".LAN_61."</td>
|
||||
<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_poster' type='text' size='50' maxlength='100' value='{$poster}' /></td>
|
||||
<td class='forumheader3'>".$frm->text('file_poster',$_POST['file_poster'],100, 'required=1')."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'><span style='text-decoration:underline'>".LAN_112."</span></td>
|
||||
<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_email' id='user_email' type='text' size='50' maxlength='100' value='".$postemail."' required /></td>
|
||||
<td class='forumheader3'>".$frm->text('file_email',$_POST['file_email'],100, 'required=1')."</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='forumheader3'><span style='text-decoration:underline'>".LAN_409."</span></td>
|
||||
<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_name' id='file_name' type='text' size='50' maxlength='100' required /></td>
|
||||
<td class='forumheader3'>".$frm->text('file_name', $_POST['file_name'], 100, 'required=1')."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>".LAN_410."</td>
|
||||
<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_version' type='text' size='10' maxlength='10' /></td>
|
||||
<td class='forumheader3'>".$frm->text('file_version',$_POST['file_version'],10)."</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'><span style='text-decoration:underline'>".LAN_411."</span></td>
|
||||
<td class='forumheader3'><input class='tbox' style='width:90%' id='file_realpath' name='file_userfile[]' type='file' size='47' /></td>
|
||||
<td class='forumheader3'>".$frm->file('file_userfile[]')."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>".LAN_IMAGE."/".LAN_SCREENSHOT."</td>
|
||||
<td class='forumheader3'><input class='tbox' style='width:90%' name='file_userfile[]' type='file' size='47' /></td>
|
||||
<td class='forumheader3'>".$frm->file('file_userfile[]')."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'><span style='text-decoration:underline'>".LAN_413."</span></td>
|
||||
<td class='forumheader3'><textarea class='tbox form-control' style='width:90%' name='file_description' id='file_description' cols='59' rows='6' required></textarea></td>
|
||||
<td class='forumheader3'>".$frm->textarea('file_description', $_POST['file_description'], 6, 59, 'size=block-level&required=1')."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>".LAN_144."</td>
|
||||
<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_website' type='text' size='50' maxlength='100' value='".(defined(USERURL) ? USERURL : "")."' /></td>
|
||||
<td class='forumheader3'>".$frm->text('file_website', $_POST['file_website'], 100)."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>".LAN_414."<br /><span class='smalltext'>".LAN_415."</span></td>
|
||||
<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_demo' type='text' size='50' maxlength='100' /></td>
|
||||
<td class='forumheader3'>".$frm->text('file_demo', $_POST['file_demo'], 100)."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
Reference in New Issue
Block a user