Location: PHPKode > projects > SOS Webpages > includes/queries.php
// +----------------------------------------------------------------------+
// SOS Webpages is an easy-to-manage website management system
// Copyright (C) 2007 - 2010 HandsomeWeb
// 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 3 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
// 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, see <http://www.gnu.org/licenses/>.
// Contact the author of this software at http://www.handsomeweb.com.
// +----------------------------------------------------------------------+

/*	includes/queries.php queries most of the data that is common site-wide. It also gets information about the page
	that is being build so that the correct module and correct template will be used. dbconnection.php is created
	at installation and contains database connection information. $dbprefix is the prefix on table names. */

// Define some variables

Require "dbconnection.php";

$dbh=mysql_connect($dbhhost,$dbhuser,$dbhpassword) or die ('I cannot connect to the database because: ' . mysql_error());

// Query Admin Data
$query = "SELECT * FROM " . $dbprefix . "hw_admin WHERE admin_id=1";

// Query Site Data
$query = "SELECT * FROM " . $dbprefix . "hw_site WHERE site_id=1";
$site_banner_image="uploads/" . mysql_result($result,$i,"site_banner_image");
$site_logo="uploads/" . mysql_result($result,$i,"site_logo");
$site_language_file="languages/" . mysql_result($result,$i,"site_language_file");

Require $site_language_file;

// Query Template Data
$query = "SELECT * FROM " . $dbprefix . "hw_templates WHERE templates_id='$site_templates_id'";

// Query Page Data using $pages_id (integer or default page loads to determine
// page $pages_uri is just in there to put keywords in URI for search engines

if (isset($_GET['pages_id'])) {
	$pages_id = trim(mysql_real_escape_string(stripslashes($_GET['pages_id'])));
	if (isset($_GET['pages_uri'])) {
		$pages_uri = trim(mysql_real_escape_string(stripslashes($_GET['pages_uri'])));
if ($pages_id=="" OR !preg_match( "/^([0-9])+$/", $pages_id)) $pages_id=$site_default_pages_id;
//Query the page
$query = "SELECT * FROM " . $dbprefix . "hw_pages WHERE pages_id='" . $pages_id . "'";
//If page does not exist re-query for default page
if ($num==0) {
	$query = "SELECT * FROM " . $dbprefix . "hw_pages WHERE pages_id='" . $site_default_pages_id . "'";

//Query Modules Data
$query = "SELECT * FROM " . $dbprefix . "hw_modules WHERE modules_id='$pages_modules_id'";

// Add an Edit link if the site administrator is logged in.
if (isset($_COOKIE["admin"])) {
	$admin = trim(mysql_real_escape_string(stripslashes($_COOKIE["admin"])));
	if ($admin=="admin") $site_long_description .= "<br/><br/><a class='admincontent' href='admin/admin_site_info.php?sitelink=true'>". EDIT_LONG_DESCRIPTION . "</a>";
Return current item: SOS Webpages