diff options
Diffstat (limited to 'admin/editLink.php')
| -rw-r--r-- | admin/editLink.php | 89 |
1 files changed, 89 insertions, 0 deletions
| diff --git a/admin/editLink.php b/admin/editLink.php new file mode 100644 index 0000000..fe4fb66 --- /dev/null +++ b/admin/editLink.php | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | <?php | ||
| 2 | /* | ||
| 3 | 444444444 | ||
| 4 | 4::::::::4 | ||
| 5 | 4:::::::::4 | ||
| 6 | 4::::44::::4 | ||
| 7 | 4::::4 4::::4 Four Island | ||
| 8 | 4::::4 4::::4 | ||
| 9 | 4::::4 4::::4 Written and maintained by Starla Insigna | ||
| 10 | 4::::444444::::444 | ||
| 11 | 4::::::::::::::::4 admin/editLink.php | ||
| 12 | 4444444444:::::444 | ||
| 13 | 4::::4 Please do not use, reproduce or steal the | ||
| 14 | 4::::4 contents of this file without explicit | ||
| 15 | 4::::4 permission from Hatkirby. | ||
| 16 | 44::::::44 | ||
| 17 | 4::::::::4 | ||
| 18 | 4444444444 | ||
| 19 | */ | ||
| 20 | |||
| 21 | if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);} | ||
| 22 | |||
| 23 | require('headerproc.php'); | ||
| 24 | |||
| 25 | $category = 'links'; | ||
| 26 | |||
| 27 | $template = new FITemplate('admin/writeLink'); | ||
| 28 | $template->add('TITLE', 'Edit Link'); | ||
| 29 | $template->add('ACTION', '/admin/editLink.php?id=' . $_GET['id'] . '&submit='); | ||
| 30 | |||
| 31 | $getlink = "SELECT * FROM links WHERE id = " . $_GET['id']; | ||
| 32 | $getlink2 = mysql_query($getlink); | ||
| 33 | $getlink3 = mysql_fetch_array($getlink2); | ||
| 34 | |||
| 35 | $pageaid = $getlink3['type']; | ||
| 36 | |||
| 37 | if (isset($_GET['submit'])) | ||
| 38 | { | ||
| 39 | if (empty($_POST['title'])) | ||
| 40 | { | ||
| 41 | $errors[] = array( 'field' => 'title', | ||
| 42 | 'text' => 'Title is a required field'); | ||
| 43 | } | ||
| 44 | |||
| 45 | if (empty($_POST['url'])) | ||
| 46 | { | ||
| 47 | $errors[] = array( 'field' => 'url', | ||
| 48 | 'text' => 'URL is a required field'); | ||
| 49 | } else if (!preg_match("/^(http(s?):\\/\\/|ftp:\\/\\/{1})((\w+\.)+)\w{2,}(\/?)$/i", $_POST['url'])) | ||
| 50 | { | ||
| 51 | $errors[] = array( 'field' => 'url', | ||
| 52 | 'text' => 'URL must be a valid URL'); | ||
| 53 | } | ||
| 54 | |||
| 55 | if (isset($errors)) | ||
| 56 | { | ||
| 57 | $template->adds_block('ISERROR',array('exi'=>1)); | ||
| 58 | |||
| 59 | $eid = 0; | ||
| 60 | foreach ($errors as $error) | ||
| 61 | { | ||
| 62 | $template->adds_block('ERROR', array( 'ID' => $eid, | ||
| 63 | 'TEXT' => $error['text'])); | ||
| 64 | $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); | ||
| 65 | $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, | ||
| 66 | 'TEXT' => $error['text'])); | ||
| 67 | |||
| 68 | $eid++; | ||
| 69 | } | ||
| 70 | } else { | ||
| 71 | $inslink = "UPDATE links SET title = \"" . mysql_real_escape_string($_POST['title']) . "\", url = \"" . mysql_real_escape_string($_POST['url']) . "\" WHERE id = " . $_GET['id']; | ||
| 72 | $inslink2 = mysql_query($inslink); | ||
| 73 | |||
| 74 | $template->adds_block('FLASH', array('TEXT' => 'Your link has been sucessfully edited.')); | ||
| 75 | } | ||
| 76 | |||
| 77 | $template->add('TITLEVALUE', $_POST['title']); | ||
| 78 | $template->add('URLVALUE', $_POST['url']); | ||
| 79 | } else { | ||
| 80 | $template->add('TITLEVALUE', $getlink3['title']); | ||
| 81 | $template->add('URLVALUE', $getlink3['url']); | ||
| 82 | } | ||
| 83 | |||
| 84 | $template->add('TYPEDISABLED', ' readonly="readonly"'); | ||
| 85 | $template->add(strtoupper($getlink3['type']) . 'SELECTED', ' checked="checked"'); | ||
| 86 | |||
| 87 | $template->display(); | ||
| 88 | |||
| 89 | ?> | ||
