النتائج 1 إلى 8 من 8

الموضوع: [STControl] Smarty Template Control

  1. #1
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    816

    [STControl] Smarty Template Control



    السلام عليكم ..

    امس قمت بكتابة كلاس بسيط خاص بـ Smarty .

    هذا الكلاس يستخدم لعرض اسماء القوالب الموجوده في مجلد معين , و يمكنك تحرير قالب من خلال لوحة تحكم السكربت و اخيراً يمكنك اضافة قالب .

    شيفرة الكلاس :

    كود PHP:
    <?php

    /*
     *************************************************************************
     * This class written by : MaaSTaaR <MaaSTaaR(at)hotmail.com>
     *
     * You can control in template with Smarty : [url]http://smarty.php.net[/url]
     *
     * Version : 1.0.0
     *
     * License : GNU GPL <[url]http://www.opensource.org/licenses/gpl-license.php[/url]>
     *************************************************************************
     */

    class STControl {
     var 
    $tdir;     #Template dir
     
    var $mainpath#main file path
     
    var $editpath#edit file path
     
    var $addpath;  #add file path
     
    var $starteditpath#start edit file path
     
    var $defualtex;     #defualt extension .. example (.tpl)


    /*
    GetTemplate :
    this function get template name and put it in list
    */
     
    function GetTemplate() {
      if (
    is_dir($this->tdir)) {
       if (
    $dh opendir($this->tdir)) {
        echo 
    '<form method="POST" action="' $this->editpath '">';
        echo 
    '<select size="1" name="D1" style="font-family: Tahoma; font-size: 10pt">';
        while ((
    $file readdir($dh)) !== false) {
         echo 
    '<option value="' $file '">' $file '</option>';;
        }
        echo 
    '</select><input type="submit" value="ÇÐåÈ" name="B1" style="font-family: Tahoma; font-size: 8pt">';
        
    closedir($dh);
       }
      }
     }
    /*
    EditTemplate :
    edit form get one parameter and usualy it $D1 , this parameter = file name
    */
     
    function EditTemplate($D1) {
      
    $check explode(".",$D1);
      if (empty(
    $check[1])) {
       
    $this->msg_die("ÇáÇÎÊíÇÑ ÎÇØÆ");
      }
      
    $fp file($this->tdir $D1);
      
    $ln count($fp);

      echo 
    '<form method="POST" action="' $this->starteditpath '&filename=' $D1 .'">';
      echo 
    '<p align="center"><textarea rows="10" name="S1" cols="56" dir="ltr" style="font-family: Tahoma; font-size: 10pt">';
      for (
    $i=0;$i<=$ln;$i++) {
       echo 
    $fp[$i];
      }
      echo 
    '</textarea>';
      echo 
    '<br><input type="submit" value="ãæÇÝÞ" name="B1" style="font-family: Tahoma; font-size: 8pt"></p>';
     }
    /*
    StartEdit :
    this function will change template code and get one parameter , it is usualy $S1
    and $S1 = template code
    */
     
    function StartEdit($S1) {
      global 
    $filename;

      
    $S1 stripslashes($S1);
      
    $fp fopen($this->tdir $filename,'w+');
      
    $fw fwrite($fp,$S1);

      if (
    $fw) {
       
    $this->msg("Êã ÈäÌÇÍ !");
       
    $this->goto($this->mainpath,'2');
      }
     }
    /*
    AddTemplate :
    this function will show add form
    */
     
    function AddTemplate() {
      echo 
    '<p align="center"><font face="Tahoma" size="2">ÇÓã ÇáÞÇáÈ : </font><form method="POST" action="' $this->addpath '"></p>';
      echo 
    '<p align="center"><input name="T1" type="text" style="font-family: Tahoma; font-size: 8pt">';
      echo 
    '<p align="center"><textarea rows="10" name="S1" cols="56" dir="ltr" style="font-family: Tahoma; font-size: 10pt">';
      echo 
    '</textarea>';
      echo 
    '<br><input type="submit" value="ãæÇÝÞ" name="B1" style="font-family: Tahoma; font-size: 8pt"></p>';
     }
    /*
    StartAdd :
    this function will add template
    */
     
    function StartAdd() {
      global 
    $T1,$S1;

      
    $S1 stripslashes($S1);
      
    $fp fopen($this->tdir $T1 $this->defualtex,'w');
      
    $fw fwrite($fp,$S1);

      if (
    $fw) {
       
    $this->msg("Êã ÈäÌÇÍ !");
       
    $this->goto($this->mainpath,'2');
      }
     }
     function 
    msg_die($msg) {
      die(
    '<p align="center" dir="rtl">' $msg '</p>');
     }
     function 
    msg($msg) {
      echo(
    '<p align="center" dir="rtl">' $msg '</p>');
     }
      function goto(
    $site,$m) {
      echo 
    "<META HTTP-EQUIV=\"refresh\" CONTENT=\"$m; URL=$site\">\n";
     }
    }

    ?>
    مثال لاستخدامه :

    كود PHP:
    <?php

    include("includes/STControl.php");

    $STC = new STControl;

    $STC->tdir      "style/template/";
    $STC->mainpath  "test.php?action=index";
    $STC->defualtex ".tpl";

    if (empty(
    $action)) { $action "index"; }

    if (
    $action == "index") {
    $STC->editpath "test.php?action=show";

    $STC->GetTemplate();
    }

    if (
    $action == "show") {
    $STC->starteditpath "test.php?action=startedit";

    $STC->EditTemplate($D1);
    }

    if (
    $action == "startedit") {
    $STC->StartEdit($S1);
    }

    if (
    $action == "add") {
    $STC->addpath "test.php?action=startadd";
    $STC->AddTemplate();
    }

    if (
    $action == "startadd") {
    $STC->StartAdd();
    }

    ?>

    تحياتي





    __________________
    http://www.el7zn.com : مدونتي :)
    MySmartBB : نظره واثقه نحو المستقبل

    You can say FireFox is also a virus that spread around the world, deleting IE
    but we all agree it's a good virus.
    MaaSTaaR غير متواجد حالياً


  2. #2
    عضو فعال جدا
    تاريخ التسجيل
    Feb 2002
    المشاركات
    2,289


    اخوي MaaSTaaR

    يا ليت لو تحط لنا الكلاس في ملف تكست

    ويعطيك الف عافيه يا غالي





    المهمة9 غير متواجد حالياً

  3. #3
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    816


    تامر امر





    الملفات المرفقة الملفات المرفقة
    __________________
    http://www.el7zn.com : مدونتي :)
    MySmartBB : نظره واثقه نحو المستقبل

    You can say FireFox is also a virus that spread around the world, deleting IE
    but we all agree it's a good virus.
    MaaSTaaR غير متواجد حالياً

  4. #4
    عضو فعال
    تاريخ التسجيل
    Aug 2000
    المشاركات
    1,382


    كلاس جميل ومهم وخصوصا لمحبين السمارتي

    تسلم استاذي العزيز


    ضفت على الكلاس
    كود PHP:
    function kll() 
    حذف التيبلت بعد اذنك طبعا استاذي


    نفتح ملف ال STControl.php


    ونبحث عن

    كود PHP:
    /*
    StartAdd :
    this function will add template
    */
     
    function StartAdd() {
      global 
    $T1,$S1;

      
    $S1 stripslashes($S1);
      
    $fp fopen($this->tdir $T1 $this->defualtex,'w');
      
    $fw fwrite($fp,$S1);

      if (
    $fw) {
       
    $this->msg("&Ecirc;&atilde; &Egrave;&auml;&Igrave;&Ccedil;&Iacute; !");
       
    $this->goto($this->mainpath,'2');
      }
     } 


    وتحته نحط هذا الكود


    كود PHP:
    /*
    kll :
    this function will kll template
    by: bokhalifa -- [email]bo@ib4arab.com[/email]
    */
     
    function kll() {
      if (
    is_dir($this->tdir)) {
       if (
    $dh opendir($this->tdir)) {
        echo 
    '<form method="POST" action="' $this->kllpath '">';
        echo 
    '<p align="center"><select size="1" name="D1" style="font-family: Tahoma; font-size: 10pt">';
        while ((
    $file readdir($dh)) !== false) {
         echo 
    '<option value="' $file '">' $file '</option>';;
        }
        echo 
    '</select><input type="submit" value="&Ccedil;&ETH;&aring;&Egrave;" name="B1" style="font-family: Tahoma; font-size: 8pt"></p>';
        
    closedir($dh);
       }
      }
     }


    /*
    dokll :
    this function will kll template
    by: bokhalifa -- [email]bo@ib4arab.com[/email]
    */
     
    function dokll($D1) {
      
    $check explode(".",$D1);
      if (empty(
    $check[1])) {
       
    $this->msg_die("&Ccedil;&aacute;&Ccedil;&Icirc;&Ecirc;&iacute;&Ccedil;&Ntilde; &Icirc;&Ccedil;&Oslash;&AElig;");
      }
      
    $fw unlink("$this->tdir/$D1");
      if (
    $fw) {
       
    $this->msg("&Ecirc;&atilde; &Egrave;&auml;&Igrave;&Ccedil;&Iacute; !");
       
    $this->goto($this->mainpath,'2');
      }
     } 


    والان نفتح ملف ال


    STC.php



    ونبحث عن


    كود PHP:

    if ($action == "startadd") {
    $STC->StartAdd();



    وتحته نحط هذا الكود



    كود PHP:
    /*
    kll function:
    this function will kll template
    by: bokhalifa -- [email]bo@ib4arab.com[/email]
    */
    if ($action == "bokll") {
    $STC->kllpath "STC.php?action=dobokll";

    $STC->kll();
    }

    if (
    $action == "dobokll") {
    $STC->dokll($D1);



    والسموحه








    __________________
    http://www.bokhalifa.com
    شبكة بوخليفه
    ((( من استغفر للمؤمنين والمؤمنات كتب الله له بكل مؤمن ومؤمنه حسنه )))
    Admin5 غير متواجد حالياً

  5. #5
    عضو فعال
    تاريخ التسجيل
    Aug 2000
    المشاركات
    1,382


    الملف المرفق





    الملفات المرفقة الملفات المرفقة
    __________________
    http://www.bokhalifa.com
    شبكة بوخليفه
    ((( من استغفر للمؤمنين والمؤمنات كتب الله له بكل مؤمن ومؤمنه حسنه )))
    Admin5 غير متواجد حالياً

  6. #6
    عضو نشيط
    تاريخ التسجيل
    Aug 2004
    المشاركات
    248


    ماستر اذا ممكن الماسنجر
    اضفني:





    __________________
    LobbyHost غير متواجد حالياً

  7. #7
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    816


    رد مقتبس من Admin5
    كلاس جميل ومهم وخصوصا لمحبين السمارتي

    تسلم استاذي العزيز


    ضفت على الكلاس
    كود PHP:
    function kll() 
    حذف التيبلت بعد اذنك طبعا استاذي


    نفتح ملف ال STControl.php


    ونبحث عن

    كود PHP:
    /*
    StartAdd :
    this function will add template
    */
     
    function StartAdd() {
      global 
    $T1,$S1;

      
    $S1 stripslashes($S1);
      
    $fp fopen($this->tdir $T1 $this->defualtex,'w');
      
    $fw fwrite($fp,$S1);

      if (
    $fw) {
       
    $this->msg("&Ecirc;&atilde; &Egrave;&auml;&Igrave;&Ccedil;&Iacute; !");
       
    $this->goto($this->mainpath,'2');
      }
     } 


    وتحته نحط هذا الكود


    كود PHP:
    /*
    kll :
    this function will kll template
    by: bokhalifa -- [email]bo@ib4arab.com[/email]
    */
     
    function kll() {
      if (
    is_dir($this->tdir)) {
       if (
    $dh opendir($this->tdir)) {
        echo 
    '<form method="POST" action="' $this->kllpath '">';
        echo 
    '<p align="center"><select size="1" name="D1" style="font-family: Tahoma; font-size: 10pt">';
        while ((
    $file readdir($dh)) !== false) {
         echo 
    '<option value="' $file '">' $file '</option>';;
        }
        echo 
    '</select><input type="submit" value="&Ccedil;&ETH;&aring;&Egrave;" name="B1" style="font-family: Tahoma; font-size: 8pt"></p>';
        
    closedir($dh);
       }
      }
     }


    /*
    dokll :
    this function will kll template
    by: bokhalifa -- [email]bo@ib4arab.com[/email]
    */
     
    function dokll($D1) {
      
    $check explode(".",$D1);
      if (empty(
    $check[1])) {
       
    $this->msg_die("&Ccedil;&aacute;&Ccedil;&Icirc;&Ecirc;&iacute;&Ccedil;&Ntilde; &Icirc;&Ccedil;&Oslash;&AElig;");
      }
      
    $fw unlink("$this->tdir/$D1");
      if (
    $fw) {
       
    $this->msg("&Ecirc;&atilde; &Egrave;&auml;&Igrave;&Ccedil;&Iacute; !");
       
    $this->goto($this->mainpath,'2');
      }
     } 


    والان نفتح ملف ال


    STC.php



    ونبحث عن


    كود PHP:

    if ($action == "startadd") {
    $STC->StartAdd();



    وتحته نحط هذا الكود



    كود PHP:
    /*
    kll function:
    this function will kll template
    by: bokhalifa -- [email]bo@ib4arab.com[/email]
    */
    if ($action == "bokll") {
    $STC->kllpath "STC.php?action=dobokll";

    $STC->kll();
    }

    if (
    $action == "dobokll") {
    $STC->dokll($D1);



    والسموحه


    اهلين بوخليفه , فعلاً اضافه جميله و ذكرتني بحذف الـ cache شرايك





    __________________
    http://www.el7zn.com : مدونتي :)
    MySmartBB : نظره واثقه نحو المستقبل

    You can say FireFox is also a virus that spread around the world, deleting IE
    but we all agree it's a good virus.
    MaaSTaaR غير متواجد حالياً

  8. #8
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    816


    رد مقتبس من LobbyHost
    ماستر اذا ممكن الماسنجر
    اضفني:
    تم اضافتك





    __________________
    http://www.el7zn.com : مدونتي :)
    MySmartBB : نظره واثقه نحو المستقبل

    You can say FireFox is also a virus that spread around the world, deleting IE
    but we all agree it's a good virus.
    MaaSTaaR غير متواجد حالياً





المواضيع المتشابهه

ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض