strlen($_POST['title']) ) { echo GetActionText( 'Please enter title' ); echo GetLinkForm( false, 0, true ); } elseif( 1 > strlen($_POST['URL']) ) { echo GetActionText( 'Please enter URL' ); echo GetLinkForm( false, 0, true ); } elseif( 1 > strlen($_POST['desc']) ) { echo GetActionText( 'Please enter description' ); echo GetLinkForm( false, 0, true ); } else { if( db_res( "INSERT INTO `Links` SET `Title` = '" . $_POST['title'] . "', `URL` = '" . $_POST['URL'] . "', `Description` = '" . $_POST['desc'] . "';" ) ) { echo GetActionText( 'link successfully added', 1); echo GetLinkList(); } else { echo GetActionText( 'action failed'); echo GetLinkList(); } } } elseif( !$demo_mode && 'edit' == $_GET['action']) { echo GetLinkForm( true, $_GET['linkID'] ); } elseif( !$demo_mode && 'update' == $_POST['action'] ) { if( 1 > strlen($_POST['title']) ) { echo GetActionText( 'Please enter title' ); echo GetLinkForm( false, 0, true ); } elseif( 1 > strlen($_POST['URL']) ) { echo GetActionText( 'Please enter URL' ); echo GetLinkForm( false, 0, true ); } elseif( 1 > strlen($_POST['desc']) ) { echo GetActionText( 'Please enter description' ); echo GetLinkForm( false, 0, true ); } else { if( db_res( "UPDATE `Links` SET `Title` = '" . process_db_input($_POST['title']) . "', `URL` = '" . process_db_input($_POST['URL']) . "', `Description` = '" . process_db_input($_POST['desc']) . "' WHERE `ID` = " . (int)$_POST['linkID'] . ";" ) ) { echo GetActionText( 'link updated successfully', 1 ); echo GetLinkList(); } else { echo GetActionText( 'action failed'); echo GetLinkList(); } } } elseif( !$demo_mode && 'delete' == $_GET['action'] ) { if( db_res( "DELETE FROM `Links` WHERE `ID` = " . (int)$_GET['linkID'] ) ) { echo GetActionText( 'link deleted successfully', 1 ); echo GetLinkList(); } else { echo GetActionText( 'action failed'); echo GetLinkList(); } } else { echo GetLinkList(); } ContentBlockFoot(); BottomCode(); function GetLinkList() { global $site; $link_query = "SELECT `ID`, `Title`, `URL`, `Description` FROM `Links`"; $link_res = db_res($link_query); $link_count = db_arr("SELECT COUNT(ID) FROM `Links`"); $link_count = $link_count['0']; $links_onpage = 10; $ret = ''; $ret .= '
'; $ret .= ''; $ret .= 'Add New Link'; $ret .= ''; $ret .= '
'; $j = 1; while( $link_arr = mysql_fetch_assoc($link_res)) { if( ($j%2) == 0 ) { $add = 'style="background-color:#E6E6E6;"'; } else { $add = ''; } $ret .= ''; $j++; } return $ret; } function GetLinkForm( $edit = false, $linkID = 0, $use_post_data = false ) { global $site; $ret = ''; if( $edit ) { $link_arr = db_arr( "SELECT `ID`, `Title`, `URL`, `Description` FROM `Links` WHERE `ID` = '" . (int)$linkID . "';"); $value_title = htmlspecialchars($link_arr['Title']); $value_URL = htmlspecialchars($link_arr['URL']); $value_desc = htmlspecialchars($link_arr['Description']); } elseif( $use_post_data ) { $value_title = htmlspecialchars( process_pass_data($_POST['title']) ); $value_URL = htmlspecialchars( process_pass_data($_POST['URL']) ); $value_desc = htmlspecialchars( process_pass_data($_POST['desc']) ); } else { $value_title = ''; $value_URL = ''; $value_desc = ''; } $ret .= ''; return $ret; } function GetActionText( $text, $success = '') { global $site; $ret = ''; if( $success ) { $ret .= '
'; //$ret .= '
'; $ret .= $text; //$ret .= '
'; $ret .= '
'; /* $ret .= '
'; $ret .= 'Back to link list'; $ret .= '
'; */ } else { $ret .= '
'; $ret .= '
'; $ret .= $text; $ret .= '
'; $ret .= '
'; /* $ret .= '
'; $ret .= 'Back to link list'; $ret .= '
'; */ } return $ret; } ?>