Index: /trunk/comments.php =================================================================== --- /trunk/comments.php (revision 17350) +++ /trunk/comments.php (revision 17351) @@ -383,4 +383,5 @@ com.author_id, com.date, + com.website_url, com.content, com.validated @@ -478,4 +479,5 @@ 'ALT' => $name, 'AUTHOR' => trigger_event('render_comment_author', $comment['author']), + 'WEBSITE_URL' => $comment['website_url'], 'DATE'=>format_date($comment['date'], true), 'CONTENT'=>trigger_event('render_comment_content',$comment['content']), Index: /trunk/include/functions.inc.php =================================================================== --- /trunk/include/functions.inc.php (revision 17350) +++ /trunk/include/functions.inc.php (revision 17351) @@ -1693,3 +1693,19 @@ return $is_mobile_theme; } + +/** + * check url format + */ +function url_check_format($url) +{ + if (version_compare(PHP_VERSION, '5.2.0') >= 0) + { + return filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)!==false; + } + else + { + // http://mathiasbynens.be/demo/url-regex @imme_emosol + return (bool)preg_match('@^https?://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@iS', $url); + } +} ?> Index: /trunk/include/functions_comment.inc.php =================================================================== --- /trunk/include/functions_comment.inc.php (revision 17350) +++ /trunk/include/functions_comment.inc.php (revision 17351) @@ -128,4 +128,15 @@ } + // website + if ( !empty($comm['website_url']) and !preg_match('/^https?/i', $comm['website_url']) ) + { + $comm['website_url'] = 'http://'.$comm['website_url']; + } + if ( !empty($comm['website_url']) and !url_check_format($comm['website_url']) ) + { + array_push($infos, l10n('Your website URL is invalid')); + $comment_action='reject'; + } + // anonymous id = ip address $ip_components = explode('.', $comm['ip']); @@ -169,5 +180,5 @@ $query = ' INSERT INTO '.COMMENTS_TABLE.' - (author, author_id, anonymous_id, content, date, validated, validation_date, image_id) + (author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url) VALUES ( \''.$comm['author'].'\', @@ -178,5 +189,6 @@ \''.($comment_action=='validate' ? 'true':'false').'\', '.($comment_action=='validate' ? 'NOW()':'NULL').', - '.$comm['image_id'].' + '.$comm['image_id'].', + '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').' ) '; Index: /trunk/include/picture_comment.inc.php =================================================================== --- /trunk/include/picture_comment.inc.php (revision 17350) +++ /trunk/include/picture_comment.inc.php (revision 17351) @@ -49,4 +49,5 @@ 'author' => trim( @$_POST['author'] ), 'content' => trim( $_POST['content'] ), + 'website_url' => trim( $_POST['website_url'] ), 'image_id' => $page['image_id'], ); @@ -146,4 +147,5 @@ date, image_id, + website_url, content, validated @@ -179,4 +181,5 @@ 'DATE' => format_date($row['date'], true), 'CONTENT' => trigger_event('render_comment_content',$row['content']), + 'WEBSITE_URL' => $row['website_url'], ); @@ -242,9 +245,10 @@ { $key = get_ephemeral_key(3, $page['image_id']); - $content = $author = ''; + $content = $author = $website_url = ''; if ('reject'===@$comment_action) { $content = htmlspecialchars( stripslashes($comm['content']) ); $author = htmlspecialchars( stripslashes($comm['author']) ); + $website_url = htmlspecialchars( stripslashes($comm['website_url']) ); } $template->assign('comment_add', @@ -255,4 +259,5 @@ 'SHOW_AUTHOR' => !is_classic_user(), 'AUTHOR' => $author , + 'WEBSITE_URL' => $website_url, )); } Index: /trunk/install/db/129-database.php =================================================================== --- /trunk/install/db/129-database.php (revision 17351) +++ /trunk/install/db/129-database.php (revision 17351) @@ -0,0 +1,38 @@ + Index: /trunk/install/piwigo_structure-mysql.sql =================================================================== --- /trunk/install/piwigo_structure-mysql.sql (revision 17350) +++ /trunk/install/piwigo_structure-mysql.sql (revision 17351) @@ -54,4 +54,5 @@ `author_id` smallint(5) DEFAULT NULL, `anonymous_id` varchar(45) NOT NULL, + `website_url` varchar(255) DEFAULT NULL, `content` longtext, `validated` enum('true','false') NOT NULL default 'false', Index: /trunk/themes/default/template/comment_list.tpl =================================================================== --- /trunk/themes/default/template/comment_list.tpl (revision 17350) +++ /trunk/themes/default/template/comment_list.tpl (revision 17351) @@ -55,5 +55,6 @@ {/if} - {$comment.AUTHOR} - {$comment.DATE} + {if $comment.WEBSITE_URL}{$comment.AUTHOR}{else}{$comment.AUTHOR}{/if} + - {$comment.DATE} {if isset($comment.IN_EDIT)} Index: /trunk/themes/default/template/picture.tpl =================================================================== --- /trunk/themes/default/template/picture.tpl (revision 17350) +++ /trunk/themes/default/template/picture.tpl (revision 17351) @@ -350,6 +350,8 @@
- {/if} + + +