Changeset 1279

Show
Ignore:
Timestamp:
07/19/08 23:01:17 (2 months ago)
Author:
rats
Message:

* Fixed #1397: E-Mail on ticket response
* Fixed #1402: awstats static not working
* Fixed #1425: Include support for templates
* Fixed #1431
* Updated phpMyAdmin to 2.11.7.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHANGELOG

    r1278 r1279  
    11ispCP ω 1.0.0 Changelog 
    22~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3 
     42008-07-18 Benedikt Heintel 
     5        - GUI: 
     6                * Fixed #1397: E-Mail on ticket response 
     7                * Fixed #1402: awstats static not working 
     8                * Fixed #1425: Include support for templates 
     9                * Fixed #1431 
     10        - TOOLS: 
     11                * Updated phpMyAdmin to 2.11.7.1 
    312 
    4132008-07-19 Jochen Manz 
     
    1322                * Fixed #1419: Template error and missing menu when a client try to create catch all: client/mail_catchall_add.php 
    1423                * Fixed #1420: Missing menu when a client try to edit email: client/mail_edit.php 
    15                 * Fixed #1421: Client can`t change sql password: client/sql_change_password.php (template error) 
     24                * Fixed #1421: Client can't change sql password: client/sql_change_password.php (template error) 
    1625                * Fixed #1423: e-mail as normal mail and e-mail forward not in /etc/courier/userdb 
    1726                * Fixed #1424: Adminstrator password created by setup is truncated at 8 characters 
  • trunk/configs/centos/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/debian/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/fedora/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/freebsd/cron.d/parts/dmn_awstats_entry.tpl

    r1192 r1279  
    1 {MINUTE} {HOUR}  * * *   perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/gentoo/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/openbsd/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/redhat/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/configs/ubuntu/cron.d/parts/dmn_awstats_entry.tpl

    r1135 r1279  
    1 {MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={AWSTATS_WEB_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
     1{MINUTE} {HOUR}  * * *   root perl {AWSTATS_ROOT_DIR}/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang={USER_LANG} -awstatsprog={AWSTATS_ENGINE_DIR}/awstats.pl -dir={APACHE_WWW_DIR}/{DMN_NAME}/statistics/ >/dev/null 2>&1 
  • trunk/gui/admin/ticket_view.php

    r1268 r1279  
    235235 
    236236        $ticket_date = time(); 
    237  
    238         $subj = clean_input($_POST['subject']); 
    239  
     237        $subject = clean_input($_POST['subject']); 
    240238        $user_message = clean_input($_POST["user_message"]); 
    241  
    242239        $ticket_status = 1; 
    243  
    244240        $ticket_reply = $_GET['ticket_id']; 
    245  
    246241        $urgency = $_POST['urgency']; 
    247242 
     
    283278SQL_QUERY; 
    284279 
    285         $rs = exec_query($sql, $query, array($ticket_from, 
    286                         $ticket_to, 
    287                         $ticket_status, 
    288                         $ticket_reply, 
    289                         $urgency, 
    290                         $ticket_date, 
    291                         $subj, 
    292                         $user_message 
    293                         )); 
     280        $rs = exec_query($sql, $query, array($ticket_from, $ticket_to, $ticket_status, 
     281                        $ticket_reply, $urgency, $ticket_date, 
     282                        htmlspecialchars($subject, ENT_QUOTES, "UTF-8"), 
     283                        htmlspecialchars($user_message, ENT_QUOTES, "UTF-8"))); 
    294284 
    295285        set_page_message(tr('Message was sent!')); 
     
    312302        } 
    313303 
    314         send_tickets_msg($ticket_to, $ticket_from, $subj); 
     304        set_page_message(tr('Message was sent.')); 
     305        send_tickets_msg($ticket_to, $ticket_from, htmlspecialchars($subject, ENT_QUOTES, "UTF-8"), 
     306                        htmlspecialchars($user_message, ENT_QUOTES, "UTF-8"), $ticket_reply); 
    315307} 
    316308 
  • trunk/gui/client/ticket_create.php

    r1265 r1279  
    4545        $ticket_date = time(); 
    4646        $urgency = $_POST['urgency']; 
    47         $subj = clean_html($_POST['subj']); 
     47        $subject = clean_html($_POST['subj']); 
    4848        $user_message = clean_input($_POST["user_message"]); 
    4949        $ticket_status = 1; 
     
    6060SQL_QUERY; 
    6161 
    62         $rs = exec_query($sql, $query, array($ticket_level, 
    63                         $user_id, 
    64                         $reseller_id, 
    65                         $ticket_status, 
    66                         $ticket_reply, 
    67                         $urgency, 
    68                         $ticket_date, 
    69                         htmlspecialchars($subj, ENT_QUOTES, "UTF-8"), 
     62        $rs = exec_query($sql, $query, array($ticket_level, $user_id, $reseller_id, 
     63                        $ticket_status, $ticket_reply, $urgency, $ticket_date, 
     64                        htmlspecialchars($subject, ENT_QUOTES, "UTF-8"), 
    7065                        htmlspecialchars($user_message, ENT_QUOTES, "UTF-8"))); 
    7166 
    72         send_tickets_msg($reseller_id, $user_id, $subj); 
    7367        set_page_message(tr('Your message was sent!')); 
     68        send_tickets_msg($reseller_id, $user_id, htmlspecialchars($subject, ENT_QUOTES, "UTF-8"), 
     69                        htmlspecialchars($user_message, ENT_QUOTES, "UTF-8"), $ticket_reply); 
    7470        header("Location: ticket_system.php"); 
    7571        exit(0); 
  • trunk/gui/client/ticket_view.php

    r1268 r1279  
    204204 
    205205        $ticket_date = time(); 
    206         $subj = clean_html($_POST['subject']); 
     206        $subject = clean_html($_POST['subject']); 
    207207        $user_message = clean_input($_POST["user_message"]); 
    208208        $ticket_status = 4; 
     
    226226SQL_QUERY; 
    227227 
    228         $rs = exec_query($sql, $query, array($ticket_from, 
    229                         $ticket_to, 
    230                         $ticket_status, 
    231                         $ticket_reply, 
    232                         $urgency, 
    233                         $ticket_date, 
    234                         $subj, 
    235                         $user_message)); 
     228        $rs = exec_query($sql, $query, array($ticket_from, $ticket_to, $ticket_status, 
     229                        $ticket_reply, $urgency, $ticket_date, 
     230                        htmlspecialchars($subject, ENT_QUOTES, "UTF-8"), 
     231                        htmlspecialchars($user_message, ENT_QUOTES, "UTF-8"))); 
    236232 
    237233        set_page_message(tr('Message was send!')); 
     
    254250        } 
    255251 
    256         send_tickets_msg($ticket_to, $ticket_from, $subj); 
     252        set_page_message(tr('Message was sent.')); 
     253        send_tickets_msg($ticket_to, $ticket_from, htmlspecialchars($subject, ENT_QUOTES, "UTF-8"), 
     254                        htmlspecialchars($user_message, ENT_QUOTES, "UTF-8"), $ticket_reply); 
    257255} 
    258256 
  • trunk/gui/include/admin-functions.php

    r1264 r1279  
    22802280} 
    22812281// Function by Tribal-Dolphin 
    2282 function send_tickets_msg($to_id, $from_id, $ticket_subject) { 
     2282function send_tickets_msg($to_id, $from_id, $ticket_subject, $ticket_message, $ticket_status) { 
    22832283        $sql = Database::getInstance(); 
    22842284        global $admin_login; 
     
    23142314        $from_uname = $res->fields['admin_name']; 
    23152315        // Prepare message 
    2316         $subject = tr('[Ticket] {SUBJ}'); 
    2317         $message = tr("Hello {TO_NAME} !\n\nYou have a new ticket to read"); 
     2316        $subject = tr('[Ticket]') . '{SUBJ}'; 
     2317        if ($ticket_status == 0) { 
     2318                $message = tr("Hello %s!\n\nYou have a new ticket:\n", "{TO_NAME}"); 
     2319        } else { 
     2320                $message = tr("Hello %s!\n\nYou have an answer for this ticket:\n", "{TO_NAME}"); 
     2321        } 
     2322        $message .= $ticket_message; 
     2323        $message .= tr("Log in to answer."); 
     2324 
    23182325        // Format adresses 
    2319  
    23202326        if ($from_fname && $from_lname) { 
    23212327                $from = "\"" . encode($from_fname . ' ' . $from_lname) . "\" <" . $from_email . ">"; 
  • trunk/gui/include/class.pTemplate.php

    r1246 r1279  
    2020 
    2121class pTemplate { 
    22         var $tpl_name; 
    23         var $tpl_data; 
    24         var $tpl_options; 
    25  
    26         var $dtpl_name; 
    27         var $dtpl_data; 
    28         var $dtpl_options; 
    29         var $dtpl_values; 
    30  
    31         var $namespace; 
    32  
    33         var $root_dir; 
    34  
    35         var $tpl_start_tag; 
    36         var $tpl_end_tag; 
    37         var $tpl_start_tag_name; 
    38         var $tpl_end_tag_name; 
    39         var $tpl_name_rexpr; 
    40  
    41         var $tpl_start_rexpr; 
    42         var $tpl_end_rexpr; 
    43  
    44         var $last_parsed; 
    45  
    46         var $stack; 
    47         var $sp; 
    48  
    49         function pTemplate($r_dir = '') { 
    50                 $this->tpl_name = array(); 
    51                 $this->tpl_data = array(); 
    52                 $this->tpl_options = array(); 
    53  
    54                 $this->dtpl_name = array(); 
    55                 $this->dtpl_data = array(); 
    56                 $this->dtpl_options = array(); 
    57                 $this->dtpl_values = array(); 
    58  
    59                 $this->namespace = array(); 
    60  
    61                 if ($r_dir) { 
    62                         $this->set_root($r_dir); 
    63                 } else { 
    64                         $this->set_root(); 
    65                 } 
    66  
    67                 $this->tpl_start_tag = '<!-- '; 
    68                 $this->tpl_end_tag = ' -->'; 
    69                 $this->tpl_start_tag_name = 'BDP: '; 
    70                 $this->tpl_end_tag_name = 'EDP: '; 
    71                 $this->tpl_name_rexpr = '([a-z0-9][a-z0-9\_]*)'; 
    72  
    73                 $this->tpl_start_rexpr = '/'; 
    74                 $this->tpl_start_rexpr .= $this->tpl_start_tag; 
    75                 $this->tpl_start_rexpr .= $this->tpl_start_tag_name; 
    76                 $this->tpl_start_rexpr .= $this->tpl_name_rexpr; 
    77                 $this->tpl_start_rexpr .= $this->tpl_end_tag . '/' ; 
    78  
    79                 $this->tpl_end_rexpr = '/'; 
    80                 $this->tpl_end_rexpr .= $this->tpl_start_tag; 
    81                 $this->tpl_end_rexpr .= $this->tpl_end_tag_name; 
    82                 $this->tpl_end_rexpr .= $this->tpl_name_rexpr; 
    83                 $this->tpl_end_rexpr .= $this->tpl_end_tag . '/'; 
    84  
    85                 $this->last_parsed = ''; 
    86  
    87                 $this->stack = array(); 
    88                 $this->sp = 0; 
    89         } 
    90  
    91         function set_root($set_dir = '.') { 
    92                 $this->root_dir = $set_dir; 
    93         } 
    94  
    95         function assign($nsp_name, $nsp_data = '') { 
    96                 if (gettype($nsp_name) == "array") { 
    97                         foreach ($nsp_name as $key => $value) { 
    98                                 $this->namespace[$key] = $value; 
    99                         } 
    100                 } else { 
    101                         $this->namespace[$nsp_name] = $nsp_data; 
    102                 } 
    103         } 
    104  
    105         function unsign($nsp_name) { 
    106                 if (gettype($nsp_name) == "array") { 
    107                         foreach ($nsp_name as $key => $value) { 
    108                                 unset($this->namespace[$key]); 
    109                         } 
    110                 } else { 
    111                         unset($this->namespace[$nsp_name]); 
    112                 } 
    113         } 
    114  
    115         function define($t_name, $t_value = '') { 
    116                 if (gettype($t_name) == "array") { 
    117                         foreach ($t_name as $key => $value) { 
    118                                 $this->tpl_name[$key] = $value; 
    119                                 $this->tpl_data[$key] = ''; 
    120                                 $this->tpl_options[$key] = ''; 
    121                         } 
    122                 } else { 
    123                         $this->tpl_name[$t_name] = $t_value; 
    124                         $this->tpl_data[$t_name] = ''; 
    125                         $this->tpl_options[$t_name] = ''; 
    126                 } 
    127         } 
    128  
    129         function define_dynamic($t_name, $t_value = '') { 
    130                 if (gettype($t_name) == "array") { 
    131                         foreach ($t_name as $key => $value) { 
    132                                 $this->dtpl_name[$key] = $value; 
    133                                 $this->dtpl_data[$key] = ''; 
    134                                 $this->dtpl_options[$key] = ''; 
    135                         } 
    136                 } else { 
    137                         $this->dtpl_name[$t_name] = $t_value; 
    138                         $this->dtpl_data[$t_name] = ''; 
    139                         $this->dtpl_options[$t_name] = ''; 
    140                 } 
    141         } 
    142  
    143         function define_no_file($t_name, $t_value = '') { 
    144                 if (gettype($t_name) == "array") { 
    145                         foreach ($t_name as $key => $value) { 
    146                                 $this->tpl_name[$key] = '_no_file_'; 
    147                                 $this->tpl_data[$key] = $value; 
    148                                 $this->tpl_options[$key] = ''; 
    149                         } 
    150                 } else { 
    151                         $this->tpl_name[$t_name] = '_no_file_'; 
    152                         $this->tpl_data[$t_name] = $t_value; 
    153                         $this->tpl_options[$t_name] = ''; 
    154                 } 
    155         } 
    156  
    157         function define_no_file_dynamic($t_name, $t_value = '') { 
    158                 if (gettype($t_name) == "array") { 
    159                         foreach ($t_name as $key => $value) { 
    160                                 $this->dtpl_name[$key] = '_no_file_'; 
    161  
    162                                 $this->dtpl_data[$key] = $value; 
    163  
    164                                 $this->dtpl_data[strtoupper($key)] = $value; 
    165  
    166                                 $this->dtpl_options[$key] = ''; 
    167                         } 
    168                 } else { 
    169                         $this->dtpl_name[$t_name] = '_no_file_'; 
    170  
    171                         $this->dtpl_data[$t_name] = $t_value; 
    172  
    173                         $this->dtpl_data[strtoupper($t_name)] = @$t_value; 
    174  
    175                         $this->dtpl_options[$t_name] = ''; 
    176                 } 
    177         } 
    178  
    179         function find_next($data, $spos) { 
    180                 do { 
    181                         $tag_spos = strpos($data, $this->tpl_start_tag, $spos + 1); 
    182  
    183                         if (gettype($tag_spos) == 'boolean') { 
    184                                 return false; 
    185                         } 
    186  
    187                         $tag_epos = strpos($data, $this->tpl_end_tag, $tag_spos + 1); 
    188  
    189                         if (gettype($tag_epos) == 'boolean') { 
    190                                 return false; 
    191                         } 
    192  
    193                         $length = $tag_epos + strlen($this->tpl_end_tag) - $tag_spos; 
    194  
    195                         $tag = substr($data, $tag_spos, $length); 
    196  
    197                         if ($tag) { 
    198                                 if (preg_match($this->tpl_start_rexpr, $tag, $matches)) { 
    199                                         return array($matches[1], 'b', $tag_spos, $tag_epos + strlen($this->tpl_end_tag) - 1); 
    200                                 } else if (preg_match($this->tpl_end_rexpr, $tag, $matches)) { 
    201                                         return array($matches[1], 'e', $tag_spos, $tag_epos + strlen($this->tpl_end_tag) - 1); 
    202                                 } else { 
    203                                         $spos = $tag_epos; 
    204                                 } 
    205                         } else { 
    206                                 return false; 
    207                         } 
    208                 } while (true); 
    209         } 
    210  
    211         function find_next_curl($data, $spos) { 
    212                 $curl_b = strpos($data, '{', $spos + 1); 
    213  
    214                 $curl_e = strpos($data, '}', $spos + 1); 
    215  
    216                 if ($curl_b) { 
    217                         if ($curl_e) { 
    218                                 if ($curl_b < $curl_e) { 
    219                                         return array('{', $curl_b); 
    220                                 } else { 
    221                                         return array('}', $curl_e); 
    222                                 } 
    223                         } else { 
    224                                 return array('{', $curl_b); 
    225                         } 
    226                 } else { 
    227                         if ($curl_e) { 
    228                                 return array('}', $curl_e); 
    229                         } else { 
    230                                 return false; 
    231                         } 
    232                 } 
    233         } 
    234  
    235         function devide_dynamic($data) { 
    236                 $start_from = -1; 
    237  
    238                 $tag = $this->find_next($data, $start_from); 
    239  
    240                 while ($tag) { 
    241                         if ($tag[1] == 'b') { 
    242                                 $this->stack[$this->sp++] = $tag; 
    243  
    244                                 $start_from = $tag[3]; 
    245                         } else { 
    246                                 $tpl_name = $tag[0]; 
    247  
    248                                 $tpl_eb_pos = $tag[2]; 
    249                                 $tpl_ee_pos = $tag[3]; 
    250  
    251                                 $tag = $this->stack [--$this->sp]; 
    252  
    253                                 $tpl_bb_pos = $tag[2]; 
    254                                 $tpl_be_pos = $tag[3]; 
    255  
    256                                 $this->dtpl_data[strtoupper($tpl_name)] = substr($data, $tpl_be_pos + 1, $tpl_eb_pos - $tpl_be_pos - 1); 
    257  
    258                                 $this->dtpl_data[$tpl_name] = substr($data, $tpl_be_pos + 1, $tpl_eb_pos - $tpl_be_pos - 1); 
    259  
    260                                 $data = substr_replace($data, "{" . strtoupper($tpl_name) . "}", $tpl_bb_pos, $tpl_ee_pos - $tpl_bb_pos + 1); 
    261  
    262                                 $start_from = $tpl_bb_pos + strlen("{" . $tpl_name . "}") - 1; 
    263                         } 
    264  
    265                         $tag = $this->find_next($data, $start_from); 
    266                 } 
    267  
    268                 return $data; 
    269         } 
    270  
    271         function substitute_dynamic($data) { 
    272                 $this->sp = 0; 
    273  
    274                 $start_from = -1; 
    275  
    276                 $curl_b = substr($data, '{', $start_from); 
    277  
    278                 if ($curl_b) { 
    279                         $this->stack[$this->sp++] = array('{', $curl_b); 
    280  
    281                         $curl = $this->find_next_curl($data, $start_from); 
    282  
    283                         while ($curl) { 
    284                                 if ($curl[0] == '{') { 
    285                                         $this->stack[$this->sp++] = $curl; 
    286  
    287                                         $start_from = $curl[1]; 
    288                                 } else { 
    289                                         $curl_e = $curl[1]; 
    290  
    291                                         if ($this->sp > 0) { 
    292                                                 $curl = $this->stack [--$this->sp]; 
    293                                                 /* CHECK for empty stack must be done HERE ! */ 
    294  
    295                                                 $curl_b = $curl[1]; 
    296  
    297                                                 if ($curl_b < $curl_e + 1) { 
    298                                                         $var_name = substr($data, $curl_b + 1, $curl_e - $curl_b - 1); 
    299  
    300                                                         /* 
    301                              * 
    302                              * The whole WORK goes here :) ; 
    303                              * 
    304                              */ 
    305  
    306                                                         if (preg_match('/[A-Z0-9][A-Z0-9\_]*/', $var_name)) { 
    307                                                                 if (isset($this->namespace[$var_name])) { 
    308                                                                         $data = substr_replace($data, $this->namespace[$var_name], $curl_b, $curl_e - $curl_b + 1); 
    309  
    310                                                                         $start_from = $curl_b - 1; 
    311                                                                         /* new value may also begin with '{' */ 
    312  
    313                                                                 } else if (isset($this->dtpl_data[$var_name])) { 
    314                                                                         $data = substr_replace($data, $this->dtpl_data[$var_name], $curl_b, $curl_e - $curl_b + 1); 
    315  
    316                                                                         $start_from = $curl_b - 1; 
    317                                                                         /* new value may also begin with '{' */ 
    318  
    319                                                                 } else { 
    320                                                                         $start_from = $curl_b; 
    321                                                                         /* no soutable value found -> go forward */ 
    322  
    323                                                                 } 
    324                                                         } else { 
    325                                                                 $start_from = $curl_b; 
    326                                                                 /* go forward, we have {not varialbe} here :) */ 
    327  
    328                                                         } 
    329                                                 } else { 
    330                                                         $start_from = $curl_e; 
    331                                                         /* go forward, we have {} here :) */ 
    332  
    333                                                 } 
    334                                         } else { 
    335                                                 $start_from = $curl_e; 
    336                                         } 
    337                                 } 
    338  
    339                                 $curl = $this->find_next_curl($data, $start_from); 
    340                         } 
    341  
    342                         return $data; 
    343                 } else { 
    344                         return $data; 
    345                         /* tghere is nothing to substitute in $data */ 
    346  
    347                 } 
    348         } 
    349  
    350         function is_safe($fname) { 
    351                 if (file_exists(($this->root_dir) . '/' . $fname)) { 
    352                         return true; 
    353                 } 
    354  
    355                 return false; 
    356         } 
    357  
    358         function get_file($fname) { 
    359                 if ($this->is_safe($fname)) { 
    360                         if (!($fp = fopen(($this->root_dir) . '/' . $fname, 'r'))) { 
    361                                 return ''; 
    362                         } 
    363  
    364                         $res = fread($fp, filesize(($this->root_dir) . '/' . $fname)); 
    365  
    366                         if (!$res) { 
    367                                 return ''; 
    368                         } 
    369  
    370                         fclose($fp); 
    371  
    372                         return $res; 
    373                 } 
    374  
    375                 return ''; 
    376         } 
    377  
    378         function find_origin($tname) { 
    379                 if (!@$this->dtpl_name[$tname]) { 
    380                         return false; 
    381                 } while (!preg_match('/\.[Tt][Pp][Ll]/', $this->dtpl_name[$tname]) && !preg_match('/_no_file_/', $this->dtpl_name[$tname]) 
    382                         ) { 
    383                         $tname = $this->dtpl_name[$tname]; 
    384                 } 
    385  
    386                 return $tname; 
    387         } 
    388  
    389         function parse_dynamic($pname, $tname, $ADD_FLAG) { 
    390                 $CHILD = false; 
    391                 $parent = ''; 
    392                 $swap = ''; 
    393  
    394                 if (!preg_match('/\.[Tt][Pp][Ll]/', @$this->dtpl_name[$tname]) && !preg_match('/_no_file_/', @$this->dtpl_name[$tname]) 
    395                                 ) { 
    396                         $CHILD = true; 
    397  
    398                         $parent = $this->find_origin($tname); 
    399  
    400                         if (!$parent) { 
    401                                 return false; 
    402                         } 
    403                 } 
    404  
    405                 if ($CHILD) { 
    406                         $swap = $parent; 
    407                         $parent = $tname; 
    408                         $tname = $swap; 
    409                 } 
    410  
    411                 if (!@$this->dtpl_data[$tname]) { 
    412                         @$this->dtpl_data[$tname] = $this->get_file(@$this->dtpl_name[$tname]); 
    413                 } 
    414  
    415                 if (!preg_match('/d\_/', @$this->dtpl_options[$tname])) { 
    416                         @$this->dtpl_options[$tname] .= 'd_'; 
    417  
    418                         $tpl_origin = @$this->dtpl_data[$tname]; 
    419  
    420                         @$this->dtpl_data[$tname] = $this->devide_dynamic($tpl_origin); 
    421                 } 
    422  
    423                 if ($CHILD) { 
    424                         $swap = $parent; 
    425                         $parent = $tname; 
    426                         $tname = $swap; 
    427                 } 
    428  
    429                 if ($ADD_FLAG) { 
    430                         $safe = @$this->namespace[$pname]; 
    431  
    432                         $this->namespace[$pname] = $safe . ($this->substitute_dynamic($this->dtpl_data[$tname], $ADD_FLAG)); 
    433                 } else { 
    434                         $this->namespace[$pname] = $this->substitute_dynamic($this->dtpl_data[$tname], $ADD_FLAG); 
    435                 } 
    436  
    437                 return true; 
    438         } 
    439  
    440         function parse($pname, $tname) { 
    441                 if (!preg_match('/[A-Z0-9][A-Z0-9\_]*/', $pname)) { 
    442                         return false; 
    443                 } 
    444  
    445                 if (!preg_match('/[A-Za-z0-9][A-Za-z0-9\_]*/', $tname)) { 
    446                         return false; 
    447                 } 
    448  
    449                 $ADD_FLAG = false; 
    450  
    451                 if (preg_match('/^\./', $tname)) { 
    452                         $tname = substr($tname, 1); 
    453  
    454                         $ADD_FLAG = true; 
    455                 } 
    456  
    457                 if (@$this->tpl_name[$tname] == '_no_file_' || preg_match('/\.[Tt][Pp][Ll]/', @$this->tpl_name[$tname])) { 
    458                         /* static NO FILE *//* static FILE */ 
    459  
    460                         if (@$this->tpl_data[$tname] == '') { 
    461                                 $this->tpl_data[$tname] = $this->get_file($this->tpl_name[$tname]); 
    462                         } 
    463  
    464                         if ($ADD_FLAG) { 
    465                                 @$this->namespace[$pname] .= $this->substitute_dynamic($this->tpl_data[$tname]); 
    466                         } else { 
    467                                 $this->namespace[$pname] = $this->substitute_dynamic($this->tpl_data[$tname]); 
    468                         } 
    469  
    470                         $this->last_parsed = $this->namespace[$pname]; 
    471                 } else if (@$this->dtpl_name[$tname] == '_no_file_' || preg_match('/\.[Tt][Pp][Ll]/', @$this->dtpl_name[$tname]) || $this->find_origin($tname)) { 
    472                         /* dynamic NO FILE *//* dynamic FILE */ 
    473  
    474                         $dres = $this->parse_dynamic($pname, $tname, $ADD_FLAG); 
    475  
    476                         if (!$dres) { 
    477                                 return $dres; 
    478                         } 
    479  
    480                         $this->last_parsed = $this->namespace[$pname]; 
    481                 } else { 
    482                         if ($ADD_FLAG) { 
    483                                 @$this->namespace[$pname] .= $this->namespace[$tname]; 
    484                         } else { 
    485                                 $this->namespace[$pname] = $this->namespace[$tname]; 
    486                         } 
    487                 } 
    488         } 
    489  
    490         function prnt($pname = '') { 
    491                 if ($pname) { 
    492                         print @$this->namespace[$pname]; 
    493                 } else { 
    494                         print @$this->last_parsed; 
    495                 } 
    496         } 
    497  
    498         function FastPrint($pname = '') { 
    499                 if ($pname) { 
    500                         $this->prnt($pname); 
    501                 } else { 
    502                         $this->prnt(); 
    503                 } 
    504         } 
    505  
    506         /* functions added for backward compatibility and debugging */ 
    507  
    508         function strict() { 
    509         } 
    510  
    511         function no_strict() { 
    512         } 
    513  
    514         function show_unknown() { 
    515         } 
    516  
    517         function print_namespace() { 
    518                 print "<br><u>'namespace' contents</u><br>"; 
    519  
    520                 foreach($this->namespace as $key => $value) { 
    521                         print "$key => $value<br>"; 
    522                 } 
    523         } 
    524  
    525         function print_tpl_name() { 
    526                 print "<br><u>'tpl_name' contents</u><br>"; 
    527  
    528                 foreach($this->tpl_name as $key => $value) { 
    529                         print "$key => $value<br>"; 
    530                 } 
    531         } 
    532  
    533         function print_dtpl_name() { 
    534                 print "<br><u>'dtpl_name' contents</u><br>"; 
    535  
    536                 foreach($this->dtpl_name as $key => $value) { 
    537                         print "$key => $value<br>"; 
    538                 } 
    539         } 
    540  
    541<