* 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)
# 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);
$permalinkNew[] = $serendipity[$permitem['var']];
}
}
- }
+ }
if (serendipity_checkPermission('siteConfiguration') && serialize($permalinkOld) != serialize($permalinkNew)) {
printf(ATTEMPT_WRITE_FILE, $serendipity['serendipityPath'] . '.htaccess');
# 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);
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>';
}
}
# 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;
}
static $avail = null;
static $show = true;
static $memUsage = 0;
-
+
if (!$show) {
return false;
}
-
+
if ($avail === false) {
return true;
} elseif ($avail === null) {
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;
$charset = '';
}
}
-
+
if (!empty($serendipity['POST']['charset'])) {
if ($serendipity['POST']['charset'] == 'UTF-8/') {
$charset = 'UTF-8/';
# 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;
}
if ($depth !== 0) {
return true;
}
-
+
if (count($_remain) > 0) {
// Remaining items need to be appended
foreach($_remain AS $key => $data) {
function serendipity_db_time() {
static $ts = null;
static $cache = 300; // Seconds to cache
-
+
if ($ts === null) {
$now = time();
$ts = $now - ($now % $cache) + $cache;
# 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
* @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;
}
$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
* @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('', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر',
'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند');
'Wed' => '5',
'Thu' => '6',
'Fri' => '7');
-
+
// calculate string
$output_str='';
-
+
for ($i=0; $i<strlen($format); $i++){
-
+
if($format[$i]=='%'){
$i++;
switch($format[$i]){
$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);
$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;
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':
$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
* @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' => 'شنبه',
'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':
$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);
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':
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);
case 's':
$output_str.=date('s', $timestamp);
break;
+ case 'e':
+ $output_str.=date('e', $timestamp);
+ break;
case 'I':
$output_str.=date('I', $timestamp);
break;
$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);
$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
* @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);
}
# 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;
}
} else {
$limit = '';
}
-
+
if ($type == 'comments' || empty($type)) {
$type = 'NORMAL';
} elseif ($type == 'trackbacks') {
if (!$showAll) {
$and .= ' AND co.status = \'approved\'';
}
-
+
$and .= $where;
if ($serendipity['dbType'] == 'postgres') {
}
$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']])) {
}
$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');
}
$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'])) {
# 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;
}
# 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;
}
# 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;
}
# 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;
}
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;
}
break;
}
}
-
+
return false;
}
--- /dev/null
+<?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
# 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;
# 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;
}
# 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;
# 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
*
$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
$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']));
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'];
}
# 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;
}
if (!isset($params['data'])) {
$params['data'] = $serendipity['POST'];
}
-
+
if (!isset($params['showToolbar'])) {
$params['showToolbar'] = true;
}
# 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
*
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;
}
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>• ' . 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);
* @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);
}
/**
$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) {
$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(";
# 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
'serendipity_event_searchhighlight',
'serendipity_event_textile'
);
-
+
$elements = array(
'ENTRY_BODY',
'EXTENDED_BODY',
$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']}'");
}
# 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');
}
case 'comments':
serendipity_printCommentsByAuthor();
// use 'content_message' for pagination?
-
+
break;
// Show the archive
# 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();
# 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;
}
<?php # $Id$
+if (IN_serendipity !== true) {
+ die ("Don't hack!");
+}
+
$probelang = dirname(__FILE__) . '/lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;