Changeset 26065
- Timestamp:
- Dec 21, 2013, 5:33:24 PM (10 years ago)
- Location:
- extensions/GuestBook
- Files:
-
- 1 added
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GuestBook/admin.php
r24889 r26065 1 1 <?php 2 if(!defined('GUESTBOOK_PATH'))die('Hacking attempt!');2 defined('GUESTBOOK_PATH') or die('Hacking attempt!'); 3 3 4 4 global $template, $page; -
extensions/GuestBook/admin/config.php
r24889 r26065 1 1 <?php 2 if (!defined('GUESTBOOK_PATH'))die('Hacking attempt!');2 defined('GUESTBOOK_PATH') or die('Hacking attempt!'); 3 3 4 4 if (isset($_POST['submit'])) … … 15 15 16 16 conf_update_param('guestbook', serialize($conf['guestbook'])); 17 array_push($page['infos'], l10n('Information data registered in database'));17 $page['infos'][] = l10n('Information data registered in database'); 18 18 } 19 19 -
extensions/GuestBook/admin/pending.php
r24889 r26065 12 12 if (empty($_POST['comments'])) 13 13 { 14 array_push( 15 $page['errors'], 16 l10n('Select at least one comment') 17 ); 14 $page['errors'][] =l10n('Select at least one comment'); 18 15 } 19 16 else 20 17 { 21 include_once( GUESTBOOK_PATH .'include/functions_comment.inc.php');18 include_once(GUESTBOOK_PATH .'include/functions_comment.inc.php'); 22 19 check_input_parameter('comments', $_POST, true, PATTERN_ID); 23 20 … … 26 23 validate_user_comment_guestbook($_POST['comments']); 27 24 28 array_push( 29 $page['infos'], 30 l10n_dec( 31 '%d user comment validated', '%d user comments validated', 32 count($_POST['comments']) 33 ) 25 $page['infos'][] = l10n_dec( 26 '%d user comment validated', '%d user comments validated', 27 count($_POST['comments']) 34 28 ); 35 29 } … … 39 33 delete_user_comment_guestbook($_POST['comments']); 40 34 41 array_push( 42 $page['infos'], 43 l10n_dec( 44 '%d user comment rejected', '%d user comments rejected', 45 count($_POST['comments']) 46 ) 35 $page['infos'][] =l10n_dec( 36 '%d user comment rejected', '%d user comments rejected', 37 count($_POST['comments']) 47 38 ); 48 39 } … … 75 66 ;'; 76 67 $result = pwg_query($query); 68 77 69 while ($row = pwg_db_fetch_assoc($result)) 78 70 { … … 101 93 ); 102 94 103 array_push($list, $row['id']);95 $list[] = $row['id']; 104 96 } 105 97 106 $template->assign('LIST', implode(',', $list) );107 98 108 $template->assign('F_ACTION', GUESTBOOK_ADMIN . '-pending'); 109 99 $template->assign(array( 100 'LIST' => implode(',', $list), 101 'F_ACTION' => GUESTBOOK_ADMIN . '-pending', 102 )); 110 103 111 104 $template->set_filename('guestbook', realpath(GUESTBOOK_PATH . 'admin/template/pending.tpl')); 112 113 ?> -
extensions/GuestBook/admin/template/config.tpl
r24889 r26065 1 {combine_css path=$GUESTBOOK_PATH| @cat:'template/style.css'}1 {combine_css path=$GUESTBOOK_PATH|cat:'template/style.css'} 2 2 3 {footer_script} {literal}3 {footer_script} 4 4 $('input[name="comments_validation"]').on('change', function() { 5 5 $('#email_admin_on_comment_validation').toggle($(this).is(':checked')); … … 11 11 }) 12 12 .trigger('change'); 13 {/literal}{/footer_script} 13 {/footer_script} 14 14 15 15 16 <div class="titrePage"> 16 <h2> {'GuestBook'|@translate}</h2>17 <h2>GuestBook</h2> 17 18 </div> 18 19 … … 23 24 <li> 24 25 <label> 25 <b>{'Number of comments per page'| @translate}</b>26 <b>{'Number of comments per page'|translate}</b> 26 27 <input type="text" size="3" maxlength="4" name="nb_comment_page" id="nb_comment_page" value="{$nb_comment_page}"> 27 28 </label> … … 31 32 <label> 32 33 <input type="checkbox" name="activate_rating" {if ($activate_rating)}checked="checked"{/if}> 33 <b>{'Activate rating'| @translate}</b>34 <b>{'Activate rating'|translate}</b> 34 35 </label> 35 36 </li> … … 38 39 <label> 39 40 <input type="checkbox" name="comments_validation" {if ($comments_validation)}checked="checked"{/if}> 40 <b>{'Validation'| @translate}</b>41 <b>{'Validation'|translate}</b> 41 42 </label> 42 43 </li> 43 44 44 45 <li> 45 <strong>{'Notify administrators when a comment is'| @translate}</strong>46 <strong>{'Notify administrators when a comment is'|translate}</strong> 46 47 47 48 <label> 48 <input type="checkbox" name="email_admin_on_comment" {if ($email_admin_on_comment)}checked="checked"{/if}> {'added'| @translate}49 <input type="checkbox" name="email_admin_on_comment" {if ($email_admin_on_comment)}checked="checked"{/if}> {'added'|translate} 49 50 </label> 50 51 51 52 <label id="email_admin_on_comment_validation"> 52 <input type="checkbox" name="email_admin_on_comment_validation" {if ($email_admin_on_comment_validation)}checked="checked"{/if}> {'pending validation'| @translate}53 <input type="checkbox" name="email_admin_on_comment_validation" {if ($email_admin_on_comment_validation)}checked="checked"{/if}> {'pending validation'|translate} 53 54 </label> 54 55 </li> 55 56 56 57 <li> 57 <strong>{'Guests (not registered) permissions :'| @translate}</strong>58 <strong>{'Guests (not registered) permissions :'|translate}</strong> 58 59 59 60 <label> 60 <input type="checkbox" name="guest_can_view" {if ($guest_can_view)}checked="checked"{/if}> {'view comments'| @translate}61 <input type="checkbox" name="guest_can_view" {if ($guest_can_view)}checked="checked"{/if}> {'view comments'|translate} 61 62 </label> 62 63 63 64 <label id="guest_can_add"> 64 <input type="checkbox" name="guest_can_add" {if ($guest_can_add)}checked="checked"{/if}> {'add comment'| @translate}65 <input type="checkbox" name="guest_can_add" {if ($guest_can_add)}checked="checked"{/if}> {'add comment'|translate} 65 66 </label> 66 67 </li> … … 69 70 70 71 <p class="formButtons"> 71 <input type="submit" name="submit" value="{'Save Settings'| @translate}">72 <input type="submit" name="submit" value="{'Save Settings'|translate}"> 72 73 </p> 73 74 </form> -
extensions/GuestBook/admin/template/pending.tpl
r15940 r26065 1 {combine_css path=$GUESTBOOK_PATH| @cat:'admin/template/style.css'}1 {combine_css path=$GUESTBOOK_PATH|cat:'admin/template/style.css'} 2 2 3 3 <div class="titrePage"> 4 <h2> {'GuestBook'|@translate}</h2>4 <h2>GuestBook</h2> 5 5 </div> 6 6 7 {footer_script}{literal} 8 jQuery(document).ready(function(){ 9 function highlighComments() { 10 jQuery(".checkComment").each(function() { 11 var parent = jQuery(this).parent('tr'); 12 if (jQuery(this).children("input[type=checkbox]").is(':checked')) { 13 jQuery(parent).addClass('selectedComment'); 14 } 15 else { 16 jQuery(parent).removeClass('selectedComment'); 17 } 18 }); 7 {footer_script} 8 function highlighComments() { 9 jQuery(".checkComment").each(function() { 10 var parent = jQuery(this).parent('tr'); 11 if (jQuery(this).children("input[type=checkbox]").is(':checked')) { 12 jQuery(parent).addClass('selectedComment'); 13 } 14 else { 15 jQuery(parent).removeClass('selectedComment'); 16 } 17 }); 18 } 19 20 jQuery(".checkComment").click(function(event) { 21 var checkbox = jQuery(this).children("input[type=checkbox]"); 22 if (event.target.type !== 'checkbox') { 23 jQuery(checkbox).attr('checked', !jQuery(checkbox).is(':checked')); 19 24 } 25 highlighComments(); 26 }); 20 27 21 jQuery(".checkComment").click(function(event) { 22 var checkbox = jQuery(this).children("input[type=checkbox]"); 23 if (event.target.type !== 'checkbox') { 24 jQuery(checkbox).attr('checked', !jQuery(checkbox).is(':checked')); 25 } 26 highlighComments(); 28 jQuery("#commentSelectAll").click(function() { 29 jQuery(".checkComment input[type=checkbox]").attr('checked', true); 30 highlighComments(); 31 return false; 32 }); 33 34 jQuery("#commentSelectNone").click(function() { 35 jQuery(".checkComment input[type=checkbox]").attr('checked', false); 36 highlighComments(); 37 return false; 38 }); 39 40 jQuery("#commentSelectInvert").click(function() { 41 jQuery(".checkComment input[type=checkbox]").each(function() { 42 jQuery(this).attr('checked', !$(this).is(':checked')); 27 43 }); 44 highlighComments(); 45 return false; 46 }); 47 {/footer_script} 28 48 29 jQuery("#commentSelectAll").click(function () {30 jQuery(".checkComment input[type=checkbox]").attr('checked', true);31 highlighComments();32 return false;33 });34 49 35 jQuery("#commentSelectNone").click(function () { 36 jQuery(".checkComment input[type=checkbox]").attr('checked', false); 37 highlighComments(); 38 return false; 39 }); 40 41 jQuery("#commentSelectInvert").click(function () { 42 jQuery(".checkComment input[type=checkbox]").each(function() { 43 jQuery(this).attr('checked', !$(this).is(':checked')); 44 }); 45 highlighComments(); 46 return false; 47 }); 48 49 }); 50 {/literal}{/footer_script} 51 52 {if !empty($comments) } 50 {if !empty($comments)} 53 51 <form method="post" action="{$F_ACTION}" id="pendingComments"> 54 52 … … 74 72 75 73 <p class="checkActions"> 76 {'Select:'| @translate}77 <a href="#" id="commentSelectAll">{'All'| @translate}</a>,78 <a href="#" id="commentSelectNone">{'None'| @translate}</a>,79 <a href="#" id="commentSelectInvert">{'Invert'| @translate}</a>74 {'Select:'|translate} 75 <a href="#" id="commentSelectAll">{'All'|translate}</a>, 76 <a href="#" id="commentSelectNone">{'None'|translate}</a>, 77 <a href="#" id="commentSelectInvert">{'Invert'|translate}</a> 80 78 </p> 81 79 82 80 <p class="bottomButtons"> 83 <input class="submit" type="submit" name="validate" value="{'Validate'| @translate}">84 <input class="submit" type="submit" name="reject" value="{'Reject'| @translate}">81 <input class="submit" type="submit" name="validate" value="{'Validate'|translate}"> 82 <input class="submit" type="submit" name="reject" value="{'Reject'|translate}"> 85 83 </p> 86 84 87 85 </form> 88 86 {else} 89 {'No pending comment'| @translate}87 {'No pending comment'|translate} 90 88 {/if} -
extensions/GuestBook/include/events.inc.php
r24889 r26065 4 4 function gb_admin_menu($menu) 5 5 { 6 array_push($menu,array(6 $menu[] = array( 7 7 'NAME' => 'GuestBook', 8 8 'URL' => GUESTBOOK_ADMIN, 9 ) );9 ); 10 10 return $menu; 11 11 } … … 24 24 if ( ($block = $menu->get_block('mbMenu')) != null ) 25 25 { 26 array_push($block->data,array(26 $block->data[] = array( 27 27 'URL' => GUESTBOOK_URL, 28 28 'TITLE' => l10n('GuestBook'), 29 29 'NAME' => l10n('GuestBook') 30 ) );30 ); 31 31 } 32 32 } … … 38 38 if ($tokens[0] == 'guestbook') 39 39 { 40 add_event_handler('loc_begin_page_header', 'gb_page_header'); 40 $page['section'] = 'guestbook'; 41 $page['body_id'] = 'theGuestBook'; 42 $page['is_external'] = true; 43 $page['is_homepage'] = false; 41 44 42 $page['section'] = 'guestbook';43 45 $page['title'] = l10n('GuestBook'); 44 46 $page['section_title'] = '<a href="'.get_gallery_home_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('GuestBook'); … … 46 48 } 47 49 48 function gb_page_header()49 {50 global $page;51 $page['body_id'] = 'theGuestBook';52 }53 54 50 function gb_index() 55 51 { 56 52 global $template, $page, $conf; 57 58 if (is_a_guest() && !$conf['guestbook']['guest_can_view'])59 {60 access_denied();61 }62 53 63 54 if (isset($page['section']) and $page['section'] == 'guestbook') 64 55 { 56 if (is_a_guest() && !$conf['guestbook']['guest_can_view']) 57 { 58 access_denied(); 59 } 60 65 61 include(GUESTBOOK_PATH . '/include/guestbook.inc.php'); 66 62 } 67 63 } 68 69 /*function gb_register_stuffs_module($modules)70 {71 array_push($modules, array(72 'path' => GUESTBOOK_PATH . '/stuffs_module',73 'name' => GB_NAME,74 'description' => l10n('gb_stuffs_desc'),75 ));76 77 return $modules;78 }*/ -
extensions/GuestBook/include/functions.inc.php
r24889 r26065 1 1 <?php 2 if (!defined('GUESTBOOK_PATH'))die('Hacking attempt!');2 defined('GUESTBOOK_PATH') or die('Hacking attempt!'); 3 3 4 4 function get_stars($score, $path) 5 5 { 6 if ( $score === null) return null;6 if (!isset($score)) return null; 7 7 8 8 $max = 5; … … 10 10 $floor = floor($score); 11 11 12 $html = null;12 $html = ''; 13 13 for ($i=1; $i<=$floor; $i++) 14 14 { -
extensions/GuestBook/include/functions_comment.inc.php
r25786 r26065 1 1 <?php 2 if (!defined('GUESTBOOK_PATH'))die('Hacking attempt!');2 defined('GUESTBOOK_PATH') or die('Hacking attempt!'); 3 3 4 4 include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); 5 add_event_handler('user_comment_check_guestbook', 'user_comment_check', 6 EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 5 7 6 8 7 function insert_user_comment_guestbook( &$comm, $key ) … … 10 9 global $conf, $user, $page; 11 10 12 $comm = array_merge( 11 $comm = array_merge($comm, 13 12 array( 14 13 'ip' => $_SERVER['REMOTE_ADDR'], … … 19 18 if (!$conf['guestbook']['comments_validation'] or is_admin()) 20 19 { 21 $comment_action='validate'; //one of validate, moderate, reject22 } 23 else 24 { 25 $comment_action='moderate'; //one of validate, moderate, reject26 } 27 28 // display author field if the user status is guest or generic20 $comment_action='validate'; 21 } 22 else 23 { 24 $comment_action='moderate'; 25 } 26 27 // author 29 28 if (!is_classic_user()) 30 29 { 31 if ( empty($comm['author']))32 { 33 array_push($page['errors'], l10n('Please enter your username'));30 if (empty($comm['author'])) 31 { 32 $page['errors'][] = l10n('Please enter your username'); 34 33 $comment_action='reject'; 35 34 } … … 37 36 { 38 37 $comm['author_id'] = $conf['guest_id']; 39 // if a guest try to use the name of an already existing user, he must be40 // rejected38 // if a guest try to use the name of an already existing user, 39 // he must be rejected 41 40 $query = ' 42 41 SELECT COUNT(*) AS user_exists 43 42 FROM '.USERS_TABLE.' 44 WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'"; 45 $row = pwg_db_fetch_assoc( pwg_query( $query ) ); 43 WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."' 44 ;"; 45 $row = pwg_db_fetch_assoc(pwg_query($query)); 46 46 47 if ( $row['user_exists'] == 1)47 if ($row['user_exists'] == 1) 48 48 { 49 array_push($page['errors'], l10n('This login is already used by another user'));49 $page['errors'][] = l10n('This login is already used by another user'); 50 50 $comment_action='reject'; 51 51 } … … 58 58 } 59 59 60 if ( empty($comm['content']) ) 61 { // empty comment content 62 $comment_action='reject'; 63 } 64 65 if ( !verify_ephemeral_key(@$key) ) 60 // content 61 if (empty($comm['content'])) 62 { 63 $comment_action='reject'; 64 } 65 66 // key 67 if (!verify_ephemeral_key(@$key)) 66 68 { 67 69 $comment_action='reject'; … … 70 72 71 73 // email 72 if ( empty($comm['email']) and is_classic_user() and !empty($user['email']))74 if (empty($comm['email']) and is_classic_user() and !empty($user['email'])) 73 75 { 74 76 $comm['email'] = $user['email']; 75 77 } 76 else if ( empty($comm['email']) and $conf['comments_email_mandatory'])77 { 78 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));79 $comment_action='reject'; 80 } 81 else if ( !empty($comm['email']) and !email_check_format($comm['email']))82 { 83 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));78 else if (empty($comm['email']) and $conf['comments_email_mandatory']) 79 { 80 $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 81 $comment_action='reject'; 82 } 83 else if (!empty($comm['email']) and !email_check_format($comm['email'])) 84 { 85 $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 84 86 $comment_action='reject'; 85 87 } 86 88 87 89 // website 88 if ( !empty($comm['website']) and !preg_match('/^(https?:\/\/)/i', $comm['website']))90 if (!empty($comm['website']) and !preg_match('/^(https?:\/\/)/i', $comm['website'])) 89 91 { 90 92 $comm['website'] = 'http://'.$comm['website']; 91 93 } 92 if ( !empty($comm['website']) and !url_check_format($comm['website']))93 { 94 array_push($page['errors'], l10n('invalid website address'));94 if (!empty($comm['website']) and !url_check_format($comm['website'])) 95 { 96 $page['errors'][] = l10n('invalid website address'); 95 97 $comment_action='reject'; 96 98 } … … 125 127 if ($counter > 0) 126 128 { 127 array_push($page['errors'], l10n('Anti-flood system : please wait for a moment before trying to post another comment'));129 $page['errors'][] = l10n('Anti-flood system : please wait for a moment before trying to post another comment'); 128 130 $comment_action='reject'; 129 131 } … … 131 133 132 134 // perform more spam check 133 $comment_action = trigger_event('user_comment_check_guestbook', 134 $comment_action, $comm 135 ); 136 137 if ( $comment_action!='reject' ) 135 $comment_action = trigger_event('user_comment_check', $comment_action, $comm); 136 137 if ($comment_action!='reject') 138 138 { 139 139 $query = ' … … 175 175 $comment_url = add_url_params(GUESTBOOK_URL, array('comment_id'=>$comm['id'])); 176 176 177 $keyargs_content = array 178 ( 177 $keyargs_content = array( 179 178 get_l10n_args('Author: %s', stripslashes($comm['author']) ), 180 179 get_l10n_args('Comment: %s', stripslashes($comm['content']) ), … … 189 188 } 190 189 191 pwg_mail_notification_admins 192 ( 190 pwg_mail_notification_admins( 193 191 get_l10n_args('Comment by %s', stripslashes($comm['author']) ), 194 192 $keyargs_content … … 196 194 } 197 195 } 196 198 197 return $comment_action; 199 198 } … … 205 204 $comment_action = 'validate'; 206 205 207 if ( !verify_ephemeral_key($post_key))208 { 209 $comment_action='reject'; 210 } 211 else if (!$conf['guestbook']['comments_validation'] or is_admin()) // should the updated comment must be validated212 { 213 $comment_action='validate'; //one of validate, moderate, reject214 } 215 else 216 { 217 $comment_action='moderate'; //one of validate, moderate, reject218 } 219 220 if ( $comment_action!='reject')206 if (!verify_ephemeral_key($post_key)) 207 { 208 $comment_action='reject'; 209 } 210 else if (!$conf['guestbook']['comments_validation'] or is_admin()) // should the updated comment must be validated 211 { 212 $comment_action='validate'; 213 } 214 else 215 { 216 $comment_action='moderate'; 217 } 218 219 if ($comment_action!='reject') 221 220 { 222 221 $user_where_clause = ''; … … 244 243 $comment_url = add_url_params(GUESTBOOK_URL, array('comment_id'=>$comm['id'])); 245 244 246 $keyargs_content = array 247 ( 245 $keyargs_content = array( 248 246 get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ), 249 247 get_l10n_args('Comment: %s', stripslashes($comment['content']) ), … … 254 252 ); 255 253 256 pwg_mail_notification_admins 257 ( 254 pwg_mail_notification_admins( 258 255 get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ), 259 256 $keyargs_content … … 274 271 ;'; 275 272 $result = pwg_query($query); 273 276 274 if (pwg_db_num_rows($result) == 0) 277 275 { … … 296 294 if (!is_admin()) 297 295 { 298 $user_where_clause = ' 296 $user_where_clause = ' AND author_id = \''.$GLOBALS['user']['id'].'\''; 299 297 } 300 298 301 299 if (is_array($comment_id)) 300 { 302 301 $where_clause = 'id IN('.implode(',', $comment_id).')'; 303 else 302 } 303 else 304 { 304 305 $where_clause = 'id = '.$comment_id; 306 } 305 307 306 308 $query = ' … … 315 317 { 316 318 if (is_array($comment_id)) 319 { 317 320 $where_clause = 'id IN('.implode(',', $comment_id).')'; 318 else 321 } 322 else 323 { 319 324 $where_clause = 'id = '.$comment_id; 325 } 320 326 321 327 $query = ' -
extensions/GuestBook/include/guestbook.inc.php
r24889 r26065 4 4 global $user; 5 5 6 include(GUESTBOOK_PATH . ' /include/functions.inc.php');6 include(GUESTBOOK_PATH . 'include/functions.inc.php'); 7 7 8 8 $url_self = empty($page['start']) ? GUESTBOOK_URL : add_url_params(GUESTBOOK_URL, array('start' => $page['start'])); … … 106 106 // | add comment | 107 107 // +-----------------------------------------------------------------------+ 108 if ( isset( $_POST['content']) && (!is_a_guest() || $conf['guestbook']['guest_can_add']))108 if (isset($_POST['content']) && (!is_a_guest() || $conf['guestbook']['guest_can_add'])) 109 109 { 110 110 $comm = array( 111 'author' => trim( @$_POST['author']),112 'email' => trim( @$_POST['email']),113 'content' => trim( $_POST['content']),114 'website' => trim( $_POST['website']),111 'author' => trim(@$_POST['author']), 112 'email' => trim(@$_POST['email']), 113 'content' => trim($_POST['content']), 114 'website' => trim($_POST['website']), 115 115 'rate' => @$_POST['score'], 116 116 ); … … 123 123 { 124 124 case 'moderate': 125 array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.'));125 $page['infos'][] = l10n('An administrator must authorize your comment before it is visible.'); 126 126 case 'validate': 127 array_push($page['infos'], l10n('Your comment has been registered'));127 $page['infos'][] = l10n('Your comment has been registered'); 128 128 break; 129 129 case 'reject': 130 130 set_status_header(403); 131 array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules') ); 131 $template->assign('GB_OPEN', true); 132 $page['errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules'); 132 133 break; 133 134 default: … … 136 137 137 138 // allow plugins to notify what's going on 138 trigger_action( 139 array_merge($comm, array('action'=>$comment_action) 139 trigger_action('user_comment_insertion', 140 array_merge($comm, array('action'=>$comment_action)) 140 141 ); 141 142 } … … 145 146 // +-----------------------------------------------------------------------+ 146 147 $where_clauses = array('1=1'); 147 if ( !is_admin())148 { 149 array_push($where_clauses, 'validated = \'true\'');148 if (!is_admin()) 149 { 150 $where_clauses[] = 'validated = \'true\''; 150 151 } 151 152 if (isset($_GET['comment_id'])) 152 153 { 153 array_push($where_clauses, 'com.id = '.pwg_db_real_escape_string($_GET['comment_id']));154 $where_clauses[] = 'com.id = '.pwg_db_real_escape_string($_GET['comment_id']); 154 155 } 155 156 … … 161 162 WHERE '.implode(' AND ', $where_clauses).' 162 163 ;'; 163 $row = pwg_db_fetch_assoc( pwg_query( $query ));164 $row = pwg_db_fetch_assoc(pwg_query($query)); 164 165 165 166 // navigation bar creation … … 178 179 ); 179 180 180 $template->assign( 181 array( 182 'COMMENT_COUNT' => $row['nb_comments'], 183 'navbar' => $navigation_bar, 184 ) 185 ); 181 $template->assign(array( 182 'COMMENT_COUNT' => $row['nb_comments'], 183 'navbar' => $navigation_bar, 184 )); 186 185 187 186 if ($row['nb_comments'] > 0) … … 223 222 } 224 223 225 $tpl_comment = 226 array( 227 'ID' => $row['id'], 228 'AUTHOR' => trigger_event('render_comment_author', $author), 229 'DATE' => format_date($row['date'], true), 230 'CONTENT' => trigger_event('render_comment_content',$row['content']), 231 'WEBSITE' => $row['website'], 224 $tpl_comment = array( 225 'ID' => $row['id'], 226 'AUTHOR' => trigger_event('render_comment_author', $author), 227 'DATE' => format_date($row['date'], true), 228 'CONTENT' => trigger_event('render_comment_content', $row['content']), 229 'WEBSITE' => $row['website'], 232 230 ); 233 231 … … 276 274 { 277 275 $tpl_comment['U_VALIDATE'] = add_url_params( 278 279 280 281 282 283 284 276 $url_self, 277 array( 278 'action' => 'validate_comment', 279 'comment_to_validate' => $row['id'], 280 'pwg_token' => get_pwg_token(), 281 ) 282 ); 285 283 } 286 284 } … … 316 314 317 315 $template->assign('comment_add', 318 array( 319 'F_ACTION' => $url_self, 320 'KEY' => get_ephemeral_key(3), 321 'CONTENT' => $content, 322 'IS_LOGGED' => is_classic_user(), 323 'AUTHOR' => $author, 324 'WEBSITE' => $website, 325 'EMAIL' => $email, 326 'ACTIVATE_RATING' => $conf['guestbook']['activate_rating'], 327 'EMAIL_MANDATORY' => $conf['comments_email_mandatory'], 328 )); 329 } 330 331 $template->assign('ABS_GUESTBOOK_PATH', realpath(GUESTBOOK_PATH) . '/'); 332 $template->assign('GUESTBOOK_PATH', GUESTBOOK_PATH); 333 334 $template->set_filename('index', realpath(GUESTBOOK_PATH . 'template/guestbook.tpl')); 316 array( 317 'F_ACTION' => $url_self, 318 'KEY' => get_ephemeral_key(3), 319 'CONTENT' => $content, 320 'IS_LOGGED' => is_classic_user(), 321 'AUTHOR' => $author, 322 'WEBSITE' => $website, 323 'EMAIL' => $email, 324 'ACTIVATE_RATING' => $conf['guestbook']['activate_rating'], 325 'EMAIL_MANDATORY' => $conf['comments_email_mandatory'], 326 )); 327 } 328 329 $template->assign(array( 330 'GUESTBOOK_PATH' => GUESTBOOK_PATH, 331 'ABS_GUESTBOOK_PATH' => realpath(GUESTBOOK_PATH) . '/', 332 )); 333 334 $template->set_filename('guestbook', realpath(GUESTBOOK_PATH . 'template/guestbook.tpl')); 335 $template->assign_var_from_handle('CONTENT', 'guestbook'); -
extensions/GuestBook/main.inc.php
r24889 r26065 9 9 */ 10 10 11 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');11 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 12 12 13 // TODO akismet 13 14 global $prefixeTable; 14 15 15 16 16 define d('GUESTBOOK_ID') or define('GUESTBOOK_ID',basename(dirname(__FILE__)));17 define('GUESTBOOK_ID', basename(dirname(__FILE__))); 17 18 define('GUESTBOOK_PATH' , PHPWG_PLUGINS_PATH . GUESTBOOK_ID . '/'); 18 19 define('GUESTBOOK_TABLE' , $prefixeTable . 'guestbook'); … … 26 27 add_event_handler('init', 'guestbook_init'); 27 28 28 // admin page29 29 if (defined('IN_ADMIN')) 30 30 { … … 32 32 } 33 33 34 // menu entry35 34 add_event_handler('blockmanager_apply', 'gb_menubar_apply', EVENT_HANDLER_PRIORITY_NEUTRAL+10); 36 35 37 // guestbook section38 36 add_event_handler('loc_end_section_init', 'gb_section_init'); 39 37 add_event_handler('loc_end_index', 'gb_index'); 40 41 // stuff42 // add_event_handler('get_stuffs_modules', 'gb_register_stuffs_module')43 38 44 39 45 40 function guestbook_init() 46 41 { 47 global $conf , $pwg_loaded_plugins;42 global $conf; 48 43 49 // apply upgrade if needed 50 if ( 51 GUESTBOOK_VERSION == 'auto' or 52 $pwg_loaded_plugins[GUESTBOOK_ID]['version'] == 'auto' or 53 version_compare($pwg_loaded_plugins[GUESTBOOK_ID]['version'], GUESTBOOK_VERSION, '<') 54 ) 55 { 56 // call install function 57 include_once(GUESTBOOK_PATH . 'include/install.inc.php'); 58 guestbook_install(); 59 60 // update plugin version in database 61 if ( $pwg_loaded_plugins[GUESTBOOK_ID]['version'] != 'auto' and GUESTBOOK_VERSION != 'auto' ) 62 { 63 $query = ' 64 UPDATE '. PLUGINS_TABLE .' 65 SET version = "'. GUESTBOOK_VERSION .'" 66 WHERE id = "'. GUESTBOOK_ID .'"'; 67 pwg_query($query); 68 69 $pwg_loaded_plugins[GUESTBOOK_ID]['version'] = GUESTBOOK_VERSION; 70 71 if (defined('IN_ADMIN')) 72 { 73 $_SESSION['page_infos'][] = 'GuestBook updated to version '. GUESTBOOK_VERSION; 74 } 75 } 76 } 44 include_once(GUESTBOOK_PATH . 'maintain.inc.php'); 45 $maintain = new GuestBook_maintain(GUESTBOOK_ID); 46 $maintain->autoUpdate(GUESTBOOK_VERSION, 'install'); 77 47 78 // load plugin language file79 48 load_language('plugin.lang', GUESTBOOK_PATH); 80 49 81 // prepare plugin configuration82 50 $conf['guestbook'] = unserialize($conf['guestbook']); 83 51 } -
extensions/GuestBook/maintain.inc.php
r24890 r26065 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 defined('GUESTBOOK_ID') or define('GUESTBOOK_ID', basename(dirname(__FILE__))); 5 include_once(PHPWG_PLUGINS_PATH . GUESTBOOK_ID . '/include/install.inc.php'); 4 class GuestBook_maintain extends PluginMaintain 5 { 6 private $installed = false; 7 8 private $default_conf = array( 9 'comments_validation' => false, 10 'email_admin_on_comment' => false, 11 'email_admin_on_comment_validation' => true, 12 'nb_comment_page' => 15, 13 'activate_rating' => true, 14 'guest_can_view' => true, 15 'guest_can_add' => true, 16 ); 6 17 7 // Installation 8 function plugin_install() 9 { 10 guestbook_install(); 11 define('guestbook_installed', true); 12 } 18 function install($plugin_version, &$errors=array()) 19 { 20 global $conf, $prefixeTable; 21 22 if (empty($conf['guestbook'])) 23 { 24 $conf['guestbook'] = serialize($this->default_conf); 25 conf_update_param('guestbook', $conf['guestbook']); 26 } 27 else 28 { 29 $old_conf = is_string($conf['guestbook']) ? unserialize($conf['guestbook']) : $conf['guestbook']; 30 31 if (!isset($old_conf['guest_can_view'])) 32 { 33 $old_conf['guest_can_view'] = true; 34 $old_conf['guest_can_add'] = true; 35 } 36 37 $conf['guestbook'] = serialize($old_conf); 38 conf_update_param('guestbook', $conf['guestbook']); 39 } 40 41 pwg_query(' 42 CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'guestbook` ( 43 `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 44 `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00", 45 `author` varchar(255) NOT NULL, 46 `author_id` smallint(5) DEFAULT NULL, 47 `anonymous_id` varchar(45) NOT NULL, 48 `email` varchar(255) DEFAULT NULL, 49 `website` varchar(255) DEFAULT NULL, 50 `content` longtext NOT NULL, 51 `rate` float(5,2) unsigned DEFAULT NULL, 52 `validated` enum("true","false") NOT NULL DEFAULT "false", 53 `validation_date` datetime DEFAULT NULL, 54 PRIMARY KEY (`id`) 55 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 56 ;'); 13 57 14 // Activation 15 function plugin_activate() 16 { 17 if (!defined('guestbook_installed'))58 $this->installed = true; 59 } 60 61 function activate($plugin_version, &$errors=array()) 18 62 { 19 guestbook_install(); 63 if (!$this->installed) 64 { 65 $this->install($plugin_version, $errors); 66 } 67 } 68 69 function deactivate() 70 { 71 } 72 73 function uninstall() 74 { 75 global $prefixeTable; 76 77 pwg_query('DROP TABLE `' . $prefixeTable . 'guestbook`;'); 78 79 conf_delete_param('guestbook'); 20 80 } 21 81 } 22 23 // Uninstallation24 function plugin_uninstall()25 {26 guestbook_uninstall();27 } -
extensions/GuestBook/template/comment_list.tpl
r20181 r26065 6 6 <div class="actions" style="float:right;font-size:90%"> 7 7 {if isset($comment.U_DELETE)} 8 <a href="{$comment.U_DELETE}" onclick="return confirm('{'Are you sure?'| @translate|@escape:javascript}');">9 {'Delete'| @translate}8 <a href="{$comment.U_DELETE}" onclick="return confirm('{'Are you sure?'|translate|@escape:javascript}');"> 9 {'Delete'|translate} 10 10 </a>{if isset($comment.U_VALIDATE) or isset($comment.U_EDIT) or isset($comment.U_CANCEL)} | {/if} 11 11 {/if} 12 12 {if isset($comment.U_CANCEL)} 13 13 <a href="{$comment.U_CANCEL}"> 14 {'Cancel'| @translate}14 {'Cancel'|translate} 15 15 </a>{if isset($comment.U_VALIDATE)} | {/if} 16 16 {/if} 17 17 {if isset($comment.U_EDIT) and !isset($comment.IN_EDIT)} 18 18 <a class="editComment" href="{$comment.U_EDIT}#edit_comment"> 19 {'Edit'| @translate}19 {'Edit'|translate} 20 20 </a>{if isset($comment.U_VALIDATE)} | {/if} 21 21 {/if} 22 22 {if isset($comment.U_VALIDATE)} 23 23 <a href="{$comment.U_VALIDATE}"> 24 {'Validate'| @translate}24 {'Validate'|translate} 25 25 </a> 26 26 {/if} … … 37 37 38 38 <div class="commentHeader"> 39 {'%s says on %s :'| @translate|@sprintf:$author:$date}<br>39 {'%s says on %s :'|translate:$author:$date}<br> 40 40 {if $comment.STARS}{$comment.STARS}{/if} 41 41 {if $comment.EMAIL} <a href="mailto:{$comment.EMAIL}">{$comment.EMAIL}</a>{/if} … … 44 44 <a name="edit_comment"></a> 45 45 <form method="post" action="{$comment.U_EDIT}" id="editComment"> 46 <p><label>{'Edit a comment'| @translate} :</label></p>46 <p><label>{'Edit a comment'|translate} :</label></p> 47 47 <p><textarea name="content" id="contenteditid" rows="5" cols="80">{$comment.CONTENT|@escape}</textarea></p> 48 48 <p><input type="hidden" name="key" value="{$comment.KEY}"> 49 49 <input type="hidden" name="pwg_token" value="{$comment.PWG_TOKEN}"> 50 50 <input type="hidden" name="image_id" value="{$comment.IMAGE_ID|@default:$current.id}"> 51 <input type="submit" value="{'Submit'| @translate}">51 <input type="submit" value="{'Submit'|translate}"> 52 52 </p> 53 53 </form> -
extensions/GuestBook/template/guestbook.tpl
r25786 r26065 1 {combine_css path=$GUESTBOOK_PATH| @cat:"template/style.css"}2 {combine_script id= "livevalidation" load="footer" path=$GUESTBOOK_PATH|@cat:"template/livevalidation.min.js"}1 {combine_css path=$GUESTBOOK_PATH|cat:'template/style.css'} 2 {combine_script id='livevalidation' load='footer' path=$GUESTBOOK_PATH|cat:'template/livevalidation.min.js'} 3 3 4 4 {footer_script require='jquery,livevalidation'} 5 {if !$comment_add.IS_LOGGED} 6 var author = new LiveValidation('author', {ldelim} onlyOnSubmit: true }); 7 author.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter your username'|@translate}" }); 8 {/if} 5 (function() { 6 {if !$comment_add.IS_LOGGED} 7 var author = new LiveValidation('author', {ldelim} onlyOnSubmit: true }); 8 author.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter your username'|translate}" }); 9 {/if} 9 10 10 {if $comment_add.EMAIL_MANDATORY and (!$comment_add.IS_LOGGED or empty($comment_add.EMAIL))}11 var email = new LiveValidation('email', {ldelim} onlyOnSubmit: true });12 email.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter your e-mail'|@translate}" });13 email.add(Validate.Email, {ldelim} failureMessage: "{'mail address must be like xxx@yyy.eee (example : jack@altern.org)'|@translate}" });14 {/if}11 {if $comment_add.EMAIL_MANDATORY and (!$comment_add.IS_LOGGED or empty($comment_add.EMAIL))} 12 var email = new LiveValidation('email', {ldelim} onlyOnSubmit: true }); 13 email.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter your e-mail'|translate}" }); 14 email.add(Validate.Email, {ldelim} failureMessage: "{'mail address must be like xxx@yyy.eee (example : jack@altern.org)'|translate}" }); 15 {/if} 15 16 16 var website = new LiveValidation('website', {ldelim} onlyOnSubmit: true });17 website.add(Validate.Format, {ldelim} pattern: /^https?:\/\/[^\s\/$.?#].[^\s]*$/i,18 failureMessage: "{'invalid website address'|@translate}"});17 var website = new LiveValidation('website', {ldelim} onlyOnSubmit: true }); 18 website.add(Validate.Format, {ldelim} pattern: /^https?:\/\/[^\s\/$.?#].[^\s]*$/i, 19 failureMessage: "{'invalid website address'|translate}"}); 19 20 20 var content = new LiveValidation('contentid', {ldelim} onlyOnSubmit: true });21 content.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a message'|@translate}" });21 var content = new LiveValidation('contentid', {ldelim} onlyOnSubmit: true }); 22 content.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a message'|translate}" }); 22 23 23 jQuery("#addComment").hide(); 24 jQuery("#guestbookAdd").css('width','180px'); 25 jQuery("#expandForm").click(function() {ldelim} 26 jQuery("#guestbookAdd").animate({ldelim}"width": "550px"}, function() {ldelim} 27 jQuery("#expandForm").slideUp(); 28 jQuery("#addComment").slideDown("slow"); 24 {if !isset($GB_OPEN)} 25 jQuery('#addComment').hide(); 26 jQuery('#guestbookAdd').css('width', '180px'); 27 jQuery('#expandForm').click(function() {ldelim} 28 jQuery('#guestbookAdd').animate({ldelim}'width': '550px'}, function() {ldelim} 29 jQuery('#expandForm').slideUp(); 30 jQuery('#addComment').slideDown('slow'); 31 }); 29 32 }); 30 }); 33 {/if} 31 34 32 jQuery("#website").on('blur', function() {ldelim} 33 var val = $(this).val(); 34 if (val.substr(0, 4) != 'http') {ldelim} 35 $(this).val('http://'+ val); 36 } 37 }); 35 jQuery('#website').on('blur', function() {ldelim} 36 var val = $(this).val(); 37 if (val.substr(0, 4) != 'http') {ldelim} 38 $(this).val('http://'+ val); 39 } 40 }); 41 }()); 38 42 {/footer_script} 39 43 40 44 {if $comment_add.ACTIVATE_RATING} 41 {combine_script id= "jquery.raty" path=$GUESTBOOK_PATH|@cat:"template/jquery.raty/jquery.raty.min.js"}45 {combine_script id='jquery.raty' path=$GUESTBOOK_PATH|cat:'template/jquery.raty/jquery.raty.min.js'} 42 46 {footer_script} 43 jQuery( "#comment_rate").raty({ldelim}44 path: "{$ROOT_URL}{$GUESTBOOK_PATH}template/jquery.raty/",47 jQuery('#comment_rate').raty({ldelim} 48 path: '{$ROOT_URL}{$GUESTBOOK_PATH}template/jquery.raty/', 45 49 half: true 46 50 }); … … 49 53 50 54 51 {* <!-- Menubar & titrePage --> *}52 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}53 {include file=$ABS_GUESTBOOK_PATH|@cat:'template/themes/stripped.tpl'}54 {assign var="clear" value="true"}55 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}56 {include file=$ABS_GUESTBOOK_PATH|@cat:'template/themes/simple.tpl'}57 {assign var="clear" value="true"}58 {else}59 {include file=$ABS_GUESTBOOK_PATH|@cat:'template/themes/default.tpl'}60 {/if}61 62 {if isset($errors) or not empty($infos)}63 {include file='infos_errors.tpl'}64 {/if}65 66 67 55 {if isset($comment_add)} 68 56 <div id="guestbookAdd"> 69 <h4 id="expandForm">{'Sign the guestbook'| @translate}</h4>57 <h4 id="expandForm">{'Sign the guestbook'|translate}</h4> 70 58 <form method="post" action="{$comment_add.F_ACTION}" id="addComment" class="contact"> 71 59 <table> … … 73 61 <tr> 74 62 <td> 75 <label for="author">{'Author'| @translate}* :</label>63 <label for="author">{'Author'|translate}* :</label> 76 64 {if $comment_add.IS_LOGGED} 77 65 {$comment_add.AUTHOR} … … 82 70 </td> 83 71 <td> 84 <label for="email">{'Email address'| @translate}{if $comment_add.EMAIL_MANDATORY}*{/if} ({'not publicly visible'|@translate}) :</label>72 <label for="email">{'Email address'|translate}{if $comment_add.EMAIL_MANDATORY}*{/if} ({'not publicly visible'|translate}) :</label> 85 73 <input type="text" name="email" id="email" value="{$comment_add.EMAIL}"> 86 74 </td> … … 90 78 {if $comment_add.ACTIVATE_RATING} 91 79 <td> 92 <label>{'Rate'| @translate} :</label>80 <label>{'Rate'|translate} :</label> 93 81 <span id="comment_rate"></span> 94 82 </td> 95 83 {/if} 96 84 <td> 97 <label for="website">{'Website'| @translate} :</label>85 <label for="website">{'Website'|translate} :</label> 98 86 <input type="text" name="website" id="website" value="{$comment_add.WEBSITE}"> 99 87 </td> … … 101 89 <tr> 102 90 <td colspan="2"> 103 <label for="contentid">{'Comment'| @translate}* :</label>91 <label for="contentid">{'Comment'|translate}* :</label> 104 92 <textarea name="content" id="contentid" rows="7">{$comment_add.CONTENT}</textarea> 105 93 </td> … … 107 95 <tr> 108 96 <td colspan="2"> 109 <input type="submit" value="{'Send'| @translate}">110 {'* : mandatory fields'| @translate}97 <input type="submit" value="{'Send'|translate}"> 98 {'* : mandatory fields'|translate} 111 99 </td> 112 100 </tr> … … 118 106 {/if} 119 107 120 <p class="comment_count">{'There are %d messages'| @translate|@sprintf:$COMMENT_COUNT}</p>108 <p class="comment_count">{'There are %d messages'|translate:$COMMENT_COUNT}</p> 121 109 122 110 {if isset($comments)} … … 124 112 {if !empty($navbar)} 125 113 <div id="pictureCommentNavBar"> 126 {include file='navigation_bar.tpl'| @get_extent:'navbar'}114 {include file='navigation_bar.tpl'|get_extent:'navbar'} 127 115 </div> 128 116 {/if} 129 {include file=$ABS_GUESTBOOK_PATH| @cat:'template/comment_list.tpl'}117 {include file=$ABS_GUESTBOOK_PATH|cat:'template/comment_list.tpl'} 130 118 </div> 131 119 {/if} 132 133 {if $clear}<div style="clear: both;"></div>134 </div>{/if}135 </div>{* <!-- content --> *}
Note: See TracChangeset
for help on using the changeset viewer.