1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 09:29:45 +01:00

Forum upgrade fixes. Forum-attachments now converted in batches.

This commit is contained in:
Cameron 2013-03-31 00:06:21 -07:00
parent 1b0760008a
commit eae211fc63
12 changed files with 1025 additions and 705 deletions

View File

@ -1304,11 +1304,15 @@ function update_706_to_800($type='')
} }
$dl_files = $fl->get_files(e_FILE.'downloads', "","standard",5); // don't use e_DOWNLOAD or a loop may occur. $dl_files = $fl->get_files(e_FILE.'downloads', "","standard",5); // don't use e_DOWNLOAD or a loop may occur.
$public_files = $fl->get_files(e_FILE.'public');
$publicFilter = array('_FT', '^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^\.cvsignore$','^\.ftpquota$','^index\.html$','^null\.txt$','\.bak$','^.tmp'); // Default file filter (regex format)
// $publicFilter = array(1);
$public_files = $fl->get_files(e_FILE.'public','',$publicFilter);
if((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' ")) if((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' "))
{ {
if ($just_check) return update_needed('Import Download and Public Files into Media Manager'); if ($just_check) return update_needed('Import '.count($dl_files).' Download File(s) and '.count($public_files).' Public File(s) into Media Manager');
// check for file-types; // check for file-types;
if (is_readable(e_ADMIN.'filetypes.php')) if (is_readable(e_ADMIN.'filetypes.php'))
{ {

View File

@ -81,7 +81,6 @@
'news' => 'news', 'news' => 'news',
'page' => 'page', 'page' => 'page',
)]]></core> )]]></core>
<core name="email_notify">0</core>
<core name="email_text"></core> <core name="email_text"></core>
<core name="emotepack">default</core> <core name="emotepack">default</core>
<core name="enable_rdns">0</core> <core name="enable_rdns">0</core>

View File

@ -1816,6 +1816,12 @@ class e_parse extends e_parser
return $text; return $text;
} }
/**
* @param $url
* @param $options ??
* @param $raw ??
* @param $full
*/
public function thumbUrl($url, $options = array(), $raw = false, $full = false) public function thumbUrl($url, $options = array(), $raw = false, $full = false)
{ {
if(substr($url,0,3)=="{e_") // Fix for broken links that use {e_MEDIA} etc. if(substr($url,0,3)=="{e_") // Fix for broken links that use {e_MEDIA} etc.
@ -2419,7 +2425,21 @@ class e_parser
{ {
$this->allowedAttributes = $array; $this->allowedAttributes = $array;
} }
/**
* Add leading zeros to a number. eg. 3 might become 000003
* @param $num integer
* @param $numDigits - total number of digits
* @return number with leading zeros.
*/
public function leadingZeros($num,$numDigits)
{
return sprintf("%0".$numDigits."d",$num);
}
/** /**
* Return an Array of all specific tags found in an HTML document and their attributes. * Return an Array of all specific tags found in an HTML document and their attributes.

View File

@ -72,6 +72,8 @@ class e_file
* @var array * @var array
*/ */
public $fileFilter; public $fileFilter;
public $filesRejected = array();
/** /**
* Defines what array format should return get_files() method * Defines what array format should return get_files() method
@ -194,7 +196,7 @@ class e_file
} }
if (($omit == 'standard') || ($omit == '')) if (($omit == 'standard') || ($omit == ''))
{ {
$omit = array(); $omit = $this->fileFilter;
} }
else else
{ {
@ -223,11 +225,12 @@ class e_file
$rejected = FALSE; $rejected = FALSE;
// Check against the generic file reject filter // Check against the generic file reject filter
foreach($this->fileFilter as $rmask) foreach($omit as $rmask)
{ {
if(preg_match("#".$rmask."#", $file)) if(preg_match("#".$rmask."#", $file))
{ {
$rejected = TRUE; $rejected = TRUE;
$this->filesRejected[] = $file;
break; // continue 2 may well work break; // continue 2 may well work
} }
} }
@ -571,13 +574,12 @@ class e_file
{ {
global $e107; global $e107;
$pref = e107::getPref(); $pref = e107::getPref();
$tp = e107::getParser(); $tp = e107::getParser();
$DOWNLOADS_DIRECTORY = e_BASE.e107::getFolder('DOWNLOADS');
$DOWNLOADS_DIRECTORY = e_BASE.e107::getFolder('DOWNLOADS'); $FILES_DIRECTORY = e_BASE.e107::getFolder('FILES');
$FILES_DIRECTORY = e_BASE.e107::getFolder('FILES'); $MEDIA_DIRECTORY = realpath(e_MEDIA); // could be image, file or other type.
$MEDIA_DIRECTORY = realpath(e_MEDIA_FILE);
$file = $tp->replaceConstants($file); $file = $tp->replaceConstants($file);
@ -594,6 +596,9 @@ class e_file
$path = realpath($filename); $path = realpath($filename);
$path_downloads = realpath($DOWNLOADS_DIRECTORY); $path_downloads = realpath($DOWNLOADS_DIRECTORY);
$path_public = realpath($FILES_DIRECTORY."public/"); $path_public = realpath($FILES_DIRECTORY."public/");
if(!strstr($path, $path_downloads) && !strstr($path,$path_public) && !strstr($path, $MEDIA_DIRECTORY)) if(!strstr($path, $path_downloads) && !strstr($path,$path_public) && !strstr($path, $MEDIA_DIRECTORY))
{ {
if(E107_DEBUG_LEVEL > 0 && ADMIN) if(E107_DEBUG_LEVEL > 0 && ADMIN)

View File

@ -727,7 +727,7 @@ class e_db_mysql
if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function. if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function.
{ {
$new_data = '';
if(!isset($arg['_FIELD_TYPES']) && !isset($arg['data'])) if(!isset($arg['_FIELD_TYPES']) && !isset($arg['data']))
{ {
//Convert data if not using 'new' format //Convert data if not using 'new' format
@ -750,10 +750,13 @@ class e_db_mysql
} }
$fieldTypes = $this->_getTypes($arg); $fieldTypes = $this->_getTypes($arg);
$new_data = '';
foreach ($arg['data'] as $fn => $fv) foreach ($arg['data'] as $fn => $fv)
{ {
$new_data .= ($new_data ? ', ' : ''); $new_data .= ($new_data ? ', ' : '');
$new_data .= "`{$fn}`=".$this->_getFieldValue($fn, $fv, $fieldTypes); $new_data .= "`{$fn}`=".$this->_getFieldValue($fn, $fv, $fieldTypes);
} }
$arg = $new_data .(isset($arg['WHERE']) ? ' WHERE '. $arg['WHERE'] : ''); $arg = $new_data .(isset($arg['WHERE']) ? ' WHERE '. $arg['WHERE'] : '');
} }
@ -868,7 +871,9 @@ class e_db_mysql
} }
} }
/* Similar to db_Update(), but splits the variables and the 'WHERE' clause. /**
* @DEPRECATED
Similar to db_Update(), but splits the variables and the 'WHERE' clause.
$vars may be an array (fieldname=>newvalue) of fields to be updated, or a simple list. $vars may be an array (fieldname=>newvalue) of fields to be updated, or a simple list.
$arg is usually a 'WHERE' clause $arg is usually a 'WHERE' clause
The way the code is written at the moment, a call to db_Update() with just the first two parameters specified can be The way the code is written at the moment, a call to db_Update() with just the first two parameters specified can be

View File

@ -2142,7 +2142,7 @@ class e107plugin
if (is_readable($setup_file)) if (is_readable($setup_file))
{ {
if(e_PAGE == 'e107_update.php') if(e_PAGE == 'e107_update.php' && E107_DBG_INCLUDES)
{ {
$mes->addDebug("Found setup file <b>".$path."_setup.php</b> "); $mes->addDebug("Found setup file <b>".$path."_setup.php</b> ");
} }
@ -2157,7 +2157,7 @@ class e107plugin
if (method_exists($obj, $method_name)) if (method_exists($obj, $method_name))
{ {
if(e_PAGE == 'e107_update.php') if(e_PAGE == 'e107_update.php' && E107_DBG_INCLUDES)
{ {
$mes->addDebug("Executing setup function <b>".$class_name." :: ".$method_name."()</b>"); $mes->addDebug("Executing setup function <b>".$class_name." :: ".$method_name."()</b>");
} }
@ -2166,7 +2166,7 @@ class e107plugin
} }
else else
{ {
if(e_PAGE == 'e107_update.php') if(e_PAGE == 'e107_update.php' && E107_DBG_INCLUDES)
{ {
$mes->addDebug("Setup function ".$class_name." :: ".$method_name."() NOT found."); $mes->addDebug("Setup function ".$class_name." :: ".$method_name."() NOT found.");
} }

View File

@ -224,17 +224,13 @@ class themeHandler
function getThemeInfo($file) function getThemeInfo($file)
{ {
$STYLESHEET = FALSE; $STYLESHEET = FALSE;
$mes = e107::getMessage();
$reject = array('$.',
'$..', $reject = array('e_.*');
'/',
'CVS', $handle2 = e107::getFile()->get_files(e_THEME.$file."/", ".php|.css|.xml|preview.jpg|preview.png", $reject, 1);
'thumbs.db',
'*._$',
'index',
'null*',
'e_*');
$handle2 = $this->fl->get_files(e_THEME.$file."/", ".php|.css|.xml|preview.jpg|preview.png", $reject, 1);
foreach ($handle2 as $fln) foreach ($handle2 as $fln)
{ {
$file2 = str_replace(e_THEME.$file."/", "", $fln['path']).$fln['fname']; $file2 = str_replace(e_THEME.$file."/", "", $fln['path']).$fln['fname'];
@ -245,18 +241,12 @@ class themeHandler
$themeArray[$file]['preview'] = e_THEME.$file."/".$file2; $themeArray[$file]['preview'] = e_THEME.$file."/".$file2;
} }
// ---------------- get information string for css file // ---------------- get information string for css file
if(strstr($file2, "css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0) if(strstr($file2, "css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0)
{ {
if($cssContents = file_get_contents(e_THEME.$file."/".$file2))
if($fp = fopen(e_THEME.$file."/".$file2, "r"))
{ {
// FIXME: use info from theme.xml alternateStyleSheet instead
$cssContents = fread($fp, filesize(e_THEME.$file."/".$file2));
fclose($fp);
$nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false; $nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false;
preg_match('/\* info:(.*?)\*\//', $cssContents, $match); preg_match('/\* info:(.*?)\*\//', $cssContents, $match);
$match[1] = varset($match[1], ''); $match[1] = varset($match[1], '');
@ -272,6 +262,10 @@ class themeHandler
$STYLESHEET = TRUE; $STYLESHEET = TRUE;
} }
} }
else
{
// $mes->addDebug("Couldn't read file: ".e_THEME.$file."/".$file2);
}
} }

View File

@ -147,6 +147,32 @@ class e107forum
*/ */
} }
function getAttachmentPath($user=0)
{
$tp = e107::getParser();
$baseDir = e_MEDIA.'plugins/forum/attachments/';
$baseDir .= ($user) ? "user_". $tp->leadingZeros($user, 6) : "anon";
$baseDir .= "/";
return $baseDir;
}
function sendFile($data)
{
$sql = e107::getDb();
$fid = intval($data['dl']);
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.intval($data['id']));
$attach = e107::getArrayStorage()->read($array['post_attachments']);
$file = $this->getAttachmentPath($array['post_user']).varset($attach['file'][$fid]);
e107::getFile()->send($file);
}
/** /**
* Handle the Ajax quick-reply. * Handle the Ajax quick-reply.

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,9 @@ if (!e_QUERY)
exit; exit;
} }
// include_lan(e_PLUGIN . 'forum/languages/'.e_LANGUAGE.'/lan_forum_viewtopic.php'); // include_lan(e_PLUGIN . 'forum/languages/'.e_LANGUAGE.'/lan_forum_viewtopic.php');
include_once (e_PLUGIN . 'forum/forum_class.php'); include_once (e_PLUGIN . 'forum/forum_class.php');
@ -43,6 +46,15 @@ include_once (e_PLUGIN . 'forum/forum_class.php');
$forum = new e107forum(); $forum = new e107forum();
$thread = new e107ForumThread(); $thread = new e107ForumThread();
if(vartrue($_GET['id']) && isset($_GET['dl']))
{
$forum->sendFile($_GET);
exit;
}
if(e_AJAX_REQUEST && varset($_POST['action']) == 'quickreply') if(e_AJAX_REQUEST && varset($_POST['action']) == 'quickreply')
{ {
$forum->ajaxQuickReply(); $forum->ajaxQuickReply();

View File

@ -70,36 +70,61 @@ class plugin_forum_view_shortcodes extends e_shortcode
$ret = '<pre>'.print_r($info, true).'</pre>'; $ret = '<pre>'.print_r($info, true).'</pre>';
} }
} }
function sc_attachments() function sc_attachments()
{ {
$tp = e107::getParser();
if($this->postInfo['post_attachments']) if($this->postInfo['post_attachments'])
{ {
$baseDir = e_MEDIA_ABS.'files/plugins/forum/attachments/'; $baseDir = $this->forum->getAttachmentPath($this->postInfo['post_user']);
$attachments = explode(',', $this->postInfo['post_attachments']);
$txt = '';
foreach($attachments as $a)
{
$info = explode('*', $a);
switch($info[0])
{
case 'file':
$txt .= IMAGE_attachment." <a href='{$baseDir}{$info[1]}'>{$info[2]}</a><br />";
break;
case 'img': $images = array();
//if image has a thumb, show it and link to main
if(isset($info[2])) $attachArray = e107::getArrayStorage()->read($this->postInfo['post_attachments']);
foreach($attachArray as $type=>$vals)
{
foreach($vals as $key=>$file)
{
list($date,$user,$tmp,$name) = explode("_",$file,4);
switch($type)
{ {
$txt .= "<a href='{$baseDir}{$info[1]}'><img src='{$baseDir}thumb/{$info[2]}' alt='' /></a><br />"; case 'file':
}
else $url = e_SELF."?id=".$this->postInfo['post_id']."&amp;dl=".$key;
{ $txt .= IMAGE_attachment." <a href='".$url."'>{$name}</a><br />";
$txt .= "<img src='{$baseDir}{$info[1]}' alt='' /><br />";
} break;
}
case 'img': //Always use thumb to hide the hash.
$thumb = $tp->thumbUrl($baseDir.$file,'x=1',true);
$full = $tp->thumbUrl($baseDir.$file,'w=1000&x=1', true);
$inc = (vartrue($parm['modal'])) ? "data-toggle='modal' data-target='#".$parm['modal']."' " : "";
$images[] = "<a {$inc} rel='external' href='{$full}'><img class='thumbnail' src='{$thumb}' alt='' /></a>";
break;
}
}
} }
if(count($images) )
{
return (deftrue('e_BOOTSTRAP')) ? "<ul class='thumbnails'><li>".implode("</li><li>",$images)."</li></ul>" : implode("<br />",$images);
}
return $txt; return $txt;
} }
} }

View File

@ -339,14 +339,12 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
{CUSTOMTITLE} {CUSTOMTITLE}
{AVATAR} {AVATAR}
{USERCOMBO} {USERCOMBO}
<div>
</div>
</div> </div>
<div class='span9 '> <div class='span9 '>
{POLL} {POLL}
{POST} {POST}
{ATTACHMENTS}
</div> </div>
</div> </div>
@ -356,7 +354,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
&nbsp; &nbsp;
</div> </div>
<div class='span9 finfobar' > <div class='span9 finfobar' >
<small>{ATTACHMENTS} {SIGNATURE=clean}</small> <small> {SIGNATURE=clean}</small>
</div> </div>
<div class='span3'> <div class='span3'>