示例#1
0
 /**
  * Use PHPTAL to generate some XHTML
  * @return string
  */
 public function execute()
 {
     try {
         $this->phptal->setTemplate($this->template);
         return $this->phptal->execute();
     } catch (Exception $e) {
         $ex = new FrameEx($e->getMessage());
         $ex->backtrace = $e->getTrace();
         throw $ex;
     }
 }
示例#2
0
    public function getContent()
    {
        global $sql;
        //Lang::load('blocks/shoutbox/lang.*.php');
        $err = new Error();
        $note = new Notifier('note-shoutbox');
        $form['author'] = LOGGED ? User::$nickname : '';
        $form['message'] = '';
        if (isset($_POST['reply-shoutbox'])) {
            $form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
            $form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
            $err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
            $err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
            $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            // No errors
            if ($err->noErrors()) {
                $sql->exec('
					INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
					VALUES (
						' . TIMESTAMP . ',
						"' . $form['author'] . '",
						"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
						' . UID . ',
						"' . IP . '")');
                $sql->clearCache('shoutbox');
                $note->success(t('Entry was added successfully.'));
                redirect(HREF . PATH . '#shoutbox');
            } else {
                $note->error($err->toArray());
            }
        }
        // If cache for shoutbox doesn't exists
        if (!($entries = $sql->getCache('shoutbox'))) {
            $query = $sql->query('
				SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
				FROM ' . DB_PREFIX . 'shoutbox s
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
				ORDER BY s.id DESC
				LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
            while ($row = $query->fetch()) {
                if ($row['author_id']) {
                    $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    $row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
                }
                $entries[] = $row;
            }
            $sql->putCacheContent('shoutbox', $entries);
        }
        try {
            $tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
            $tpl->entries = $entries;
            $tpl->err = $err->toArray();
            $tpl->form = $form;
            $tpl->note = $note;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e->getMessage());
            //echo Note::error($e->getMessage());
        }
    }
示例#3
0
文件: View.php 项目: jeko/pksworld
 function execute()
 {
     // Variablen an Template zuweisen
     $this->__set('javascriptContent', $this->_javascript);
     $this->__set('messages', $this->_messages);
     parent::execute();
 }
示例#4
0
 private function echoExecute(PHPTAL $tpl)
 {
     try {
         ob_start();
         $this->assertEquals(0, strlen($tpl->echoExecute()));
         $res = ob_get_clean();
     } catch (Exception $e) {
         ob_end_clean();
         throw $e;
     }
     $res2 = $tpl->execute();
     $res3 = $tpl->execute();
     $this->assertEquals($res2, $res3, "Multiple runs should give same result");
     $this->assertEquals($res2, $res, "Execution with and without buffering should give same result");
     return normalize_html($res);
 }
示例#5
0
 /**
  * This method is used to process the data into the view and than return it to the main method that will handle what to do.
  * It also uses buffer to handle that content.
  *
  * @author Klederson Bueno <*****@*****.**>
  * @version 0.1a
  *
  * @param String $___phpBurnFilePath
  * @param Array $__phpBurnData
  * @return String
  */
 public function processViewData($___phpBurnFilePath, $__phpBurnData)
 {
     $tpl = new PHPTAL($___phpBurnFilePath);
     $tpl->setOutputMode(PHPTAL::HTML5);
     $tr = new PHPTAL_GetTextTranslator();
     // set language to use for this session (first valid language will
     // be used)
     $tr->setLanguage('pt_BR.utf8', 'pt_BR');
     // register gettext domain to use
     $tr->addDomain('system', SYS_BASE_PATH . 'locale');
     // specify current domain
     $tr->useDomain('system');
     // tell PHPTAL to use our translator
     $tpl->setTranslator($tr);
     foreach ($__phpBurnData as $index => $value) {
         if (is_string($value)) {
             $value = PhpBURN_Views::lazyTranslate($value, $_SESSION['lang']);
         }
         $tpl->{$index} = $value;
     }
     ob_start();
     try {
         echo $tpl->execute();
     } catch (Exception $e) {
         echo $e;
     }
     $___phpBurnBufferStored = ob_get_contents();
     //
     //        //Cleaning the buffer for new sessions
     ob_clean();
     return $___phpBurnBufferStored;
 }
示例#6
0
 public static function getForm($errors = array())
 {
     global $cfg;
     if (LOGGED) {
         redirect(REFERER);
     }
     $note = new Notifier();
     $err = new Error();
     if ($errors) {
         $note->error($errors);
     }
     if ($_POST['login'] && $_POST['module']) {
         $form = array('logname' => $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '', 'password' => $_POST['password-session'] ? filter($_POST['password-session'], 100) : '');
         $err->setError('empty_logname', t('Logname field is required.'))->condition(!$form['logname']);
         $err->setError('logname_not_exists', t('The logname you used isn&apos;t registered.'))->condition($form['logname'] && !User::loginNameRegistered($form['logname']));
         $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
         $err->setError('password_invalid', t('Password is invalid.'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
         $err->noErrors() ? redirect(REFERER) : $note->restore()->error($err->toArray());
     }
     $tpl = new PHPTAL('modules/login/form.html');
     $tpl->form = $form;
     $tpl->err = $err->toArray();
     $tpl->note = $note;
     echo $tpl->execute();
 }
示例#7
0
 /**
  * Return the content in the right format, it tell to the child class to execute template vars inflating
  *
  * @see controller::finalize
  *
  * @return mixed|void
  */
 public function finalize()
 {
     /**
      * Call child for template vars fill
      *
      */
     $this->setTemplateVars();
     try {
         $buffer = ob_get_contents();
         ob_get_clean();
         ob_start("ob_gzhandler");
         // compress page before sending
         $this->nocache();
         header('Content-Type: text/html; charset=utf-8');
         /**
          * Execute Template Rendering
          */
         echo $this->template->execute();
     } catch (Exception $e) {
         echo "<pre>";
         print_r($e);
         echo "\n\n\n";
         echo "</pre>";
         exit;
     }
 }
示例#8
0
 public function getContent()
 {
     // User is logged in
     if (LOGGED) {
         $this->subcodename = 'logged';
         $tpl = new PHPTAL('blocks/user_panel/logged.html');
         $tpl->user = User::format(User::$id, User::$nickname, User::$groupId);
         $pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm');
         $tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout'));
         return $tpl->execute();
     } else {
         $err = new Error();
         $note = new Notifier('note-user_panel');
         $this->subcodename = 'not_logged';
         $form = array('logname' => null, 'password' => null);
         if ($_POST['login'] && $_POST['user_panel']) {
             $form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '';
             $form['password'] = $_POST['password-session'] ? $_POST['password-session'] : '';
             $err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
             $err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname']));
             $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
             $err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
             if ($err->noErrors()) {
                 redirect('./');
             } else {
                 $note->error($err->toArray());
             }
         }
         $tpl = new PHPTAL('blocks/user_panel/not_logged.html');
         $tpl->note = $note;
         $tpl->form = $form;
         $tpl->err = $err->toArray();
         return $tpl->execute();
     }
 }
示例#9
0
文件: tal.php 项目: abbra/midcom
 public function render(&$toolbar)
 {
     if (!class_exists('PHPTAL')) {
         require 'PHPTAL.php';
     }
     $tal = new PHPTAL();
     $tal->toolbar = $toolbar;
     $tal->setSource($this->template);
     $html = $tal->execute();
     return $html;
 }
示例#10
0
 public function parse($tplDir, $tplFile, $args)
 {
     if (!$this->is_included) {
         $this->include_php_tal_file();
     }
     /**
      * @var PHPTAL
      */
     $tpl = new PHPTAL($tplDir . "/" . $tplFile);
     $tpl->doc = $args;
     return $tpl->execute();
 }
示例#11
0
    public function getContent()
    {
        global $sql;
        $note = new Notifier('note-poll');
        $stmt = $sql->setCache('poll_topic')->query('
			SELECT id, title, votes
			FROM ' . DB_PREFIX . 'poll_topics
			WHERE active = 1');
        $topic = $stmt->fetch(PDO::FETCH_ASSOC);
        if ($topic) {
            $vote_id = $sql->query('
				SELECT option_id
				FROM ' . DB_PREFIX . 'poll_votes
				WHERE topic_id = ' . $topic['id'] . ' AND voter_ip = "' . IP . '"')->fetchColumn();
            $stmt = $sql->setCache('poll_options')->query('
				SELECT id, title, votes
				FROM ' . DB_PREFIX . 'poll_options
				WHERE topic_id = ' . $topic['id'] . ' ORDER BY votes DESC');
            // User already voted
            if ($vote_id) {
                $options = array();
                $block->subcodename = 'results';
                foreach ($stmt as $row) {
                    $row['percent'] = @round(100 * ($row['votes'] / $topic['votes']), 1);
                    $options[] = $row;
                }
                $tpl = new PHPTAL('blocks/poll/results.html');
                $tpl->vote_id = $vote_id;
            } else {
                if ($_POST['vote-poll'] && $_POST['option-poll']) {
                    $option_id = (int) $_POST['option-poll'];
                    $sql->clearCacheGroup('poll_*')->exec('
					UPDATE ' . DB_PREFIX . 'poll_options o, ' . DB_PREFIX . 'poll_topics t
					SET o.votes = o.votes + 1, t.votes = t.votes + 1
					WHERE o.topic_id = ' . $topic['id'] . ' AND o.id = ' . $option_id . ' AND t.id = ' . $topic['id'] . ';
					INSERT INTO ' . DB_PREFIX . 'poll_votes (topic_id, option_id, voter_id, voter_ip, voted)
					VALUES (' . $topic['id'] . ', ' . $option_id . ', ' . $user->id . ', "' . IP . '", ' . TIMESTAMP . ')');
                    redirect(PATH . '#poll');
                } else {
                    $block->subcodename = 'voting';
                    $options = $stmt->fetchAll(PDO::FETCH_ASSOC);
                    $tpl = new PHPTAL('blocks/poll/voting.html');
                }
            }
            $stmt->closeCursor();
            $tpl->topic = $topic;
            $tpl->options = $options;
            $tpl->note = $note;
            return $tpl->execute();
        } else {
            return t('There is no content to display.');
        }
    }
示例#12
0
    public function getContent()
    {
        global $sql;
        // $kio->disableRegion('left');
        if (u1 || LOGGED) {
            // TODO: Zamiast zapytania dla własnego konta dać User::toArray()
            $profile = $sql->query('
				SELECT u.*
				FROM ' . DB_PREFIX . 'users u
				WHERE u.id = ' . (ctype_digit(u1) ? u1 : UID))->fetch();
        }
        if ($profile) {
            Kio::addTitle(t('Users'));
            Kio::addBreadcrumb(t('Users'), 'users');
            Kio::addTitle($profile['nickname']);
            Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1 . '/' . clean_url($profile['nickname']));
            Kio::setDescription(t('%nickname&apos;s profile', array('%nickname' => $profile['nickname'])) . ($profile['title'] ? ' - ' . $profile['title'] : ''));
            Kio::addTabs(array(t('Edit profile') => 'edit_profile/' . u1));
            if ($profile['birthdate']) {
                $profile['bd'] = $profile['birthdate'] ? explode('-', $profile['birthdate']) : '';
                // DD Month YYYY (Remaining days to next birthday)
                $profile['birthdate'] = $profile['bd'][2] . ' ' . Kio::$months[$profile['bd'][1]] . ' ' . $profile['bd'][0] . ' (' . day_diff(mktime(0, 0, 0, $profile['bd'][1], $profile['bd'][2] + 1, date('y')), t('%d days remaining')) . ')';
                $profile['age'] = get_age($profile['bd'][2], $profile['bd'][1], $profile['bd'][0]);
                if (Plugin::exists('zodiac')) {
                    require_once ROOT . 'plugins/zodiac/zodiac.plugin.php';
                    $profile['zodiac'] = Zodiac::get($profile['bd'][2], $profile['bd'][1]);
                }
            }
            if ($profile['http_agent'] && Plugin::exists('user_agent')) {
                require_once ROOT . 'plugins/user_agent/user_agent.plugin.php';
                $profile['os'] = User_Agent::getOS($profile['http_agent']);
                $profile['browser'] = User_Agent::getBrowser($profile['http_agent']);
            }
            $group = Kio::getGroup($profile['group_id']);
            $profile['group'] = $group['name'] ? $group['inline'] ? sprintf($group['inline'], $group['name']) : $group['name'] : '';
            if ($profile['gender']) {
                $profile['gender'] = $profile['gender'] == 1 ? t('Male') : t('Female');
            }
            try {
                // TODO: Zrobić modyfikator dla funkcji o wielu parametrach (teraz jest tylko jeden możliwy)
                $tpl = new PHPTAL('modules/profile/profile.tpl.html');
                $tpl->profile = $profile;
                return $tpl->execute();
            } catch (Exception $e) {
                return template_error($e);
            }
        } else {
            return not_found(t('Selected user doesn&apos;t exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
        }
    }
示例#13
0
 public function getContent()
 {
     //Lang::load('blocks/calendar/lang.*.php');
     $today = date('j');
     $month = date('n');
     $year = date('Y');
     if ($month < 8 && $month % 2 == 1 || $month > 7 && $month % 2 == 0) {
         $total_days = 31;
     } else {
         $total_days = $month == 2 ? date('L') ? 29 : 28 : 30;
     }
     $first_day = date('w', mktime(1, 1, 1, $month, 0, $year));
     $last_day = date('w', mktime(1, 1, 1, $month, $total_days - 1, $year));
     if ($first_day != 0) {
         $colspan = $first_day;
     }
     if (6 - $last_day != 0) {
         $colspan2 = 6 - $last_day;
     }
     $days = null;
     for ($day = 1; $day <= $total_days; ++$day) {
         $day_of_week = date('w', mktime(1, 1, 1, $month, $day - 1, $year));
         if ($day == 1 || $day_of_week == 0) {
             $days .= '<tr class="border-1-parent" title="' . t('Week: %week', array('%week' => date('W', mktime(1, 1, 1, $month, $day, $year)))) . '">';
             if ($colspan > 0 && $day == 1) {
                 $days .= '<td colspan="' . $colspan . '" class="empty">&nbsp;</td>';
             }
         }
         $days .= '<td><a';
         if ($day == $today) {
             $days .= ' class="today border-2"';
         }
         $days .= ' href="#' . $day . '.' . $month . '.' . $year . '">' . $day . '</a></td>';
         if ($day == $total_days && $colspan2 > 0) {
             $days .= '<td colspan="' . $colspan2 . '" class="empty">&nbsp;</td>';
         }
         if ($day_of_week == 6 || $day == $total_days) {
             $days .= '</tr>';
         }
     }
     try {
         $tpl = new PHPTAL('blocks/calendar/month_view.html');
         $tpl->days = $days;
         $tpl->month_year = date('m') . '/' . $year;
         return $tpl->execute();
     } catch (Exception $e) {
         return template_error($e->getMessage());
     }
 }
示例#14
0
    public function getContent()
    {
        global $sql;
        $pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users'));
        $pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc');
        $query = $sql->query('
			SELECT id, name, inline, members
			FROM ' . DB_PREFIX . 'groups
			ORDER BY display_order');
        while ($row = $query->fetch()) {
            if ($row['inline']) {
                $row['name'] = sprintf($row['inline'], $row['name']);
            }
            $groups[] = $row;
        }
        $query = $sql->query('
			SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name
			FROM ' . DB_PREFIX . 'users u
			LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id
			ORDER BY ' . $pager->orderBy . '
			LIMIT ' . $pager->limit . '
			OFFSET ' . $pager->offset);
        while ($row = $query->fetch()) {
            $row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']);
            switch ($row['gender']) {
                case 1:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />';
                    break;
                case 2:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />';
                    break;
                default:
                    $row['gender'] = '';
            }
            $users[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/users/users.tpl.html');
            $tpl->sort = $pager->sorters;
            $tpl->users = $users;
            $tpl->groups = $groups;
            $tpl->pagination = $pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
示例#15
0
文件: PHPTAL.php 项目: hasanozgan/joy
 public function execute($view)
 {
     parent::execute($view);
     return $view->render();
     $context = Joy_Context::getInstance();
     $resource = $view->getResourceList();
     $context->response->addScript($resource["javascripts"]);
     $context->response->addStyle($resource["stylesheets"]);
     $application = $context->config->application->get("application");
     $application["i18n"] = $view->getLocale();
     $tpl = new PHPTAL();
     $tpl->setSource($view->getTemplate());
     $tpl->import = new Joy_Render_Template_Importer($view);
     $tpl->application = $application;
     $tpl->get = (array) $view->assignAll();
     return $tpl->execute();
 }
示例#16
0
 public function getContent()
 {
     $err = new Error();
     $note = new Notifier('note-newsletter');
     $form = array();
     $tpl = 'blocks/newsletter/newsletter_form.html';
     if (isset($_POST['add-newsletter']) || isset($_POST['delete-newsletter']) || isset($_POST['delete2-newsletter'])) {
         include_once ROOT . 'blocks/newsletter/action.php';
     }
     try {
         $tpl = new PHPTAL($tpl);
         $tpl->err = $err->toArray();
         $tpl->note = $note;
         $tpl->form = $form;
         return $tpl->execute();
     } catch (Exception $e) {
         return template_error($e->getMessage());
     }
 }
示例#17
0
 /**
  * This method is used to process the data into the view and than return it to the main method that will handle what to do.
  * It also uses buffer to handle that content.
  *
  * @author Klederson Bueno <*****@*****.**>
  * @version 0.1a
  *
  * @param String $___phpBurnFilePath
  * @param Array $__phpBurnData
  * @return String
  */
 public function processViewData($___phpBurnFilePath, $__phpBurnData)
 {
     $tpl = new PHPTAL($___phpBurnFilePath);
     $tpl->setOutputMode(PHPTAL::HTML5);
     foreach ($__phpBurnData as $index => $value) {
         $tpl->{$index} = $value;
     }
     ob_start();
     try {
         echo $tpl->execute();
     } catch (Exception $e) {
         echo $e;
     }
     $___phpBurnBufferStored = ob_get_contents();
     //
     //        //Cleaning the buffer for new sessions
     ob_clean();
     return $___phpBurnBufferStored;
 }
示例#18
0
function vanilla_shortcode($shortcode)
{
    global $tpl_set, $tpl;
    $active_template = vanilla_get_template('shortcodes/' . $shortcode . ".html");
    if (!$active_template) {
        return "";
    }
    // No need to include the PHP tpl file here. Already loaded at init.
    $tpl_source = '<metal:block define-macro="' . $shortcode . '_shortcode">' . "\n" . "<!-- shortcode: " . $shortcode . " -->\n" . '<span tal:condition="php:VANILLA_DEBUG" class="widget-debug">SHORTCODE: ' . $shortcode . '</span>' . "\n" . '<span metal:use-macro="' . $active_template . '/loader" />' . "\n" . '<span metal:define-slot="' . $shortcode . '" />' . "\n" . '</metal:block><metal:block use-macro="' . $shortcode . '_shortcode" />' . "\n";
    //return "<textarea style='width:500px; height:300px;'> $tpl_source </textarea>";
    // Load and fire the PHPTAL template!
    $template = new PHPTAL();
    $template->setSource($tpl_source, $tpl_set . $shortcode);
    $template->set('vanilla', $tpl);
    try {
        return $template->execute();
    } catch (Exception $e) {
        return $e;
    }
}
示例#19
0
 /**
  * Get the evaluated contents of the view.
  *
  * @param string $path
  * @param array $data
  *
  * @return string
  */
 public function get($path, array $data = [])
 {
     if (!empty($data)) {
         foreach ($data as $field => $value) {
             // Creating error properties in ViewErrorBag
             if ($field == 'errors') {
                 $bags = $value->getBags();
                 if (!in_array('default', array_keys($bags))) {
                     $value->default = new MessageBag([]);
                 }
                 $this->phptal->errors = $value;
             }
             if (!preg_match('/^_|\\s/', $field)) {
                 $this->phptal->{$field} = $value;
             }
         }
     }
     $this->phptal->setTemplate($path);
     return $this->phptal->execute();
 }
示例#20
0
 function apply(&$regionContent)
 {
     $this->checkRequiredValues($regionContent);
     $templateSource = @implode('', file($this->fileName));
     $templateSource = $this->fixUrl($templateSource);
     $compiler = org_glizy_ObjectFactory::createObject('org.glizy.compilers.Skin');
     $compiledFileName = $compiler->verify($this->fileName, array('defaultHtml' => $templateSource));
     $pathInfo = pathinfo($compiledFileName);
     $templClass = new PHPTAL($pathInfo['basename'], $pathInfo['dirname'], org_glizy_Paths::getRealPath('CACHE_CODE'));
     foreach ($regionContent as $region => $content) {
         $templClass->set($region, $content);
     }
     $res = $templClass->execute();
     if (PEAR::isError($res)) {
         $templateSource = $res->toString() . "\n";
     } else {
         $templateSource = $res;
     }
     if (isset($regionContent['__body__'])) {
         $templateSource = $this->modifyBodyTag($regionContent['__body__'], $templateSource);
     }
     $templateSource = $this->fixLanguages($templateSource);
     return $templateSource;
 }
示例#21
0
 * You should have received a copy of the GNU Affero General Public License
 * along with eCamp.  If not, see <http://www.gnu.org/licenses/>.
 */
include "./config.php";
include $lib_dir . "/mysql.php";
include $lib_dir . "/functions/error.php";
require_once "./lib/PHPTAL.php";
db_connect();
$user_id = mysql_escape_string($_REQUEST['user_id']);
$login = mysql_escape_string($_REQUEST['login']);
$acode = mysql_escape_string($_REQUEST['acode']);
$query = "\tSELECT user.id FROM user WHERE id = {$user_id} AND mail = '{$login}' AND acode = '{$acode}'";
$result = mysql_query($query);
if (mysql_error() || !mysql_num_rows($result)) {
    die("FEHLER; Support anfragen");
}
if ($_SESSION[skin] == "") {
    $_SESSION[skin] = $GLOBALS[skin];
}
$html = new PHPTAL("public/skin/" . $_SESSION[skin] . "/pwreset.tpl");
$html->setEncoding('UTF-8');
$html->set('SHOW_MSG', false);
if (isset($_REQUEST['msg'])) {
    $html->set('SHOW_MSG', true);
    $html->set('MSG', mysql_escape_string($_REQUEST['msg']));
}
$html->set('user_id', $user_id);
$html->set('login', $login);
$html->set('acode', $acode);
echo $html->execute();
示例#22
0
<?php

require_once './libs/PHPTAL-1.3.0/PHPTAL.php';
// render the whole page using PHPTAL
// finally, create a new template object
$template = new PHPTAL('admin.xhtml');
// now add the variables for processing and that you created from above:
$template->page_title = "Admin Signup";
// execute the template
try {
    echo $template->execute();
} catch (Exception $e) {
    // not much else we can do here if the template engine barfs
    echo $e;
}
示例#23
0
// KioCMS - Kiofol Content Managment System
// modules/news/admin/entries/index.php
if ($kio->stats['news_entries']) {
    $pager = new Pager('admin/modules/news', $kio->stats['news_entries']);
    $pager->limit()->sort(array(t('ID') => 'n_id', t('Title') => 'n_title', t('Language') => 'lang', t('Content') => 'content', t('Author') => 'nickname', t('Category') => 'c_name', t('Added') => 'added'), 'added', 'desc');
    $query = $sql->query('
		SELECT u.nickname, u.group_id, c.id c_id, c.name c_name, c.description c_description, n.*, n.id n_id, n.title n_title
		FROM ' . DB_PREFIX . 'news n
		LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = n.author_id
		LEFT JOIN ' . DB_PREFIX . 'news_categories c ON c.id = n.category_id
		ORDER BY ' . $pager->order . '
		LIMIT ' . $pager->limit . '
		OFFSET ' . $pager->offset);
    while ($row = $query->fetch()) {
        if ($row['author_id']) {
            $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
        }
        $row['url_title'] = ($row['c_name'] ? clean_url($row['c_name']) . '/' : null) . clean_url($row['title']);
        $entries[] = $row;
    }
    $tpl = new PHPTAL('modules/news/admin/entries.html');
    $tpl->stats = $kio->stats;
    $tpl->entries = $entries;
    $tpl->sort = $pager->sorters;
    $tpl->limit_form = $pager->limit_form;
    $tpl->pagination = $pager->links();
    echo $tpl->execute();
} else {
    echo $lang_admin['NULL'];
}
示例#24
0
    public function getContent()
    {
        global $sql;
        $err = new Error();
        $form = array();
        if (Kio::getConfig('informations', 'contact')) {
            $info = Notifier::factory('note-contact_info')->info(parse(Kio::getConfig('informations', 'contact'), BBCODE . AUTOLINKS . EMOTICONS . CENSURE . PRE));
        }
        if (isset($_POST['send'])) {
            // Form values
            $form = array('receiver' => filter($_POST['receiver'], 100), 'sender' => LOGGED ? User::$nickname : filter($_POST['sender'], 100), 'email' => LOGGED ? User::$email : filter($_POST['email'], 100), 'subject' => filter($_POST['subject'], 100), 'message' => filter($_POST['message'], 250));
            if (!empty($_COOKIE[COOKIE . '-flood-contact']) && Kio::getConfig('flood_interval')) {
                $err->setError('flood', t('ERROR_FLOOD'));
            } else {
                // Errors
                if (!LOGGED) {
                    $err->setError('sender_empty', t('Sender field is required.'))->condition(!$form['sender']);
                    $err->setError('sender_exists', t('ERROR_SENDER_EXISTS'))->condition(is_registered($form['sender'], 'nickname'));
                    $err->setError('email_empty', t('E-mail address field is required.'))->condition(!$form['email']);
                    $err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email']));
                }
                //				$err->setError('phone_invalid', t('ERROR_PHONE_INVALID'))
                //					->condition($form['phone'] && !preg_match('#^[0-9 ()+-]+$#', $form['phone']));
                $err->setError('subject_empty', t('Subject field is required.'))->condition(!$form['subject']);
                $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            }
            if ($err->noErrors()) {
                $from = "From: {$form['email']}2";
                $msg = "Imię: {$imie}\nE-Mail: {$form['email']}2\nTelefon: {$telefon}\n\nTreść wiadomości:\n{$form['message']}\n\n\n----\nWiadomość została wysłana ze strony {$adres}\nIP: {$ip}";
                echo mail($form['email'], $temat, $msg, $from) ? $note->success(t('SUCCESS')) . redirect() : $note->error(t('Wystąpił błąd, spróbuj wysłać później'));
                if (Kio::getConfig('flood_interval')) {
                    setcookie(COOKIE . '-contact', 'true', TIMESTAMP + Kio::getConfig('flood_interval') + 1, '/');
                }
                $to = "*****@*****.**";
                $subject = "Test mail";
                $message = "Hello! This is a simple email message.";
                $from = "*****@*****.**";
                $headers = "From: {$from}";
                mail($to, $subject, $message, $headers);
            } else {
                $this->note->error($err->toArray());
            }
        }
        $stmt = $sql->setCache('contact')->prepare('
			SELECT id, nickname, group_id
			FROM ' . DB_PREFIX . 'users
			WHERE id IN (:receivers)');
        $stmt->bindParam(':receivers', Kio::getConfig('receivers', 'contact'));
        $stmt->execute();
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $row['g_name'] = Kio::getGroup($row['group_id'], 'name');
            $receivers[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/contact/contact.tpl.html');
            $tpl->message_limit = Kio::getConfig('message_max', 'contact');
            $tpl->form = $form;
            $tpl->user = User::toArray();
            $tpl->receivers = $receivers;
            $tpl->err = $err->toArray();
            $tpl->note = $this->note;
            $tpl->info = isset($info) ? $info : '';
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
示例#25
0
文件: midgard.php 项目: abbra/midcom
 /**
  * Show the loaded contents using the template engine
  *
  * @param string $content Content to display
  */
 public function display()
 {
     $data = $_MIDCOM->context->get();
     $cache_file = $this->cache_directory . '/' . $this->get_cache_identifier() . '.php';
     ob_start();
     include $cache_file;
     $content = ob_get_clean();
     // FIXME: Remove this once we can actually invalidate cache
     unlink($cache_file);
     switch ($data['template_engine']) {
         case 'tal':
             if (!class_exists('PHPTAL')) {
                 require 'PHPTAL.php';
                 include_once 'TAL/modifiers.php';
             }
             if ($_MIDCOM->timer) {
                 $_MIDCOM->timer->setMarker('post-require');
             }
             $tal = new PHPTAL($this->get_cache_identifier());
             $tal->show_toolbar = false;
             if (isset($_MIDCOM->toolbar) && $_MIDCOM->toolbar->can_view()) {
                 $tal->show_toolbar = true;
             }
             if ($_MIDCOM->timer) {
                 $_MIDCOM->timer->setMarker('post-set-show_toolbar');
             }
             $tal->uimessages = false;
             $uimessages = $_MIDCOM->serviceloader->load('uimessages');
             if ($uimessages->has_messages() && $uimessages->can_view()) {
                 $tal->uimessages = $uimessages->render();
             }
             if ($_MIDCOM->timer) {
                 $_MIDCOM->timer->setMarker('post-set-show_uimessages');
             }
             //TODO: Do something else here :)
             $tal->navigation = false;
             /*$tal->navigation = $_MIDCOM->navigation;
               
               if ($_MIDCOM->timer)
               {
                   $_MIDCOM->timer->setMarker('post-set-navigation');
               }*/
             $tal->MIDCOM = $_MIDCOM;
             if ($_MIDCOM->timer) {
                 $_MIDCOM->timer->setMarker('post-set-MIDCOM');
             }
             foreach ($data as $key => $value) {
                 $tal->{$key} = $value;
                 if ($_MIDCOM->timer) {
                     $_MIDCOM->timer->setMarker("post-set-{$key}");
                 }
             }
             $tal->setSource($content);
             if ($_MIDCOM->timer) {
                 $_MIDCOM->timer->setMarker('post-source');
             }
             $content = $tal->execute();
             if ($_MIDCOM->timer) {
                 $_MIDCOM->timer->setMarker('post-execute');
             }
             break;
         default:
             break;
     }
     echo $content;
     if ($_MIDCOM->timer && $_MIDCOM->context->get_current_context() == 0 && $_MIDCOM->context->mimetype == 'text/html') {
         $_MIDCOM->timer->display();
     }
     if ($_MIDCOM->configuration->get('enable_included_list')) {
         $included = get_included_files();
         echo "<p>" . count($included) . " included files:</p>\n";
         echo "<ul>\n";
         foreach ($included as $filename) {
             echo "<li>{$filename}</li>\n";
         }
         echo "</ul>\n";
     }
     ///TODO: Connect this to some signal that tells the MidCOM execution has ended.
     $uimessages = $_MIDCOM->serviceloader->load('uimessages');
     $uimessages->store();
 }
示例#26
0
    public function getContent()
    {
        global $sql;
        $this->err = new Error();
        $this->pager = new Pager('guestbook', Kio::getStat('entries', 'guestbook'), Kio::getConfig('limit', 'guestbook'));
        $show_form = true;
        $entries = $this->getEntries();
        // Editing entry
        if (ctype_digit(u2)) {
            // guestbook/edit/u2
            $edited_id = u1 == 'edit' ? u2 : '';
            if (!User::hasPermit('guestbook edit')) {
                $this->note->error(t('You don&apos;t have access to edit entries.'));
                $show_form = false;
            } else {
                if ($edited_id) {
                    $row = $sql->query('
					SELECT id, added, author, author_id, author_ip, email, website, message
					FROM ' . DB_PREFIX . 'guestbook
					WHERE id = ' . $edited_id)->fetch();
                    // Entry exists
                    if ($row) {
                        $form = $row;
                        $this->edit_mode = true;
                        if (!$row['author']) {
                            $form['author'] = User::getNickname(BY_ID, $row['author_id']);
                        }
                    } else {
                        $this->note->error(t('Selected entry doesn&apos;t exist.'));
                    }
                }
            }
        }
        if (!$this->edit_mode) {
            $form['author'] = User::$nickname;
        }
        // Form action
        $add = isset($_POST['add']) ? true : false;
        $edit = isset($_POST['edit']) ? true : false;
        // On form submit
        if ($add || $edit) {
            $form = $this->formSumbit();
        } else {
            if (isset($_POST['delete_id']) && ctype_digit($_POST['delete_id']) && $_POST['auth'] == AUTH && User::hasPermit('guestbook delete')) {
                $sql->exec('
				UPDATE ' . DB_PREFIX . 'stats SET content = content - 1 WHERE name = "guestbook_entries";
				DELETE FROM ' . DB_PREFIX . 'guestbook WHERE id = ' . $_POST['delete_id']);
                $sql->clearCacheGroup('guestbook_*');
            }
        }
        try {
            $tpl = new PHPTAL('modules/guestbook/guestbook.tpl.html');
            $tpl->message_limit = Kio::getConfig('message_max', 'guestbook');
            $tpl->form = $form;
            $tpl->edit_mode = $this->edit_mode;
            $tpl->entries = $entries;
            $tpl->err = $this->err->toArray();
            $tpl->show_form = $show_form;
            $tpl->note = $this->note;
            $tpl->pagination = $this->pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
示例#27
0
 public function getContent()
 {
     $tpl = new PHPTAL('blocks/searcher/search_form.html');
     return $tpl->execute();
 }
示例#28
0
    public function getContent()
    {
        global $sql;
        $this->err = new Error();
        $pager = new Pager('guestbook', Kio::getStat('entries', 'guestbook'), Kio::getConfig('limit', 'guestbook'));
        if (Kio::getConfig('order_by', 'guestbook') == 'DESC') {
            $x = $pager->items + 1 - $pager->offset;
            $y = '$x--;';
        } else {
            $x = $pager->offset;
            $y = '$x++;';
        }
        //		$entries = $sql->getCache('guestbook_'.$pager->current);
        if (!$entries) {
            $stmt = $sql->query('
				SELECT gb.id, gb.added, gb.author, gb.email, gb.website, gb.message, gb.author_id, gb.author_ip,
					u.nickname, u.group_id, u.avatar, u.signature
				FROM ' . DB_PREFIX . 'guestbook gb
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = gb.author_id
				ORDER BY gb.id ' . Kio::getConfig('order_by', 'guestbook') . '
				LIMIT ' . $pager->limit . '
				OFFSET ' . $pager->offset);
            if ($stmt->rowCount()) {
                while ($row = $stmt->fetch()) {
                    eval($y);
                    $row['number'] = $x;
                    if ($row['author_id']) {
                        $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    }
                    $row['message'] = parse($row['message'], Kio::getConfig('parsers', 'guestbook'));
                    $row['signature'] = $row['signature'] ? parse($row['signature'], Kio::getConfig('parsers', 'guestbook')) : '';
                    $entries[] = $row;
                }
                $sql->putCacheContent('guestbook_' . $pager->current, $entries);
            } else {
                $this->note->info('Jeszcze nikt nie dodał żadnego wpisu.');
            }
        }
        // Editing entry
        if (ctype_digit(u2)) {
            // guestbook/edit/u2
            $edited_id = u1 == 'edit' ? u2 : '';
            if (!User::hasPermit('guestbook edit')) {
                $this->note->error(t('You do not have access to edit entries.'));
            } else {
                if ($edited_id) {
                    $row = $sql->query('
					SELECT id, added, author, author_id, author_ip, email, website, message
					FROM ' . DB_PREFIX . 'guestbook
					WHERE id = ' . $edited_id)->fetch();
                    // Entry exists
                    if ($row) {
                        $form = $row;
                        $form['edit_mode'] = true;
                        if (!$row['author']) {
                            $form['author'] = User::getNickname(BY_ID, $row['author_id']);
                        }
                    } else {
                        $this->note->error(t('Selected entry doesn&apos;t exist.'));
                    }
                }
            }
        }
        if (!$form['edit_mode']) {
            $form['author'] = User::$nickname;
        }
        // Form action
        $add = $_POST['add'] ? true : false;
        $edit = $_POST['edit'] ? true : false;
        // On form submit
        if ($add || $edit) {
            $this->formSumbit();
        } else {
            if (ctype_digit($_POST['delete_id']) && $_POST['auth'] == AUTH && User::hasPermit('guestbook delete')) {
                $sql->exec('
				UPDATE ' . DB_PREFIX . 'stats SET content = content - 1 WHERE name = "guestbook_entries";
				DELETE FROM ' . DB_PREFIX . 'guestbook WHERE id = ' . $_POST['delete_id']);
                $sql->clearCacheGroup('guestbook_*');
            }
        }
        try {
            $tpl = new PHPTAL('modules/guestbook/guestbook.tpl.html');
            $tpl->message_limit = Kio::getConfig('message_max', 'guestbook');
            $tpl->form = $form;
            $tpl->entries = $entries;
            $tpl->err = $this->err->toArray();
            $tpl->note = $this->note;
            $tpl->pagination = $pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
示例#29
0
    public $name;
    public $phone;
    function Person($name, $phone)
    {
        $this->name = $name;
        $this->phone = $phone;
    }
    function getName($val)
    {
        return $val;
    }
}
// Создаем массив объектов для тестирования
$people = array();
$people[] = new Person("foo", "01-344-121-021");
$people[] = new Person("bar", "05-999-165-541");
$people[] = new Person("baz", "01-389-321-024");
$people[] = new Person("quz", "05-321-378-654");
// Передаем массив данных обработчику шаблонов
$template->title = 'Я Заголовок';
$template->subj = $subj;
$template->people = $people;
$template->store = $store;
// Выполняем обработку шаблона
try {
    $editortmpl->tmpl = $template->execute();
    //    echo $editortmpl->execute();
    echo $template->execute();
} catch (Exception $e) {
    echo $e;
}
示例#30
0
    private function getEntries()
    {
        global $sql;
        $pager_url = 'news';
        $category_id = 0;
        if (u1 == 'category') {
            $category_id = (int) u2;
        }
        $total = Kio::getStat('entries', 'news');
        if ($category_id) {
            $category = $sql->setCache('news_categories_' . $category_id)->query('
				SELECT id, name, description, entries
				FROM ' . DB_PREFIX . 'news_categories
				WHERE id = ' . $category_id)->fetch(PDO::FETCH_ASSOC);
            if ($category) {
                $total = $category['entries'];
                if ($category['description']) {
                    Kio::setDescription($category['name'] . ' - ' . $category['description']);
                }
                Kio::addTitle($category['name']);
                Kio::addBreadcrumb($category['name'], 'news/category/' . $category_id . '/' . clean_url($category['name']));
                $pager_url = 'news/category/' . $category_id . '/' . clean_url($category['name']);
            } else {
                return not_found(t('Selected category does not exists.'), array(t('Category was moved or deleted.'), t('Entered URL is invalid.')));
            }
        }
        if (!empty($category) || empty($category)) {
            $this->subcodename = 'entries';
            $pager = new Pager($pager_url, $total, Kio::getConfig('limit', 'news'));
            $stmt = $sql->setCache('news_' . $category_id . '_' . $pager->current)->query('
				SELECT u.nickname, u.group_id, c.id c_id, c.name c_name, c.description c_description, n.*
				FROM ' . DB_PREFIX . 'news n
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = n.author_id
				LEFT JOIN ' . DB_PREFIX . 'news_categories c ON c.id = n.category_id
				WHERE ' . ($category_id ? 'c.id = ' . $category_id . '
					AND ' : '') . (LOGGED ? 'n.publication > 0' : 'n.publication = 1') . '
					AND n.added < ' . TIMESTAMP . '
				ORDER BY ' . Kio::getConfig('order_by', 'news') . '
				LIMIT ' . $pager->limit . '
				OFFSET ' . $pager->offset);
            while ($row = $stmt->fetch()) {
                if ($row['author_id']) {
                    $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                }
                $row['url_title'] = ($row['c_name'] ? clean_url($row['c_name']) . '/' : '') . clean_url($row['title']);
                $row['content'] = parse($row['content'], Kio::getConfig('parsers', 'news'));
                $entries[] = $row;
            }
            try {
                $tpl = new PHPTAL('modules/news/news.tpl.html');
                $tpl->entries = $entries;
                $tpl->pagination = $pager->getLinks();
                return $tpl->execute();
            } catch (Exception $e) {
                return template_error($e);
            }
        }
    }