The patch file (General)

by erikp, Wednesday, March 12, 2008, 11:14 (5883 days ago) @ erikp

As I wrote in my post, you can get the patch, together with a "prepatched" posting.inc.php, and install instructions from
http://www.djingis.se/~ep/patch4.tar.gz

For you who don't want to download it, I'll post the patch and the php-script that adds some settings to the settings table in the database (se my former post).

The patch (I don't know if it will survive the forum processing):

 
/*===================== START - CUT HERE ===================================*/
--- posting.inc.php.ORG 2008-03-06 23:05:19.000000000 +0100
+++ posting.inc.php     2008-03-09 17:48:21.000000000 +0100
@@ -237,7 +237,21 @@
           }
          else
           {
+
+// Added - removes ending
+if ( isset($settings['picstring_add']) && $settings['picstring_add'] 
+  && isset($settings['picstring']) && isset($settings['picstring_plural']) ) {
+       $headline = htmlspecialchars(stripslashes($field['subject']));
+       $picstring[0] = $settings['picstring'];
+       $picstring[1] = $settings['picstring_plural'];
+       $pic_pattern = "/s*[s*d*s*(" . escapeshellcmd($picstring[0]) . "|" . escapeshellcmd($picstring[1]) . ")s*]s*$/i";
+       $headline = preg_replace($pic_pattern, "", $headline);
+       $smarty->assign('subject', $headline);
+}
+else {
            $smarty->assign('subject',htmlspecialchars(stripslashes($field['subject'])));
+}
+
            $smarty->assign('p_category',$field['category']);
            $text = stripslashes($field['text']);
            $text = quote_reply($text);
@@ -331,6 +345,19 @@
    if(isset($_POST['email_notification'])) $email_notification = intval($_POST['email_notification']); else $email_notification=0;;
    if(isset($_POST['subject'])) $subject = trim($_POST['subject']);
    if(isset($_POST['text'])) $text = trim($_POST['text']);
+   
+// Ok lets add stuff to the subject in case of img tag in posting...
+if ( isset($subject) && isset($text) && isset($settings['picstring_add']) && $settings['picstring_add'] 
+        && isset($settings['picstring']) && isset($settings['picstring_plural']) ) {
+       $picstring[0] = $settings['picstring'];
+       $picstring[1] = $settings['picstring_plural'];
+       $pic_pattern = "/s*[s*d*s*(" . escapeshellcmd($picstring[0]) . "|" . escapeshellcmd($picstring[1]) . ")s*]s*$/i";
+       $subject = preg_replace($pic_pattern, "", $subject);
+       if ( $nbr = preg_match_all("/[img]/i", $text, $foo) ) $subject = $subject . " [$nbr " . $picstring[$nbr > 1] . "]";
+}
+   
+   
+   
    if(isset($_POST['setcookie'])) $setcookie = trim($_POST['setcookie']); else $setcookie=0;
    if(isset($_POST['sticky']) && $_POST['sticky']==1 && isset($_SESSION[$settings['session_prefix'].'user_type']) && ($_SESSION[$settings['session_prefix'].'use
r_type']>0)) $sticky=1; else $sticky=0;
    if(isset($_POST['terms_of_use_agree']) && $_POST['terms_of_use_agree']==1) $terms_of_use_agree=1; else $terms_of_use_agree=0;
=========================== END - CUT HERE ===============================
 
 
And the php script that adds some settings to the database:
=========================== START ========================
<html>
<head></head>
<body>
 
<?php
define('IN_INDEX', TRUE);
 
include('config/db_settings.php');
include('includes/functions.inc.php');
 
$connid = connect_db($db_settings['host'], $db_settings['user'], $db_settings['password'], $db_settings['database']);
mysql_query('insert into ' . $db_settings['settings_table'] . ' values("picstring", "picture")', $connid);
mysql_query('insert into ' . $db_settings['settings_table'] . ' values("picstring_plural", "pictures")', $connid);
mysql_query('insert into ' . $db_settings['settings_table'] . ' values("picstring_add", "1")', $connid);
 
mysql_close($connid);
?>
 
The database has been updated.<br/><br/>
But check it.<br/><br/>
Log in as admin<br/>
On Admin -> Forum settings -> Advanced settings there should be:<br/>
<ol>
<li>picstring - the mark if there is only one picture. This is set to "picture" as default</li>
<li>picstring_plural - the mark if there is more than one picture in the post. Default is "pictures"</li>
<li>picstring_add - If the function is activated or not. Set to 1, that is activated, as default. Set to 0 to deactivate. </li>
</ol>
Important: Run this file ONLY ONCE and the REMOVE THE FILE from the server.
 
</body>
</html>
/*====================== STOP ============================*/
 

/erik

locked
4009 views

Complete thread:

 RSS Feed of thread