]> git.mjollnir.org Git - s9y.git/commitdiff
Ensure to not be able to call s9y files under circumstances where .htaccess does...
authorgarvinhicking <garvinhicking>
Thu, 30 Nov 2006 21:34:29 +0000 (21:34 +0000)
committergarvinhicking <garvinhicking>
Thu, 30 Nov 2006 21:34:29 +0000 (21:34 +0000)
23 files changed:
docs/NEWS
include/admin/configuration.inc.php
include/admin/installer.inc.php
include/compat.inc.php
include/functions.inc.php
include/functions_calendars.inc.php
include/functions_comments.inc.php
include/functions_config.inc.php
include/functions_entries.inc.php
include/functions_entries_admin.inc.php
include/functions_images.inc.php
include/functions_images_crop.inc.php [new file with mode: 0644]
include/functions_installer.inc.php
include/functions_permalinks.inc.php
include/functions_plugins_admin.inc.php
include/functions_rss.inc.php
include/functions_smarty.inc.php
include/functions_trackbacks.inc.php
include/functions_upgrader.inc.php
include/genpage.inc.php
include/lang.inc.php
include/plugin_internal.inc.php
templates/kubrick/config.inc.php

index 499bbff6e8c52b99f5e87c4fc260e6b798660e01..0f3c40c17d9f9e784a5ed94b9401197524b78405 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -350,7 +350,14 @@ Version 1.1-alpha5()
    * Removed config option "XHTML11 compliance" and enabled by default
      now (garvinhicking)
 
-Version 1.0.3 ()
+Version 1.0.4 ()
+------------------------------------------------------------------------
+
+   * Fix local file inclusion bug on systems with two conditions:
+     register_globals=on AND missing .htaccess for restricting access to
+     .inc.php files. (garvinhicking)
+
+Version 1.0.3 (November 7th, 2006)
 ------------------------------------------------------------------------
 
    * Fix PHP 5.2.0 compatibility issue. (garvinhicking)
index a4af5e2fa4e27d9a34a804e0881ae4bb21cbfc7e..4ecb2cfdc0a8c84aa89392f1fa8e1ff022ced9ec 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 umask(0000);
 $umask = 0775;
 @define('IN_installer', true);
@@ -47,7 +51,7 @@ switch ($_POST['installAction'] && serendipity_checkFormToken()) {
                         $permalinkNew[] = $serendipity[$permitem['var']];
                     }
                 }
-            }            
+            }
 
             if (serendipity_checkPermission('siteConfiguration') && serialize($permalinkOld) != serialize($permalinkNew)) {
                 printf(ATTEMPT_WRITE_FILE, $serendipity['serendipityPath'] . '.htaccess');
index 36ddc05d05d789cb7779a7e374e6d6420742f0a1..3da52dfd907d3016fc9c3569712c5f319d648060 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 umask(0000);
 $umask = 0775;
 @define('IN_installer', true);
@@ -36,11 +40,11 @@ function serendipity_installerResultDiagnose($result, $s) {
         return '<span style="color: green; font-weight: bold">'. $s .'</span>';
     }
     if ( $result === S9Y_I_WARNING ) {
-        return '<span style="color: orange; font-weight: bold">'. $s .'</span>';
+        return '<span style="color: orange; font-weight: bold">'. $s .' [?]</span>';
     }
     if ( $result === S9Y_I_ERROR ) {
         $errorCount++;
-        return '<span style="color: red; font-weight: bold">'. $s .'</span>';
+        return '<span style="color: red; font-weight: bold">'. $s .' [!]</span>';
     }
 }
 
index 467968c6096efefd263b8868733185ea6331161b..8bf2f09c2222de18702b3b03788e74396b0cd012 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_COMPAT')) {
     return;
 }
@@ -38,11 +42,11 @@ function memSnap($tshow = '') {
     static $avail    = null;
     static $show     = true;
     static $memUsage = 0;
-    
+
     if (!$show) {
         return false;
     }
-    
+
     if ($avail === false) {
         return true;
     } elseif ($avail === null) {
@@ -53,11 +57,11 @@ function memSnap($tshow = '') {
             return false;
         }
     }
-    
+
     if ($memUsage === 0) {
         $memUsage = $avail;
     }
-    
+
     $current = memory_get_usage();
     echo '[' . date('d.m.Y H:i') . '] ' . number_format($current - $memUsage, 2, ',', '.') . ' label "' . $tshow . '", totalling ' . number_format($current, 2, ',', '.') . '<br />' . "\n";
     $memUsage = $current;
@@ -222,7 +226,7 @@ function serendipity_getCharset() {
             $charset = '';
         }
     }
-    
+
     if (!empty($serendipity['POST']['charset'])) {
         if ($serendipity['POST']['charset'] == 'UTF-8/') {
             $charset = 'UTF-8/';
index 09058b6ec972060ac76e727404ed1278313fc96b..24aeba5b96ed5ee0297053cf6ee9955db47c59d1 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_FUNCTIONS')) {
     return;
 }
@@ -323,7 +327,7 @@ function serendipity_walkRecursive($ary, $child_name = 'id', $parent_name = 'par
     if ($depth !== 0) {
         return true;
     }
-    
+
     if (count($_remain) > 0) {
         // Remaining items need to be appended
         foreach($_remain AS $key => $data) {
@@ -1146,7 +1150,7 @@ function &serendipity_pickKey(&$array, $key, $default) {
 function serendipity_db_time() {
     static $ts    = null;
     static $cache = 300; // Seconds to cache
-    
+
     if ($ts === null) {
         $now = time();
         $ts = $now - ($now % $cache) + $cache;
index e347b5f955ab2fd78e6fde43fc6ac1bf9a879ba0..2c8dae4773177b1fa9b4da8566d202959e356fe9 100644 (file)
@@ -2,8 +2,17 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
+if (defined('S9Y_FRAMEWORK_CALENDARS')) {
+    return;
+}
+@define('S9Y_FRAMEWORK_CALENDARS', true);
+
 /**
- * Gregorian to Jalali Convertor
+ * Gregorian to Persian Convertor
  *
  * @author farsiweb.info
  * @access public
  * @param   int day
  * @return  array   converted time
  */
-function g2j($g_y, $g_m, $g_d){
+function g2p($g_y, $g_m, $g_d){
     $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
-    
+
     $gy = $g_y-1600;
     $gm = $g_m-1;
     $gd = $g_d-1;
-    
+
     $g_day_no = 365*$gy+floor(($gy+3)/4)-floor(($gy+99)/100)+floor(($gy+399)/400);
-    
+
     for ($i=0; $i < $gm; ++$i){
         $g_day_no += $g_days_in_month[$i];
     }
-        
+
     if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0))){
         /* leap and after Feb */
         ++$g_day_no;
     }
-        
+
     $g_day_no += $gd;
     $j_day_no = $g_day_no-79;
     $j_np = floor($j_day_no/12053);
     $j_day_no %= 12053;
     $jy = 979+33*$j_np+4*floor($j_day_no/1461);
     $j_day_no %= 1461;
-    
+
     if ($j_day_no >= 366) {
         $jy += floor(($j_day_no-1)/365);
         $j_day_no = ($j_day_no-1)%365;
     }
     $j_all_days = $j_day_no+1;
-    
+
     for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) {
         $j_day_no -= $j_days_in_month[$i];
     }
-    
+
     $jm = $i+1;
     $jd = $j_day_no+1;
-    
+
     return array($jy, $jm, $jd, $j_all_days);
 }
 
 /**
- * Jalali to Gregorian Convertor
+ * Persian to Gregorian Convertor
  *
  * @author farsiweb.info
  * @access public
@@ -64,7 +73,7 @@ function g2j($g_y, $g_m, $g_d){
  * @param   int day
  * @return  array   converted time
  */
-function j2g($j_y, $j_m, $j_d){
+function p2g($j_y, $j_m, $j_d){
     $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
     $jy = $j_y-979;
@@ -102,12 +111,12 @@ function j2g($j_y, $j_m, $j_d){
     }
     $gm = $i+1;
     $gd = $g_day_no+1;
-        
+
     return array($gy, $gm, $gd);
 }
-    
+
 /**
- * Format a string according to Jalali calendar (UTF)
+ * Format a string according to Persian calendar (UTF)
  *
  * @author  Omid Mottaghi
  * @access public
@@ -115,13 +124,17 @@ function j2g($j_y, $j_m, $j_d){
  * @param   int     Timestamp to format
  * @return  string  Formatted local time/date according to locale settings
  */
-function jalali_strftime_utf($format, $timestamp) {
-    
+function persian_strftime_utf($format, $timestamp='') {
+
+       if($timestamp==''){
+       $timestamp = mktime();
+    }
+
     $g_d=date('j', $timestamp);
     $g_m=date('n', $timestamp);
     $g_y=date('Y', $timestamp);
 
-    list($jy, $jm, $jd, $j_all_days) = g2j($g_y, $g_m, $g_d);
+    list($jy, $jm, $jd, $j_all_days) = g2p($g_y, $g_m, $g_d);
 
     $j_month_name = array('', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر',
             'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند');
@@ -146,12 +159,12 @@ function jalali_strftime_utf($format, $timestamp) {
                            'Wed' => '5',
                            'Thu' => '6',
                            'Fri' => '7');
-    
+
     // calculate string
     $output_str='';
-    
+
     for ($i=0; $i<strlen($format); $i++){
-        
+
         if($format[$i]=='%'){
             $i++;
             switch($format[$i]){
@@ -167,7 +180,7 @@ function jalali_strftime_utf($format, $timestamp) {
                     $output_str.=$j_month_name[$jm];
                     break;
                 case 'c':
-                    $output_str.=jalali_strftime_utf('%y/%m/%d %I:%M:%S', $timestamp);
+                    $output_str.=persian_strftime_utf('%y/%m/%d %I:%M:%S', $timestamp);
                     break;
                 case 'C':
                     $output_str.=floor($jy/100);
@@ -188,7 +201,7 @@ function jalali_strftime_utf($format, $timestamp) {
                     $output_str.=date('h', $timestamp);
                     break;
                 case 'j':
-                    $output_str.=sprintf("%03d", $j_all_days);
+                    $output_str.=sprintf('%03d', $j_all_days);
                     break;
                 case 'm':
                     if($jm<10) $output_str.='0'.$jm; else $output_str.=$jm;
@@ -215,17 +228,17 @@ function jalali_strftime_utf($format, $timestamp) {
                 case 'U':
                 case 'V':
                 case 'W':
-                    $output_str.=sprintf("%02d", floor(($j_all_days+1)/7));
+                    $output_str.=sprintf('%02d', floor(($j_all_days+1)/7));
                     break;
                 case 'u':
                 case 'w':
                     $output_str.=$j_week_number[date('D', $timestamp)];
                     break;
                 case 'x':
-                    $output_str.=jalali_strftime_utf('%y/%m/%d', $timestamp);
+                    $output_str.=persian_strftime_utf('%y/%m/%d', $timestamp);
                     break;
                 case 'X':
-                    $output_str.=jalali_strftime_utf('%I:%M:%S', $timestamp);
+                    $output_str.=persian_strftime_utf('%I:%M:%S', $timestamp);
                     break;
                 case 'g':
                 case 'y':
@@ -247,12 +260,12 @@ function jalali_strftime_utf($format, $timestamp) {
             $output_str.=$format[$i];
         }
     }
-    
+
     return $output_str;
 }
 
 /**
- * Format a string according to Jalali calendar (UTF)
+ * Format a string according to Persian calendar (UTF)
  *
  * @author  Omid Mottaghi
  * @access public
@@ -260,17 +273,25 @@ function jalali_strftime_utf($format, $timestamp) {
  * @param   int     Timestamp to format
  * @return  string  Formatted local time/date
  */
-function jalali_date_utf($format, $timestamp) {
-    
-    $g_d=date('j', $timestamp);
+function persian_date_utf($format, $timestamp='') {
+
+    if($timestamp==''){
+       $timestamp = mktime();
+    }
+
+       $g_d=date('j', $timestamp);
     $g_m=date('n', $timestamp);
     $g_y=date('Y', $timestamp);
-    
-    list($jy, $jm, $jd, $j_all_days) = g2j($g_y, $g_m, $g_d);
-    
+
+    list($jy, $jm, $jd, $j_all_days) = g2p($g_y, $g_m, $g_d);
+
     $j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
-    if(($g_y % 4) == 3) $j_days_in_month[12]++;
-    
+    $leap = 0;
+    if ($g_m>1 && (($g_y%4==0 && $g_y%100!=0) || ($g_y%400==0))){
+       $j_days_in_month[12]++;
+       $leap = 1;
+    }
+
     $j_month_name = array('', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر',
             'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند');
     $j_week_name = array('Saturday' => 'شنبه',
@@ -294,12 +315,12 @@ function jalali_date_utf($format, $timestamp) {
                            'Wed' => '5',
                            'Thu' => '6',
                            'Fri' => '7');
-    
+
     // calculate string
     $output_str='';
-    
+
     for ($i=0; $i<strlen($format); $i++){
-        
+
         if($format[$i]!='\\'){
             switch($format[$i]){
                 case 'd':
@@ -320,7 +341,7 @@ function jalali_date_utf($format, $timestamp) {
                     $output_str.=$j_week_number[date('D', $timestamp)];
                     break;
                 case 'z':
-                    $output_str.=sprintf("%03d", $j_all_days);
+                    $output_str.=sprintf('%03d', $j_all_days);
                     break;
                 case 'W':
                     $output_str.=floor(($j_all_days+1)/7);
@@ -334,10 +355,12 @@ function jalali_date_utf($format, $timestamp) {
                     break;
                 case 'n':
                     $output_str.=$jm;
+                    break;
                 case 't':
                     $output_str.=$j_days_in_month[$jm];
                     break;
-                case 'L': // incomplete
+                case 'L':
+                       $output_str.=$leap;
                     break;
                 case 'o':
                 case 'Y':
@@ -351,7 +374,7 @@ function jalali_date_utf($format, $timestamp) {
                     if(date('a', $timestamp)=='pm') $output_str.='بعد از ظهر'; else $output_str.='قبل از ظهر';
                     break;
                 case 'B':
-                    $output_str.=date('a', $timestamp);
+                    $output_str.=date('B', $timestamp);
                     break;
                 case 'g':
                     $output_str.=date('g', $timestamp);
@@ -371,6 +394,9 @@ function jalali_date_utf($format, $timestamp) {
                 case 's':
                     $output_str.=date('s', $timestamp);
                     break;
+                case 'e':
+                    $output_str.=date('e', $timestamp);
+                    break;
                 case 'I':
                     $output_str.=date('I', $timestamp);
                     break;
@@ -381,10 +407,10 @@ function jalali_date_utf($format, $timestamp) {
                     $output_str.=date('Z', $timestamp);
                     break;
                 case 'c':
-                    $output_str.=date('d-m-Y\TH:i:sO', $timestamp);
+                    $output_str.=persian_date_utf('d-m-Y\TH:i:sO', $timestamp);
                     break;
                 case 'r':
-                    $output_str.=date('D، j F Y H:i:s O', $timestamp);
+                    $output_str.=persian_date_utf('D، j F Y H:i:s O', $timestamp);
                     break;
                 case 'U':
                     $output_str.=date('U', $timestamp);
@@ -398,12 +424,13 @@ function jalali_date_utf($format, $timestamp) {
             $output_str.=$format[$i];
         }
     }
-    
+
     return $output_str;
 }
 
 /**
- * Create a Unix timestamp for a Jalali date
+ * Create a Unix timestamp for a Persian date
+ * This function works only with day > 0
  *
  * @author Omid Mottaghi
  * @access public
@@ -416,7 +443,73 @@ function jalali_date_utf($format, $timestamp) {
  * @param   int is daylight savings time set?
  * @return  int returned timestamp
  */
-function jalali_mktime($hour=0, $min=0, $sec=0, $mon=1, $day=1, $year=1349, $is_dst=-1){
-    list($year, $mon, $day)=j2g($year, $mon, $day);
+function persian_mktime($hour='', $min='', $sec='', $mon='', $day='', $year='', $is_dst=-1){
+       $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
+
+       if ( (string) $hour == '') { $hour = persian_date_utf('H'); }
+       if ( (string) $min  == '') { $min  = persian_date_utf('i'); }
+       if ( (string) $sec  == '') { $sec  = persian_date_utf('s'); }
+       if ( (string) $day  == '') { $day  = persian_date_utf('j'); }
+       if ( (string) $mon  == '') { $mon  = persian_date_utf('n'); }
+       if ( (string) $year == '') { $year = persian_date_utf('Y'); }
+
+       /*
+          an ugly, beta code snippet to support days <= zero!
+          it should work, but days in one or more months should calculate!
+       */
+
+       /*
+       if($day <= 0){
+               // change sign
+               $day = abs($day);
+
+               // calculate months and days that shall decrease
+               // this do-while has a lot of errors!!!
+               do{
+                       // $month_days = $j_days_in_month[$mon]
+                       $months  = floor($day/30);
+                       $days = $day % 30;
+               }while();
+
+               $mon -= $months;
+               $day -= $days;
+               if ($day < 1) {
+                       $mon--;
+               }
+       }
+       */
+
+       if($mon <= 0){
+               // change sign
+               $mon = abs($mon);
+
+               // calculate years and months that shall decrease
+               $years  = floor($mon/12);
+               $months = $mon % 12;
+
+               $year -= $years;
+               $mon  -= $months;
+               if ($mon < 1) {
+                       $year--;
+                       $mon += 12;
+               }
+       }
+
+       if ($day < 1) {
+               $temp_month = $mon-1;
+               $temp_year  = $year;
+               if($temp_month <= 0){
+                       $temp_month = 12;
+                       $temp_year--;
+               }
+               if ($temp_month>1 && (($temp_year%4==0 && $temp_year%100!=0) || ($temp_year%400==0))){
+               $j_days_in_month[12] = 30;
+       }else{
+               $j_days_in_month[12] = 29;
+       }
+               $day += $j_days_in_month[$temp_month];
+       }
+
+    list($year, $mon, $day)=p2g($year, $mon, $day);
     return mktime($hour, $min, $sec, $mon, $day, $year, $is_dst);
 }
index ffab9c85e78a19ac4a86604624bf85f58e81d1fb..2e64a53aaa7a8f927a103c49a5d57dee8a9a1020 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_COMMENTS')) {
     return;
 }
@@ -126,7 +130,7 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f
     } else {
         $limit = '';
     }
-    
+
     if ($type == 'comments' || empty($type)) {
         $type = 'NORMAL';
     } elseif ($type == 'trackbacks') {
@@ -142,7 +146,7 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f
     if (!$showAll) {
         $and .= ' AND co.status = \'approved\'';
     }
-    
+
     $and .= $where;
 
     if ($serendipity['dbType'] == 'postgres') {
@@ -332,7 +336,7 @@ function serendipity_printCommentsByAuthor() {
     }
     $sql_limit = $serendipity['fetchLimit'] * ($serendipity['GET']['page']-1) . ',' . $serendipity['fetchLimit'];
     $c = serendipity_fetchComments(null, $sql_limit, 'co.entry_id DESC, co.id ASC', false, $type, $sql_where);
-    
+
     $entry_comments = array();
     foreach($c as $i => $comment) {
         if (!isset($entry_comments[$comment['entry_id']])) {
@@ -341,7 +345,7 @@ function serendipity_printCommentsByAuthor() {
         }
         $entry_comments[$comment['entry_id']]['comments'][] = $comment;
     }
-    
+
     foreach($entry_comments AS $entry_id => $_data) {
         $entry_comments[$entry_id]['tpl_comments'] =& serendipity_printComments($_data['comments'], VIEWMODE_LINEAR, 0, null, 'COMMENTS', 'comments.tpl');
     }
@@ -356,10 +360,10 @@ function serendipity_printCommentsByAuthor() {
         $and .= ' AND co.status = \'approved\'';
     }
 
-    $cc = serendipity_db_query("SELECT count(co.id) AS counter 
+    $cc = serendipity_db_query("SELECT count(co.id) AS counter
                                   FROM {$serendipity['dbPrefix']}comments AS co
-                                 WHERE co.entry_id > 0 
-                                   AND co.type LIKE '" . $type . "' 
+                                 WHERE co.entry_id > 0
+                                   AND co.type LIKE '" . $type . "'
                                    AND co.status = 'approved' " . $sql_where . "
                               GROUP BY co.author", true, 'assoc');
     if (!isset($cc['counter'])) {
index f8ec76d6014eced6ef339a24408b27e0c05eb5ff..e03c2d37911fd6baadca917ada4c31fbd7c33bdf 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_CONFIG')) {
     return;
 }
index ec0845e16b73eb9ed44bb0ed282c0c5000358986..5911b2e63233c11ed3a970a4c4d002f50a592f58 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_ENTRIES')) {
     return;
 }
index 5927e0622c37db940aa5cc5c84b4437c67aa747f..6321489dccf927699d92baab80e0ce5ccda4eeaf 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_ENTRIES_ADMIN')) {
     return;
 }
index 44a1af20b25854d9bca6ff97ecd67f2185774bd5..f29d50c5d4230713f79278e891ac61faf1c4975f 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_IMAGES')) {
     return;
 }
@@ -3315,15 +3319,15 @@ function serendipity_checkDirUpload($dir) {
         return true;
     }
     */
-    
+
     $allowed  = serendipity_ACLGet(0, 'directory', 'write', $dir);
     $mygroups = serendipity_checkPermission(null, null, true);
-    
+
     // Usergroup "0" always means that access is granted. If no array exists, no ACL restrictions have been set and all is fine.
     if (!is_array($allowed) || isset($allowed[0])) {
         return true;
     }
-    
+
     if (!is_array($mygroups)) {
         return true;
     }
@@ -3334,6 +3338,6 @@ function serendipity_checkDirUpload($dir) {
             break;
         }
     }
-    
+
     return false;
 }
diff --git a/include/functions_images_crop.inc.php b/include/functions_images_crop.inc.php
new file mode 100644 (file)
index 0000000..3992a3b
--- /dev/null
@@ -0,0 +1,450 @@
+<?php\r
+/**************************************************\r
+ * imgedit.inc.php\r
+ * 2003-10-17\r
+ * www.sonnd.com / www.supergarv.de\r
+ *\r
+ * COPYRIGHT (C) BY sonnd / Garvin Hicking\r
+ * Published as LGPL. Copyright notice has to stay in effect.\r
+ **************************************************/\r
+\r
+class imgedit {\r
+    // Needed variables.\r
+    var $orientation_available;\r
+    var $real_img_name, $real_img_info, $real_img_width, $real_img_height, $http_img_name;\r
+    var $img_width, $img_height, $img_name;\r
+    var $zoombox_width;\r
+    var $area_border, $area_width, $area_height, $inner_area_x, $inner_area_y;\r
+    var $harea_width, $harea_height, $harea_img_name, $harea_visibility;\r
+    var $varea_width, $varea_height, $varea_img_name, $varea_visibility;\r
+    var $ratio;\r
+    var $overlay_clip_top, $overlay_clip_bottom, $overlay_clip_left, $overlay_clip_right;\r
+    var $slice_from_x, $slice_from_y, $slice_to_x, $slice_to_y;\r
+    var $output_template = '';\r
+    var $imgedit_smarty = array();\r
+\r
+    // Helper function to cycle through an array. Strips of "_x" and "_y" coordinates if an 'input type="image"'\r
+    // variable has been submitted.\r
+    function makeImgComp(&$array) {\r
+        foreach($array AS $key => $val) {\r
+            if (is_array($val)) {\r
+                $this->makeImgComp($array[$key]);\r
+            } elseif (preg_match('@^.*_(x|y)$@', $key)) {\r
+                $array[preg_replace('@^(.*)_(x|y)$@', '\1', $key)] = $val;\r
+            }\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    // Constructor.\r
+    function imgedit($img_name, $http_img_name) {\r
+        global $serendipity;\r
+        $this->makeImgComp($_REQUEST);\r
+\r
+        // Store the given variables\r
+        $this->real_img_name      = $this->img_name = $img_name;\r
+        $this->real_img_info      = getimagesize($this->real_img_name);\r
+        $this->real_img_width     = $this->real_img_info[0];\r
+        $this->real_img_height    = $this->real_img_info[1];\r
+\r
+        $this->http_img_name      = $http_img_name;\r
+\r
+        // Set even more variables\r
+        $this->setDefaults();\r
+\r
+        return true;\r
+    }\r
+\r
+    // The main logic\r
+    function main() {\r
+\r
+        // 1. Parse the $_REQUEST vars.\r
+        $this->parseRequest();\r
+\r
+        // 2. Get the current size of the cropping area\r
+        $this->getCurrentArea();\r
+\r
+        // 3. Parse any actions\r
+        $this->parseRequestActions();\r
+\r
+        // 4. Valide the results of any actions\r
+        $this->validateCoordinates();\r
+\r
+        // 5. Populate the template\r
+        $this->setVars();\r
+\r
+        return true;\r
+    }\r
+\r
+    // Sets default vars.\r
+    function setDefaults() {\r
+        $this->orientation_available = true;\r
+\r
+        $this->img_width             = $this->real_img_width;\r
+        $this->img_height            = $this->real_img_height;\r
+        $this->img_name              = $this->real_img_name;\r
+\r
+        $this->zoombox_width         = 100;\r
+        $this->area_border           = 6;\r
+\r
+        // Set values if they haven't been submitted yet.\r
+        if (!isset($_REQUEST['area_orientation']) || ($_REQUEST['area_orientation'] != 'h' && $_REQUEST['area_orientation'] != 'v')) {\r
+            $_REQUEST['area_orientation'] = 'h';\r
+        }\r
+\r
+        if (!isset($_REQUEST['autoguess_clicked'])) {\r
+            $_REQUEST['autoguess_clicked'] = 'false';\r
+        }\r
+\r
+        if (!isset($_REQUEST['zoombox_x'])) {\r
+            $_REQUEST['zoombox_x'] = -$this->area_border;\r
+        }\r
+\r
+        if (!isset($_REQUEST['zoombox_y'])) {\r
+            $_REQUEST['zoombox_y'] = -$this->area_border;\r
+        }\r
+\r
+        if (!isset($_REQUEST['move_increase'])) {\r
+            $_REQUEST['move_increase'] = 8;\r
+        } else {\r
+            $_REQUEST['move_increase'] = intval($_REQUEST['move_increase']);\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    // Parse the $_REQUEST vars\r
+    function parseRequest() {\r
+        if (isset($_REQUEST['toggle_area_orientation'])) {\r
+            if ($_REQUEST['area_orientation'] == 'h') {\r
+                $_REQUEST['area_orientation'] = 'v';\r
+            } else {\r
+                $_REQUEST['area_orientation'] = 'h';\r
+            }\r
+        }\r
+\r
+        if (isset($_REQUEST['zoombox_factor'])) {\r
+            $_REQUEST['zoombox_factor'] = floatval($_REQUEST['zoombox_factor']);\r
+        } else {\r
+            $_REQUEST['zoombox_factor'] = 1;\r
+        }\r
+\r
+        if (isset($_REQUEST['action']['enlarge'])) {\r
+            $_REQUEST['zoombox_factor'] += 0.1;\r
+        } elseif (isset($_REQUEST['action']['reduce'])) {\r
+            $_REQUEST['zoombox_factor'] -= 0.1;\r
+        }\r
+\r
+        if ($_REQUEST['zoombox_factor'] > 3) {\r
+            $_REQUEST['zoombox_factor'] = 3;\r
+        } elseif ($_REQUEST['zoombox_factor'] < 0.1) {\r
+            $_REQUEST['zoombox_factor'] = 0.1;\r
+        }\r
+\r
+        if (isset($_REQUEST['action']['moveup'])) {\r
+            $_REQUEST['zoombox_y'] -= $_REQUEST['move_increase'];\r
+        } elseif (isset($_REQUEST['action']['movedown'])) {\r
+            $_REQUEST['zoombox_y'] += $_REQUEST['move_increase'];\r
+        } elseif (isset($_REQUEST['action']['moveleft'])) {\r
+            $_REQUEST['zoombox_x'] -= $_REQUEST['move_increase'];\r
+        } elseif (isset($_REQUEST['action']['moveright'])) {\r
+            $_REQUEST['zoombox_x'] += $_REQUEST['move_increase'];\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    // Fit an image inside the cropping area.\r
+    function imgFit($orientation) {\r
+        if ($orientation == 'height') {\r
+            $this->imgFitHeight();\r
+        } else {\r
+            $this->imgFitWidth();\r
+        }\r
+\r
+        $_REQUEST['zoombox_factor']    = $this->ratio;\r
+        $_REQUEST['autoguess_clicked'] = 'true';\r
+        $_REQUEST['zoombox_x']         = -$this->area_border;\r
+        $_REQUEST['zoombox_y']         = -$this->area_border;\r
+\r
+        return true;\r
+    }\r
+\r
+    // Fit an image, using height as fixed value\r
+    function imgFitHeight() {\r
+        $this->img_height = $this->inner_area_y - $this->area_border;\r
+        $this->ratio      = round($this->img_height / $this->real_img_height, 3);\r
+        $this->img_width  = intval(round($this->real_img_width * $this->ratio));\r
+\r
+        return true;\r
+    }\r
+\r
+    // Fit an image, using width as fixed value\r
+    function imgFitWidth() {\r
+        $this->img_width  = $this->inner_area_x - $this->area_border;\r
+        $this->ratio      = round($this->img_width / $this->real_img_width, 3);\r
+        $this->img_height = intval(round($this->real_img_height * $this->ratio));\r
+\r
+        return true;\r
+    }\r
+\r
+    // Parse actions that were submitted\r
+    function parseRequestActions() {\r
+        global $serendipity;\r
+\r
+        if (isset($_REQUEST['autoscale'])) {\r
+\r
+            if ($this->real_img_width > $this->real_img_height) {\r
+                // The image is a horizontal one. Resize height to fit.\r
+                $this->imgFit('height');\r
+            } else {\r
+                // The image is a vertical one. Resize width to fit.\r
+                $this->imgFit('width');\r
+            }\r
+\r
+\r
+        } elseif (isset($_REQUEST['scale'])) {\r
+\r
+\r
+            if ($this->real_img_width > $this->real_img_height) {\r
+                // The image is a horizontal one. Resize width to fit.\r
+                $this->imgFit('width');\r
+            } else {\r
+                // The image is a vertical one. Resize height to fit.\r
+                $this->imgFit('height');\r
+            }\r
+\r
+        } else {\r
+\r
+            $this->img_width  = intval(round($this->real_img_width  * $_REQUEST['zoombox_factor']));\r
+            $this->img_height = intval(round($this->real_img_height * $_REQUEST['zoombox_factor']));\r
+\r
+        }\r
+\r
+\r
+        // Check which template to use\r
+        if (isset($_REQUEST['crop'])) {\r
+            $this->output_template = 'admin/media_imgedit_done.tpl';\r
+        } else {\r
+            $this->output_template = 'admin/media_imgedit.tpl';\r
+            if ($this->orientation_available) {\r
+                $this->imgedit_smarty['orientation_available'] = true;\r
+            }\r
+        }\r
+\r
+        // The final action. Cropping will take place.\r
+        if (isset($_REQUEST['crop'])) {\r
+            $new_img_name = $this->img_name . '.tmp';\r
+\r
+            if ($this->img_width <= $this->area_width && $this->img_height <= $this->area_height) {\r
+                $this->imgedit_smarty['image_no_cut'] = true;\r
+\r
+                $new_img_width  = $this->img_width;\r
+                $new_img_height = $this->img_height;\r
+            } else {\r
+                $this->imgedit_smarty['image_cut'] = true;\r
+\r
+                $new_img_width  = $this->area_width  - $this->area_border - $this->area_border;\r
+                $new_img_height = $this->area_height - $this->area_border - $this->area_border;\r
+            }\r
+\r
+            $this->slice_from_x = ($this->area_border + $_REQUEST['zoombox_x']) / $_REQUEST['zoombox_factor'];\r
+            $this->slice_from_y = ($this->area_border + $_REQUEST['zoombox_y']) / $_REQUEST['zoombox_factor'];\r
+\r
+            $slice_width  = $new_img_width  / $_REQUEST['zoombox_factor'];\r
+            $slice_height = $new_img_height / $_REQUEST['zoombox_factor'];\r
+\r
+            $this->slice_to_x = $this->slice_from_x + $this->slice_width;\r
+            $this->slice_to_y = $this->slice_from_y + $this->slice_height;\r
+\r
+            // TODO:\r
+            // - Operate also on PNG, TIFF etc.\r
+            // - Support image magick\r
+            // - Save file as new image!\r
+            // - Optionally ask whether to only make a thumbnail from the extracted portion\r
+\r
+            // PHP: int imagecopyresampled ( resource dst_im, resource src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)\r
+            // Open the user's image.\r
+            $img_res      = imagecreatefromjpeg($this->img_name);\r
+\r
+            // Init a blank picture to save the cropped image in.\r
+            $new_img_res  = imagecreatetruecolor($new_img_width, $new_img_height);\r
+\r
+            // Crop the image based on user input, save the resulting image. If either action fails, report an error.\r
+            if (!imagecopyresampled($new_img_res, $img_res, 0, 0, $this->slice_from_x, $this->slice_from_y, $new_img_width, $new_img_height, $slice_width, $slice_height) ||\r
+                !imageJpeg($new_img_res, $new_img_name, 90)) {\r
+\r
+                $this->imgedit_smarty['image_error'] = true;\r
+            }\r
+\r
+            $backup = $this->increment($this->img_name);\r
+            rename($this->img_name, $backup . '.backup');\r
+            rename($new_img_name, $this->img_name);\r
+            $http_new_file = preg_replace('@^' . preg_quote($serendipity['serendipityPath'] . $serendipity['uploadPath']) . '@', '', $this->img_name);\r
+            serendipity_makeThumbnail(basename($http_new_file), dirname($http_new_file) . '/');\r
+\r
+            $this->img_name   = $new_img_name;\r
+            $this->img_width  = $new_img_width;\r
+            $this->img_height = $new_img_height;\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    function increment($fullfile) {\r
+        $d = dirname($fullfile) . '/';\r
+        $f = basename($fullfile);\r
+\r
+        $f = time() . '.' . $f;\r
+\r
+        return $d . $f;\r
+    }\r
+\r
+    // Checks if any coordinates are out of allowed range\r
+    function validateCoordinates() {\r
+        if ($this->img_width > $this->area_width) {\r
+            $c_img_width = $this->img_width;\r
+            $ca_img_width = $this->area_width;\r
+            $x_area_border = $this->area_border;\r
+        } else {\r
+            $c_img_width = $this->area_width;\r
+            $ca_img_width = $this->img_width;\r
+            $x_area_border = -$this->area_border;\r
+        }\r
+\r
+        if ($this->img_height > $this->area_height) {\r
+            $c_img_height = $this->img_height;\r
+            $ca_img_height = $this->area_height;\r
+            $y_area_border = $this->area_border;\r
+        } else {\r
+            $c_img_height = $this->area_height;\r
+            $ca_img_height = $this->img_height;\r
+            $y_area_border = -$this->area_border;\r
+        }\r
+\r
+        if ($_REQUEST['zoombox_x'] < (0 - $this->area_border)) {\r
+            $_REQUEST['zoombox_x'] = 0 - $this->area_border;\r
+        } elseif ($_REQUEST['zoombox_x'] > ($this->img_width - $ca_img_width + $x_area_border)) {\r
+            $_REQUEST['zoombox_x'] = $this->img_width - $ca_img_width + $x_area_border;\r
+        }\r
+\r
+        if ($_REQUEST['zoombox_y'] < (0 - $this->area_border)) {\r
+            $_REQUEST['zoombox_y'] = 0 - $this->area_border;\r
+        } elseif ($_REQUEST['zoombox_y'] > ($this->img_height - $ca_img_height + $y_area_border)) {\r
+            $_REQUEST['zoombox_y'] = $this->img_height - $ca_img_height + $y_area_border;\r
+        }\r
+\r
+        $this->overlay_clip_top    += $_REQUEST['zoombox_y'];\r
+        $this->overlay_clip_bottom += $_REQUEST['zoombox_y'];\r
+        $this->overlay_clip_left   += $_REQUEST['zoombox_x'];\r
+        $this->overlay_clip_right  += $_REQUEST['zoombox_x'];\r
+\r
+        return true;\r
+    }\r
+\r
+    // Sets the sizes of the cropping area\r
+    function setArea($img_name, $orientation = 'h') {\r
+        global $serendipity;\r
+\r
+        $fimg         = serendipity_getTemplateFile('admin/img/' . $img_name, 'serendipityPath');\r
+        $hfimg        = serendipity_getTemplateFile('admin/img/' . $img_name, 'serendipityHTTPPath');\r
+        $img_info     = getImageSize($fimg);\r
+\r
+        if ($orientation == 'h') {\r
+            $this->harea_width    = $img_info[0];\r
+            $this->harea_height   = $img_info[1];\r
+            $this->harea_img_name = $hfimg;\r
+        } else {\r
+            $this->varea_width    = $img_info[0];\r
+            $this->varea_height   = $img_info[1];\r
+            $this->varea_img_name = $hfimg;\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    // Get the size of the selected cropping area\r
+    function getCurrentArea() {\r
+        if ($_REQUEST['area_orientation'] == 'h') {\r
+            $this->area_width       = $this->harea_width;\r
+            $this->area_height      = $this->harea_height;\r
+            $this->varea_visibility = 'hidden';\r
+            $this->harea_visibility = 'visible';\r
+        } else {\r
+            $this->area_width       = $this->varea_width;\r
+            $this->area_height      = $this->varea_height;\r
+            $this->varea_visibility = 'visible';\r
+            $this->harea_visibility = 'hidden';\r
+        }\r
+\r
+        $this->inner_area_x         = $this->area_width  - $this->area_border;\r
+        $this->inner_area_y         = $this->area_height - $this->area_border;\r
+\r
+        $this->overlay_clip_top     = $this->area_border;\r
+        $this->overlay_clip_right   = $this->area_width  - $this->area_border;\r
+        $this->overlay_clip_bottom  = $this->area_height - $this->area_border;\r
+        $this->overlay_clip_left    = $this->area_border;\r
+\r
+        return true;\r
+    }\r
+\r
+    // Set the template variables\r
+    function setVars() {\r
+\r
+        $this->imgedit_smarty['zoombox_width'] =       $this->zoombox_width;\r
+        $this->imgedit_smarty['zoombox_padding'] =     $this->zoombox_width + 20;\r
+        $this->imgedit_smarty['area_width'] =          $this->area_width;\r
+        $this->imgedit_smarty['area_height'] =         $this->area_height;\r
+        $this->imgedit_smarty['varea_width'] =         $this->varea_width;\r
+        $this->imgedit_smarty['varea_height'] =        $this->varea_height;\r
+        $this->imgedit_smarty['varea_img_name'] =      $this->varea_img_name;\r
+        $this->imgedit_smarty['varea_visibility'] =    $this->varea_visibility;\r
+        $this->imgedit_smarty['harea_width'] =         $this->harea_width;\r
+        $this->imgedit_smarty['harea_height'] =        $this->harea_height;\r
+        $this->imgedit_smarty['harea_img_name'] =      $this->harea_img_name;\r
+        $this->imgedit_smarty['harea_visibility'] =    $this->harea_visibility;\r
+        $this->imgedit_smarty['area_border'] =         $this->area_border;\r
+        $this->imgedit_smarty['refresh_line'] =        time();\r
+\r
+        $this->imgedit_smarty['real_img_width'] =      $this->real_img_width;\r
+        $this->imgedit_smarty['real_img_height'] =     $this->real_img_height;\r
+        $this->imgedit_smarty['real_img_name'] =       $this->real_img_name;\r
+        $this->imgedit_smarty['http_img_name'] =       $this->http_img_name;\r
+\r
+        $this->imgedit_smarty['img_width'] =           $this->img_width;\r
+        $this->imgedit_smarty['img_height'] =          $this->img_height;\r
+        $this->imgedit_smarty['zoom_img_width'] =      $this->img_width;\r
+        $this->imgedit_smarty['zoom_img_height'] =     $this->img_height;\r
+        $this->imgedit_smarty['img_name'] =            $this->img_name;\r
+\r
+        $this->imgedit_smarty['overlay_clip_top'] =    $this->overlay_clip_top;\r
+        $this->imgedit_smarty['overlay_clip_bottom'] = $this->overlay_clip_bottom;\r
+        $this->imgedit_smarty['overlay_clip_left'] =   $this->overlay_clip_left;\r
+        $this->imgedit_smarty['overlay_clip_right'] =  $this->overlay_clip_right;\r
+\r
+        $this->imgedit_smarty['slice_from_x'] =        $this->slice_from_x;\r
+        $this->imgedit_smarty['slice_from_y'] =        $this->slice_from_y;\r
+        $this->imgedit_smarty['slice_to_x'] =          $this->slice_to_x;\r
+        $this->imgedit_smarty['slice_to_y'] =          $this->slice_to_y;\r
+\r
+        $this->imgedit_smarty['zoombox_x'] =           $_REQUEST['zoombox_x'];\r
+        $this->imgedit_smarty['zoombox_y'] =           $_REQUEST['zoombox_y'];\r
+        $this->imgedit_smarty['zoombox_factor'] =      $_REQUEST['zoombox_factor'];\r
+\r
+        $this->imgedit_smarty['php_self'] =            $_SERVER['PHP_SELF'];\r
+        $this->imgedit_smarty['area_orientation'] =    $_REQUEST['area_orientation'];\r
+        $this->imgedit_smarty['move_increase'] =       $_REQUEST['move_increase'];\r
+        $this->imgedit_smarty['autoguess_clicked'] =   $_REQUEST['autoguess_clicked'];\r
+\r
+        $this->imgedit_smarty['my_url']            =   htmlspecialchars($_SERVER['REQUEST_URI']);\r
+\r
+        if ($_REQUEST['autoguess_clicked'] == 'true') {\r
+            $this->imgedit_smarty['scale_visibility'] = 'visible';\r
+        } else {\r
+            $this->imgedit_smarty['scale_visibility'] = 'hidden';\r
+        }\r
+\r
+        return true;\r
+    }\r
+}\r
index 2a72978a104a80a61754b90822d5cf7c7fd4a6aa..69d7ce6a1da1a97ddf38b834bebdb4184f7c5593 100644 (file)
@@ -2,6 +2,9 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
 
 if (defined('S9Y_FRAMEWORK_INSTALLER')) {
     return;
index a11c1ab34fd68f0b0ef10330d9661b5adca34919..85680a04c5124ace4644c4281aa90a9468729b65 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_PERMALINKS')) {
     return;
 }
index 5ed42b4d8364eb7df21a6d59263b5ebe4a520a56..fd9bd58a56736669bfd368c2b4ed6d0dcce2dff9 100644 (file)
@@ -2,6 +2,9 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
 
 if (defined('S9Y_FRAMEWORK_PLUGINS_ADMIN')) {
     return;
index af1701018b89a808c05c3cc6167b17942debb71c..451b2c7b9852680e8eb0036bab749e520c01fa29 100644 (file)
@@ -2,6 +2,15 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
+if (defined('S9Y_FRAMEWORK_RSS')) {
+    return;
+}
+@define('S9Y_FRAMEWORK_RSS', true);
+
 /**
  * Parses entries to display them for RSS/Atom feeds to be passed on to generic Smarty templates
  *
@@ -36,7 +45,10 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
             $entry['feed_entryLink'] = serendipity_archiveURL($entry['feed_id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
             if ($options['comments'] == true) {
                 // Display username as part of the title for easier feed-readability
-                $entry['title'] = $entry['author'] . ': ' . $entry['title'];
+                if ($entry['type'] == 'TRACKBACK' && !empty($entry['ctitle'])) {
+                    $entry['author'] .= ' - ' . $entry['ctitle'];
+                }
+                $entry['title'] = (!empty($entry['author']) ? $entry['author'] : ANONYMOUS) . ': ' . $entry['title'];
             }
 
             // Embed a link to extended entry, if existing
@@ -78,7 +90,7 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
                     $cat['feed_category_name'] = serendipity_utf8_encode(htmlspecialchars($cat['category_name']));
                 }
             }
-            
+
             // Prepare variables
             // 1. UTF8 encoding + htmlspecialchars.
             $entry['feed_title']     = serendipity_utf8_encode(htmlspecialchars($entry['title']));
@@ -101,28 +113,28 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
                 case 'opml1.0':
                     $entry_hook = 'frontend_display:opml-1.0:per_entry';
                     break;
-            
+
                 case '0.91':
                     $entry_hook = 'frontend_display:rss-0.91:per_entry';
                     break;
-            
+
                 case '1.0':
                     $entry_hook = 'frontend_display:rss-1.0:per_entry';
                     break;
-            
+
                 case '2.0':
                     $entry_hook = 'frontend_display:rss-2.0:per_entry';
                     break;
-            
+
                 case 'atom0.3':
                     $entry_hook = 'frontend_display:atom-0.3:per_entry';
                     break;
-            
+
                 case 'atom1.0':
                     $entry_hook = 'frontend_display:atom-1.0:per_entry';
                     break;
             }
-            
+
             serendipity_plugin_api::hook_event($entry_hook, $entry);
             $entry['per_entry_display_dat'] = $entry['display_dat'];
         }
index 55aeba39481351aaadb1d864607c077dad6fc4b6..2a2602a5d56fb1bda583ed57ebd37037bbc5777e 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_SMARTY')) {
     return;
 }
@@ -354,7 +358,7 @@ function serendipity_smarty_showCommentForm($params, &$smarty) {
     if (!isset($params['data'])) {
         $params['data'] = $serendipity['POST'];
     }
-  
+
     if (!isset($params['showToolbar'])) {
         $params['showToolbar'] = true;
     }
index c14081b14ccf663fe91b2ba8a0eae63983df61ee..1781acab71ac2d7fd8b3f7ae293a3433103dc9ce 100644 (file)
@@ -2,6 +2,15 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
+if (defined('S9Y_FRAMEWORK_TRACKBACKS')) {
+    return;
+}
+@define('S9Y_FRAMEWORK_TRACKBACKS', true);
+
 /**
  * Check a HTTP response if it is a valid XML trackback response
  *
@@ -86,15 +95,19 @@ function _serendipity_send($loc, $data) {
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
     $options = array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'POST');
     serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_send');
+    serendipity_request_start();
+
     $req = &new HTTP_Request($uri, $options);
     $req->addRawPostData($data, true);
     $res = $req->sendRequest();
 
     if (PEAR::isError($res)) {
+        serendipity_request_end();
         return false;
     }
 
     $fContent = $req->getResponseBody();
+    serendipity_request_end();
     return $fContent;
 }
 
@@ -199,15 +212,18 @@ global $serendipity;
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
     $options = array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'GET');
     serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_detect');
+    serendipity_request_start();
     $req = &new HTTP_Request($parsed_loc, $options);
     $res = $req->sendRequest();
 
     if (PEAR::isError($res)) {
         echo '<div>&#8226; ' . sprintf(TRACKBACK_COULD_NOT_CONNECT, $u['host'], $u['port']) .'</div>';
+        serendipity_request_end();
         return;
     }
 
     $fContent = $req->getResponseBody();
+    serendipity_request_end();
 
     if (strlen($fContent) != 0) {
         serendipity_trackback_autodiscover($fContent, $parsed_loc, $url, $author, $title, $text, $loc);
@@ -322,7 +338,7 @@ function add_pingback ($id, $postdata) {
  * @return  string  Output text
  */
 function serendipity_trackback_excerpt($text) {
-    return substr(strip_tags($text), 0, 255);
+    return serendipity_mb('substr', strip_tags($text), 0, 255);
 }
 
 /**
@@ -443,7 +459,8 @@ function serendipity_handle_references($id, $author, $title, $text) {
 
         $query = "SELECT COUNT(id) FROM {$serendipity['dbPrefix']}references
                                   WHERE entry_id = '". (int)$tmpid ."'
-                                    AND link = '" . serendipity_db_escape_string($locations[$i]) . "'";
+                                    AND link = '" . serendipity_db_escape_string($locations[$i]) . "'
+                                    AND type = ''";
 
         $row = serendipity_db_query($query, true, 'num');
         if ($row[0] > 0) {
@@ -455,7 +472,7 @@ function serendipity_handle_references($id, $author, $title, $text) {
             $checked_locations[$locations[$i]] = true; // Store trackbacked link so that no further trackbacks will be sent to the same link
         }
     }
-    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id='" . (int)$tmpid . "'");
+    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id='" . (int)$tmpid . "' AND type = ''");
 
     for ($i = 0; $i < $j; ++$i) {
         $query = "INSERT INTO {$serendipity['dbPrefix']}references (entry_id, name, link) VALUES(";
index 6045123fece8b51bfa028f195329ce0d4e502f17..804f5a55c95358452a04bf3e2d539bfb12a1755e 100644 (file)
@@ -2,6 +2,15 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
+if (defined('S9Y_FRAMEWORK_UPGRADER')) {
+    return;
+}
+@define('S9Y_FRAMEWORK_UPGRADER', true);
+
 /**
  * This is a list of functions that are used by the upgrader. Define functions here that
  * are not used within usual Serendipity control flow
@@ -84,7 +93,7 @@ function serendipity_fixPlugins($case) {
                 'serendipity_event_searchhighlight',
                 'serendipity_event_textile'
             );
-            
+
             $elements = array(
                 'ENTRY_BODY',
                 'EXTENDED_BODY',
@@ -97,24 +106,24 @@ function serendipity_fixPlugins($case) {
                 $where[] = "name LIKE '$plugin:%'";
             }
 
-            $rows = serendipity_db_query("SELECT name, value, authorid 
-                                            FROM {$serendipity['dbPrefix']}config  
+            $rows = serendipity_db_query("SELECT name, value, authorid
+                                            FROM {$serendipity['dbPrefix']}config
                                            WHERE " . implode(' OR ', $where));
             if (!is_array($rows)) {
                 return false;
             }
-            
+
             foreach($rows AS $row) {
                 if (preg_match('@^(serendipity_event_.+):([a-z0-9]+)/(.+)@i', $row['name'], $plugin_data)) {
                     foreach($elements AS $element) {
                         if ($plugin_data[3] != constant($element)) {
                             continue;
                         }
-                        
+
                         $new = $plugin_data[1] . ':' . $plugin_data[2] . '/' . $element;
                         serendipity_db_query("UPDATE {$serendipity['dbPrefix']}config
                                                  SET name     = '$new'
-                                               WHERE name     = '{$row['name']}' 
+                                               WHERE name     = '{$row['name']}'
                                                  AND value    = '{$row['value']}'
                                                  AND authorid = '{$row['authorid']}'");
                     }
index 36f02da87c145f0d7bfb39ea0a40c525ed61cb18..504a12a0da815a5b3b867e6333c18713dfd7ca4a 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (!defined('S9Y_FRAMEWORK')) {
     include('serendipity_config.inc.php');
 }
@@ -97,7 +101,7 @@ if ($serendipity['smarty_raw_mode']) {
         case 'comments':
             serendipity_printCommentsByAuthor();
             // use 'content_message' for pagination?
-            
+
             break;
 
         // Show the archive
index 5f62335fffec948f5ab1d88c74c83debf7125f0c..e2302a11f7edaaf980afaf612e7bf3d1c3ed8c97 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
     $charset = serendipity_getCharset();
 
index 17cc3f496942d34ebe2785bdd4e457cecf5dfdf1..fefade7e055277039e4516418c47b9d66e4ca355 100644 (file)
@@ -2,6 +2,10 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+
 if (defined('S9Y_FRAMEWORK_PLUGIN_INTERNAL')) {
     return;
 }
index 091e22cea4abafbe6b65aee7fe9ac1147ae552a6..8d5978f4f2169308844499dabbbacf878ad956ce 100644 (file)
@@ -1,5 +1,9 @@
 <?php # $Id$
 
+if (IN_serendipity !== true) {
+    die ("Don't hack!");
+}
+    
 $probelang = dirname(__FILE__) . '/lang_' . $serendipity['lang'] . '.inc.php';
 if (file_exists($probelang)) {
     include $probelang;