diff options
| -rw-r--r-- | admin/editLink.php | 89 | ||||
| -rw-r--r-- | admin/links.php | 114 | ||||
| -rw-r--r-- | admin/newLink.php | 93 | ||||
| -rw-r--r-- | theme/admin/links.tpl | 94 | ||||
| -rw-r--r-- | theme/admin/writeLink.tpl | 53 |
5 files changed, 443 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 | ?> | ||
| diff --git a/admin/links.php b/admin/links.php new file mode 100644 index 0000000..d1ab878 --- /dev/null +++ b/admin/links.php | |||
| @@ -0,0 +1,114 @@ | |||
| 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/links.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 | require_once('Pager.php'); | ||
| 25 | |||
| 26 | if (isset($_GET['type'])) | ||
| 27 | { | ||
| 28 | $type = $_GET['type']; | ||
| 29 | } else { | ||
| 30 | $type = 'affiliates'; | ||
| 31 | } | ||
| 32 | |||
| 33 | $category = 'links'; | ||
| 34 | $pageaid = $type; | ||
| 35 | |||
| 36 | if (isset($_GET['action'])) | ||
| 37 | { | ||
| 38 | if ($_GET['action'] == 'delete') | ||
| 39 | { | ||
| 40 | if (is_numeric($_POST['id'])) | ||
| 41 | { | ||
| 42 | $dellink = "DELETE FROM links WHERE id = " . $_POST['id']; | ||
| 43 | $dellink2 = mysql_query($dellink); | ||
| 44 | |||
| 45 | $flashmsg = 'The selected link has been deleted.'; | ||
| 46 | } | ||
| 47 | } else if ($_GET['action'] == 'deletes') | ||
| 48 | { | ||
| 49 | $ids = explode(',', $_POST['ids']); | ||
| 50 | |||
| 51 | if (is_array($ids) && !empty($ids)) | ||
| 52 | { | ||
| 53 | foreach ($ids as $id) | ||
| 54 | { | ||
| 55 | $dellink = "DELETE FROM links WHERE id = " . $id; | ||
| 56 | $dellink2 = mysql_query($dellink); | ||
| 57 | } | ||
| 58 | |||
| 59 | $flashmsg = 'The selected links have been deleted.'; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | $template = new FITemplate('admin/links'); | ||
| 65 | |||
| 66 | if ($type == 'affiliates') | ||
| 67 | { | ||
| 68 | $template->add('TITLE', 'Manage Affiliates'); | ||
| 69 | } else if ($type == 'webprojs') | ||
| 70 | { | ||
| 71 | $template->add('TITLE', 'Manage Website Projects'); | ||
| 72 | } | ||
| 73 | |||
| 74 | $getlinks = "SELECT * FROM links WHERE type = \"" . mysql_real_escape_string($type) . "\" ORDER BY id ASC"; | ||
| 75 | $getlinks2 = mysql_query($getlinks); | ||
| 76 | $i=0; | ||
| 77 | while ($getlinks3[$i] = mysql_fetch_array($getlinks2)) | ||
| 78 | { | ||
| 79 | $i++; | ||
| 80 | } | ||
| 81 | |||
| 82 | if ($i != 0) | ||
| 83 | { | ||
| 84 | $template->adds_block('AVAIL',array('exi'=>1)); | ||
| 85 | } else { | ||
| 86 | $template->adds_block('NOTAVAIL',array('exi'=>1)); | ||
| 87 | } | ||
| 88 | |||
| 89 | $pager = &Pager::factory(array( 'mode' => 'Sliding', | ||
| 90 | 'perPage' => 20, | ||
| 91 | 'delta' => 2, | ||
| 92 | 'itemData' => $getlinks3)); | ||
| 93 | |||
| 94 | $j=0; | ||
| 95 | |||
| 96 | foreach ($pager->getPageData() as $link) | ||
| 97 | { | ||
| 98 | if (!empty($link)) | ||
| 99 | { | ||
| 100 | $template->adds_block('LINK', array( 'TITLE' => $link['title'], | ||
| 101 | 'URL' => $link['url'], | ||
| 102 | 'ID' => $link['id'], | ||
| 103 | 'ODD' => ($j % 2 ? '' : ' class="odd"'))); | ||
| 104 | } | ||
| 105 | |||
| 106 | $j++; | ||
| 107 | } | ||
| 108 | |||
| 109 | $template->add('PAGEID', $pager->getCurrentPageID()); | ||
| 110 | $template->add('PAGINATION', $pager->links); | ||
| 111 | |||
| 112 | $template->display(); | ||
| 113 | |||
| 114 | ?> | ||
| 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 @@ | |||
| 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/newLink.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 | $pageaid = 'newlink'; | ||
| 27 | |||
| 28 | $template = new FITemplate('admin/writeLink'); | ||
| 29 | |||
| 30 | if (isset($_GET['submit'])) | ||
| 31 | { | ||
| 32 | if (empty($_POST['title'])) | ||
| 33 | { | ||
| 34 | $errors[] = array( 'field' => 'title', | ||
| 35 | 'text' => 'Title is a required field'); | ||
| 36 | } | ||
| 37 | |||
| 38 | if (empty($_POST['url'])) | ||
| 39 | { | ||
| 40 | $errors[] = array( 'field' => 'url', | ||
| 41 | 'text' => 'URL is a required field'); | ||
| 42 | } else if (!preg_match("/^(http(s?):\\/\\/|ftp:\\/\\/{1})((\w+\.)+)\w{2,}(\/?)$/i", $_POST['url'])) | ||
| 43 | { | ||
| 44 | $errors[] = array( 'field' => 'url', | ||
| 45 | 'text' => 'URL must be a valid URL'); | ||
| 46 | } | ||
| 47 | |||
| 48 | if (empty($_POST['type'])) | ||
| 49 | { | ||
| 50 | $errors[] = array( 'field' => 'type', | ||
| 51 | 'text' => 'Type is a required field'); | ||
| 52 | } | ||
| 53 | |||
| 54 | if (isset($errors)) | ||
| 55 | { | ||
| 56 | $template->adds_block('ISERROR',array('exi'=>1)); | ||
| 57 | |||
| 58 | $eid = 0; | ||
| 59 | foreach ($errors as $error) | ||
| 60 | { | ||
| 61 | $template->adds_block('ERROR', array( 'ID' => $eid, | ||
| 62 | 'TEXT' => $error['text'])); | ||
| 63 | $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); | ||
| 64 | $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, | ||
| 65 | 'TEXT' => $error['text'])); | ||
| 66 | |||
| 67 | $eid++; | ||
| 68 | } | ||
| 69 | |||
| 70 | $template->add('TITLE', 'New Link'); | ||
| 71 | $template->add('ACTION', '/admin/newLink.php?submit='); | ||
| 72 | } else { | ||
| 73 | $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']) . "\")"; | ||
| 74 | $inslink2 = mysql_query($inslink); | ||
| 75 | |||
| 76 | $template->adds_block('FLASH', array('TEXT' => 'Your link has been sucessfully created.')); | ||
| 77 | |||
| 78 | $template->add('TITLE', 'Edit Link'); | ||
| 79 | $template->add('ACTION', '/admin/editLink.php?id=' . mysql_insert_id() . '&submit='); | ||
| 80 | $template->add('TYPEDISABLED', ' readonly="readonly"'); | ||
| 81 | } | ||
| 82 | |||
| 83 | $template->add('TITLEVALUE', $_POST['title']); | ||
| 84 | $template->add('URLVALUE', $_POST['url']); | ||
| 85 | $template->add(strtoupper($_POST['type']) . 'SELECTED', ' checked="checked"'); | ||
| 86 | } else { | ||
| 87 | $template->add('TITLE', 'New Link'); | ||
| 88 | $template->add('ACTION', '/admin/newLink.php?submit='); | ||
| 89 | } | ||
| 90 | |||
| 91 | $template->display(); | ||
| 92 | |||
| 93 | ?> | ||
| diff --git a/theme/admin/links.tpl b/theme/admin/links.tpl new file mode 100644 index 0000000..d666f61 --- /dev/null +++ b/theme/admin/links.tpl | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | <h2><!--TITLE--></h2> | ||
| 2 | |||
| 3 | <div class="clear"></div> | ||
| 4 | |||
| 5 | <script type="text/javascript"> | ||
| 6 | function deleteLink(id) | ||
| 7 | { | ||
| 8 | if (confirm("Are you sure you would like to delete this link?")) | ||
| 9 | { | ||
| 10 | postwith("/admin/links.php?pageID=<!--PAGEID-->&action=delete",{id:id}); | ||
| 11 | } | ||
| 12 | } | ||
| 13 | |||
| 14 | // following function taken from http://mentaljetsam.wordpress.com/2008/06/02/using-javascript-to-post-data-between-pages/ | ||
| 15 | function postwith (to,p) { | ||
| 16 | var myForm = document.createElement("form"); | ||
| 17 | myForm.method="post" ; | ||
| 18 | myForm.action = to ; | ||
| 19 | for (var k in p) { | ||
| 20 | var myInput = document.createElement("input") ; | ||
| 21 | myInput.setAttribute("name", k) ; | ||
| 22 | myInput.setAttribute("value", p[k]); | ||
| 23 | myForm.appendChild(myInput) ; | ||
| 24 | } | ||
| 25 | document.body.appendChild(myForm) ; | ||
| 26 | myForm.submit() ; | ||
| 27 | document.body.removeChild(myForm) ; | ||
| 28 | } | ||
| 29 | |||
| 30 | function bulkAction() | ||
| 31 | { | ||
| 32 | var bulk=new Array(); | ||
| 33 | $(".the-check:checked").each(function() { | ||
| 34 | bulk.push($(this).val()); | ||
| 35 | }); | ||
| 36 | var ids = bulk.join(",") | ||
| 37 | |||
| 38 | if (ids != "") | ||
| 39 | { | ||
| 40 | if ($('#manage-bulk select').val() == "delete") | ||
| 41 | { | ||
| 42 | if (confirm("Are you sure you would like to delete the selected links?")) | ||
| 43 | { | ||
| 44 | postwith("/admin/links.php?pageID=<!--PAGEID-->&action=deletes",{ids:ids}); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | $(document).ready(function() { | ||
| 51 | $("input#all-check").click(function() { | ||
| 52 | var what = this.checked; | ||
| 53 | $("input.the-check").each(function() { | ||
| 54 | this.checked = what; | ||
| 55 | }); | ||
| 56 | }); | ||
| 57 | }); | ||
| 58 | </script> | ||
| 59 | |||
| 60 | <!--BEGIN AVAIL--> | ||
| 61 | <div id="manage-options"> | ||
| 62 | <div id="manage-bulk"> | ||
| 63 | <select name="bulk-type"> | ||
| 64 | <option value="delete">Delete</option> | ||
| 65 | </select> | ||
| 66 | |||
| 67 | <button id="bulk" type="button" onclick="bulkAction()">Bulk</button> | ||
| 68 | </div> | ||
| 69 | </div> | ||
| 70 | |||
| 71 | <div class="manage-pagination"><!--PAGINATION--></div> | ||
| 72 | |||
| 73 | <table> | ||
| 74 | <tr class="table-header"> | ||
| 75 | <td class="table-checkbox"><input type="checkbox" id="all-check" /></td> | ||
| 76 | <td>Post Name</td> | ||
| 77 | <td colspan="3">Actions</td> | ||
| 78 | </tr> | ||
| 79 | <!--BEGIN LINK--> | ||
| 80 | <tr<!--LINK.ODD-->> | ||
| 81 | <td class="table-checkbox"><input class="the-check" type="checkbox" name="bulk" value="<!--LINK.ID-->" /></td> | ||
| 82 | <td><!--LINK.TITLE--></td> | ||
| 83 | <td class="table-img"><a href="/admin/editLink.php?id=<!--LINK.ID-->"><img src="/theme/images/icons/page_edit.png" alt="Edit" /></a></td> | ||
| 84 | <td class="table-img"><a href="#" onclick="deleteLink(<!--LINK.ID-->)"><img src="/theme/images/icons/page_delete.png" alt="Delete" /></a></td> | ||
| 85 | <td class="table-img"><a href="<!--LINK.URL-->"><img src="/theme/images/icons/page_go.png" alt="View" /></a></td> | ||
| 86 | </tr> | ||
| 87 | <!--END LINK--> | ||
| 88 | </table> | ||
| 89 | |||
| 90 | <div class="manage-pagination"><!--PAGINATION--></div> | ||
| 91 | <!--END AVAIL--> | ||
| 92 | <!--BEGIN NOTAVAIL--> | ||
| 93 | <div class="manage-pagination">There are no links.</div> | ||
| 94 | <!--END NOTAVAIL--> | ||
| diff --git a/theme/admin/writeLink.tpl b/theme/admin/writeLink.tpl new file mode 100644 index 0000000..9cb1d1a --- /dev/null +++ b/theme/admin/writeLink.tpl | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | <h2><!--TITLE--></h2> | ||
| 2 | |||
| 3 | <form action="<!--ACTION-->" method="post" class="uniForm"> | ||
| 4 | <!--BEGIN ISERROR--> | ||
| 5 | <div id="errorMsg"> | ||
| 6 | <h3>Oops! There was an error!</h3> | ||
| 7 | |||
| 8 | <ol> | ||
| 9 | <!--BEGIN ERROR--> | ||
| 10 | <li><a href="#error<!--ERROR.ID-->" title="Jump to error"><!--ERROR.TEXT--></a></li> | ||
| 11 | <!--END ERROR--> | ||
| 12 | </ol> | ||
| 13 | </div> | ||
| 14 | <!--END ISERROR--> | ||
| 15 | |||
| 16 | <!--BEGIN FLASH--> | ||
| 17 | <div id="OKMsg"><p><!--FLASH.TEXT--></p></div> | ||
| 18 | <!--END FLASH--> | ||
| 19 | |||
| 20 | <fieldset class="inlineLabels"> | ||
| 21 | <div class="ctrlHolder<!--ISTITLEERROR-->"> | ||
| 22 | <!--BEGIN TITLEERROR--> | ||
| 23 | <p id="error<!--TITLEERROR.ID-->" class="errorField"><strong><!--TITLEERROR.TEXT--></strong></p> | ||
| 24 | <!--END TITLEERROR--> | ||
| 25 | <label for="title">Title</label> | ||
| 26 | <input type="text" name="title" id="title" value="<!--TITLEVALUE-->" /> | ||
| 27 | </div> | ||
| 28 | |||
| 29 | <div class="ctrlHolder<!--ISURLERROR-->"> | ||
| 30 | <!--BEGIN URLERROR--> | ||
| 31 | <p id="error<!--URLERROR.ID-->" class="errorField"><strong><!--URLERROR.TEXT--></strong></p> | ||
| 32 | <!--END URLERROR--> | ||
| 33 | <label for="url">URL</label> | ||
| 34 | <input type="text" name="url" id="url" value="<!--URLVALUE-->" /> | ||
| 35 | </div> | ||
| 36 | |||
| 37 | <div class="ctrlHolder<!--ISTYPEERROR-->"> | ||
| 38 | <!--BEGIN TYPEERROR--> | ||
| 39 | <p id="error<!--TYPEERROR.ID-->" class="errorField"><strong><!--TYPEERROR.TEXT--></strong></p> | ||
| 40 | <!--END TYPEERROR--> | ||
| 41 | <p class="label"><em>*</em> Link Type</p> | ||
| 42 | <div class="multiField"> | ||
| 43 | <label for="type_affiliates" class="inlineLabel"><input name="type" id="type_affiliates" value="affiliates" type="radio"<!--AFFILIATESSELECTED--><!--TYPEDISABLED--> /> Affiliates</label> | ||
| 44 | <label for="type_webprojs" class="inlineLabel"><input name="type" id="type_webprojs" value="webprojs" type="radio"<!--WEBPROJSSELECTED--><!--TYPEDISABLED--> /> Website Projects</label> | ||
| 45 | </div> | ||
| 46 | </div> | ||
| 47 | </fieldset> | ||
| 48 | |||
| 49 | <div class="buttonHolder"> | ||
| 50 | <button type="reset" class="resetButton">Reset</button> | ||
| 51 | <button type="submit" class="primaryAction">Submit</button> | ||
| 52 | </div> | ||
| 53 | </form> | ||
