Ejemplo n.º 1
0
<?php

require_once "HTML/IT.php";
require_once "inc/funcs.inc.php";
session_start();
$PASSWORD = "******";
$headtpl = new IntegratedTemplate("tpl");
$headtpl->loadTemplatefile("head.tpl.html", true, true);
$tpl = new IntegratedTemplate("tpl");
$error_message = "";
# post actions
if ($_POST[action] != "") {
    if ($_POST[action] == "login") {
        $headtpl->SetVariable("titel", "Login");
        if ($_POST[password] == $PASSWORD) {
            $_SESSION[password] = $PASSWORD;
            $error_message = "Logged in";
        } else {
            $error_message = "Wrong password. Fool.";
        }
    } elseif ($_POST[action] == "new") {
        $headtpl->SetVariable("titel", "Neuen Eintrag speichern");
        if ($_SESSION[password] == $PASSWORD) {
            new_article();
            $error_message = "New Article saved";
        } else {
            $error_message = "Nicht authentifiziert. Fool.";
        }
    } elseif ($_POST[action] == "kill") {
        if ($_SESSION[password] == $PASSWORD) {
            $headtpl->SetVariable("titel", "Eintrag Löschen");
 /**
  * Renders the PHPDoc XML files as HTML files 
  *
  * @param    string  Targetformat, currently only "html" is available.
  * @param    string  Target directory for the html files
  * @param    string  Directory with the html templates
  * @return   bool    $ok
  * @throws   PhpdocError
  * @access   public
  */
 function render($type = "html", $target = "", $template = "")
 {
     $this->outl("Starting to render...");
     $target = "" == $target ? $this->target : $this->getCheckedDirname($target);
     $template = "" == $template ? $this->templateRoot : $this->getCheckedDirname($template);
     switch (strtolower($type)) {
         case "html":
         default:
             $renderer = new PhpdocHTMLRendererManager($target, $template, $this->application, $this->targetFileSuffix);
             break;
     }
     $fileHandler = new PhpdocFileHandler();
     $files = $fileHandler->getFilesInDirectory($target, "xml");
     sort($files);
     $len = strlen($target);
     $tpl = new IntegratedTemplate($this->templateRoot);
     $tpl->loadTemplateFile("xmlfiles.html");
     $tpl->setCurrentBlock("file_loop");
     // Do not change the file prefixes!
     reset($files);
     while (list($k, $file) = each($files)) {
         $tpl->setVariable("FILE", substr($file, $len));
         $tpl->parseCurrentBlock();
         if ("class_" == substr($file, $len, 6)) {
             $renderer->render(substr($file, $len), "class");
         } else {
             if ("module_" == substr($file, $len, 7)) {
                 $renderer->render(substr($file, $len), "module");
             } else {
                 if ("classtree_" == substr($file, $len, 10)) {
                     $renderer->render(substr($file, $len), "classtree");
                 } else {
                     if ("modulegroup_" == substr($file, $len, 12)) {
                         $renderer->render(substr($file, $len), "modulegroup");
                     } else {
                         if ("warnings_" == substr($file, $len, 9)) {
                             $renderer->render(substr($file, $len), "warning");
                         }
                     }
                 }
             }
         }
     }
     $renderer->finish();
     // 3/11/2002 - Tim Gallagher added the next two lines
     // so the version and link could be put in and easily
     // changed as versions, and urls change.
     $tpl->setVariable("PHPDOCVERSION", PHPDOC_VERSION);
     $tpl->setVariable("PHPDOC_LINK", PHPDOC_LINK);
     $tpl->setVariable("PHPDOC_GENERATED_DATE", PHPDOC_GENERATED_DATE);
     $fileHandler->createFile($target . "phpdoc_xmlfiles" . $this->targetFileSuffix, $tpl->get());
     $this->outl($this->finishInstructions);
     return true;
 }
Ejemplo n.º 3
0
<?php

include 'tplutil.inc';
require_once 'HTML/IT.php';
$tpl = new IntegratedTemplate('slides/pragmatic');
$tpl->loadTemplateFile('integratedtemplate.tpl');
foreach (get_users() as $user) {
    $tpl->setCurrentBlock('option');
    $tpl->setVariable('USER', $user);
    $tpl->parseCurrentBlock();
}
$tpl->setVariable('TITLE', 'My Title');
$tpl->setVariable('USER', 'jimw');
$tpl->show();
Ejemplo n.º 4
0
<?php

require_once "HTML/IT.php";
require_once "inc/funcs.inc.php";
header("Content-type: text/xml");
if ($entries = get_latest_articles()) {
    $tpl = new IntegratedTemplate("tpl");
    $tpl->loadTemplatefile("rss.tpl.html", true, true);
    foreach ($entries as $entry) {
        $tpl->SetCurrentBlock("eintrag");
        $tpl->SetVariable("title", $entry[title]);
        #$tpl->SetVariable("text","no more");
        $tpl->SetVariable("text", $entry[text]);
        $tpl->SetVariable("date", $entry[date]);
        $tpl->SetVariable("link", htmlspecialchars("http://jan.krutisch.de/janzyklopedie/index.php?action=entry&id=" . $entry[entry_id]));
        $tpl->ParseCurrentBlock("eintrag");
    }
    $tpl->show();
} else {
    die("Sorry, didn't work out...");
}
?>

Ejemplo n.º 5
0
 /**
  * Reads a file from disk and returns its content.
  * 
  */
 function makeDebug()
 {
     //set timer OFF for global execute time
     /*$exec_time = -1;
     		$try = 0;
     		while ($exec_time < 0 && $try++<999) {
     		$exec_time = microtime() - $GLOBALS['start_time'];
     		}*/
     $GLOBALS['exec_time'] = $exec_time = getmicrotime() - $GLOBALS['start_time'];
     if (defined('DEBUG') and DEBUG == 1) {
         $this->free();
         $debug_array = array('GET' => $_GET, 'POST' => $_POST, 'SESSION' => $_SESSION, 'COOKIE' => $_COOKIE);
         $colors = array('GENERAL' => '8495BB', 'GET' => 'FFCC66', 'POST' => '00FF66', 'SESSION' => '9999FF', 'COOKIE' => 'CC99FF', 'SQL' => 'FF9999', 'DATA' => 'FCFC00', 'FILESYS' => 'FCFC00', 'AUTH' => 'CCCCCC', 'EMAIL' => 'CCCCCC', 'DEBUG' => 'FFFF66');
         $tpl_name_debug = '/' . SYS_ROOT . TPL_PATH . '/global/debug.htm';
         parent::loadTemplatefile($tpl_name_debug, true, true);
         // GENERAL
         $name = 'GENERAL';
         $time = 0;
         $this->setCurrentBlock('variable_item');
         $this->setVariable(array('NAME' => 'Script name:', 'VALUE' => $_SERVER['PHP_SELF']));
         $this->parseCurrentBlock();
         //AUTH info
         global $app;
         if (is_array($app->user)) {
             $auth_info = 'id: ' . $app->user['id'] . BR . 'login: '******'login'];
         } else {
             $auth_info = 'False';
         }
         $this->setVariable(array('NAME' => 'Authorization:', 'VALUE' => $auth_info));
         $this->parseCurrentBlock();
         $this->setCurrentBlock('variable_category');
         $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
         $this->parseCurrentBlock();
         $this->setCurrentBlock('variable');
         $this->parseCurrentBlock();
         // END GENERAL
         if (is_array(@$GLOBALS['DEBUG'])) {
             $name = 'DEBUG';
             $time = 0;
             $this->setCurrentBlock('debug_item');
             foreach ($GLOBALS['DEBUG'] as $item) {
                 ob_start();
                 print_r($item['value']);
                 $val_r = ob_get_contents();
                 ob_end_clean();
                 $this->setVariable(array('NAME' => $item['name'], 'LINE' => $item['line'], 'VALUE' => nl2br($val_r)));
                 $this->parseCurrentBlock();
             }
             $this->setCurrentBlock('debug_category');
             $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
             $this->parseCurrentBlock();
             $this->setCurrentBlock('debug');
             $this->parseCurrentBlock();
         }
         // SQL DEBUG
         if (is_array($GLOBALS['SQLS'])) {
             $name = 'SQL';
             $time = 0;
             foreach ($GLOBALS['SQLS'] as $sql) {
                 if (isset($sql['error']) and $sql['error'] != '') {
                     $this->setCurrentBlock('sql_error');
                     $this->setVariable(array('ERROR' => $sql['error']));
                     $this->parseCurrentBlock();
                 }
                 $this->setCurrentBlock('sql_item');
                 $this->setVariable(array('NAME' => $sql['sql'], 'VALUE' => $sql['time']));
                 $this->parseCurrentBlock();
                 $time += $sql['time'];
             }
             $this->setVariable(array('NAME' => 'TOTAL', 'VALUE' => "<b>{$time}</b>"));
             $this->parseCurrentBlock();
             $this->setCurrentBlock('sql_category');
             $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
             $this->parseCurrentBlock();
             $this->setCurrentBlock('sql');
             $this->parseCurrentBlock();
         }
         // DATA DEBUG
         if (is_array(@$GLOBALS['DATA_DEBUG'])) {
             $name = 'DATA';
             $time = 0;
             foreach ($GLOBALS['DATA_DEBUG'] as $data) {
                 $this->setCurrentBlock('data_item');
                 $this->setVariable(array('ACTION' => $data['action'], 'PARAMS' => $data['params'], 'REZ' => $data['rez']));
                 $this->parseCurrentBlock();
             }
             $this->setCurrentBlock('data_category');
             $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
             $this->parseCurrentBlock();
             $this->setCurrentBlock('data');
             $this->parseCurrentBlock();
         }
         // FILESYS DEBUG
         if (is_array(@$GLOBALS['FILESYS_DEBUG'])) {
             $name = 'FILESYS';
             $time = 0;
             foreach ($GLOBALS['FILESYS_DEBUG'] as $data) {
                 $this->setCurrentBlock('data_item');
                 $this->setVariable(array('ACTION' => $data['action'], 'PARAMS' => $data['params'], 'REZ' => $data['rez']));
                 $this->parseCurrentBlock();
             }
             $this->setCurrentBlock('data_category');
             $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
             $this->parseCurrentBlock();
             $this->setCurrentBlock('data');
             $this->parseCurrentBlock();
         }
         // AUTH DEBUG
         if (is_array(@$GLOBALS['AUTH_DEBUG'])) {
             $name = 'AUTH';
             $time = 0;
             foreach ($GLOBALS['AUTH_DEBUG'] as $data) {
                 $this->setCurrentBlock('data_item');
                 $this->setVariable(array('ACTION' => $data['action'], 'PARAMS' => $data['params'], 'REZ' => formatDebug($data['rez'])));
                 $this->parseCurrentBlock();
             }
             $this->setCurrentBlock('data_category');
             $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
             $this->parseCurrentBlock();
             $this->setCurrentBlock('data');
             $this->parseCurrentBlock();
         }
         // Email debug
         $emails = @$GLOBALS['email_debug'];
         if (isset($emails) && is_array($emails) and sizeof($emails) > 0) {
             $this->setCurrentBlock('variable_item');
             foreach ($emails as $email_name => $email_info) {
                 $this->setVariable(array('NAME' => $email_name, 'VALUE' => '<b>recipients: </b>' . $email_info['recipients'] . HR . '<b>subject: </b>' . $email_info['subject'] . HR . '<b>header: </b>' . $email_info['header'] . HR . '<b>body: </b>' . $email_info['body']));
                 $this->parseCurrentBlock();
             }
             $this->setCurrentBlock('variable_category');
             $this->setVariable(array('NAME' => 'Email send', 'COLOR' => $colors['EMAIL']));
             $this->parseCurrentBlock();
         }
         $printed = false;
         foreach ($debug_array as $name => $array) {
             if (is_array($array) and sizeof($array) > 0) {
                 $printed = true;
                 $this->setCurrentBlock('variable_item');
                 foreach ($array as $key => $val) {
                     //don't include previous $_SESSION[old_debug] data
                     if ($key != 'old_debug') {
                         ob_start();
                         print_r($val);
                         $val_r = ob_get_contents();
                         ob_end_clean();
                         $this->setVariable(array('NAME' => $key, 'VALUE' => nl2br($val_r)));
                         $this->parseCurrentBlock();
                     }
                 }
                 $this->setCurrentBlock('variable_category');
                 $this->setVariable(array('NAME' => $name, 'COLOR' => $colors[$name]));
                 $this->parseCurrentBlock();
             }
         }
         if ($printed) {
             $this->setCurrentBlock('variable');
             $this->parseCurrentBlock();
         }
         //get previuos debug data
         $this->setCurrentBlock('old_debug');
         $this->setVariable(array('OLD_DEBUG' => @$_SESSION['old_debug']));
         $this->parseCurrentBlock();
         //
         $this->setCurrentBlock('win');
         $this->setVariable('EXEC_TIME', $GLOBALS['exec_time']);
         $this->parseCurrentBlock();
         $text = $this->get('win');
         $this->setCurrentBlock('js');
         $search = array('/[\\n|\\r]*/', "/'/");
         $replace = array('', "&#39;");
         $text_r = preg_replace($search, $replace, $text);
         $this->setVariable(array('TEXT' => $text_r));
         $this->parseCurrentBlock();
         //set this debug data to $_SESSION[old_debug]
         $output = $this->get('win');
         preg_match("/<dontdelete>(.*)<dontdelete>/ms", $output, $matches);
         $_SESSION['old_debug'] = $matches[1];
         return $this->get('js');
     }
 }