بسم الله الرحمن الرحيم
السلام عليكم ورحمة الله وبركاته
حاولت القيام ببرمجة محرك قوالب يعتمد على Mysql ثم يقوم بتخزيل النتيجة داخل ملف html وبعدها يقوم بتضمين الملف عند طلب القالب
وجعلت الكود كالآتي
<?
/*
محرك قوالب يعتمد على قواعد البيانات
*/
$defultstyle = 1;
class display
{
global $defultstyle;
$sql_style = @mysql_query("SELECT * FROM style where idstyle=$defultstyle")
or die ("خطأ في جلب جدول الستايل");
$tpl_style = @mysql_fetch_array($sql_style);
function _assign($tpl,$var,$definie)
{
$tpl = eregi_replace($var,$definie,$tpl);
}
function _Head($name_title)
{
$tpl_style[thm_dir] = stripslashes($tpl_style[thm_dir]);
$path_dir = $tpl_style[thm_dir]."/".$tpl_style[cache];
$file_dir = $path_dir."/head_".$name_title.".ch";
$readfile = @fopen($file_dir,"r");
if (!$readfile)
{
// get seo sql
$sql_seo = @mysql_query("SELECT * FROM seo ") or die ("خطأ في جلب جدول seo");
$tpl_seo = @mysql_fetch_array($sql_seo);
// for title and css
$tpl_style[Head] = stripslashes($tpl_style[Head]);
$tpl_style[css] = stripslashes($tpl_style[css]);
// for seo
$tpl_seo[keywords] = stripslashes($tpl_seo[keywords]);
$tpl_seo[description] = stripslashes($tpl_seo[description]);
$tpl_seo[copyright] = stripslashes($tpl_seo[copyright]);
$tpl_seo[author] = stripslashes($tpl_seo[author]);
$tpl_seo[classification] = stripslashes($tpl_seo[classification]);
$tpl_seo[robots] = stripslashes($tpl_seo[robots]);
$tpl_seo[revisit-after] = intval($tpl_seo[revisit-after]);
$this->_assign($tpl_style[Head],'{title}',$name_title);
$this->_assign($tpl_style[Head],'{css}',$tpl_style[css]);
$this->_assign($tpl_style[Head],'{keywords}',$tpl_seo[keywords]);
$this->_assign($tpl_style[Head],'{description}',$tpl_seo[description]);
$this->_assign($tpl_style[Head],'{copyright}',$tpl_seo[copyright]);
$this->_assign($tpl_style[Head],'{author}',$tpl_seo[author]);
$this->_assign($tpl_style[Head],'{classification}',$tpl_seo[classification]);
$this->_assign($tpl_style[Head],'{robots}',$tpl_seo[robots]);
$this->_assign($tpl_style[Head],'{revisit-after}',$tpl_seo[revisit-after]);
// content of th head
$print_head = $tpl_style[Head];
// check the folders and the files
if(!is_dir($path_dir))
{
$mkdir = @mkdir ($path_dir, 0755, true);
@fclose ($mkdir);
}
$writefile = @fopen($file_dir,"w");
$addtofile = @fwrite($writefile,$print_head);
@fclose ($writefile);
@fclose ($addtofile);
@mysql_free_result($sql_seo);
}
@fclose ($readfile);
@mysql_free_result($sql_style);
include($file_dir); // head template file
}
}
?>
وأعذروني إن كانت هناك أخطاء فأنا مبتدى في الـ php
هل هذه الطريقة مجديه ؟
ماهي عيوبها ؟
كيف استطيع جعل الدوال if و while وغيرها تعمل مثل محرك سمارتي؟
الرجاء إجابة في أقرب وقت


