Location: PHPKode > projects > Free Ads Manager Script > templates.class.php
<?PHP
class template
{
    var $template;
    function get_template($template_arr, $path='', $_temp='', $admin='')
    {

         if(is_array($template_arr) && ($path || $_temp))
         {
            foreach($template_arr as $key=>$value)
            {
                $old[] = '$'.$key;
                $new[] = $value;
            }
            if($path)
            {
                if($admin != "true")
                {
                    $_template_f = @fopen('templates/'.$path.'.html', r) or die($this->Error_temp("Template (".$path.") Not Found !"));
                }
                else
                {
                    $_template_f = @fopen('../templates/'.$path.'.html', r) or die($this->Error_temp("Template (".$path.") Not Found !"));
                }
                while(!feof($_template_f))
                {
                    $_template .= fgets($_template_f);
                }
            }
            elseif($_temp)
            {
                  $_template = $_temp;
            }

            $_template = str_replace($old, $new, $_template);
         }

         if(!is_array($_Phrase))
         {
            global $_Phrase;
         }

         if(is_array($_Phrase))
         {
             foreach($_Phrase as $key => $value)
             {
                  $_template = str_replace('$phrase"'.$key.'"', $value, $_template);
             }
         }

         return $_template;
    }

    function Error_temp($_Err)
    {
        //message
        $template = '
        <html>
        <head>
        <title>Template Error..</title>
        </head>
        <body>
        <center><h1 style="color: red;">Template Error</h1>
        <br />
        <div dir="ltr" style="text-align: left; background-color: #FFFFCC; color: red; width: 500px; height: 400px; border: 1px solid #000000; font-size: 14px; padding: 10px;"><b>'.$_Err.'</b></div>
        </center></body>
        </html>
        ';
        //send_mail
        $send_msg = send_mail(_admin_Mail, "DataBase Error !",$template ,"Content-Type: text/html; \n"."From: ".$_SESSION['mail']);

        //error message
        return $template;
    }

    function admin_temp()
    {
      global $DB;
      global $_Phrase;

      $rs = $DB->fetch_f("select * from users where userid='".$_SESSION['userid']."' ");
      $folder = $rs['style_admin'];
      if(!file_exists('styles'.$folder.'/style.css'))
      {
          $folder = "default";
      }
      if(date("Y") != "2008")
      {
        $fot = " - ".date("Y");
      }
      $data = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" dir="'.$_Phrase['dir'].'">
      <head>
      <meta http-equiv="content-type" content="text/html; charset='.$_Phrase['charset'].'" />
      <title>$title - EXPBuilder CPanel</title>
      $scripts
      <meta name="keywords" content="" />
      <meta name="description" content="" />
      <link href="styles/'.$folder.'/style.css" rel="stylesheet" type="text/css" />

      </head>
      <body>
      <div id="header">
        <ul>
            <li id="logo" onclick="window.open(\'http://www.expbuilder.com\');">&nbsp;</li>
            <li>&nbsp;</li>
        </ul>
      </div>
        <table width="100%" border=0>
        <tr>
            <td id="menu">$menu</li>
            <td id="body">
                $data
            </td>
        </tr>
      </table>
      <div id="footer">
        Powered by <a href="http://www.expbuilder.com">EXPBuilder</a> © 2008 '.$fot.'
      </div>
      </body>
      </html>';
return $data;
    }


    function script_admin($data_ar)
    {

        $data_ar['scripts'] .= '
<script type="text/javascript" src="../scripts/global.js"></script>
<script type="text/javascript" src="../scripts/dyn.js"></script>
<link href="../scripts/dyn.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
ddaccordion.init({headerclass: "expandable",contentclass: "categoryitems",collapseprev: true, defaultexpanded: [0],animatedefault: false, persiststate: true, toggleclass: ["", "openheader"], togglehtml: ["prefix", "", ""], animatespeed: "normal", oninit:function(headers, expandedindices){},onopenclose:function(header, index, state, isclicked){}
})

ddaccordion.init({headerclass: "subexpandable", contentclass: "subcategoryitems", collapseprev: true, defaultexpanded: [], animatedefault: false, persiststate: true, toggleclass: ["opensubheader", "closedsubheader"], togglehtml: ["none", "", ""], animatespeed: "normal", oninit:function(headers, expandedindices){},onopenclose:function(header, index, state, isclicked){}
})

</script>
        ';

        $data_ar['menu'] .='
<div class="arrowlistmenu">

<h3 class="menuheader expandable">$phrase"sys_optn"</h3>
<ul class="categoryitems">
<li><a href="../index.php" target="_blank">$phrase"man_pag"</a></li>
<li><a href="?">$phrase"ad_man_pag"</a></li>
<li><a href="?do=option">$phrase"man_optn"</a></li>
<li><a href="?do=myacount">$phrase"myacount"</a></li>
<li><a href="?do=cat">$phrase"ads" $phrase"Category"</a></li>
<li><a href="?do=tags">$phrase"tags"</a></li>
<li><a href="../index.php?do=logout">$phrase"logout"</a></li>
</ul>

<h3 class="menuheader expandable">$phrase"free_ads"</h3>
<ul class="categoryitems">
<li><a href="?do=ads_fee">$phrase"free_ads" $phrase"Management"</a></li>
<li><a href="?do=wat_ads_fee">$phrase"waiting" $phrase"free_ads"</a></li>
<li><a href="?do=new_f_ads">$phrase"add_new_ads" $phrase"free_ads"</a></li>
</ul>

<h3 class="menuheader expandable">$phrase"prm_ads"</h3>
<ul class="categoryitems">
<li><a href="?do=ads_prm" >$phrase"prm_ads"</a></li>
<li><a href="?do=wat_ads_prm">$phrase"waiting" $phrase"prm_ads"</a></li>
<li><a href="?do=new_p_ads">$phrase"add_new_ads" $phrase"prm_ads"</a></li>
</ul>

<h3 class="menuheader expandable">$phrase"banner_ads"</h3>
<ul class="categoryitems">
    <li><a href="?do=banners" >$phrase"banner_ads" $phrase"Management"</a></li>
</ul>

<h3 class="menuheader expandable">$phrase"msgs"</h3>
<ul class="categoryitems">
    <li><a href="?do=msgs" >$phrase"msgs"</a></li>
</ul>

<div>
        ';
        return $this->get_template($data_ar, 0, $this->admin_temp());
    }



    function mask_box()
    {
        $data = '
<script>
function msg_mask(form_id)
{
    center_form(form_id);
    var mask = document.getElementById(\'mask\')
    mask.style.width = document.body.scrollWidth + "px";
    mask.style.height = document.body.scrollHeight + "px";
    mask.style.visibility = "visible";
}
function center_form(form_id)
{

    var tbl = document.getElementById(form_id);
    var scw = screen.width;
    var sch = screen.height;

    var remaining_w = scw - 200;
    var remaining_h = sch - 160;

    var align_w = remaining_w / 2 ;
    var align_h = remaining_h / 3 ;
    tbl.style.left =  align_w + "px";
    //tbl.style.top =  align_h + "px";
}

function close_this()
{
   var mask = document.getElementById(\'mask\');
   mask.style.visibility = "hidden";
}
</script>
<style>
.mask
{
    background-color: #FFFFFF;
    position:absolute;
    left:0px;
    top:0px;
    visibility: hidden;
    filter: alpha(opacity=60);opacity: 0.60;
}

</style>
<span id="mask" class="mask" style="z-index: 6000; position: absolute; visibility: hidden;">&nbsp;</span>
';
    return $data;
    }

}
?>
Return current item: Free Ads Manager Script