diff --git a/wp-admin/b2-2-wp.php b/wp-admin/b2-2-wp.php index af0a7d8d6f..c2550ae3b9 100644 --- a/wp-admin/b2-2-wp.php +++ b/wp-admin/b2-2-wp.php @@ -123,6 +123,7 @@ if (!$got_links) { " link_rating int NOT NULL DEFAULT '0', " . " link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " . " link_rel varchar(255) NOT NULL default '', " . + " link_notes MEDIUMTEXT NOT NULL default '', " . " PRIMARY KEY (link_id) " . ") "; $result = mysql_query($sql) or print ("Can't create the table '$tablelinks' in the database." . $sql . "" . mysql_error()); diff --git a/wp-admin/linkmanager.php b/wp-admin/linkmanager.php index a1bbc6aebd..78dc1ccbaa 100644 --- a/wp-admin/linkmanager.php +++ b/wp-admin/linkmanager.php @@ -33,25 +33,25 @@ require_once("../wp-links/links.php"); $title = 'Manage Links'; function add_magic_quotes($array) { - foreach ($array as $k => $v) { - if (is_array($v)) { - $array[$k] = add_magic_quotes($v); - } else { - $array[$k] = addslashes($v); - } - } - return $array; -} + foreach ($array as $k => $v) { + if (is_array($v)) { + $array[$k] = add_magic_quotes($v); + } else { + $array[$k] = addslashes($v); + } + } + return $array; +} if (!get_magic_quotes_gpc()) { - $HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS); - $HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS); - $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS); + $HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS); + $HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS); + $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS); } $b2varstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', - 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel'); + 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes'); for ($i=0; $iquery("UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category"); } - - $wpdb->query("INSERT INTO $tablelinks (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel) " . + $wpdb->query("INSERT INTO $tablelinks (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes) " . " VALUES('" . addslashes($link_url) . "','" . addslashes($link_name) . "', '" . addslashes($link_image) . "', '$link_target', $link_category, '" - . addslashes($link_description) . "', '$link_visible', $user_ID, $link_rating, '" . addslashes($link_rel) ."')"); + . addslashes($link_description) . "', '$link_visible', $user_ID, $link_rating, '" . addslashes($link_rel) . "', '" . addslashes($link_notes) . "')"); header('Location: linkmanager.php'); break; @@ -134,6 +134,7 @@ switch ($action) { $link_visible = $HTTP_POST_VARS["visible"]; $link_rating = $HTTP_POST_VARS["rating"]; $link_rel = $HTTP_POST_VARS["rel"]; + $link_notes = $HTTP_POST_VARS["notes"]; $auto_toggle = get_autotoggle($link_category); if ($user_level < $minadminlevel) @@ -150,7 +151,8 @@ switch ($action) { " link_target='$link_target',\n link_category=$link_category,\n " . " link_visible='$link_visible',\n link_description='" . addslashes($link_description) . "',\n " . " link_rating=$link_rating,\n" . - " link_rel='" . addslashes($link_rel) . "'\n" . + " link_rel='" . addslashes($link_rel) . "',\n" . + " link_notes='" . addslashes($link_notes) . "'\n" . " WHERE link_id=$link_id"); //error_log($sql); } // end if save @@ -173,7 +175,7 @@ switch ($action) { if (isset($links_show_cat_id) && ($links_show_cat_id != '')) $cat_id = $links_show_cat_id; - + if (!isset($cat_id) || ($cat_id == '')) { if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) $cat_id = 'All'; @@ -183,7 +185,7 @@ switch ($action) { header("Location: linkmanager.php"); break; } // end Delete - + case 'linkedit': { $standalone=0; @@ -192,12 +194,12 @@ switch ($action) { die("You have no right to edit the links for this blog.Ask for a promotion to your blog admin. :)"); } - $row = $wpdb->get_row("SELECT link_url, link_name, link_image, link_target, link_description, link_visible, link_category AS cat_id, link_rating, link_rel " . + $row = $wpdb->get_row("SELECT link_url, link_name, link_image, link_target, link_description, link_visible, link_category AS cat_id, link_rating, link_rel, link_notes " . " FROM $tablelinks " . " WHERE link_id = $link_id"); if ($row) { - $link_url = $row->link_url; + $link_url = stripslashes($row->link_url); $link_name = stripslashes($row->link_name); $link_image = $row->link_image; $link_target = $row->link_target; @@ -206,13 +208,15 @@ switch ($action) { $link_visible = $row->link_visible; $link_rating = $row->link_rating; $link_rel = stripslashes($row->link_rel); + $link_notes = stripslashes($row->link_notes); } ?> - - + + + @@ -220,30 +224,35 @@ switch ($action) { Edit a link: - + URL: - + Display Name/Alt text: - + Image: - + Description: - + Rel: - + + Notes: + + + Rating: - - + +'.$r.''); } ?> - - (Leave at 0 for no rating.) - - - Target: - - > - _blank - - > - _top - - > - none + (Leave at 0 for no rating.) - - Visible: - - - Y - - N + + Target: + > _blank + > _top + > none + - - Category: - - + Visible: + + + Yes + + + No + + + + Category: + +get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id"); echo " \n"; - foreach($results as $row) { + foreach ($results as $row) { echo " cat_id."\""; if ($row->cat_id == $link_category) echo " selected"; @@ -294,10 +299,10 @@ switch ($action) { ?> - - - - + + + + @@ -329,7 +334,7 @@ switch ($action) { { if (isset($links_show_cat_id) && ($links_show_cat_id != '')) $cat_id = $links_show_cat_id; - + if (!isset($cat_id) || ($cat_id == '')) { if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) $cat_id = 'All'; @@ -337,7 +342,7 @@ switch ($action) { $links_show_cat_id = $cat_id; if (isset($links_show_order) && ($links_show_order != '')) $order_by = $links_show_order; - + if (!isset($order_by) || ($order_by == '')) $order_by = 'order_name'; $links_show_order = $order_by; @@ -357,17 +362,21 @@ switch ($action) { case 'order_desc': $sqlorderby = 'description'; break; case 'order_owner': $sqlorderby = 'owner'; break; case 'order_rating': $sqlorderby = 'rating'; break; - case 'order_name': + case 'order_name': default: $sqlorderby = 'name'; break; } - + if ($action != "popup") { ?> - Link Categories:Manage Link CategoriesImport Blogroll + + Link Categories: + Manage Link Categories + Import Blogroll + Show links in category: @@ -418,17 +427,17 @@ switch ($action) { - + - + Name URL Category - Relevance + Relationship Image Visible @@ -441,7 +450,7 @@ switch ($action) { FROM $tablelinks LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id LEFT JOIN $tableusers on $tableusers.ID = $tablelinks.link_owner "; - + // have we got a where clause? if (($use_adminlevels) || (isset($cat_id) && ($cat_id != 'All')) ) { $sql .= " WHERE "; @@ -464,30 +473,34 @@ switch ($action) { $links = $wpdb->get_results($sql); if ($links) { foreach ($links as $link) { - $short_url = str_replace('http://', '', $link->link_url); + $short_url = str_replace('http://', '', stripslashes($link->link_url)); $short_url = str_replace('www.', '', $short_url); - if ('/' == substr($short_url, -1)) $short_url = substr($short_url, 0, -1); - if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...'; - + if ('/' == substr($short_url, -1)) + $short_url = substr($short_url, 0, -1); + if (strlen($short_url) > 35) + $short_url = substr($short_url, 0, 32).'...'; + $link->link_name = stripslashes($link->link_name); $link->category = stripslashes($link->category); $link->link_rel = stripslashes($link->link_rel); + $link->link_description = stripslashes($link->link_description); $image = ($link->link_image != null) ? 'Yes' : 'No'; $visible = ($link->link_visible == 'Y') ? 'Yes' : 'No'; ++$i; $style = ($i % 2) ? ' class="alternate"' : ''; echo << - $link->link_name - Description: $link->link_description - $short_url - $link->category - $link->link_rel - $image - $visible - - - + + $link->link_name + Description: $link->link_description + $short_url + $link->category + $link->link_rel + $image + $visible + + + + LINKS; } } @@ -511,7 +524,7 @@ LINKS; Display Name/Alt text: - + Image: @@ -525,6 +538,10 @@ LINKS; Rel: + + Notes: + + Rating: @@ -539,23 +556,23 @@ LINKS; Target: - _blank - - _top - none + _blank + _top + none + Visible: - - Y - - - - N + + Yes + + + No + - Category: + Category: get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id"); diff --git a/wp-admin/upgrade-071-to-072.php b/wp-admin/upgrade-071-to-072.php index e67f4c7eaf..ec689e41db 100644 --- a/wp-admin/upgrade-071-to-072.php +++ b/wp-admin/upgrade-071-to-072.php @@ -70,10 +70,30 @@ switch($step) { you’re all ready, let's go! Step 1 +There are some changes we need to make to the links tables with this version, so lets get those out of + the way. +'; +} else { + $res .= 'There was a problem with ' . $tablename . ''; + ++$error_count; +} +?> +OK, that wasn't too bad was it? Let's move on to step 2! + + +Step 2 There are a few new database tables with this version, so lets get those out of the way. get_results("DESC $table_name"); + + foreach ($results as $row ) { + print_r($row); + if ($row->Field == $col_name) { + // got our column, check the params + echo ("checking $row->Type != $col_type\n"); + if (($col_type != null) && ($row->Type != $col_type)) { + ++$diffs; + } + if (($is_null != null) && ($row->Null != $is_null)) { + ++$diffs; + } + if (($key != null) && ($row->Key != $key)) { + ++$diffs; + } + if (($default != null) && ($row->Default != $default)) { + ++$diffs; + } + if (($extra != null) && ($row->Extra != $extra)) { + ++$diffs; + } + if ($diffs > 0) + return false; + return true; + } // end if found our column + } + return false; +} + +/* +echo "testing"; +echo ""; + +//check_column('wp_links', 'link_description', 'mediumtext'); +//if (check_column($tablecomments, 'comment_author', 'tinytext')) +// echo "ok\n"; +$error_count = 0; +$tablename = $tablelinks; +// check the column +if (!check_column($tablelinks, 'link_description', 'varchar(255)')) +{ + $ddl = "ALTER TABLE $tablelinks MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; + $q = $wpdb->query($ddl); +} +if (check_column($tablelinks, 'link_description', 'varchar(255)')) { + $res .= $tablename . ' - ok '; +} else { + $res .= 'There was a problem with ' . $tablename . ''; + ++$error_count; +} +echo ""; +*/ ?> \ No newline at end of file diff --git a/wp-admin/wp-install.php b/wp-admin/wp-install.php index ef5a7a7160..835036fc25 100644 --- a/wp-admin/wp-install.php +++ b/wp-admin/wp-install.php @@ -113,6 +113,7 @@ if (!$got_links) { " link_rating int NOT NULL DEFAULT '0', " . " link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " . " link_rel varchar(255) NOT NULL default '', " . + " link_notes MEDIUMTEXT NOT NULL default '', " . " PRIMARY KEY (link_id) " . ") "; $result = mysql_query($sql) or print ("Can't create the table '$tablelinks' in the database." . $sql . "" . mysql_error());
There are some changes we need to make to the links tables with this version, so lets get those out of + the way.
OK, that wasn't too bad was it? Let's move on to step 2!
There are a few new database tables with this version, so lets get those out of the way.
testing
"; + +//check_column('wp_links', 'link_description', 'mediumtext'); +//if (check_column($tablecomments, 'comment_author', 'tinytext')) +// echo "ok\n"; +$error_count = 0; +$tablename = $tablelinks; +// check the column +if (!check_column($tablelinks, 'link_description', 'varchar(255)')) +{ + $ddl = "ALTER TABLE $tablelinks MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; + $q = $wpdb->query($ddl); +} +if (check_column($tablelinks, 'link_description', 'varchar(255)')) { + $res .= $tablename . ' - ok '; +} else { + $res .= 'There was a problem with ' . $tablename . ''; + ++$error_count; +} +echo "