bookmarks.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:6k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: bookmarks.php,v $
- // | $Date: 2004/02/10 01:34:30 $
- // | $Revision: 1.15 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Bookmarks manager.
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- include "./../global.php";
- tech_nav('resources');
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- $result = $db->query_return("SELECT categories FROM tech_folders WHERE type = 'bookmarks' AND techid = '$user[id]'");
- $categories = unserialize($result[categories]);
- $cat_jump[0] = 'Top Category';
- if (is_array($categories)) {
- foreach ($categories AS $key => $var) {
- $cat_jump[$key] = $var;
- }
- }
- if ($_REQUEST['go'] == 'Go') {
- $_REQUEST['do'] = 'view';
- }
- ############################### ADD A BOOKMARK ###############################
- if ($_REQUEST['do'] == "add") {
- while ($i < 10) {
- $table[] = array(
- form_input($i, '', '25', 'name'),
- form_input($i, 'http://', '30', 'url'),
- form_select($i, $cat_jump, 'category'),
- form_input($i, '', '50', 'comments')
- );
- $i++;
-
- }
- $cols = array('Name (required)', 'URL (required)', 'Category (required)', 'Comments (optional)');
- table_header('Add New Bookmarks', 'bookmarks.php', array('do' => 'add2'));
- table_content($cols, $table);
- table_footer('Add Bookmarks');
- }
- ############################### ADD A BOOKMARK (2) ###############################
- if ($_REQUEST['do'] == "add2") {
- foreach ($_REQUEST['name'] AS $key => $var) {
- if (($var) AND (validate_url($_REQUEST['url'][$key]))) {
- $db->query("INSERT INTO tech_bookmarks SET
- name = '" . mysql_escape_string($var) . "',
- url = '" . mysql_escape_string($_REQUEST['url'][$key]) . "',
- comments = '" . mysql_escape_string($_REQUEST['comments'][$key]) . "',
- techid = '$user[id]'
- ");
- $i++;
- }
- }
- if ($i) {
- $url = "bookmarks.php?do=view";
- $message = "$i bookmarks added";
- } else {
- $url = "bookmarks.php?do=add";
- $message = "No bookmarks added. Please try again";
- }
- jump($url, $message);
- }
- ############################### BOOKMARKS ACTIONS ###############################
- if ($_REQUEST['do'] == "doactions") {
- // ids of what we are changing (check they don't press submit with no ids!)
- if (is_array($_REQUEST['ids'])) {
- foreach ($_REQUEST['ids'] AS $key => $var) {
- if ($var = 1) {
- $id_array[] = $key;
- }
- }
- }
- if (is_array($id_array)) {
- if ($_REQUEST['actiontype'] == 'delete') {
- $db->query("DELETE FROM tech_bookmarks
- WHERE techid = '$user[id]'
- AND id IN " . array2sql($id_array) . "
- ");
-
- } elseif ($_REQUEST['actiontype'] == 'move') {
- $db->query("UPDATE tech_bookmarks
- SET category = '$_REQUEST[B]'
- WHERE techid = '$user[id]'
- AND id IN " . array2sql($id_array) . "
- ");
- }
- }
- $_REQUEST['do'] = 'view';
-
- }
- ############################### VIEW BOOKMARKS ###############################
- if ($_REQUEST['do'] == "view") {
- // for category javascript
- foreach($cat_jump AS $key => $var) {
- $js .= ""$var","$key",";
- }
- $js = substr($js, 0, -1);
- echo get_javascript('DynamicOptionList.js');
- echo "
- <SCRIPT LANGUAGE="JavaScript">
- var listB = new DynamicOptionList("B","actiontype");
- listB.addOptions("move",$js);
- listB.setDefaultOption("move","0");
- function init() {
- var theform = document.forms[0];
- listB.init(theform);
- }
- </SCRIPT>
- ";
- $form =
- "<select name="actiontype" onChange="listB.populate();">
- <option value="delete">Delete</option>
- <option value="move">Move</option>
- </select>
-
- <select name="B" id="B">
- <script language="JavaScript">listB.printOptions()</script>
- </select>
-
- <input type="submit" name="Process" value="Process">
- <script language="JavaScript">
- init()
- </script>
- ";
- $db->query("SELECT * FROM tech_bookmarks
- WHERE techid = '$user[id]'
- AND category = '$_REQUEST[category]'
- ");
- while ($bookmark = $db->row_array()) {
- $table[] = array(
- form_checkbox_single($bookmark[id], 1, '', 'ids'),
- "<a href="$bookmark[url]" target="_blank">$bookmark[name]</a>",
- $bookmark[comments],
- "<a href="$bookmark[url]" target="_blank">$bookmark[url]</a>"
- );
- }
- $toprow = "<p align="right"><b>Category Jump:</b> " . form_select('category', $cat_jump, '', $_REQUEST[category]) . " <input type="submit" name="go" value="Go"> " . thelp('Resources', 'Bookmarks');
- $width = array('5', '30%', '40%', '30%');
- $cols = array("<input type="checkbox" name="allbox" onclick="checkall(this.form);" />", 'Name', 'Comments', 'url');
- table_header('Your Bookmarks', 'bookmarks.php', array('do' => 'doactions'), '', 'dpform');
- table_content($cols, $table, '', '', $toprow, '', $width);
- table_footer('', 'Left', $form);
- echo "<br /><br /><center><a href="bookmarks.php?do=add"><b>Add Bookmarks</b></a> <a href="folders.php?type=bookmarks"><b>Edit Folders</b></a></center>";
- }
- tech_footer();
- ?>