diff options
author | rvelices <rv-github@modusoptimus.com> | 2009-02-14 02:28:21 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2009-02-14 02:28:21 +0000 |
commit | 368059d5353209ddad495081bc9d5d9218a9de23 (patch) | |
tree | 18c0de692f0102d0275b254f82756a3fa00c4e7f | |
parent | 35e9af66be0b6da3055d032123bd38100b58bca9 (diff) |
merge 3145-3146 from trunk
Last (I hope) paranoic optims ...
- move get_uysername and get_groupname from public to admin/functions.inc.php
- optim in index.php
- tags.tpl does not need smarty modifier included
- move func get_comment_post_key from functions_comment to functions (avoid extra inclusion every time on picture page)
git-svn-id: http://piwigo.org/svn/branches/2.0@3147 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 61 | ||||
-rw-r--r-- | include/functions.inc.php | 34 | ||||
-rw-r--r-- | include/functions_comment.inc.php | 22 | ||||
-rw-r--r-- | include/functions_user.inc.php | 56 | ||||
-rw-r--r-- | include/picture_comment.inc.php | 11 | ||||
-rw-r--r-- | include/ws_functions.inc.php | 11 | ||||
-rw-r--r-- | index.php | 12 | ||||
-rw-r--r-- | tags.php | 2 | ||||
-rw-r--r-- | template/yoga/index.tpl | 2 | ||||
-rw-r--r-- | template/yoga/tags.tpl | 2 |
10 files changed, 99 insertions, 114 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 86d274687..5fdee9684 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -143,7 +143,7 @@ function delete_elements($ids, $physical_deletion=false) if ($physical_deletion) { include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); - + // we can currently delete physically only photo with no // storage_category_id (added via pLoader) // @@ -1864,7 +1864,7 @@ function get_extents($start='') { $extents = array_merge($extents, get_extents($path)); } - elseif ( !is_link($path) and file_exists($path) + elseif ( !is_link($path) and file_exists($path) and get_extension($path) == 'tpl' ) { $extents[] = substr($path, 21); @@ -2009,7 +2009,7 @@ function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0) $host = $src['host']; $path = isset($src['path']) ? $src['path'] : '/'; $path .= isset($src['query']) ? '?'.$src['query'] : ''; - + if (($s = @fsockopen($host,80,$errno,$errstr,5)) === false) { return false; @@ -2066,4 +2066,59 @@ function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0) return true; } + +/** + * returns the groupname corresponding to the given group identifier if + * exists + * + * @param int group_id + * @return mixed + */ +function get_groupname($group_id) +{ + $query = ' +SELECT name + FROM '.GROUPS_TABLE.' + WHERE id = '.intval($group_id).' +;'; + $result = pwg_query($query); + if (mysql_num_rows($result) > 0) + { + list($groupname) = mysql_fetch_row($result); + } + else + { + return false; + } + + return $groupname; +} + +/** + * returns the username corresponding to the given user identifier if exists + * + * @param int user_id + * @return mixed + */ +function get_username($user_id) +{ + global $conf; + + $query = ' +SELECT '.$conf['user_fields']['username'].' + FROM '.USERS_TABLE.' + WHERE '.$conf['user_fields']['id'].' = '.intval($user_id).' +;'; + $result = pwg_query($query); + if (mysql_num_rows($result) > 0) + { + list($username) = mysql_fetch_row($result); + } + else + { + return false; + } + + return $username; +} ?>
\ No newline at end of file diff --git a/include/functions.inc.php b/include/functions.inc.php index 1675dbce8..83c9980de 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -493,7 +493,6 @@ function get_languages($target_charset = null) } closedir($dir); @asort($languages); - @reset($languages); return $languages; } @@ -1373,17 +1372,6 @@ function load_language($filename, $dirname = '', $source_file = $f; break; } - - if ($target_charset=='utf-8') - { // we accept conversion from ISO-8859-1 to UTF-8 - $f = $dir.'.iso-8859-1/'.$filename; - if (file_exists($f)) - { - $source_charset = 'iso-8859-1'; - $source_file = $f; - break; - } - } } if ( !empty($source_file) ) @@ -1483,4 +1471,26 @@ function secure_directory($dir) @file_put_contents($file, 'Not allowed!'); } } + +/** + * returns a "secret key" that is to be sent back when a user enters a comment + * + * @param int image_id + */ +function get_comment_post_key($image_id) +{ + global $conf; + + $time = time(); + + return sprintf( + '%s:%s', + $time, + hash_hmac( + 'md5', + $time.':'.$image_id, + $conf['secret_key'] + ) + ); +} ?>
\ No newline at end of file diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php index 9dca86146..c8dd6f3e0 100644 --- a/include/functions_comment.inc.php +++ b/include/functions_comment.inc.php @@ -21,26 +21,6 @@ // | USA. | // +-----------------------------------------------------------------------+ -/** - * returns a "secret key" that is to be sent back when a user enters a comment - */ -function get_comment_post_key($image_id) -{ - global $conf; - - $time = time(); - - return sprintf( - '%s:%s', - $time, - hash_hmac( - 'md5', - $time.':'.$image_id, - $conf['secret_key'] - ) - ); -} - //returns string action to perform on a new comment: validate, moderate, reject function user_comment_check($action, $comment) { @@ -189,7 +169,7 @@ INSERT INTO '.COMMENTS_TABLE.' if ( ($comment_action=='validate' and $conf['email_admin_on_comment']) - or + or ($comment_action!='validate' and $conf['email_admin_on_comment_validation']) ) { diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 1b85ba44f..d7ef88992 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -673,34 +673,6 @@ DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.' } /** - * returns the username corresponding to the given user identifier if exists - * - * @param int user_id - * @return mixed - */ -function get_username($user_id) -{ - global $conf; - - $query = ' -SELECT '.$conf['user_fields']['username'].' - FROM '.USERS_TABLE.' - WHERE '.$conf['user_fields']['id'].' = '.intval($user_id).' -;'; - $result = pwg_query($query); - if (mysql_num_rows($result) > 0) - { - list($username) = mysql_fetch_row($result); - } - else - { - return false; - } - - return $username; -} - -/** * returns user identifier thanks to his name, false if not found * * @param string username @@ -934,34 +906,6 @@ function create_user_infos($arg_id, $override_values = null) } /** - * returns the groupname corresponding to the given group identifier if - * exists - * - * @param int group_id - * @return mixed - */ -function get_groupname($group_id) -{ - $query = ' -SELECT name - FROM '.GROUPS_TABLE.' - WHERE id = '.intval($group_id).' -;'; - $result = pwg_query($query); - if (mysql_num_rows($result) > 0) - { - list($groupname) = mysql_fetch_row($result); - } - else - { - return false; - } - - return $groupname; -} - - -/** * returns the auto login key or false on error * @param int user_id * @param time_t time diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php index eb2cd710b..73b245b6b 100644 --- a/include/picture_comment.inc.php +++ b/include/picture_comment.inc.php @@ -88,11 +88,11 @@ elseif ( isset($_POST['content']) ) if ($page['show_comments']) { - // number of comment for this picture - $query = 'SELECT COUNT(*) AS nb_comments'; - $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$page['image_id']; - $query.= " AND validated = 'true'"; - $query.= ';'; + // number of comments for this picture + $query = ' +SELECT COUNT(*) AS nb_comments + FROM '.COMMENTS_TABLE.' + WHERE image_id='.$page['image_id']." AND validated = 'true'"; $row = mysql_fetch_array( pwg_query( $query ) ); // navigation bar creation @@ -160,7 +160,6 @@ SELECT id,author,date,image_id,content if (!is_a_guest() or (is_a_guest() and $conf['comments_forall'])) { - include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); $key = get_comment_post_key($page['image_id']); $content = ''; if ('reject'===@$comment_action) diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index fd87ef02e..a85fa2e4b 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -522,8 +522,6 @@ SELECT DISTINCT image_id return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); } - include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); - $comm = array( 'author' => trim( stripslashes($params['author']) ), 'content' => trim( stripslashes($params['content']) ), @@ -702,7 +700,6 @@ SELECT id, date, author, content ) ) { - include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); $comment_post_data['author'] = $user['username']; $comment_post_data['key'] = get_comment_post_key($params['image_id']); } @@ -1041,15 +1038,15 @@ SELECT { // last chance to make the directory writable @chmod($high_dir, 0777); - + if (!is_writable($high_dir)) { return new PwgError(500, 'high directory has no write access'); } } - + secure_directory($high_dir); - + // high resolution path, same name as web size file $high_path = sprintf( '%s/%s.%s', @@ -1617,7 +1614,7 @@ SELECT { $current_rank_of[$cat_id] = 0; } - + if ('auto' == $rank_on_category[$cat_id]) { $rank_on_category[$cat_id] = $current_rank_of[$cat_id] + 1; @@ -228,8 +228,11 @@ if ( count($page['items']) > 0 // image order $order_idx = pwg_get_session_var( 'image_order', 0 ); - $orders = get_category_preferred_image_orders(); - foreach ($orders as $order_id => $order) + $url = add_url_params( + duplicate_index_url(), + array('image_order' => '') + ); + foreach (get_category_preferred_image_orders() as $order_id => $order) { if ($order[2]) { @@ -237,10 +240,7 @@ if ( count($page['items']) > 0 'image_orders', array( 'DISPLAY' => $order[0], - 'URL' => add_url_params( - duplicate_index_url(), - array('image_order' => $order_id) - ), + 'URL' => $url.$order_id, 'SELECTED' => ($order_idx == $order_id ? true:false), ) ); @@ -149,7 +149,7 @@ if ($page['display_mode'] == 'letters') { // flush last letter if (count($letter['tags']) > 0) { - $letter['CHANGE_COLUMN'] = false; + unset($letter['CHANGE_COLUMN']); $letter['TITLE'] = $current_letter; $template->append( 'letters', diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl index 2da9d04b5..e1547bd38 100644 --- a/template/yoga/index.tpl +++ b/template/yoga/index.tpl @@ -24,7 +24,7 @@ {/if} {if isset($U_SEARCH_RULES) } - <li><a href="{$U_SEARCH_RULES}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{'Search rules'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/search_rules.png" class="button" alt="(?)"></a></li> + <li><a href="{$U_SEARCH_RULES}" onclick="popuphelp(this.href); return false;" title="{'Search rules'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/search_rules.png" class="button" alt="(?)" /></a></li> {/if} {if isset($U_SLIDESHOW) } diff --git a/template/yoga/tags.tpl b/template/yoga/tags.tpl index a69d1d2ec..e81fe7f75 100644 --- a/template/yoga/tags.tpl +++ b/template/yoga/tags.tpl @@ -41,7 +41,7 @@ {/foreach} </table> </fieldset> - {if $letter.CHANGE_COLUMN|@default:false} + {if isset($letter.CHANGE_COLUMN) } </td> <td valign="top"> {/if} |