i have created simple php engine, i want that this engine used html/php codes from mysql. Here is this php code and please if you find out some mistakes or bugs, please post here. I realy want to use this code for my website but i want to be sure this code safe and bug fixed, so help!
<?php
session_start();
if (isset($_SESSION['last-update']) and isset($_SESSION['update-num'])){
if ($_SESSION['last-update'] == date('H:i') and $_SESSION['update-num'] > 30){die();}
if ($_SESSION['last-update'] == date('H:i')){$_SESSION['update-num'] = $_SESSION['update-num'] + 1;} else {$_SESSION['last-update'] = date('H:i'); $_SESSION['update-num'] = 0;}
} else {
$_SESSION['last-update'] = date('H:i');
$_SESSION['update-num'] = 0;
}
include("scripts/dbconnect.php");
mysql_select_db("website");
if (isset($_GET['page'])){
if (strlen($_GET['page']) > 50){die("incodrect URL !");}
$result = mysql_query("SELECT * FROM modules WHERE page = ';".mysql_real_escape_string($_GET['page']).";'");
} else {
$result = mysql_query("SELECT * FROM modules WHERE page LIKE ';home;'");
}
$modules = array('top-header1','top-header2','header','bottom-header','top-body1','top-body2','body-top', 'body-left', 'body-center', 'body-right', 'body-bottom', 'bottom-body', 'footer-top', 'footer', 'bottom-footer');
while($row = mysql_fetch_array($result)){
switch ($row['position']){
case 'top-header1':$modules['top-header1'][] = $row['source']; break;
case 'top-header2':$modules['top-header2'][] = $row['source']; break;
case 'header':$modules['header'][] = $row['source']; break;
case 'bottom-header':$modules['bottom-header'][] = $row['source']; break;
case 'top-body1':$modules['top-body1'][] = $row['source']; break;
case 'top-body2':$modules['top-body2'][] = $row['source']; break;
case 'body-top':$modules['body-top'][] = $row['source']; break;
case 'body-left':$modules['body-left'][] = $row['source']; break;
case 'body-center':$modules['body-center'][] = $row['source']; break;
case 'body-right':$modules['body-right'][] = $row['source']; break;
case 'body-bottom':$modules['body-bottom'][] = $row['source']; break;
case 'footer-top':$modules['footer-top'][] = $row['source']; break;
case 'footer':$modules['footer'][] = $row['source']; break;
case 'bottom-footer':$modules['bottom-footer'][] = $row['source']; break;
}
}
mysql_close();
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>
<body>
<div id="root">
<div id="top-header1"><?php if(isset($modules['top-header1'])){foreach($modules['top-header1'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="top-header2"><?php if(isset($modules['top-header2'])){foreach($modules['top-header2'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="header"><?php if(isset($modules['header'])){foreach($modules['header'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="bottom-header"><?php if(isset($modules['bottom-header'])){foreach($modules['bottom-header'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="top-body1"><?php if(isset($modules['top-body1'])){foreach($modules['top-body1'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="top-body2"><?php if(isset($modules['top-body2'])){foreach($modules['top-body2'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="body">
<div id="body-top"><?php if(isset($modules['body-top'])){foreach($modules['body-top'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="body-left"><?php if(isset($modules['body-left'])){foreach($modules['body-left'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="body-center"><?php if(isset($modules['body-center'])){foreach($modules['body-center'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="body-right"><?php if(isset($modules['body-right'])){foreach($modules['body-right'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="body-bottom"><?php if(isset($modules['body-bottom'])){foreach($modules['body-bottom'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
</div>
<div id="footer-top"><?php if(isset($modules['footer-top'])){foreach($modules['footer-top'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="footer"><?php if(isset($modules['footer'])){foreach($modules['footer'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
<div id="bottom-footer"><?php if(isset($modules['bottom-footer'])){foreach($modules['bottom-footer'] as $value){eval($value);}} ?><div style="clear:both;"></div></div>
</div>
</body>
</html>
incorrect
wrong \$\endgroup\$