|
From: Maxim <wz...@us...> - 2005-09-09 14:44:23
|
Update of /cvsroot/bbps/bbps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6419 Modified Files: bookmark.php procesa.php support_functions.php _init.php.orig Log Message: * made orphanes searchable * fixed most of the bugs that were on sf.net * making some extra comments * made upgrade schema more complete * for more info, see CHANGELOG entries for September 7 and September 9, 2005. Index: support_functions.php =================================================================== RCS file: /cvsroot/bbps/bbps/support_functions.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** support_functions.php 4 Jun 2005 21:09:57 -0000 1.2 --- support_functions.php 9 Sep 2005 14:44:14 -0000 1.3 *************** *** 136,138 **** function GetParameter($parameter_name, $default = null){ return isset($_GET[$parameter_name]) ? $_GET[$parameter_name] : $default; ! } \ No newline at end of file --- 136,157 ---- function GetParameter($parameter_name, $default = null){ return isset($_GET[$parameter_name]) ? $_GET[$parameter_name] : $default; ! } ! ! /** ! * @param string $page optional name of page to redirect to, if not to ./ ! * @desc creating location to redirect to, eliminating the extra slash in URL's which used to break bbps after a search ! * return string returns the location bbps should redirect to, whether it's installed in a rootdir or a subdir ! */ ! ! function makeRedirect($page='') { ! ! $dir = dirname($_SERVER['PHP_SELF']); ! ! if ( $dir == "/") { ! $dir = ""; ! } ! ! $location = "Location: http://".$_SERVER['HTTP_HOST'].$dir."/".$page; ! return $location; ! ! } Index: procesa.php =================================================================== RCS file: /cvsroot/bbps/bbps/procesa.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** procesa.php 6 Sep 2005 20:23:16 -0000 1.14 --- procesa.php 9 Sep 2005 14:44:14 -0000 1.15 *************** *** 41,45 **** if($_SESSION['AUTHORIZED']){ // redirect to index ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/"); exit; }else{ --- 41,46 ---- if($_SESSION['AUTHORIZED']){ // redirect to index ! $redirect = makeRedirect(index.php); ! header($redirect); exit; }else{ *************** *** 67,71 **** // setcookie("AUTHORIZED", "", $exp_time); // redirect to index ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/"); exit; } --- 68,73 ---- // setcookie("AUTHORIZED", "", $exp_time); // redirect to index ! $redirect = makeRedirect(index.php); ! header($redirect); exit; } *************** *** 75,79 **** * Stores changes to a bookmark */ ! function SaveBookmark(){ // we save the previous state of the bookmark so that we can compare changes // TODO: is better to compare against the db. --- 77,81 ---- * Stores changes to a bookmark */ ! function SaveBookmark(){ // we save the previous state of the bookmark so that we can compare changes // TODO: is better to compare against the db. *************** *** 87,91 **** ! if ($_POST['f_bookmark_recheck_bookmark'] == TRUE) { // Fetching or updating bookmark favicon $favicon_fname = DownloadFavicon($_POST['f_bookmark_url']); --- 89,93 ---- ! if (isset($_POST['f_bookmark_recheck_bookmark']) and $_POST['f_bookmark_recheck_bookmark'] == TRUE) { // Fetching or updating bookmark favicon $favicon_fname = DownloadFavicon($_POST['f_bookmark_url']); *************** *** 107,111 **** mysql_query( $l_strQuery ) or die(mysql_error()); ! // process keywords $l_arKeywords = split("\n", $_POST['f_bookmark_keyword_list'] ); $keyword = ""; --- 109,113 ---- mysql_query( $l_strQuery ) or die(mysql_error()); ! // process submitted keywords $l_arKeywords = split("\n", $_POST['f_bookmark_keyword_list'] ); $keyword = ""; *************** *** 122,126 **** $l_nKeyPos = array_search($keyword_name, $l_currKeywords); ! // the next line makes the program accept only php 4.2 (because of array_search). This will be fixed later. if ($l_nKeyPos !== FALSE ) { // we erase the keyword from the backup. The ones left at the end are be the ones that were erased. --- 124,128 ---- $l_nKeyPos = array_search($keyword_name, $l_currKeywords); ! // the next line makes the program accept only php 4.2 and above (because of array_search). This will be fixed later. if ($l_nKeyPos !== FALSE ) { // we erase the keyword from the backup. The ones left at the end are be the ones that were erased. *************** *** 137,141 **** } // redirect ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php"); exit; } --- 139,144 ---- } // redirect ! $redirect = makeRedirect(index.php); ! header($redirect); exit; } *************** *** 216,220 **** $l_strQuery = sprintf( $l_strQuery, $keyword_name ); // adding the keyword ! mysql_query($l_strQuery) or die(mysql_error()); // return the new id return mysql_insert_id(); --- 219,223 ---- $l_strQuery = sprintf( $l_strQuery, $keyword_name ); // adding the keyword ! mysql_query($l_strQuery) or die (mysql_errno()); // return the new id return mysql_insert_id(); *************** *** 252,256 **** } ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php"); } --- 255,260 ---- } ! $redirect = makeRedirect(index.php); ! header($redirect); } *************** *** 266,270 **** $res1 = mysql_query($delete_relations_query) or die(mysql_error()); ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php"); } --- 270,275 ---- $res1 = mysql_query($delete_relations_query) or die(mysql_error()); ! $redirect = makeRedirect(index.php); ! header($redirect); } *************** *** 278,282 **** $alter_keyword_query = "update bbps_keywords set bbps_keyword_name = '$new_keyword_name' where bbps_keyword_id = '$keyid'"; $res1 = mysql_query($alter_keyword_query) or die(mysql_error()); ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php"); } --- 283,288 ---- $alter_keyword_query = "update bbps_keywords set bbps_keyword_name = '$new_keyword_name' where bbps_keyword_id = '$keyid'"; $res1 = mysql_query($alter_keyword_query) or die(mysql_error()); ! $redirect = makeRedirect(index.php); ! header($redirect); } *************** *** 302,317 **** } elseif ($_POST['add'] == "Add New Tag") { ! $keyword_id = AddKeyword($_POST['new_keyword']); $bookmark_id = $_POST['relations']; ! ! if (isset($bookmark_id)) { foreach($bookmark_id as $bm_id) { ! LinkKeywordToBookmark($keyword_id, $bm_id); } } } ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php"); } --- 308,330 ---- } elseif ($_POST['add'] == "Add New Tag") { ! // Check existence of keyword ! $l_nKeywordID = FindKeywordID( $_POST['new_keyword'] ); ! if( $l_nKeywordID == -1 ){ ! // keyword does not exit. Add it and link it. ! $l_nKeywordID = AddKeyword( $keyword_name ); ! } $bookmark_id = $_POST['relations']; ! ! // Make new links to the keyword from each of the submitted bookmarks ! if (isset($bookmark_id)) { foreach($bookmark_id as $bm_id) { ! LinkKeywordToBookmark($l_nKeywordID, $bm_id); } } } ! $redirect = makeRedirect(index.php); ! header($redirect); } *************** *** 343,347 **** } // Redirect to index ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php"); } --- 356,361 ---- } // Redirect to index ! $redirect = makeRedirect(index.php); ! header($redirect); } Index: _init.php.orig =================================================================== RCS file: /cvsroot/bbps/bbps/_init.php.orig,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** _init.php.orig 4 Jun 2005 21:52:54 -0000 1.12 --- _init.php.orig 9 Sep 2005 14:44:14 -0000 1.13 *************** *** 78,81 **** --- 78,85 ---- // special when people you rate might be visiting your bookmarks and you dont want them to // see the rating you gave them + // + // Make sure you fill the table bbps_cat_ratings if you enable this option! + // Just enter an ID and a name for each rating, starting from [1], [Not too good] to [5], [Brilliant] for example + // The default schema for bbps does NOT include this! You can choose your own amount of ratings and name them. // $CONF_DISPLAY_RATING = TRUE; Index: bookmark.php =================================================================== RCS file: /cvsroot/bbps/bbps/bookmark.php,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** bookmark.php 7 Sep 2005 00:39:55 -0000 1.24 --- bookmark.php 9 Sep 2005 14:44:14 -0000 1.25 *************** *** 185,189 **** $l_strTitle = "Search for '".$_POST['f_search']."' returned: "; if (isset($_POST['f_search']) and strlen($_POST['f_search'])>0) { ! $l_strWhere = sprintf(" AND (bbps_bookmark_comment like '%%%s%%' or bbps_bookmark_name like '%%%s%%') ORDER BY bbps_bookmark_name ASC", $_POST['f_search'], $_POST['f_search']); }else{ $l_bError = TRUE; --- 185,189 ---- $l_strTitle = "Search for '".$_POST['f_search']."' returned: "; if (isset($_POST['f_search']) and strlen($_POST['f_search'])>0) { ! $l_strWhere = sprintf(" (bbps_bookmark_comment like '%%%s%%' or bbps_bookmark_name like '%%%s%%') ORDER BY bbps_bookmark_name ASC", $_POST['f_search'], $_POST['f_search']); }else{ $l_bError = TRUE; *************** *** 287,293 **** --- 287,300 ---- $l_strQueryKeywords = "SELECT DISTINCT bbps_keyword_id, bbps_keyword_name FROM bbps_keywords, bbps_rel_keywords_bookmarks WHERE bbps_rel_keyword_id=bbps_keyword_id AND bbps_rel_bookmark_id=%s"; + // Orphan catcher if (eregi("LEFT JOIN", $sql_where)) { $l_strQuery = $sql_where; } + // Search query (has to differ from below in order to search orpaned bookmarks too) + elseif (eregi("like", $sql_where)) { + $l_strQuery = "SELECT DISTINCT bbps_bookmarks.* FROM bbps_bookmarks WHERE %s "; + $l_strQuery = sprintf($l_strQuery, $sql_extra, $_SESSION['AUTHORIZED'] ? '' : ' AND bbps_bookmark_private = 0 ' ).$sql_where; + } + // Normal bookmarklist query else { $l_strQuery = "SELECT DISTINCT bbps_bookmarks.* %s FROM bbps_bookmarks, bbps_rel_keywords_bookmarks WHERE bbps_rel_bookmark_id=bbps_bookmark_id %s "; *************** *** 411,417 **** $RatingAmount = mysql_num_rows($GetRatingAmount); ! $Rating = (round(($curr_rating / $RatingAmount) * 10) /2); ! $RoundedRating = round($Rating,1); ! if ($text == "yes") { echo $l_strBuffer['bbps_rating_description']." <img align=\"".$align."\" src=\"images/".$RoundedRating.".png\" title=\"".$l_strBuffer['bbps_rating_description']."\" alt=\"".$l_strBuffer['bbps_rating_description']."\">"; --- 418,430 ---- $RatingAmount = mysql_num_rows($GetRatingAmount); ! //$Rating = (round(($curr_rating / $RatingAmount) * 10) /2); ! // Fix divide by zero error by daviddudek ! if ($RatingAmount != 0) { ! $Rating = (round(($curr_rating / $RatingAmount) * 10) /2); ! } else { ! $Rating = 0; ! } ! $RoundedRating = round($Rating,1); ! if ($text == "yes") { echo $l_strBuffer['bbps_rating_description']." <img align=\"".$align."\" src=\"images/".$RoundedRating.".png\" title=\"".$l_strBuffer['bbps_rating_description']."\" alt=\"".$l_strBuffer['bbps_rating_description']."\">"; *************** *** 493,497 **** // redirecting ! header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/"); exit; } --- 506,511 ---- // redirecting ! $redirect = makeRedirect(); ! header($redirect); exit; } |