TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 321
  • Total: 321

[Block] Linkit - A member submittable links block

Started by Thurnok, August 02, 2006, 10:01:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thurnok


Thurnok

Update 1.6
  • changed radio buttons to checkboxes
  • allow multiple links to be deleted simultaneously
  • added visual link verification
  • added class to form buttons / text  ;o)

see code for info

Updated code in first post

RoarinRow


SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

Ken.

Very nice additions Thurnok, especially the visual link verification.
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

funxlab

Thurnok
It could see linkit buttons and text fields/test etc as Admin, but not as a normal member. So I tried to change groups allowed to submitt links but now I see this line appearing on TP.

Parse error: syntax error, unexpected '*' in /home/casestud/public_html/Sources/Load.php(1733) : eval()'d code(35) : eval()'d code on line 1


My phpblock has the following code

*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// *****   SECURITY OPTIONS   *****
// who has addlink access? -  format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('1', '2', '3' '4', '5', '6' '7' '8');
$li_addlink_groups = array('1', '2', '3' '4', '5', '6' '7' '8');
// who can edit links? - same format as addlink
$li_editlink_groups = array('1', '2', '3' '4', '5', '6' '7' '8');
// who can delete links? - same format as addlink
$li_dellink_groups = array('1', '2', '3');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;

// *****   LAYOUT OPTIONS   *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns?  change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';

// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;


// *****   OTHER OPTIONS   *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "linkit";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links!  Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $li_title . '</b></center><br />';
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;

// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}

switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}

// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];

// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}

// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed!  Table NOT Created!<br />\n");
}
}

// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT Inserted into database!<br />\n");
}
}

// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT modified in database!<br />\n");
}
}
}

// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT Deleted from database!<br />\n");
}
}

///////////  MAIN CODE HERE  ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];

// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}

// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}

// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}

////////////  MAIN DISPLAY CODE HERE  ///////////////

// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY

url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER

BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename";
}

$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}

// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}

function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}

function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}

function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}

// -->
</script>
';

// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}

// preset our current column to first column
$li_current_column = 1;

// start our table and first row
echo '<table width="100%" border="0"><tr>' . "\n";

// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;

// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] .

'</a></td>' . "\n";
// next column number
$li_current_column++;
}

// end our last row and our table
echo "</tr>\n</table>\n";

// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form,

\'li_checkbox\');"> Check/Uncheck all</input></div>';
}

// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test"

onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" />&nbsp;&nbsp;';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" />&nbsp;&nbsp;';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}

// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';

// and finally, end our form
echo '</form>';

// free the result for good measure
mysql_free_result($dbresult);




Please help me where could be the problem..
Best regards,  :)
Jim

Thurnok

You are missing several lines of code.  Putting a forward slash ( / ) before the first asterisk ( * ) on your line one would do the trick, but here's the lines you are missing that go above your shown line 1:


//////////////////////////////////////////////
// Linkit Version 1.6
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update January 23, 2007
//
// 2.0:
// - changed radio buttons to checkboxes
// - allow multiple links to be deleted simultaneously
// - added visual link verification
// - added class to form buttons / text  ;o)
//
// This is a php block and/or php Article snippet.  It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate.  Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links.  You
// can create the table manually if necessary.
//
//////////////////////////////////////////////

/*



Also something for you to note, unless you somehow changed group 1 from the Admin group to something else, you should take that out of all the arrays.  It is not necessary, as admins automatically can do all the features.

Additionally, groups 4-8 (the default post count groups) can be removed from the arrays and simply add the group 0 to them if you want all registered users to have the capability.

One final note, I see you have it so registered users (all the post count groups anyway) set to also edit links.  The $li_editlink_groups array is to allow someone to edit "any" links, not just their own.  I'm not sure you intended on allowing all registered users to have the capability to edit "any" links.  Instead, you can simply turn on edit own and/or delete own (as I see you have), and remove the post count groups (and registered member group 0) from $li_editlink_groups completely.

In otherwords, here's what I would change your permissions in the block to:

// Example: $li_addlink_groups = array('14');
$li_addlink_groups = array('0','2','3');
// who can edit links? - same format as addlink
$li_editlink_groups = array('2','3');
// who can delete links? - same format as addlink
$li_dellink_groups = array('2','3');


Groups 2 and 3 are for global mods and local mods.  I'm assuming you want them to have the ability to Add/Edit/Delete links without regard to what actual member groups they are in, so you can leave just those two groups in the edit/delete arrays.

The above will let any of your registered users to Add links to the block.  It will also allow them to edit or delete their own (assuming you don't change that part of the code where you already have it set for them).  However, global mods and local mods will be able to Add/Edit/Delete any links in the block.

funxlab

Thurnok !
Thank you for your great help. It is working for me now. Kindly see that I dont want all users be able to delete and edit links so I did as you advised. Here is my code now.


//////////////////////////////////////////////
// Linkit Version 1.6
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update January 23, 2007
//
// 2.0:
// - changed radio buttons to checkboxes
// - allow multiple links to be deleted simultaneously
// - added visual link verification
// - added class to form buttons / text  ;o)
//
// This is a php block and/or php Article snippet.  It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate.  Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links.  You
// can create the table manually if necessary.
//
//////////////////////////////////////////////

/*

/*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// *****   SECURITY OPTIONS   *****
// who has addlink access? -  format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('2', '3' '4', '5', '6' '7' '8');
$li_addlink_groups = array('0');
// who can edit links? - same format as addlink
$li_editlink_groups = array('2','3');
// who can delete links? - same format as addlink
$li_dellink_groups = array('2','3');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;

// *****   LAYOUT OPTIONS   *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns?  change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';

// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;


// *****   OTHER OPTIONS   *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "linkit";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links!  Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $li_title . '</b></center><br />';
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;

// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}

switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}

// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];

// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}

// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed!  Table NOT Created!<br />\n");
}
}

// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT Inserted into database!<br />\n");
}
}

// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT modified in database!<br />\n");
}
}
}

// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT Deleted from database!<br />\n");
}
}

///////////  MAIN CODE HERE  ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];

// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}

// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}

// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}

////////////  MAIN DISPLAY CODE HERE  ///////////////

// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY

url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER

BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename";
}

$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}

// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}

function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}

function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}

function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}

// -->
</script>
';

// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}

// preset our current column to first column
$li_current_column = 1;

// start our table and first row
echo '<table width="100%" border="0"><tr>' . "\n";

// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;

// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] .

'</a></td>' . "\n";
// next column number
$li_current_column++;
}

// end our last row and our table
echo "</tr>\n</table>\n";

// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form,

\'li_checkbox\');"> Check/Uncheck all</input></div>';
}

// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test"

onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" />&nbsp;&nbsp;';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" />&nbsp;&nbsp;';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}

// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';

// and finally, end our form
echo '</form>';

// free the result for good measure
mysql_free_result($dbresult);


Thank you once again, Have a good day.  :)
Jim

Thurnok

No problem, you are welcome.  :)

I should probably have changed the comments in my code to make it more clear with respect to edit/delete for "all" links vs. "own" links.  I'll do that in a future version.

Happy Linking!

houston

Quote from: funxlab on January 30, 2007, 01:59:26 AM
Thurnok !
Thank you for your great help. It is working for me now. Kindly see that I dont want all users be able to delete and edit links so I did as you advised. Here is my code now.


//////////////////////////////////////////////
// Linkit Version 1.6
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update January 23, 2007
//
// 2.0:
// - changed radio buttons to checkboxes
// - allow multiple links to be deleted simultaneously
// - added visual link verification
// - added class to form buttons / text  ;o)
//
// This is a php block and/or php Article snippet.  It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate.  Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links.  You
// can create the table manually if necessary.
//
//////////////////////////////////////////////

/*

/*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// *****   SECURITY OPTIONS   *****
// who has addlink access? -  format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('2', '3' '4', '5', '6' '7' '8');
$li_addlink_groups = array('0');
// who can edit links? - same format as addlink
$li_editlink_groups = array('2','3');
// who can delete links? - same format as addlink
$li_dellink_groups = array('2','3');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;

// *****   LAYOUT OPTIONS   *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns?  change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';

// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;


// *****   OTHER OPTIONS   *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "linkit";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links!  Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $li_title . '</b></center><br />';
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;

// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}

switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}

// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];

// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}

// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed!  Table NOT Created!<br />\n");
}
}

// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT Inserted into database!<br />\n");
}
}

// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT modified in database!<br />\n");
}
}
}

// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed!  Link NOT Deleted from database!<br />\n");
}
}

///////////  MAIN CODE HERE  ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];

// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}

// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}

// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}

////////////  MAIN DISPLAY CODE HERE  ///////////////

// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY

url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER

BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename";
}

$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}

// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}

function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}

function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}

function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}

// -->
</script>
';

// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}

// preset our current column to first column
$li_current_column = 1;

// start our table and first row
echo '<table width="100%" border="0"><tr>' . "\n";

// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;

// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] .

'</a></td>' . "\n";
// next column number
$li_current_column++;
}

// end our last row and our table
echo "</tr>\n</table>\n";

// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form,

\'li_checkbox\');"> Check/Uncheck all</input></div>';
}

// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test"

onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" />&nbsp;&nbsp;';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" />&nbsp;&nbsp;';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}

// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';

// and finally, end our form
echo '</form>';

// free the result for good measure
mysql_free_result($dbresult);


Thank you once again, Have a good day.  :)
Jim

Hmmmmm I can't seem to delete the checked links.An error box keeps popping up telling me to select a link.

Oh Well.

funxlab

houston ,
you need to enter an link first and then click on test. Can you add a link without testing it first?
Jim

This website is proudly hosted on Crocweb Cloud Website Hosting.