id = (int)$_GET['id'];
}
function setListSize( $size )
{
if ( is_numeric( $size ) )
$this->list_size = $size;
}
function getMenu()
{
$query = "SELECT id,url,text FROM menu ORDER BY 'id' ASC";
$result = mysql_query ($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$url = $row['url'];
$text = $row['text'];
echo "
" . $text . "\n";
}
}
function getPage()
{
if(is_numeric($this->id))
{
if($this->id == "2")
{
$this->getNews();
}
if($this->id == "5")
{
$this->getResults();
}
if($this->id == "6")
{
$this->getSingleResult();
}
if($this->id == "7")
{
$this->getGallery();
}
if($this->id == "8")
{
$this->getGuestbook();
}
if($this->id == "9")
{
$this->getContact();
}else{
$query = "SELECT * FROM pages WHERE id = ".$this->id;
$result = mysql_query($query);
while ($row = mysql_fetch_assoc ($result)) {
$id = $row['id'];
$title = $row['title'];
$text = $row['text'];
echo "$title
\n";
echo $text;
}//endwhile
}
}//endnumeric
}//endfunction
function getSidebar()
{
$query = "SELECT * FROM sidebar";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$title = $row['title'];
$text = $row['text'];
echo "$title
\n";
echo $text;
}
function getContact()
{
echo '
Contact us
';
}
function getNews()
{
$query = "SELECT id, title, text, DATE_FORMAT(date, '%d/%m %Y') as date FROM news ORDER by id";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc ($result)) {
$id = $row['id'];
$title = $row['title'];
$date = $row['date'];
$text = $row['text'];
echo "\n";
echo "
$date
\n";
echo "
$text
\n";
echo "
\n";
}
}
function getResults()
{
$query = "SELECT id, title, result, date FROM results ORDER by id";
$result = mysql_query($query);
echo "Results
";
while ($row = mysql_fetch_assoc ($result)) {
$id = $row['id'];
$title = $row['title'];
$date = $row['date'];
echo "- $title - $date
\n";
}
echo "
";
}
function getSingleResult()
{
$resultid = $_GET['result'];
$query = "SELECT * FROM results WHERE id=$resultid";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc ($result)) {
$title = $row['title'];
$date = $row['date'];
$text = $row['result'];
echo "$title
\n";
echo $text;
}
}
function getgallery()
{
//INSERT
}
############# CAPTCHA
function createCaptcha()
{
$_SESSION["captcha"] = "";
for ($i = 0; $i < 5; $i++) {
$_SESSION["captcha"] .= chr(rand(65, 90));
}
}
function ensureCaptcha()
{
if (!isset($_SESSION["captcha"])) {
createCaptcha();
}
}
function getGuestbook()
{
ensureCaptcha();
$invalidCaptcha = false;
echo 'Guestbook
';
$query = "SELECT * FROM guestbook ORDER by id ASC";
while ( $row = mysql_fecth_assoc($query)) {
$id = $row['id'];
$name = $row['name'];
$date = $row['date'];
$email = $row['email'];
$url = $row['url'];
$text = $row['text'];
echo '
';
echo '';
echo '
'.$url.'
'.$email.'
'.$text.'
';
echo '
';
}
echo '
';
if( isset($_POST["submit"])) {
if (strtoupper($_POST["captcha"]) != $_SESSION["captcha"]) {
$invalidCaptcha = true;
createCaptcha();
} else {
$name = $_POST['name'];
$url = $_POST['url'];
$email = $_POST['email'];
$text = $_POST['text'];
$query = "INSERT INTO guestbook(name, date, url, text) VALUES ('$name','','$url','$email','$text');";
if( mysql_query($query))
{
echo "Your query was saved!";
}
}
if ($invalidCaptcha) { ?>
The verification code was invalid!
Besøkende: $count";
}
}//end class
?>