1
0

Small code cleanup by Falk Doering:

- PHP6 forward compatibility on accessing strings
- Better indenting, other cleanups on the plugin API file
This commit is contained in:
Garvin Hicking
2007-07-17 11:31:20 +00:00
parent 1e846ef160
commit 14f04bd485
18 changed files with 574 additions and 560 deletions

View File

@ -259,7 +259,7 @@ class HTTP_Request {
$this->_timeout = null; $this->_timeout = null;
$this->_response = null; $this->_response = null;
foreach ($params as $key => $value) { foreach ($params AS $key => $value) {
$this->{'_' . $key} = $value; $this->{'_' . $key} = $value;
} }
@ -483,7 +483,7 @@ class HTTP_Request {
return call_user_func($callback, $value); return call_user_func($callback, $value);
} else { } else {
$map = array(); $map = array();
foreach ($value as $k => $v) { foreach ($value AS $k => $v) {
$map[$k] = $this->_arrayMapRecursive($callback, $v); $map[$k] = $this->_arrayMapRecursive($callback, $v);
} }
return $map; return $map;
@ -507,7 +507,7 @@ class HTTP_Request {
if (!is_array($fileName) && !is_readable($fileName)) { if (!is_array($fileName) && !is_readable($fileName)) {
return PEAR::raiseError("File '{$fileName}' is not readable"); return PEAR::raiseError("File '{$fileName}' is not readable");
} elseif (is_array($fileName)) { } elseif (is_array($fileName)) {
foreach ($fileName as $name) { foreach ($fileName AS $name) {
if (!is_readable($name)) { if (!is_readable($name)) {
return PEAR::raiseError("File '{$name}' is not readable"); return PEAR::raiseError("File '{$name}' is not readable");
} }
@ -653,7 +653,7 @@ class HTTP_Request {
$this->_url = &new Net_URL($redirect); $this->_url = &new Net_URL($redirect);
$this->addHeader('Host', $this->_generateHostHeader()); $this->addHeader('Host', $this->_generateHostHeader());
// Absolute path // Absolute path
} elseif ($redirect{0} == '/') { } elseif ($redirect[0] == '/') {
$this->_url->path = $redirect; $this->_url->path = $redirect;
// Relative path // Relative path
@ -777,7 +777,7 @@ class HTTP_Request {
// Request Headers // Request Headers
if (!empty($this->_requestHeaders)) { if (!empty($this->_requestHeaders)) {
foreach ($this->_requestHeaders as $name => $value) { foreach ($this->_requestHeaders AS $name => $value) {
$canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); $canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
$request .= $canonicalName . ': ' . $value . "\r\n"; $request .= $canonicalName . ': ' . $value . "\r\n";
} }
@ -805,20 +805,20 @@ class HTTP_Request {
$postdata = ''; $postdata = '';
if (!empty($this->_postData)) { if (!empty($this->_postData)) {
$flatData = $this->_flattenArray('', $this->_postData); $flatData = $this->_flattenArray('', $this->_postData);
foreach ($flatData as $item) { foreach ($flatData AS $item) {
$postdata .= '--' . $boundary . "\r\n"; $postdata .= '--' . $boundary . "\r\n";
$postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"';
$postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n";
} }
} }
foreach ($this->_postFiles as $name => $value) { foreach ($this->_postFiles AS $name => $value) {
if (is_array($value['name'])) { if (is_array($value['name'])) {
$varname = $name . ($this->_useBrackets? '[]': ''); $varname = $name . ($this->_useBrackets? '[]': '');
} else { } else {
$varname = $name; $varname = $name;
$value['name'] = array($value['name']); $value['name'] = array($value['name']);
} }
foreach ($value['name'] as $key => $filename) { foreach ($value['name'] AS $key => $filename) {
$fp = fopen($filename, 'r'); $fp = fopen($filename, 'r');
$data = fread($fp, filesize($filename)); $data = fread($fp, filesize($filename));
fclose($fp); fclose($fp);
@ -860,7 +860,7 @@ class HTTP_Request {
return array(array($name, $values)); return array(array($name, $values));
} else { } else {
$ret = array(); $ret = array();
foreach ($values as $k => $v) { foreach ($values AS $k => $v) {
if (empty($name)) { if (empty($name)) {
$newName = $k; $newName = $k;
} elseif ($this->_useBrackets) { } elseif ($this->_useBrackets) {
@ -928,7 +928,7 @@ class HTTP_Request {
*/ */
function _notify($event, $data = null) function _notify($event, $data = null)
{ {
foreach (array_keys($this->_listeners) as $id) { foreach (array_keys($this->_listeners) AS $id) {
$this->_listeners[$id]->update($this, $event, $data); $this->_listeners[$id]->update($this, $event, $data);
} }
} }
@ -1183,7 +1183,7 @@ class HTTP_Response
*/ */
function _notify($event, $data = null) function _notify($event, $data = null)
{ {
foreach (array_keys($this->_listeners) as $id) { foreach (array_keys($this->_listeners) AS $id) {
$this->_listeners[$id]->update($this, $event, $data); $this->_listeners[$id]->update($this, $event, $data);
} }
} }

View File

@ -166,7 +166,7 @@ class Net_URL
// Default querystring // Default querystring
$this->querystring = array(); $this->querystring = array();
foreach ($urlinfo as $key => $value) { foreach ($urlinfo AS $key => $value) {
switch ($key) { switch ($key) {
case 'scheme': case 'scheme':
$this->protocol = $value; $this->protocol = $value;
@ -181,7 +181,7 @@ class Net_URL
break; break;
case 'path': case 'path':
if ($value{0} == '/') { if ($value[0] == '/') {
$this->path = $value; $this->path = $value;
} else { } else {
$path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path);
@ -272,9 +272,9 @@ class Net_URL
function getQueryString() function getQueryString()
{ {
if (!empty($this->querystring)) { if (!empty($this->querystring)) {
foreach ($this->querystring as $name => $value) { foreach ($this->querystring AS $name => $value) {
if (is_array($value)) { if (is_array($value)) {
foreach ($value as $k => $v) { foreach ($value AS $k => $v) {
$querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v); $querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v);
} }
} elseif (!is_null($value)) { } elseif (!is_null($value)) {
@ -303,7 +303,7 @@ class Net_URL
$parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY); $parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY);
$return = array(); $return = array();
foreach ($parts as $part) { foreach ($parts AS $part) {
if (strpos($part, '=') !== false) { if (strpos($part, '=') !== false) {
$value = substr($part, strpos($part, '=') + 1); $value = substr($part, strpos($part, '=') + 1);
$key = substr($part, 0, strpos($part, '=')); $key = substr($part, 0, strpos($part, '='));

View File

@ -140,7 +140,7 @@ class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse {
{ {
// when prefixed with !, it's explicitly not a wiki link. // when prefixed with !, it's explicitly not a wiki link.
// return everything as it was. // return everything as it was.
if ($matches[2]{0} == '!') { if ($matches[2][0] == '!') {
return $matches[1] . substr($matches[2], 1) . $matches[3]; return $matches[1] . substr($matches[2], 1) . $matches[3];
} }

View File

@ -56,7 +56,7 @@ class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render {
} else { } else {
// allow for alternative targets on non-anchor HREFs // allow for alternative targets on non-anchor HREFs
if ($href{0} == '#') { if ($href[0] == '#') {
$target = ''; $target = '';
} else { } else {
$target = $this->getConf('target'); $target = $this->getConf('target');

View File

@ -159,7 +159,7 @@ class Text_Wiki_Rule_wikilink extends Text_Wiki_Rule {
{ {
// when prefixed with !, it's explicitly not a wiki link. // when prefixed with !, it's explicitly not a wiki link.
// return everything as it was. // return everything as it was.
if ($matches[2]{0} == '!') { if ($matches[2][0] == '!') {
return $matches[1] . substr($matches[2], 1) . $matches[3]; return $matches[1] . substr($matches[2], 1) . $matches[3];
} }

View File

@ -31,7 +31,7 @@ class Serendipity_Import_Pivot extends Serendipity_Import {
$res = serendipity_fetchCategories('all'); $res = serendipity_fetchCategories('all');
$ret = array(0 => NO_CATEGORY); $ret = array(0 => NO_CATEGORY);
if (is_array($res)) { if (is_array($res)) {
foreach ($res as $v) { foreach ($res AS $v) {
$ret[$v['categoryid']] = $v['category_name']; $ret[$v['categoryid']] = $v['category_name'];
} }
} }
@ -112,7 +112,7 @@ class Serendipity_Import_Pivot extends Serendipity_Import {
$i = 0; $i = 0;
while (false !== ($dir = readdir($root))) { while (false !== ($dir = readdir($root))) {
if ($dir{0} == '.') continue; if ($dir[0] == '.') continue;
if (substr($dir, 0, 8) == 'standard') { if (substr($dir, 0, 8) == 'standard') {
printf('&nbsp;&nbsp;&middot; ' . CHECKING_DIRECTORY . '...<br />', $dir); printf('&nbsp;&nbsp;&middot; ' . CHECKING_DIRECTORY . '...<br />', $dir);
$data = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/index-' . $dir . '.php'); $data = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/index-' . $dir . '.php');
@ -124,7 +124,7 @@ class Serendipity_Import_Pivot extends Serendipity_Import {
continue; continue;
} }
foreach($data as $entry) { foreach($data AS $entry) {
$entryid = str_pad($entry['code'], 5, '0', STR_PAD_LEFT); $entryid = str_pad($entry['code'], 5, '0', STR_PAD_LEFT);
if ($i >= $max_import) { if ($i >= $max_import) {
@ -166,7 +166,7 @@ class Serendipity_Import_Pivot extends Serendipity_Import {
$i++; $i++;
if (isset($entrydata['comments']) && count($entrydata['comments']) > 0) { if (isset($entrydata['comments']) && count($entrydata['comments']) > 0) {
foreach($entrydata['comments'] as $comment) { foreach($entrydata['comments'] AS $comment) {
$comment = array('entry_id ' => $entry['id'], $comment = array('entry_id ' => $entry['id'],
'parent_id' => 0, 'parent_id' => 0,
'timestamp' => $this->toTimestamp($comment['date']), 'timestamp' => $this->toTimestamp($comment['date']),

View File

@ -314,7 +314,7 @@ function serendipity_db_schema_import($query) {
$query = trim(str_replace($search, $replace, $query)); $query = trim(str_replace($search, $replace, $query));
if ($query{0} == '@') { if ($query[0] == '@') {
// Errors are expected to happen (like duplicate index creation) // Errors are expected to happen (like duplicate index creation)
return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true); return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true);
} else { } else {

View File

@ -283,7 +283,7 @@ function serendipity_db_schema_import($query) {
} }
$query = trim(str_replace($search, $replace, $query)); $query = trim(str_replace($search, $replace, $query));
if ($query{0} == '@') { if ($query[0] == '@') {
// Errors are expected to happen (like duplicate index creation) // Errors are expected to happen (like duplicate index creation)
return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true); return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true);
} else { } else {

View File

@ -158,7 +158,7 @@ function serendipity_db_insert_id($table = '', $id = '') {
$query = "SELECT currval('{$serendipity['dbPrefix']}{$table}_{$id}_seq'::text) AS {$id}"; $query = "SELECT currval('{$serendipity['dbPrefix']}{$table}_{$id}_seq'::text) AS {$id}";
$res = $serendipity['dbConn']->prepare($query); $res = $serendipity['dbConn']->prepare($query);
$res->execute(); $res->execute();
foreach($res->fetchAll(PDO::FETCH_ASSOC) as $row) { foreach($res->fetchAll(PDO::FETCH_ASSOC) AS $row) {
return $row[$id]; return $row[$id];
} }
return $serendipity['dbConn']->lastInsertId(); return $serendipity['dbConn']->lastInsertId();
@ -224,7 +224,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
$n = 0; $n = 0;
$rows = array(); $rows = array();
foreach($serendipity['dbSth']->fetchAll($result_type) as $row) { foreach($serendipity['dbSth']->fetchAll($result_type) AS $row) {
if (!empty($assocKey)) { if (!empty($assocKey)) {
// You can fetch a key-associated array via the two function parameters assocKey and assocVal // You can fetch a key-associated array via the two function parameters assocKey and assocVal
if (empty($assocVal)) { if (empty($assocVal)) {
@ -266,7 +266,7 @@ function serendipity_db_schema_import($query) {
} }
$query = trim(str_replace($search, $replace, $query)); $query = trim(str_replace($search, $replace, $query));
if ($query{0} == '@') { if ($query[0] == '@') {
// Errors are expected to happen (like duplicate index creation) // Errors are expected to happen (like duplicate index creation)
return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true); return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true);
} else { } else {

View File

@ -279,7 +279,7 @@ function serendipity_db_schema_import($query) {
} }
$query = trim(str_replace($search, $replace, $query)); $query = trim(str_replace($search, $replace, $query));
if ($query{0} == '@') { if ($query[0] == '@') {
// Errors are expected to happen (like duplicate index creation) // Errors are expected to happen (like duplicate index creation)
return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true); return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true);
} else { } else {

View File

@ -149,7 +149,7 @@ function serendipity_db_sqlite_fetch_array($res, $type = SQLITE_BOTH)
} }
/* strip any slashes, correct fieldname */ /* strip any slashes, correct fieldname */
foreach ($row as $i => $v) { foreach ($row AS $i => $v) {
// TODO: If a query of the format 'SELECT a.id, b.text FROM table' is used, // TODO: If a query of the format 'SELECT a.id, b.text FROM table' is used,
// the sqlite extension will give us key indizes 'a.id' and 'b.text' // the sqlite extension will give us key indizes 'a.id' and 'b.text'
// instead of just 'id' and 'text' like in mysql/postgresql extension. // instead of just 'id' and 'text' like in mysql/postgresql extension.
@ -339,7 +339,7 @@ function serendipity_db_schema_import($query)
} }
$query = trim(str_replace($search, $replace, $query)); $query = trim(str_replace($search, $replace, $query));
if ($query{0} == '@') { if ($query[0] == '@') {
// Errors are expected to happen (like duplicate index creation) // Errors are expected to happen (like duplicate index creation)
return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true); return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true);
} else { } else {

View File

@ -148,7 +148,7 @@ function serendipity_db_sqlite_fetch_array($res, $type = SQLITE3_BOTH)
} }
/* strip any slashes, correct fieldname */ /* strip any slashes, correct fieldname */
foreach ($row as $i => $v) { foreach ($row AS $i => $v) {
// TODO: If a query of the format 'SELECT a.id, b.text FROM table' is used, // TODO: If a query of the format 'SELECT a.id, b.text FROM table' is used,
// the sqlite extension will give us key indizes 'a.id' and 'b.text' // the sqlite extension will give us key indizes 'a.id' and 'b.text'
// instead of just 'id' and 'text' like in mysql/postgresql extension. // instead of just 'id' and 'text' like in mysql/postgresql extension.
@ -165,7 +165,7 @@ function serendipity_db_sqlite_fetch_array($res, $type = SQLITE3_BOTH)
if ($type != SQLITE3_ASSOC) { if ($type != SQLITE3_ASSOC) {
$i = 0; $i = 0;
foreach($row as $k => $v) { foreach($row AS $k => $v) {
$frow[$i] = $v; $frow[$i] = $v;
$i++; $i++;
} }
@ -350,7 +350,7 @@ function serendipity_db_schema_import($query)
} }
$query = trim(str_replace($search, $replace, $query)); $query = trim(str_replace($search, $replace, $query));
if ($query{0} == '@') { if ($query[0] == '@') {
// Errors are expected to happen (like duplicate index creation) // Errors are expected to happen (like duplicate index creation)
return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true); return serendipity_db_query(substr($query, 1), false, 'both', false, false, false, true);
} else { } else {

View File

@ -288,7 +288,7 @@ function serendipity_updateImageInDatabase($updates, $id) {
$i=0; $i=0;
if (sizeof($updates) > 0) { if (sizeof($updates) > 0) {
foreach ($updates as $k => $v) { foreach ($updates AS $k => $v) {
$q[] = $k ." = '" . serendipity_db_escape_string($v) . "'"; $q[] = $k ." = '" . serendipity_db_escape_string($v) . "'";
} }
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}images SET ". implode($q, ',') ." WHERE id = " . (int)$id . " $admin"); serendipity_db_query("UPDATE {$serendipity['dbPrefix']}images SET ". implode($q, ',') ." WHERE id = " . (int)$id . " $admin");
@ -339,7 +339,7 @@ function serendipity_deleteImage($id) {
} }
serendipity_plugin_api::hook_event('backend_media_delete', $dThumb); serendipity_plugin_api::hook_event('backend_media_delete', $dThumb);
foreach($dThumb as $thumb) { foreach($dThumb AS $thumb) {
$dfnThumb = $file['path'] . $file['name'] . (!empty($thumb['fthumb']) ? '.' . $thumb['fthumb'] : '') . '.' . $file['extension']; $dfnThumb = $file['path'] . $file['name'] . (!empty($thumb['fthumb']) ? '.' . $thumb['fthumb'] : '') . '.' . $file['extension'];
$dfThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dfnThumb; $dfThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dfnThumb;
@ -385,7 +385,7 @@ function serendipity_fetchImages($group = false, $start = 0, $end = 20, $images
} }
@closedir($dir); @closedir($dir);
sort($aTempArray); sort($aTempArray);
foreach($aTempArray as $f) { foreach($aTempArray AS $f) {
if (strpos($f, $serendipity['thumbSuffix']) !== false) { if (strpos($f, $serendipity['thumbSuffix']) !== false) {
// This is a s9y thumbnail, skip it. // This is a s9y thumbnail, skip it.
continue; continue;
@ -777,7 +777,7 @@ function serendipity_generateThumbs() {
$i=0; $i=0;
$serendipity['imageList'] = serendipity_fetchImagesFromDatabase(0, 0, $total); $serendipity['imageList'] = serendipity_fetchImagesFromDatabase(0, 0, $total);
foreach ($serendipity['imageList'] as $k => $file) { foreach ($serendipity['imageList'] AS $k => $file) {
$is_image = serendipity_isImage($file); $is_image = serendipity_isImage($file);
if ($is_image && !$file['hotlink']) { if ($is_image && !$file['hotlink']) {
@ -1507,14 +1507,14 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
$dprops = $keywords = array(); $dprops = $keywords = array();
if ($serendipity['parseMediaOverview']) { if ($serendipity['parseMediaOverview']) {
$ids = array(); $ids = array();
foreach ($serendipity['imageList'] as $k => $file) { foreach ($serendipity['imageList'] AS $k => $file) {
$ids[] = $file['id']; $ids[] = $file['id'];
} }
$allprops =& serendipity_fetchMediaProperties($ids); $allprops =& serendipity_fetchMediaProperties($ids);
} }
if (count($serendipity['imageList']) > 0) { if (count($serendipity['imageList']) > 0) {
foreach ($serendipity['imageList'] as $k => $file) { foreach ($serendipity['imageList'] AS $k => $file) {
if (!($serendipity['authorid'] == $file['authorid'] || $file['authorid'] == '0' || serendipity_checkPermission('adminImagesViewOthers'))) { if (!($serendipity['authorid'] == $file['authorid'] || $file['authorid'] == '0' || serendipity_checkPermission('adminImagesViewOthers'))) {
// This is a fail-safe continue. Basically a non-matching file should already be filtered in SQL. // This is a fail-safe continue. Basically a non-matching file should already be filtered in SQL.
continue; continue;
@ -2789,23 +2789,23 @@ function serendipity_getMediaRaw($filename) {
$filedata = fread($f, 2); $filedata = fread($f, 2);
if ($filedata{0} != "\xFF") { if ($filedata[0] != "\xFF") {
fclose($f); fclose($f);
return $ret; return $ret;
} }
while (!$abort && !feof($f) && $filedata{1} != "\xD9") { while (!$abort && !feof($f) && $filedata[1] != "\xD9") {
if ((ord($filedata{1}) < 0xD0) || (ord($filedata{1}) > 0xD7)) { if ((ord($filedata[1]) < 0xD0) || (ord($filedata[1]) > 0xD7)) {
$ordret = fread($f, 2); $ordret = fread($f, 2);
$ordstart = ftell($f); $ordstart = ftell($f);
$int = unpack('nsize', $ordret); $int = unpack('nsize', $ordret);
if (ord($filedata{1}) == 225) { if (ord($filedata[1]) == 225) {
$content = fread($f, $int['size'] - 2); $content = fread($f, $int['size'] - 2);
if (substr($content, 0, 24) == 'http://ns.adobe.com/xap/') { if (substr($content, 0, 24) == 'http://ns.adobe.com/xap/') {
$ret[] = array( $ret[] = array(
'ord' => ord($filedata{1}), 'ord' => ord($filedata[1]),
'ordstart' => $ordstart, 'ordstart' => $ordstart,
'int' => $int, 'int' => $int,
'content' => $content 'content' => $content
@ -2816,11 +2816,11 @@ function serendipity_getMediaRaw($filename) {
} }
} }
if ($filedata{1} == "\xDA") { if ($filedata[1] == "\xDA") {
$abort = true; $abort = true;
} else { } else {
$filedata = fread($f, 2); $filedata = fread($f, 2);
if ($filedata{0} != "\xFF") { if ($filedata[0] != "\xFF") {
fclose($f); fclose($f);
return $ret; return $ret;
} }
@ -3180,7 +3180,7 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
// Rename file // Rename file
rename($renameValues[0]['from'], $renameValues[0]['to']); rename($renameValues[0]['from'], $renameValues[0]['to']);
foreach($renameValues as $renameData) { foreach($renameValues AS $renameData) {
// Rename thumbnail // Rename thumbnail
rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . (!empty($renameData['fthumb']) ? '.' . $renameData['fthumb'] : '') . '.' . $file['extension'], rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . (!empty($renameData['fthumb']) ? '.' . $renameData['fthumb'] : '') . '.' . $file['extension'],
$serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $newDir . '.' . $renameData['thumb'] . '.' . $file['extension']); $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $newDir . '.' . $renameData['thumb'] . '.' . $file['extension']);
@ -3232,7 +3232,7 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
// Rename file // Rename file
rename($renameValues[0]['from'], $renameValues[0]['to']); rename($renameValues[0]['from'], $renameValues[0]['to']);
foreach($renameValues as $renameData) { foreach($renameValues AS $renameData) {
// Rename thumbnail // Rename thumbnail
rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $oldDir . $pick['name'] . (!empty($renameData['fthumb']) ? '.' . $renameData['fthumb'] : '') . '.' . $pick['extension'], rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $oldDir . $pick['name'] . (!empty($renameData['fthumb']) ? '.' . $renameData['fthumb'] : '') . '.' . $pick['extension'],
$serendipity['serendipityPath'] . $serendipity['uploadPath'] . $newDir . $pick['name'] . '.' . $renameData['thumb'] . '.' . $pick['extension']); $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $newDir . $pick['name'] . '.' . $renameData['thumb'] . '.' . $pick['extension']);

File diff suppressed because it is too large Load Diff

View File

@ -97,23 +97,23 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
$_args = $serendipity['uriArguments']; $_args = $serendipity['uriArguments'];
/* Attempt to locate hidden variables within the URI */ /* Attempt to locate hidden variables within the URI */
foreach ($_args as $k => $v){ foreach ($_args AS $k => $v){
if ($v == PATH_ARCHIVES) { if ($v == PATH_ARCHIVES) {
continue; continue;
} }
if ($v{0} == 'C') { /* category */ if ($v[0] == 'C') { /* category */
$cat = substr($v, 1); $cat = substr($v, 1);
if (is_numeric($cat)) { if (is_numeric($cat)) {
$serendipity['GET']['category'] = $cat; $serendipity['GET']['category'] = $cat;
unset($_args[$k]); unset($_args[$k]);
} }
} elseif ($v{0} == 'A') { /* Author */ } elseif ($v[0] == 'A') { /* Author */
$url_author = substr($v, 1); $url_author = substr($v, 1);
if (is_numeric($url_author)) { if (is_numeric($url_author)) {
$serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author; $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author;
unset($_args[$k]); unset($_args[$k]);
} }
} elseif ($v{0} == 'W') { /* Week */ } elseif ($v[0] == 'W') { /* Week */
$week = substr($v, 1); $week = substr($v, 1);
if (is_numeric($week)) { if (is_numeric($week)) {
unset($_args[$k]); unset($_args[$k]);
@ -121,7 +121,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
} elseif ($v == 'summary') { /* Summary */ } elseif ($v == 'summary') { /* Summary */
$serendipity['short_archives'] = true; $serendipity['short_archives'] = true;
unset($_args[$k]); unset($_args[$k]);
} elseif ($v{0} == 'P') { /* Page */ } elseif ($v[0] == 'P') { /* Page */
$page = substr($v, 1); $page = substr($v, 1);
if (is_numeric($page)) { if (is_numeric($page)) {
$serendipity['GET']['page'] = $page; $serendipity['GET']['page'] = $page;
@ -358,18 +358,18 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
$serendipity['GET']['action'] = 'archives'; $serendipity['GET']['action'] = 'archives';
$_args = $serendipity['uriArguments']; $_args = $serendipity['uriArguments'];
/* Attempt to locate hidden variables within the URI */ /* Attempt to locate hidden variables within the URI */
foreach ($_args as $k => $v){ foreach ($_args AS $k => $v){
if ($v == PATH_ARCHIVE) { if ($v == PATH_ARCHIVE) {
continue; continue;
} }
if ($v{0} == 'C') { /* category */ if ($v[0] == 'C') { /* category */
$cat = substr($v, 1); $cat = substr($v, 1);
if (is_numeric($cat)) { if (is_numeric($cat)) {
$serendipity['GET']['category'] = $cat; $serendipity['GET']['category'] = $cat;
unset($_args[$k]); unset($_args[$k]);
} }
} elseif ($v{0} == 'A') { /* Author */ } elseif ($v[0] == 'A') { /* Author */
$url_author = substr($v, 1); $url_author = substr($v, 1);
if (is_numeric($url_author)) { if (is_numeric($url_author)) {
$serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author; $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author;
@ -402,18 +402,18 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
$_args = $serendipity['uriArguments']; $_args = $serendipity['uriArguments'];
/* Attempt to locate hidden variables within the URI */ /* Attempt to locate hidden variables within the URI */
foreach ($_args as $k => $v) { foreach ($_args AS $k => $v) {
if ($v == PATH_CATEGORIES) { if ($v == PATH_CATEGORIES) {
continue; continue;
} }
if ($v{0} == 'P') { /* Page */ if ($v[0] == 'P') { /* Page */
$page = substr($v, 1); $page = substr($v, 1);
if (is_numeric($page)) { if (is_numeric($page)) {
$serendipity['GET']['page'] = $page; $serendipity['GET']['page'] = $page;
unset($_args[$k]); unset($_args[$k]);
unset($serendipity['uriArguments'][$k]); unset($serendipity['uriArguments'][$k]);
} }
} elseif ($v{0} == 'A') { /* Author */ } elseif ($v[0] == 'A') { /* Author */
$url_author = substr($v, 1); $url_author = substr($v, 1);
if (is_numeric($url_author)) { if (is_numeric($url_author)) {
$serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author; $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author;
@ -455,8 +455,8 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
$_args = $serendipity['uriArguments']; $_args = $serendipity['uriArguments'];
/* Attempt to locate hidden variables within the URI */ /* Attempt to locate hidden variables within the URI */
foreach ($_args as $k => $v){ foreach ($_args AS $k => $v){
if ($v{0} == 'P') { /* Page */ if ($v[0] == 'P') { /* Page */
$page = substr($v, 1); $page = substr($v, 1);
if (is_numeric($page)) { if (is_numeric($page)) {
$serendipity['GET']['page'] = $page; $serendipity['GET']['page'] = $page;
@ -489,12 +489,12 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
/* Attempt to locate hidden variables within the URI */ /* Attempt to locate hidden variables within the URI */
$search = array(); $search = array();
foreach ($_args as $k => $v){ foreach ($_args AS $k => $v){
if ($v == PATH_SEARCH) { if ($v == PATH_SEARCH) {
continue; continue;
} }
if ($v{0} == 'P') { /* Page */ if ($v[0] == 'P') { /* Page */
$page = substr($v, 1); $page = substr($v, 1);
if (is_numeric($page)) { if (is_numeric($page)) {
$serendipity['GET']['page'] = $page; $serendipity['GET']['page'] = $page;
@ -523,12 +523,12 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
/* Attempt to locate hidden variables within the URI */ /* Attempt to locate hidden variables within the URI */
$search = array(); $search = array();
foreach ($_args as $k => $v){ foreach ($_args AS $k => $v){
if ($v == PATH_COMMENTS) { if ($v == PATH_COMMENTS) {
continue; continue;
} }
if ($v{0} == 'P') { /* Page */ if ($v[0] == 'P') { /* Page */
$page = substr($v, 1); $page = substr($v, 1);
if (is_numeric($page)) { if (is_numeric($page)) {
$serendipity['GET']['page'] = $page; $serendipity['GET']['page'] = $page;

View File

@ -34,7 +34,7 @@ if (!$d) {
$const = array(); $const = array();
$const['checked'] = get_defined_constants(); $const['checked'] = get_defined_constants();
while(($file = readdir($d)) !== false) { while(($file = readdir($d)) !== false) {
if ($file{0} == '.') { if ($file[0] == '.') {
continue; continue;
} }

View File

@ -34,7 +34,7 @@ if (!$d) {
$const = array(); $const = array();
$const['checked'] = get_defined_constants(); $const['checked'] = get_defined_constants();
while(($file = readdir($d)) !== false) { while(($file = readdir($d)) !== false) {
if ($file{0} == '.') { if ($file[0] == '.') {
continue; continue;
} }

View File

@ -50,9 +50,9 @@ class serendipity_event_weblogping extends serendipity_event
$manual_services = explode(',', $this->get_config('manual_services')); $manual_services = explode(',', $this->get_config('manual_services'));
if (is_array($manual_services)) { if (is_array($manual_services)) {
foreach($manual_services as $ms_index => $ms_name) { foreach($manual_services AS $ms_index => $ms_name) {
if (!empty($ms_name)) { if (!empty($ms_name)) {
$is_extended = ($ms_name{0} == '*' ? true : false); $is_extended = ($ms_name[0] == '*' ? true : false);
$ms_name = trim($ms_name, '*'); $ms_name = trim($ms_name, '*');
$ms_parts = explode('/', $ms_name); $ms_parts = explode('/', $ms_name);
$ms_host = $ms_parts[0]; $ms_host = $ms_parts[0];
@ -151,7 +151,7 @@ class serendipity_event_weblogping extends serendipity_event
} }
// First cycle through list of services to remove superseding services which may have been checked // First cycle through list of services to remove superseding services which may have been checked
foreach ($this->services as $index => $service) { foreach ($this->services AS $index => $service) {
if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) { if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) {
$supersedes = explode(', ', $service['supersedes']); $supersedes = explode(', ', $service['supersedes']);
foreach($supersedes AS $sid => $servicename) { foreach($supersedes AS $sid => $servicename) {
@ -160,7 +160,7 @@ class serendipity_event_weblogping extends serendipity_event
} }
} }
} }
foreach ($this->services as $index => $service) { foreach ($this->services AS $index => $service) {
if (isset($serendipity['POST']['announce_entries_' . $service['name']]) || (defined('SERENDIPITY_IS_XMLRPC') && serendipity_db_bool($this->get_config($service['name'])))) { if (isset($serendipity['POST']['announce_entries_' . $service['name']]) || (defined('SERENDIPITY_IS_XMLRPC') && serendipity_db_bool($this->get_config($service['name'])))) {
if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) { if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) {
printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...', $service['host']); printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...', $service['host']);