<?php
// =======================================================================
// Module name: Pages
// File name: pages.inc
// Version: 1.0
// Description: This script contains php code for website pages.
//
// Comments are included within this script to document changes made to
// the code with each new version of the script. Each comment also lists
// the author's initials to document who made the changes to the code.
//
// Copyright (C) 2006-2010 Dustin Cowell Enterprises
//
// License: GNU General Public License, Version 2
//
// Link: http://www.gnu.org/licenses/gpl-2.0.txt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to:
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301 USA
// =======================================================================
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($request == "install" and $admin_rights == "Admin") {
echo("<b>Pages - Install Module</b><p>");
$db_lookup_admin_settings = @mysql_query("SELECT id FROM pages");
$db_pages = @mysql_fetch_array($db_lookup_pages);
if ($db_pages) {
echo("This module is already installed. The current installation must be uninstalled before a new installation can be created");
} else {
echo("Click the link below to install this module.<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?include=$include&request=run_install'>" . $link_color . "Install</font></a>]");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($request == "run_install" and $admin_rights == "Admin") {
if ($install_type != "express") {
echo("<b>Pages - Install Module</b><p>");
}
$db_create_pages = "CREATE TABLE pages (" .
"id int not null auto_increment primary key, " .
"title text, " .
"page text, " .
"file_name text, " .
"content text, " .
"meta_title text, " .
"meta_description text, " .
"meta_keywords text" .
")";
$db_create_pages_images = "CREATE TABLE pages_images (" .
"id int not null auto_increment primary key, " .
"pages_id text, " .
"file_name text, " .
"file_path text" .
")";
if ($install_type != "express") {
echo("Pages Installation Status:<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
}
echo("<tr>");
echo("<td>" . $font_body . "Pages Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./pages")) {
chmod("./pages", 0755);
echo "Exists, set permissions";
} else {
mkdir("./pages", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Pages Images Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./pages_images")) {
chmod("./pages", 0755);
echo "Exists, set permissions";
} else {
mkdir("./pages_images", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
$home_page_content = "Welcome to $db_themes_website_name!";
$home_page_content = str_replace("\\", "", $home_page_content);
$file = "pages/home.inc";
$method = fopen($file, 'w');
fwrite($method, $home_page_content);
fclose($method);
$home_page_content = htmlspecialchars($home_page_content, ENT_QUOTES);
$home_page_content = str_replace("\\", "", $home_page_content);
$db_insert_pages_home = "INSERT INTO pages SET " .
"title = 'Home', " .
"page = 'home', " .
"file_name = 'home.inc', " .
"content = '$home_page_content'";
$about_page_content = "This page will contain information about $db_themes_website_name.";
$about_page_content = str_replace("\\", "", $about_page_content);
$file = "pages/about.inc";
$method = fopen($file, 'w');
fwrite($method, $about_page_content);
fclose($method);
$about_page_content = htmlspecialchars($about_page_content, ENT_QUOTES);
$about_page_content = str_replace("\\", "", $about_page_content);
$db_insert_pages_about = "INSERT INTO pages SET " .
"title = 'About', " .
"page = 'about', " .
"file_name = 'about.inc', " .
"content = '$about_page_content'";
$policies_page_content = "This page will contain $db_themes_website_name\'s policies.";
$policies_page_content = str_replace("\\", "", $policies_page_content);
$file = "pages/policies.inc";
$method = fopen($file, 'w');
fwrite($method, $policies_page_content);
fclose($method);
$policies_page_content = htmlspecialchars($policies_page_content, ENT_QUOTES);
$policies_page_content = str_replace("\\", "", $policies_page_content);
$db_insert_pages_policies = "INSERT INTO pages SET " .
"title = 'Policies', " .
"page = 'policies', " .
"file_name = 'policies.inc', " .
"content = '$policies_page_content'";
$db_insert_pages_contact = "INSERT INTO pages SET " .
"title = 'Contact', " .
"page = 'contact', " .
"file_name = 'contact.php'";
$old_file = 'contact.php';
$new_file = './pages/contact.php';
echo("<tr>");
echo("<td>" . $font_body . "Pages Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_pages)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Pages Images Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_pages_images)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Pages Home</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_pages_home)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Pages About</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_pages_about)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Pages Policies</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_pages_policies)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Pages Contact</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_pages_contact)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Copy Contact File</font></td>");
echo("<td>" . $font_body . "");
if (rename($old_file, $new_file)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
$db_lookup_admin_menu_categories = @mysql_query("SELECT id FROM admin_menu_categories WHERE name='Website'");
$db_admin_menu_categories = @mysql_fetch_array($db_lookup_admin_menu_categories);
$db_admin_menu_categories_id = $db_admin_menu_categories['id'];
if (!$db_admin_menu_categories_id) {
$db_insert_admin_menu_categories_website = "INSERT INTO admin_menu_categories SET " .
"name = 'Website'";
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Categories Website</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_categories_website)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
}
$db_lookup_admin_menu_categories = @mysql_query("SELECT id FROM admin_menu_categories WHERE name='Website'");
$db_admin_menu_categories = @mysql_fetch_array($db_lookup_admin_menu_categories);
$db_admin_menu_categories_id = $db_admin_menu_categories['id'];
$db_insert_admin_menu_pages = "INSERT INTO admin_menu SET " .
"menu_categories_id = '$db_admin_menu_categories_id', " .
"name = 'Pages', " .
"include_file = 'pages.inc', " .
"page = 'pages'";
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Pages</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_pages)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Pages'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
if (!$db_menu_categories_id) {
$db_insert_menu_categories = "INSERT INTO menu_categories SET " .
"name = 'Pages', " .
"left_right = 'Left'";
echo("<tr>");
echo("<td>" . $font_body . "Insert Pages Menu Categories</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_menu_categories)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
}
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Pages'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_insert_menu_home = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = 'Home', " .
"include_file = '../pages/home.inc', " .
"page = 'home'";
$db_insert_menu_about = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = 'About', " .
"include_file = '../pages/about.inc', " .
"page = 'about'";
$db_insert_menu_contact = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = 'Contact', " .
"include_file = '../pages/contact.php', " .
"page = 'contact'";
$db_insert_menu_policies = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = 'Policies', " .
"include_file = '../pages/policies.inc', " .
"page = 'policies'";
echo("<tr>");
echo("<td>" . $font_body . "Insert Menu Home</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_menu_home)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Menu About</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_menu_about)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Menu Contact</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_menu_contact)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Menu Policies</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_menu_policies)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
if ($install_type != "express") {
echo("</table>");
echo("<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and !$request and $admin_rights) {
echo("<b>Pages</b><p>");
$db_lookup_pages = @mysql_query("SELECT id FROM pages");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_id = $db_pages['id'];
if ($db_pages_id) {
// ==================== START OF PAGE # HEADER ====================
if ($_POST["results_per_page"]) {
$results_per_page = $_POST["results_per_page"];
$_SESSION['results_per_page'] = $results_per_page;
} else {
if (!$_SESSION['results_per_page']) {
$results_per_page=10;
}
}
if ($_GET["start_page"]) {
$start_page = $_GET["start_page"];
} else {
$start_page=1;
}
$start_from = ($start_page-1) * $results_per_page;
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_pages = @mysql_query("SELECT COUNT(id) FROM pages");
$row = @mysql_fetch_row($db_count_pages);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=pages&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # HEADER ====================
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page'>" . $link_color . "New</font></a>] ");
echo("<p><table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Title</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_pages = @mysql_query("SELECT id, title FROM pages ORDER BY title ASC LIMIT $start_from, $results_per_page");
while ($db_pages = @mysql_fetch_array($db_lookup_pages)) {
$db_pages_id = $db_pages['id'];
$db_pages_title = $db_pages['title'];
echo("<tr>");
echo("<td>" . $font_body . $db_pages_title . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=view_page&page_id=" . $db_pages_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=" . $db_pages_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=delete_page&page_id=" . $db_pages_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page'>" . $link_color . "New</font></a>] ");
// ==================== START OF PAGE # FOOTER ====================
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_pages = @mysql_query("SELECT COUNT(id) FROM pages");
$row = @mysql_fetch_row($db_count_pages);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=pages&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # FOOTER ====================
} else {
echo("No pages were found in the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page'>" . $link_color . "New</font></a>]<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_page" and $admin_rights) {
echo("<b>Pages - New Page</b><p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page_create'>" . $link_color . "Create New Page</font></a>]<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page_upload'>" . $link_color . "Upload New Page</font></a>]<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_page_create" and $admin_rights) {
echo("<b>Pages - Create New Page</b><p>");
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page_create_submit' method='post'>");
echo("<b>Title:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<input type='text' name='title' maxlength='200'></font></td>");
echo("</tr>");
echo("<tr>");
echo("</table>");
echo("<p>");
echo("<b>Page content:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<textarea rows='20' cols='70' name='content'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Use of HTML code is allowed. Examples: <b><b>bold</b></b> <i><i>italic</i></i> <u><u>underline</u></u><br><a href='http://www.google.com'><a href='http://www.google.com'>example link to google</a></a>.<p>To insert an image into your content, insert the code <img src='./pages_images/xxxxxxxxxx.xxx'>. After inserting the code, upload the image file below. Change \"xxxxxxxxxx.xxx\" in the image code to match the image file name of the image you are uploading.</font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Page images:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_1'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_11'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_2'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_12'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_3'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_13'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_4'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_14'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_5'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_15'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_6'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_16'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_7'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_17'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_8'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_18'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_9'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_19'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_10'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_20'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<input type='submit' name ='submit' value ='Submit'><p>");
echo("</form>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_page_create_submit" and $admin_rights) {
echo("<b>Pages - Create New Page</b><p>");
$title = $_POST['title'];
$content = $_POST['content'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if (!$meta_title) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$title";
$meta_title = substr($meta_title, 0, 60);
}
if (!$meta_description) {
$meta_description = "$content";
$meta_description = substr($meta_description, 0, 140);
}
if (!$meta_keywords) {
$meta_keywords = strtolower($content);
$common_words = array ('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','lot','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero',' \'');
$meta_keywords = preg_replace('/\b('.implode('|',$common_words).')\b/','',$meta_keywords);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
}
$title_original = $title;
$title = strtolower($title);
$title = str_replace("\'", "", $title);
$title = str_replace("\"", "", $title);
$title = preg_replace("/[^A-Za-z0-9]/","",$title);
$page_name = str_replace(' ', '_', $title);
$file_name = $page_name . ".inc";
$db_lookup_pages = @mysql_query("SELECT id FROM pages WHERE title='$title' and content='$content'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_id = $db_pages['id'];
if ($db_pages_id) {
echo("Page already exists in database, duplicates are not allowed.");
} else {
$static_page_content = $content;
$static_page_content = str_replace("\'", "'", $static_page_content);
$content = htmlspecialchars($content, ENT_QUOTES);
$db_insert_pages = "INSERT INTO pages SET " .
"title = '$title_original', " .
"page = '$page_name', " .
"file_name = '$file_name', " .
"content = '$content', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'";
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Pages'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_insert_menu = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$title_original', " .
"include_file = '../pages/$file_name', " .
"page = '$page_name'";
if (@mysql_query($db_insert_pages) and @mysql_query($db_insert_menu)) {
echo("Page creation successful.<p>");
$db_lookup_pages = @mysql_query("SELECT id FROM pages WHERE title='$title' and content='$content'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_id = $db_pages['id'];
$static_page_content = str_replace("\r", '<br>', $static_page_content);
$static_page_content = str_replace("\n", "<p>", $static_page_content);
$static_page_content = str_replace("<br><p><br><p>", "<p>", $static_page_content);
$static_page_content = str_replace("<br><p>", "<br>", $static_page_content);
$static_page_content = str_replace("\\", "", $static_page_content);
$static_page_content = str_replace('"', '\"', $static_page_content);
$file = "pages/$file_name";
$method = fopen($file, 'w');
$data = "<?php\r\r";
fwrite($method, $data);
$data = "echo(\"";
fwrite($method, $data);
fwrite($method, $static_page_content);
$data = "\");";
fwrite($method, $data);
$data = "\r\r?>";
fwrite($method, $data);
fclose($method);
$uploadedfile_1 = $_FILES['image_1']['tmp_name'];
$uploadedfile_2 = $_FILES['image_2']['tmp_name'];
$uploadedfile_3 = $_FILES['image_3']['tmp_name'];
$uploadedfile_4 = $_FILES['image_4']['tmp_name'];
$uploadedfile_5 = $_FILES['image_5']['tmp_name'];
$uploadedfile_6 = $_FILES['image_6']['tmp_name'];
$uploadedfile_7 = $_FILES['image_7']['tmp_name'];
$uploadedfile_8 = $_FILES['image_8']['tmp_name'];
$uploadedfile_9 = $_FILES['image_9']['tmp_name'];
$uploadedfile_10 = $_FILES['image_10']['tmp_name'];
$uploadedfile_11 = $_FILES['image_11']['tmp_name'];
$uploadedfile_12 = $_FILES['image_12']['tmp_name'];
$uploadedfile_13 = $_FILES['image_13']['tmp_name'];
$uploadedfile_14 = $_FILES['image_14']['tmp_name'];
$uploadedfile_15 = $_FILES['image_15']['tmp_name'];
$uploadedfile_16 = $_FILES['image_16']['tmp_name'];
$uploadedfile_17 = $_FILES['image_17']['tmp_name'];
$uploadedfile_18 = $_FILES['image_18']['tmp_name'];
$uploadedfile_19 = $_FILES['image_19']['tmp_name'];
$uploadedfile_20 = $_FILES['image_20']['tmp_name'];
if ($uploadedfile_1) {
$image_count = 1;
}
if ($uploadedfile_2) {
$image_count = 2;
}
if ($uploadedfile_3) {
$image_count = 3;
}
if ($uploadedfile_4) {
$image_count = 4;
}
if ($uploadedfile_5) {
$image_count = 5;
}
if ($uploadedfile_6) {
$image_count = 6;
}
if ($uploadedfile_7) {
$image_count = 7;
}
if ($uploadedfile_8) {
$image_count = 8;
}
if ($uploadedfile_9) {
$image_count = 9;
}
if ($uploadedfile_10) {
$image_count = 10;
}
if ($uploadedfile_11) {
$image_count = 11;
}
if ($uploadedfile_12) {
$image_count = 12;
}
if ($uploadedfile_13) {
$image_count = 13;
}
if ($uploadedfile_14) {
$image_count = 14;
}
if ($uploadedfile_15) {
$image_count = 15;
}
if ($uploadedfile_16) {
$image_count = 16;
}
if ($uploadedfile_17) {
$image_count = 17;
}
if ($uploadedfile_18) {
$image_count = 18;
}
if ($uploadedfile_19) {
$image_count = 19;
}
if ($uploadedfile_20) {
$image_count = 20;
}
while ($image_count > 0) {
$uploadedfile = $_FILES["image_" . $image_count]['tmp_name'];
$file_type = $_FILES["image_" . $image_count]['type'];
$file_name = $_FILES["image_" . $image_count]['name'];
if ($file_name) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if ($width>$height) {
if ($width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=500;
$large_height=($height/$width)*500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width<$height) {
if ($height <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width == $height) {
if ($height <= "500" || $width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
$large_file = "./pages_images/". $file_name;
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($large_tmp,$large_file);
}
if ($file_type == "image/gif") {
imagegif($large_tmp,$large_file);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($large_tmp,$large_file);
}
$large_file_path = addslashes($large_file);
$large_file_name = $file_name;
imagedestroy($src);
imagedestroy($large_tmp);
$db_insert_pages_images = "INSERT INTO pages_images SET " .
"pages_id = '$db_pages_id', " .
"file_name = '$large_file_name', " .
"file_path = '$large_file_path'";
@mysql_query($db_insert_pages_images);
}
if ($image_count == "1") {
echo "Page images were successfully uploaded.";
}
$image_count = $image_count - 1;
}
} else {
echo("Page creation error.<p>");
}
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_page_upload" and $admin_rights) {
echo("<b>Pages - Upload New Page</b><p>");
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page_upload_submit' method='post'>");
echo("<b>Title:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<input type='text' name='title' maxlength='200'></font></td>");
echo("</tr>");
echo("<tr>");
echo("</table>");
echo("<p>");
echo("<b>Page file:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<input type='file' name ='page_file'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Page images:</b><p>");
echo("Images included in the page file should have image paths in the following format:<br><img src='./pages_images/xxxxxxxxxx.xxx'>.<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_1'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_11'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_2'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_12'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_3'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_13'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_4'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_14'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_5'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_15'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_6'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_16'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_7'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_17'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_8'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_18'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_9'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_19'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_10'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_20'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<input type='submit' name ='submit' value ='Submit'><p>");
echo("</form>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_page_upload_submit" and $admin_rights) {
echo("<b>Pages - Upload New Page</b><p>");
$title = $_POST['title'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if (!$meta_title) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$title";
$meta_title = substr($meta_title, 0, 60);
}
if (!$meta_description) {
$meta_description = "$title page on $db_themes_website_name";
}
if (!$meta_keywords) {
$meta_keywords = "$title, $db_themes_website_name";
}
$title_original = $title;
$title = strtolower($title);
$title = str_replace("\'", "", $title);
$title = str_replace("\"", "", $title);
$title = preg_replace("/[^A-Za-z0-9]/","",$title);
$page_name = str_replace(' ', '_', $title);
$uploaded_file = $_FILES["page_file"]["tmp_name"];
$file_name = $_FILES["page_file"]["name"];
$file_type = $_FILES["page_file"]["type"];
if ($file_type == "text/html") {
if (file_exists("./pages/" . $file_name)) {
echo "Page already exists.<p>";
} else {
if (move_uploaded_file($uploaded_file, "./pages/" . $file_name)) {
$db_insert_pages = "INSERT INTO pages SET " .
"title = '$title_original', " .
"page = '$page_name', " .
"file_name = '$file_name', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'";
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Pages'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_insert_menu_page_upload = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$title_original', " .
"include_file = '../pages/$file_name', " .
"page = '$page_name'";
$db_insert_pages_result = @mysql_query($db_insert_pages);
$db_insert_menu_page_upload_result = @mysql_query($db_insert_menu_page_upload);
if ($db_insert_pages_result and $db_insert_menu_page_upload_result) {
echo "Page upload successful.<p>";
$db_lookup_pages = @mysql_query("SELECT id FROM pages WHERE title='$title_original' and file_name='$file_name'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_id = $db_pages['id'];
$uploadedfile_1 = $_FILES['image_1']['tmp_name'];
$uploadedfile_2 = $_FILES['image_2']['tmp_name'];
$uploadedfile_3 = $_FILES['image_3']['tmp_name'];
$uploadedfile_4 = $_FILES['image_4']['tmp_name'];
$uploadedfile_5 = $_FILES['image_5']['tmp_name'];
$uploadedfile_6 = $_FILES['image_6']['tmp_name'];
$uploadedfile_7 = $_FILES['image_7']['tmp_name'];
$uploadedfile_8 = $_FILES['image_8']['tmp_name'];
$uploadedfile_9 = $_FILES['image_9']['tmp_name'];
$uploadedfile_10 = $_FILES['image_10']['tmp_name'];
$uploadedfile_11 = $_FILES['image_11']['tmp_name'];
$uploadedfile_12 = $_FILES['image_12']['tmp_name'];
$uploadedfile_13 = $_FILES['image_13']['tmp_name'];
$uploadedfile_14 = $_FILES['image_14']['tmp_name'];
$uploadedfile_15 = $_FILES['image_15']['tmp_name'];
$uploadedfile_16 = $_FILES['image_16']['tmp_name'];
$uploadedfile_17 = $_FILES['image_17']['tmp_name'];
$uploadedfile_18 = $_FILES['image_18']['tmp_name'];
$uploadedfile_19 = $_FILES['image_19']['tmp_name'];
$uploadedfile_20 = $_FILES['image_20']['tmp_name'];
if ($uploadedfile_1) {
$image_count = 1;
}
if ($uploadedfile_2) {
$image_count = 2;
}
if ($uploadedfile_3) {
$image_count = 3;
}
if ($uploadedfile_4) {
$image_count = 4;
}
if ($uploadedfile_5) {
$image_count = 5;
}
if ($uploadedfile_6) {
$image_count = 6;
}
if ($uploadedfile_7) {
$image_count = 7;
}
if ($uploadedfile_8) {
$image_count = 8;
}
if ($uploadedfile_9) {
$image_count = 9;
}
if ($uploadedfile_10) {
$image_count = 10;
}
if ($uploadedfile_11) {
$image_count = 11;
}
if ($uploadedfile_12) {
$image_count = 12;
}
if ($uploadedfile_13) {
$image_count = 13;
}
if ($uploadedfile_14) {
$image_count = 14;
}
if ($uploadedfile_15) {
$image_count = 15;
}
if ($uploadedfile_16) {
$image_count = 16;
}
if ($uploadedfile_17) {
$image_count = 17;
}
if ($uploadedfile_18) {
$image_count = 18;
}
if ($uploadedfile_19) {
$image_count = 19;
}
if ($uploadedfile_20) {
$image_count = 20;
}
while ($image_count > 0) {
$uploadedfile = $_FILES["image_" . $image_count]['tmp_name'];
$file_type = $_FILES["image_" . $image_count]['type'];
$file_name = $_FILES["image_" . $image_count]['name'];
if ($file_name) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if ($width>$height) {
if ($width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=500;
$large_height=($height/$width)*500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width<$height) {
if ($height <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width == $height) {
if ($height <= "500" || $width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
$large_file = "./pages_images/". $file_name;
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($large_tmp,$large_file);
}
if ($file_type == "image/gif") {
imagegif($large_tmp,$large_file);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($large_tmp,$large_file);
}
$large_file_path = addslashes($large_file);
$large_file_name = $file_name;
imagedestroy($src);
imagedestroy($large_tmp);
$db_insert_pages_images = "INSERT INTO pages_images SET " .
"pages_id = '$db_pages_id', " .
"file_name = '$large_file_name', " .
"file_path = '$large_file_path'";
@mysql_query($db_insert_pages_images);
}
if ($image_count == "1") {
echo "Page images were successfully uploaded.";
}
$image_count = $image_count - 1;
}
}
}
}
} else {
echo "Error: Page file extension must be either .htm or .html format. Please make sure file is in the correct format and try again.<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page_upload'>" . $link_color . "Upload New Page</font></a>]";
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "view_page" and $admin_rights) {
echo("<b>Pages - View Page</b><p>");
$page_id = $_GET['page_id'];
$db_lookup_pages = @mysql_query("SELECT title, file_name, meta_title, meta_description, meta_keywords FROM pages WHERE id='$page_id'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_title = $db_pages['title'];
$db_pages_file_name = $db_pages['file_name'];
$db_pages_meta_title = $db_pages['meta_title'];
$db_pages_meta_description = $db_pages['meta_description'];
$db_pages_meta_keywords = $db_pages['meta_keywords'];
echo "<b>Title:</b><p>$db_pages_title<p>";
echo "<b>Page content:</b><p>";
include("./pages/" . $db_pages_file_name);
echo "<p><b>Search Engine Marketing:</b><p>";
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</td>");
echo("<td>" . $font_body . $db_pages_meta_title . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</td>");
echo("<td>" . $font_body . $db_pages_meta_description . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</td>");
echo("<td>" . $font_body . $db_pages_meta_keywords . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "edit_page" and $admin_rights) {
echo("<b>Pages - Edit Page</b><p>");
$page_id = $_GET['page_id'];
$db_lookup_pages = @mysql_query("SELECT title, file_name, content, meta_title, meta_description, meta_keywords FROM pages WHERE id='$page_id'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_title = $db_pages['title'];
$db_pages_file_name = $db_pages['file_name'];
$db_pages_content = $db_pages['content'];
$db_pages_meta_title = $db_pages['meta_title'];
$db_pages_meta_description = $db_pages['meta_description'];
$db_pages_meta_keywords = $db_pages['meta_keywords'];
if ($db_pages_content) {
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page_submit' method='post'>");
echo("<input type='hidden' name='page_id' value='$page_id'>");
echo("<input type='hidden' name='upload_type' value='content'>");
echo("<b>Title:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<input type='text' name='title' value='$db_pages_title' maxlength='200'></font></td>");
echo("</tr>");
echo("<tr>");
echo("</table>");
echo("<p>");
echo("<b>Page content:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<textarea rows='20' cols='70' name='content'>$db_pages_content</textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
$db_pages_meta_title = htmlspecialchars("$db_pages_meta_title", ENT_QUOTES);
echo("<td>" . $font_body . "<input type='text' name='meta_title' value='$db_pages_meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'>$db_pages_meta_description</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'>$db_pages_meta_keywords</textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<input type='submit' name ='submit' value ='Update'><p>");
echo("</form>");
echo("<b>Instructions:</b><p>Use of HTML code is allowed. Examples: <b><b>bold</b></b> <i><i>italic</i></i> <u><u>underline</u></u><br><a href='http://www.google.com'><a href='http://www.google.com'>example link to google</a></a>.<p>To insert an image into your content, insert the image code below the images shown below.");
} else {
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page_submit' method='post'>");
echo("<input type='hidden' name='page_id' value='$page_id'>");
echo("<input type='hidden' name='upload_type' value='file'>");
echo("<b>Title:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<input type='text' name='title' value='$db_pages_title' maxlength='200'></font></td>");
echo("</tr>");
echo("<tr>");
echo("</table>");
echo("<p>");
echo("<b>Page file:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Current file: </font></td>");
echo("<td>" . $font_body . "$db_pages_file_name</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Replace with: </font></td>");
echo("<td>" . $font_body . "<input type='file' name ='page_file'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
$db_pages_meta_title = htmlspecialchars("$db_pages_meta_title", ENT_QUOTES);
echo("<td>" . $font_body . "<input type='text' name='meta_title' value='$db_pages_meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'>$db_pages_meta_description</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'>$db_pages_meta_keywords</textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<input type='submit' name ='submit' value ='Update'><p>");
echo("</form>");
}
echo("<b>Images:</b>");
$db_lookup_pages_images = @mysql_query("SELECT id FROM pages_images WHERE pages_id='$page_id'");
$db_pages_images = @mysql_fetch_array($db_lookup_pages_images);
$db_pages_images_id = $db_pages_images['id'];
if ($db_pages_images_id) {
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_pages_images&page_id=$page_id'>" . $link_color . "Add Images</font></a>]<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
$db_lookup_pages_images = @mysql_query("SELECT id, file_name FROM pages_images WHERE pages_id='$page_id' ORDER BY id DESC");
while ($db_pages_images = @mysql_fetch_array($db_lookup_pages_images)) {
$db_pages_images_id = $db_pages_images['id'];
$db_pages_images_file_name = $db_pages_images['file_name'];
echo("<tr>");
echo("<td><img border='0' src='./pages_images/" . $db_pages_images_file_name . "'></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image code: <img src='./pages_images/$db_pages_images_file_name'></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body);
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=view_pages_images&pages_images_id=$db_pages_images_id&page_id=$page_id'>" . $link_color . "View</font></a>]<br>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=delete_pages_images&pages_images_id=$db_pages_images_id&page_id=$page_id'>" . $link_color . "Delete</font></a>]<br> ");
echo ("</td>");
echo("</tr>");
}
echo("</table>");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_pages_images&page_id=$page_id'>" . $link_color . "Add Images</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "edit_page_submit" and $admin_rights) {
echo("<b>Pages - Edit Page</b><p>");
$page_id = $_POST['page_id'];
$title = $_POST['title'];
$content = $_POST['content'];
$upload_type = $_POST['upload_type'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if (!$meta_title) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$title";
$meta_title = substr($meta_title, 0, 60);
}
if ($upload_type == "content") {
if (!$meta_description) {
$meta_description = "$content";
$meta_description = substr($meta_description, 0, 140);
}
} else {
$meta_description = "$title page on $db_themes_website_name";
}
if ($upload_type == "content") {
if (!$meta_keywords) {
$meta_keywords = strtolower($content);
$common_words = array ('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','lot','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero',' \'');
$meta_keywords = preg_replace('/\b('.implode('|',$common_words).')\b/','',$meta_keywords);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
}
} else {
$meta_keywords = "$title, $db_themes_website_name";
}
$db_lookup_pages = @mysql_query("SELECT title, page, file_name FROM pages WHERE id='$page_id'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_original_title = $db_pages['title'];
$db_pages_original_page = $db_pages['page'];
$db_pages_original_file_name = $db_pages['file_name'];
if ($upload_type == "content") {
$title_original = $title;
$title = strtolower($title);
$title = str_replace("\'", "", $title);
$title = str_replace("\"", "", $title);
$page_name = str_replace(' ', '_', $title);
$file_name = $page_name . ".inc";
$static_page_content = $content;
$static_page_content = str_replace("\'", "'", $static_page_content);
$content = htmlspecialchars($content, ENT_QUOTES);
$db_update_pages = "UPDATE pages SET " .
"title = '$title_original', " .
"page = '$page_name', " .
"file_name = '$file_name', " .
"content = '$content', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'" .
"WHERE id = '$page_id'";
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Pages'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_update_menu = "UPDATE menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$title_original', " .
"include_file = '../pages/$file_name', " .
"page = '$page_name'" .
"WHERE name = '$db_pages_original_title' and page = '$db_pages_original_page'";
if (@mysql_query($db_update_pages) and @mysql_query($db_update_menu)) {
echo("Page updated successfully.<p>");
$static_page_content = str_replace("\r", '<br>', $static_page_content);
$static_page_content = str_replace("\n", "<p>", $static_page_content);
$static_page_content = str_replace("<br><p><br><p>", "<p>", $static_page_content);
$static_page_content = str_replace("<br><p>", "<br>", $static_page_content);
$static_page_content = str_replace("\\", "", $static_page_content);
$static_page_content = str_replace('"', '\"', $static_page_content);
$old_file_name = "./pages/" . $db_pages_original_file_name;
unlink($old_file_name);
$file = "pages/$file_name";
$method = fopen($file, 'w');
$data = "<?php\r\r";
fwrite($method, $data);
$data = "echo(\"";
fwrite($method, $data);
fwrite($method, $static_page_content);
$data = "\");";
fwrite($method, $data);
$data = "\r\r?>";
fwrite($method, $data);
fclose($method);
}
}
if ($upload_type == "file") {
$title_original = $title;
$title = strtolower($title);
$page_name = str_replace(' ', '_', $title);
$uploaded_file = $_FILES["page_file"]["tmp_name"];
$file_name = $_FILES["page_file"]["name"];
$file_type = $_FILES["page_file"]["type"];
if ($file_type == "text/html") {
unlink("./pages/" . $db_pages_original_file_name);
if (move_uploaded_file($uploaded_file, "./pages/" . $file_name)) {
$db_update_pages = "UPDATE pages SET " .
"title = '$title_original', " .
"page = '$page_name', " .
"file_name = '$file_name'" .
"WHERE id = '$page_id'";
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Pages'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_update_menu_page_upload = "UPDATE menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$title_original', " .
"include_file = '../pages/$file_name', " .
"page = '$page_name'" .
"WHERE name = '$db_pages_original_title' and page = '$db_pages_original_page'";
$db_update_pages_result = @mysql_query($db_update_pages);
$db_update_menu_page_upload_result = @mysql_query($db_update_menu_page_upload);
if ($db_update_pages_result and $db_update_menu_page_upload_result) {
echo "Page updated successfully.<p>";
}
}
} else {
echo "Error: Page file extension must be either .htm or .html format. Please make sure file is in the correct format and try again.<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_page_upload'>" . $link_color . "Upload New Page</font></a>]";
}
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "delete_page" and $admin_rights == "Admin") {
echo("<b>Pages - Delete Page</b><p>");
$page_id = $_GET['page_id'];
$db_lookup_pages = @mysql_query("SELECT title FROM pages WHERE id='$page_id'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_title = $db_pages['title'];
echo("Page title: $db_pages_title<p>");
echo("<p>Are you sure you want to delete this page?<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=delete_page_submit&page_id=$page_id'>" . $link_color . "Yes</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=delete_page_cancel&page_id=$page_id'>" . $link_color . "No</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "delete_page_submit" and $admin_rights == "Admin") {
echo("<b>Pages - Delete Page</b><p>");
$page_id = $_GET['page_id'];
$db_lookup_pages = @mysql_query("SELECT title, page, file_name FROM pages WHERE id='$page_id'");
$db_pages = @mysql_fetch_array($db_lookup_pages);
$db_pages_title = $db_pages['title'];
$db_pages_page = $db_pages['page'];
$db_pages_file_name = $db_pages['file_name'];
$db_lookup_pages_images = @mysql_query("SELECT file_name FROM pages_images WHERE pages_id='$page_id'");
while ($db_pages_images = @mysql_fetch_array($db_lookup_pages_images)) {
$db_pages_images_file_name = $db_pages_images['file_name'];
$db_delete_pages_images_file_path = unlink("./pages_images/" . $db_pages_images_file_name);
}
$db_delete_pages_file_path = unlink("./pages/" . $db_pages_file_name);
$db_delete_pages = @mysql_query("DELETE FROM pages WHERE id='$page_id'");
$db_delete_pages_images = @mysql_query("DELETE FROM pages_images WHERE pages_id='$page_id'");
$db_delete_menu = @mysql_query("DELETE FROM menu WHERE page='$db_pages_page'");
if ($db_delete_pages and $db_delete_pages_images and $db_delete_pages_file_path and $db_delete_menu) {
echo("The page has been deleted.");
} else {
echo("Error deleting page.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "delete_page_cancel" and $admin_rights == "Admin") {
echo("<b>Pages - Delete Page</b><p>");
$page_id = $_GET['page_id'];
echo("The page has not been deleted.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_pages_images" and $admin_rights) {
echo("<b>Pages - Add Images</b><p>");
$page_id = $_GET['page_id'];
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=pages&request=new_pages_images_submit' method='post'>");
echo("<input type='hidden' name='page_id' value='$page_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_1'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_11'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_2'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_12'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_3'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_13'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_4'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_14'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_5'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_15'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_6'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_16'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_7'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_17'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_8'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_18'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_9'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_19'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_10'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_20'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p><input type='submit' name ='submit' value ='Submit'>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=$page_id'>" . $link_color . "Edit Page</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "pages" and $request == "new_pages_images_submit" and $admin_rights) {
echo("<b>Pages - Add Images</b><p>");
$page_id = $_POST['page_id'];
$uploadedfile_1 = $_FILES['image_1']['tmp_name'];
$uploadedfile_2 = $_FILES['image_2']['tmp_name'];
$uploadedfile_3 = $_FILES['image_3']['tmp_name'];
$uploadedfile_4 = $_FILES['image_4']['tmp_name'];
$uploadedfile_5 = $_FILES['image_5']['tmp_name'];
$uploadedfile_6 = $_FILES['image_6']['tmp_name'];
$uploadedfile_7 = $_FILES['image_7']['tmp_name'];
$uploadedfile_8 = $_FILES['image_8']['tmp_name'];
$uploadedfile_9 = $_FILES['image_9']['tmp_name'];
$uploadedfile_10 = $_FILES['image_10']['tmp_name'];
$uploadedfile_11 = $_FILES['image_11']['tmp_name'];
$uploadedfile_12 = $_FILES['image_12']['tmp_name'];
$uploadedfile_13 = $_FILES['image_13']['tmp_name'];
$uploadedfile_14 = $_FILES['image_14']['tmp_name'];
$uploadedfile_15 = $_FILES['image_15']['tmp_name'];
$uploadedfile_16 = $_FILES['image_16']['tmp_name'];
$uploadedfile_17 = $_FILES['image_17']['tmp_name'];
$uploadedfile_18 = $_FILES['image_18']['tmp_name'];
$uploadedfile_19 = $_FILES['image_19']['tmp_name'];
$uploadedfile_20 = $_FILES['image_20']['tmp_name'];
if ($uploadedfile_1) {
$image_count = 1;
}
if ($uploadedfile_2) {
$image_count = 2;
}
if ($uploadedfile_3) {
$image_count = 3;
}
if ($uploadedfile_4) {
$image_count = 4;
}
if ($uploadedfile_5) {
$image_count = 5;
}
if ($uploadedfile_6) {
$image_count = 6;
}
if ($uploadedfile_7) {
$image_count = 7;
}
if ($uploadedfile_8) {
$image_count = 8;
}
if ($uploadedfile_9) {
$image_count = 9;
}
if ($uploadedfile_10) {
$image_count = 10;
}
if ($uploadedfile_11) {
$image_count = 11;
}
if ($uploadedfile_12) {
$image_count = 12;
}
if ($uploadedfile_13) {
$image_count = 13;
}
if ($uploadedfile_14) {
$image_count = 14;
}
if ($uploadedfile_15) {
$image_count = 15;
}
if ($uploadedfile_16) {
$image_count = 16;
}
if ($uploadedfile_17) {
$image_count = 17;
}
if ($uploadedfile_18) {
$image_count = 18;
}
if ($uploadedfile_19) {
$image_count = 19;
}
if ($uploadedfile_20) {
$image_count = 20;
}
while ($image_count > 0) {
$uploadedfile = $_FILES["image_" . $image_count]['tmp_name'];
$file_type = $_FILES["image_" . $image_count]['type'];
$file_name = $_FILES["image_" . $image_count]['name'];
if ($file_name) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if ($width>$height) {
if ($width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=500;
$large_height=($height/$width)*500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width<$height) {
if ($height <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width == $height) {
if ($height <= "500" || $width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
$large_file = "./pages_images/". $file_name;
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($large_tmp,$large_file,80);
}
if ($file_type == "image/gif") {
imagegif($large_tmp,$large_file);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($large_tmp,$large_file);
}
$large_file_path = addslashes($large_file);
$large_file_name = $file_name;
imagedestroy($src);
imagedestroy($large_tmp);
$db_insert_pages_images = "INSERT INTO pages_images SET " .
"pages_id = '$page_id', " .
"file_name = '$large_file_name', " .
"file_path = '$large_file_path'";
@mysql_query($db_insert_pages_images);
}
if ($image_count == "1") {
echo "Pages images were successfully uploaded.";
}
$image_count = $image_count - 1;
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=$page_id'>" . $link_color . "Edit Page</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "view_pages_images" and $admin_rights) {
echo("<b>Pages - View Images</b><p>");
$page_id = $_GET['page_id'];
$pages_images_id = $_GET['pages_images_id'];
$db_lookup_pages_images = @mysql_query("SELECT id, file_name FROM pages_images WHERE id='$pages_images_id'");
$db_pages_images = @mysql_fetch_array($db_lookup_pages_images);
$db_pages_images_file_name = $db_pages_images['file_name'];
echo("<img border='0' src='./pages_images/" . $db_pages_images_file_name . "'>");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=$page_id'>" . $link_color . "Edit Page</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "delete_pages_images" and $admin_rights == "Admin") {
echo("<b>Pages - Delete Images</b><p>");
$page_id = $_GET['page_id'];
$pages_images_id = $_GET['pages_images_id'];
$db_lookup_pages_images = @mysql_query("SELECT id, pages_id, file_name FROM pages_images WHERE id='$pages_images_id'");
$db_pages_images = @mysql_fetch_array($db_lookup_pages_images);
$db_pages_images_id = $db_pages_images['id'];
$db_pages_images_pages_id = $db_pages_images['pages_id'];
$db_pages_images_file_name = $db_pages_images['file_name'];
echo("<img border='0' src='./pages_images/" . $db_pages_images_file_name . "'>");
echo("<p>Are you sure you want to delete this page image?<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=delete_pages_images_submit&page_id=$db_pages_images_pages_id&pages_images_id=$db_pages_images_id'>" . $link_color . "Yes</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=delete_pages_images_cancel&page_id=$db_pages_images_pages_id&pages_images_id=$db_pages_images_id'>" . $link_color . "No</font></a>] ");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=$db_pages_images_pages_id'>" . $link_color . "Edit Page</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "delete_pages_images_submit" and $admin_rights == "Admin") {
echo("<b>Pages - Delete Images</b><p>");
$page_id = $_GET['page_id'];
$pages_images_id = $_GET['pages_images_id'];
$db_lookup_pages_images = @mysql_query("SELECT file_name, file_path FROM pages_images WHERE id='$pages_images_id'");
$db_pages_images = @mysql_fetch_array($db_lookup_pages_images);
$db_pages_images_file_name = $db_pages_images['file_name'];
$db_pages_images_file_path = $db_pages_images['file_path'];
$db_delete_pages_images = @mysql_query("DELETE FROM pages_images WHERE id='$pages_images_id'");
$db_delete_pages_images_file_path = unlink("./pages_images/" . $db_pages_images_file_name);
if ($db_delete_pages_images and $db_delete_pages_images_file_path) {
echo("The page image has been deleted from the database.");
} else {
echo("Error deleting page image.");
}
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=$page_id'>" . $link_color . "Edit Page</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "pages" and $request == "delete_pages_images_cancel" and $admin_rights == "Admin") {
echo("<b>Pages - Delete Images</b><p>");
$page_id = $_GET['page_id'];
$pages_images_id = $_GET['pages_images_id'];
echo("The page image has not been deleted from the database.");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages&request=edit_page&page_id=$page_id'>" . $link_color . "Edit Page</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=pages'>" . $link_color . "Pages</font></a>]<p>");
}
?>