From 00586f1e8ada8f5baa6e3013525862dccac77b4a Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Mon, 17 Aug 2009 15:52:44 -0400 Subject: Added new files from previous commit --- admin/newLink.php | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 admin/newLink.php (limited to 'admin/newLink.php') diff --git a/admin/newLink.php b/admin/newLink.php new file mode 100644 index 0000000..3f6b42c --- /dev/null +++ b/admin/newLink.php @@ -0,0 +1,93 @@ + 'title', + 'text' => 'Title is a required field'); + } + + if (empty($_POST['url'])) + { + $errors[] = array( 'field' => 'url', + 'text' => 'URL is a required field'); + } else if (!preg_match("/^(http(s?):\\/\\/|ftp:\\/\\/{1})((\w+\.)+)\w{2,}(\/?)$/i", $_POST['url'])) + { + $errors[] = array( 'field' => 'url', + 'text' => 'URL must be a valid URL'); + } + + if (empty($_POST['type'])) + { + $errors[] = array( 'field' => 'type', + 'text' => 'Type is a required field'); + } + + if (isset($errors)) + { + $template->adds_block('ISERROR',array('exi'=>1)); + + $eid = 0; + foreach ($errors as $error) + { + $template->adds_block('ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); + $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + + $eid++; + } + + $template->add('TITLE', 'New Link'); + $template->add('ACTION', '/admin/newLink.php?submit='); + } else { + $inslink = "INSERT INTO links (title,url,type) VALUES (\"" . mysql_real_escape_string($_POST['title']) . "\",\"" . mysql_real_escape_string($_POST['url']) . "\",\"" . mysql_real_escape_string($_POST['type']) . "\")"; + $inslink2 = mysql_query($inslink); + + $template->adds_block('FLASH', array('TEXT' => 'Your link has been sucessfully created.')); + + $template->add('TITLE', 'Edit Link'); + $template->add('ACTION', '/admin/editLink.php?id=' . mysql_insert_id() . '&submit='); + $template->add('TYPEDISABLED', ' readonly="readonly"'); + } + + $template->add('TITLEVALUE', $_POST['title']); + $template->add('URLVALUE', $_POST['url']); + $template->add(strtoupper($_POST['type']) . 'SELECTED', ' checked="checked"'); +} else { + $template->add('TITLE', 'New Link'); + $template->add('ACTION', '/admin/newLink.php?submit='); +} + +$template->display(); + +?> -- cgit 1.4.1