Changeset 425
- Timestamp:
- 01/18/06 02:50:17 (3 years ago)
- Files:
-
- trunk/src/lib/functions.php (modified) (3 diffs)
- trunk/src/lyceum/wp-admin/admin-functions.php (modified) (1 diff)
- trunk/src/lyceum/wp-admin/edit-comments.php (modified) (3 diffs)
- trunk/src/lyceum/wp-admin/edit-form-advanced.php (modified) (1 diff)
- trunk/src/lyceum/wp-admin/edit.php (modified) (6 diffs)
- trunk/src/lyceum/wp-admin/post.php (modified) (1 diff)
- trunk/src/lyceum/wp-includes/functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/lib/functions.php
r422 r425 15 15 } 16 16 17 function tokeninput($targetscript, $action='default', $id=0){ 18 $token = formtoken($targetscript, $action, $id); 19 return "<input type=\"hidden\" name=\"token\" value=\"$token\" />"; 20 } 21 17 22 function hv($thing){//"has value" 18 23 return ( isset($thing) && (''!=$thing) ); 19 }20 21 function homeurl(){22 global $blog;23 return get_settings('home')."?b=$blog";24 24 } 25 25 … … 81 81 } 82 82 83 function formtoken($targetscript, $action, $id=0) { 84 trace('formtoken: $targetscript, $action, $id', "$targetscript, $action, $id"); 83 function formtoken($targetscript, $action='default', $id=0) { 85 84 $name = "$targetscript-$action-$id"; 86 85 arrayify($_SESSION['formtokens']); … … 88 87 $token = md5(uniqid(rand(), TRUE)); 89 88 $_SESSION['formtokens']["$name-tokens"][$token] = time();//TODO clear out old tokens(otherwise thousands will accumulate) 89 trace('formtoken: $token, $targetscript, $action, $id', "$token, $targetscript, $action, $id"); 90 90 return $token; 91 91 } 92 92 93 function tokenIsValid ($token, $targetscript, $action , $id=0) {94 trace('tokenIsValid: $targetscript, $action, $id', "$targetscript, $action, $id");93 function tokenIsValid ($token, $targetscript, $action='default', $id=0) { 94 trace('tokenIsValid: $token, $targetscript, $action, $id', "$token, $targetscript, $action, $id"); 95 95 $name = "$targetscript-$action-$id"; 96 96 //trace('$_SESSION[\'formtokens\']["$name-tokens"]', $_SESSION['formtokens']["$name-tokens"]); 97 97 if (!array_key_exists($token, $_SESSION['formtokens']["$name-tokens"])) 98 98 return false; trunk/src/lyceum/wp-admin/admin-functions.php
r400 r425 630 630 <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> 631 631 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 632 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php? b=$blog&action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>633 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?b=$blog& action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', $blog, " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>632 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?token=".formtoken('post.php','edit',$id)."&action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 633 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?b=$blog&token=".formtoken('post.php','delete',$id)."&action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', $blog, " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> 634 634 </tr> 635 635 trunk/src/lyceum/wp-admin/edit-comments.php
r396 r425 99 99 <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A'); 100 100 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 101 echo " | <a href=\"post.php?b=$blog& action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";102 echo " | <a href=\"post.php?b=$blog& action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $blog, $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . "</a> — ";101 echo " | <a href=\"post.php?b=$blog&token=".formtoken('post.php','editcomment',$comment->comment_ID)."&action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>"; 102 echo " | <a href=\"post.php?b=$blog&token=".formtoken('post.php','deletecomment',$comment->comment_ID)."&action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $blog, $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . "</a> — "; 103 103 } // end if any comments to show 104 104 // Get post title … … 107 107 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = '$comment->comment_post_ID'"); 108 108 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 109 ?> <a href="post.php?b=<?=$blog?>& action=edit&post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post “%s”'), stripslashes($post_title)); ?></a>109 ?> <a href="post.php?b=<?=$blog?>&token=<?=formtoken('post.php','edit',$comment->comment_post_ID)?>&action=edit&post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post “%s”'), stripslashes($post_title)); ?></a> 110 110 <?php } ?> 111 111 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p> … … 151 151 <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td> 152 152 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 153 echo "<a href='post.php?b=$blog& action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>153 echo "<a href='post.php?b=$blog&token=".formtoken('post.php','editcomment',$comment->comment_ID)."&action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> 154 154 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 155 echo "<a href=\"post.php?b=$blog&a ction=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . "</a>"; } ?></td>155 echo "<a href=\"post.php?b=$blog&token=".formtoken('post.php','deletecomment',$comment-comment_ID)."&action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . "</a>"; } ?></td> 156 156 </tr> 157 157 <?php trunk/src/lyceum/wp-admin/edit-form-advanced.php
r399 r425 55 55 <input type="hidden" name="action" value="<?php echo $form_action ?>" /> 56 56 <input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" /> 57 <?trace('$form_action, $post_ID', "$form_action, $post_ID");?> 58 <?=tokeninput('post.php', $form_action, isset($post_ID) ? $post_ID : 0)?> 57 59 58 60 <?php echo $form_extra ?> trunk/src/lyceum/wp-admin/edit.php
r421 r425 25 25 if ($draft->post_title == '') 26 26 $draft->post_title = sprintf(__('Post #%s'), $draft->ID); 27 echo "<a href='post.php?b=$blog &action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";27 echo "<a href='post.php?b=$blogdata->blogname&action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; 28 28 ++$i; 29 29 } … … 42 42 if ($draft->post_title == '') 43 43 $draft->post_title = sprintf(__('Post #%s'), $draft->ID); 44 echo "<a href='post.php?b=$blog &action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";44 echo "<a href='post.php?b=$blogdata->blogname&action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; 45 45 ++$i; 46 46 } … … 186 186 case 'comments': 187 187 ?> 188 <td><a href="edit.php?b=<?=$blog ;?>&p=<?php echo $id ?>&c=1">188 <td><a href="edit.php?b=<?=$blogdata->blogname;?>&p=<?php echo $id ?>&c=1"> 189 189 <?php comments_number(__('0'), __('1'), __('%')) ?> 190 190 </a></td> … … 206 206 case 'control_edit': 207 207 ?> 208 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?b=$blog &action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>208 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?b=$blogdata->blogname&action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 209 209 <?php 210 210 break; … … 212 212 case 'control_delete': 213 213 ?> 214 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?b=$blog &action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'post', $blog, " . $id . ", '" . sprintf(__("You are about to delete this post "%s".\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>214 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?b=$blogdata->blogname&action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'post', $blogdata->blogname, " . $id . ", '" . sprintf(__("You are about to delete this post "%s".\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 215 215 <?php 216 216 break; … … 263 263 <?php 264 264 if ( current_user_can('edit_post', $post->ID) ) { 265 echo "[ <a href=\"post.php? b=".$blog."&action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit') . "</a>";266 echo " - <a href=\"post.php? b=".$blog."&action=deletecomment&p=".$post->ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";265 echo "[ <a href=\"post.php?token=".formtoken('post.php','editcomment',$comment->comment_ID)."&action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit') . "</a>"; 266 echo " - <a href=\"post.php?token=".formtoken('post.php','deletecomment',$comment->comment_ID)."&action=deletecomment&p=".$post->ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> "; 267 267 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 268 268 if ('approved' == wp_get_comment_status($comment->comment_ID)) { 269 echo " - <a href=\"post.php? b=".$blog."&action=unapprovecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";269 echo " - <a href=\"post.php?token=".formtoken('post.php','unapprovecomment',$comment->comment_ID)."&action=unapprovecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> "; 270 270 } else { 271 echo " - <a href=\"post.php? b=".$blogdata->name."&token=".formtoken('post.php','approvecomment',$comment->comment_ID)."&action=approvecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Approve') . "</a> ";271 echo " - <a href=\"post.php?token=".formtoken('post.php','approvecomment',$comment->comment_ID)."&action=approvecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Approve') . "</a> "; 272 272 } 273 273 } trunk/src/lyceum/wp-admin/post.php
r424 r425 30 30 $editing = true; 31 31 32 if (!( 33 tokenIsValid($_REQUEST['token'], 'post.php', $action, (int)$_REQUEST['comment']) || 34 tokenIsValid($_REQUEST['token'], 'post.php', $action, (int)$_REQUEST['post']) || 35 tokenIsValid($_REQUEST['token'], 'post.php', $action) 36 )) 37 die("token is not valid"); 32 if (isset($_REQUEST['action'])) 33 if (!( 34 tokenIsValid($_REQUEST['token'], 'post.php', $action, (int)$_REQUEST['comment']) || 35 tokenIsValid($_REQUEST['token'], 'post.php', $action, (int)$_REQUEST['post']) || 36 tokenIsValid($_REQUEST['token'], 'post.php', $action) 37 )) 38 die("token is not valid"); 38 39 39 40 switch($action) { trunk/src/lyceum/wp-includes/functions.php
r396 r425 1007 1007 1008 1008 if ( $wpdb->get_var(" 1009 SELECT post_id FROM $wpdb->postmeta1009 SELECT $wpdb->postmeta.post_id FROM $wpdb->postmeta 1010 1010 INNER JOIN $wpdb->post2cat ON ($wpdb->post2cat.post_id = $wpdb->postmeta.post_id) 1011 1011 INNER JOIN $wpdb->categories ON (category_id = cat_ID)
