当前位置: 首页>>代码示例>>PHP>>正文


PHP template::start_block方法代码示例

本文整理汇总了PHP中template::start_block方法的典型用法代码示例。如果您正苦于以下问题:PHP template::start_block方法的具体用法?PHP template::start_block怎么用?PHP template::start_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在template的用法示例。


在下文中一共展示了template::start_block方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: template

 static function mod_pg($pg)
 {
     $p = plugins::getinst();
     $user = $p->d->getrow('SELECT * FROM users WHERE name="' . $pg . '";');
     if ($user->account_id == $_SESSION['datiaccount']['id']) {
         $t = new template('template/mod_pg.tpl');
         $t->assign_var('PG_NAME', $pg);
         if ($_POST) {
             $query = 'UPDATE users SET description="' . $_POST['desc'] . '",image="' . $_POST['image'] . '" WHERE name="' . $pg . '";';
             $upd = $p->d->query($query);
             if (!$upd) {
                 $t->start_block('mod_failed');
                 $t->end_block('mod_failed');
             } else {
                 $t->start_block('mod_success');
                 $t->end_block('mod_success');
             }
         } else {
             $t->start_block('mod_failed');
             $t->end_block('mod_failed');
         }
         $p->action('mod_pg');
         $t->out();
     }
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:25,代码来源:scheda.php

示例2: template

 static function mp_list_arrived($page = 1)
 {
     global $t;
     $p = plugins::getinst();
     $msg_for_page = 10;
     $limit = ($page - 1) * $msg_for_page;
     $t = new template('template/mp_list.tpl');
     $msgs = $p->d->getresults('SELECT * FROM messaggi WHERE dest="' . $_SESSION['datiuser']['id'] . '" ORDER BY id DESC LIMIT ' . $limit . ',' . $msg_for_page . ';');
     if ($msgs) {
         $t->start_block('if_messages');
         foreach ($msgs as $msg) {
             $t->start_block('messaggio');
             $t->assign_block_vars(array('TIME' => $msg->time, 'TO' => $_SESSION['datiuser']['name'], 'FROM' => $p->d->getvar('SELECT name FROM users WHERE id="' . $msg->mittente . '";'), 'ID' => $msg->id));
             $t->end_block('messaggio');
         }
         $t->end_block('if_messages');
         $num_mess = $p->d->getvar('SELECT COUNT(`id`) FROM messaggi WHERE dest="' . $_SESSION['datiuser']['id'] . '";');
         for ($i = 1; $i <= $num_mess / $msg_for_page + 1; $i++) {
             $t->to_comp['if_pages'][0]['link_page'][] = array('TYPE' => 'arrived', 'PAGE' => $i);
         }
     } else {
         $t->to_comp['if_not_messages'][] = array();
     }
     $p->action('mp_list_arrived');
     @$t->out();
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:26,代码来源:mp.php

示例3: template

 static function get_chat($last_time = NULL)
 {
     $p = plugins::getinst();
     $t = new template('template/chat_messages.tpl');
     $chat_id = $_SESSION['stanza'];
     $query = 'SELECT * FROM messaggi_chat WHERE time > "' . $last_time . '" AND chat_id="' . $chat_id . '" ORDER BY time DESC;';
     if (empty($last_time)) {
         $query = 'SELECT * FROM messaggi_chat WHERE time > ' . (time() * 1000 - 30 * 60 * 1000) . ' AND chat_id="' . $chat_id . '" ORDER BY time DESC;';
     }
     $messages = $p->d->getresults($query);
     if ($messages) {
         foreach ($messages as $mess) {
             $time = date('H:i', $mess->time / 1000);
             $t->start_block('message');
             $message = array('HOUR' => $time, 'USERNAME' => $mess->user, 'TEXT' => stripslashes($mess->text));
             switch ($mess->text[0]) {
                 //in base al primo carattere del messaggio
                 //se è un + il messaggio è in terza persona
                 case '+':
                     $t->start_block('third_person');
                     $message['TEXT'] = substr($message['TEXT'], 1);
                     $t->assign_block_vars($message);
                     //assegno l'array message preparato prima
                     $t->end_block('third_person');
                     break;
                     //se è * è del master, ma controllo che chi l'ha scritto sia realmente un master prima
                 //se è * è del master, ma controllo che chi l'ha scritto sia realmente un master prima
                 case '*':
                     $master = $p->d->getvar('SELECT master FROM accounts WHERE id=(SELECT account_id FROM users WHERE name="' . $mess->user . '");');
                     if ($master == 1) {
                         $t->start_block('master');
                         $message['TEXT'] = substr($message['TEXT'], 1);
                         $t->assign_block_vars($message);
                         //assegno l'array message preparato prima
                         $t->end_block('master');
                     } else {
                         $t->to_comp['message'][]['normal'][] = $message;
                     }
                     break;
                     //altrimenti è un messaggio normale
                 //altrimenti è un messaggio normale
                 default:
                     $t->start_block('normal');
                     $t->assign_block_vars($message);
                     //assegno l'array message preparato prima
                     $t->end_block('normal');
                     break;
             }
             $t->end_block('message');
         }
     }
     //$p->action('chat_body');
     @$t->out();
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:54,代码来源:stanza.php

示例4: template

 static function chat_mod($id = 0)
 {
     global $t;
     $p = plugins::getinst();
     $t = new template('template/chat_mod.tpl');
     //controllo che l'utente sia admin
     $access = control_access(ADMIN_ACCESS);
     if (!$access) {
         $t->block_null('not_admin');
         $t->out();
         exit;
     }
     //faccio un update della stanza in base ai dati che mi sono arrivati
     $query = 'UPDATE stanze SET name="' . mysql_real_escape_string(htmlspecialchars($_POST['name'])) . '",image="' . mysql_real_escape_string(htmlspecialchars($_POST['img'])) . '",description="' . mysql_real_escape_string(htmlspecialchars($_POST['desc'])) . '" WHERE id="' . mysql_real_escape_string($id) . '";';
     //Apro il blocco
     $t->start_block('is_admin');
     //faccio la query e controllo l'esito
     $upd = $p->d->query($query);
     if (!$upd) {
         $t->block_null('mod_failed');
     } else {
         $t->block_null('mod_success');
     }
     //Chiudo il blocco
     $t->end_block('is_admin');
     //Eseguo l'azione "chat_mod"
     $p->action('chat_mod');
     $t->out();
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:29,代码来源:gst_chats.php

示例5: template

 static function news_list()
 {
     $p = plugins::getinst();
     $t = new template('template/news_list.tpl');
     $messages = $p->d->getresults('SELECT * FROM news ORDER BY id DESC;');
     foreach ($messages as $news) {
         $t->start_block('news_row');
         $t->assign_block_vars(array('AUTHOR' => $news->author, 'DATE' => $news->date, 'TEXT' => stripslashes($news->text)));
         $t->end_block('news_row');
     }
     $t->out();
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:12,代码来源:news.php

示例6: template

 static function register_action()
 {
     global $p;
     $t = new template('template/register.tpl');
     //inizializzo il template
     if ($_POST) {
         //controllo e modifico le stringhe passate per evitare bugs
         $email = mysql_real_escape_string(htmlspecialchars($_POST['email']));
         $username = mysql_real_escape_string(htmlspecialchars($_POST['username']));
         //$surname=mysql_real_escape_string(htmlspecialchars($_POST['surname']));
         $password = md5($_POST['password']);
         //$race_id=$_POST['race'];
         //$sex=$_POST['sex'];
         //controllo se l'email dell'utente esiste già, per evitare i doppi
         if ($p->d->getvar('SELECT COUNT(id) FROM accounts WHERE email="' . $email . '" OR username="' . $username . '";') > 0) {
             $t->start_block('register_failed');
             $t->end_block('register_failed');
             $p->action('register_failed');
         } else {
             //$query='INSERT INTO users SET name="'.$username.'",surname="'.$surname.'",password="'.$password.'",email="'.$email.'",sex="'.$sex.'",race="'.$race_id.'";';
             $query = 'INSERT INTO accounts SET username="' . $username . '",password="' . $password . '",email="' . $email . '",last_change_pwd=NOW() ;';
             $result = $p->d->query($query);
             if ($result == 1) {
                 $t->start_block('register_success');
                 $t->assign_block_var('USERNAME', $username);
                 $t->end_block('register_success');
             } else {
                 $t->start_block('register_failed');
                 $t->end_block('register_failed');
             }
         }
     } else {
         $t->start_block('register_failed');
         $t->end_block('register_failed');
     }
     $t->out();
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:37,代码来源:register.php

示例7: online

function online()
{
    $p = plugins::getinst();
    $t = new template('template/online.tpl');
    //seleziono distintamente le stanze dove si trovano i pg
    $stanze = $p->d->getresults('SELECT DISTINCT chat_name,chat_id FROM sessioni GROUP BY chat_id ASC;');
    //per ogni stanza aggiungo al template i pg presenti
    for ($i = 0; $i < count($stanze); $i++) {
        $chat = $stanze[$i];
        $t->start_block('online_chat');
        $t->assign_block_vars(array('CHAT_ID' => $chat->chat_id, 'CHAT_NAME' => $chat->chat_name));
        $users = $p->d->getcol('SELECT pg_id FROM sessioni WHERE chat_id="' . $chat->chat_id . '";');
        foreach ($users as $user) {
            $username = $p->d->getvar('SELECT name FROM users WHERE id="' . $user . '";');
            $t->start_block('online_row');
            $t->assign_block_var('USERNAME', $username);
            $t->end_block('online_row');
        }
        $t->end_block('online_chat');
    }
    @$t->out();
}
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:22,代码来源:main.php

示例8: template

 static function account_switch($action = '')
 {
     /* prendo l'istanza della classe plugin dal singleton | Call Singleton Plugin */
     $p = plugins::getinst();
     /* prendo l'id dell'account | gain account id
      * TODO Fix filtraggio input
      */
     $account_id = $_SESSION['datiaccount']['id'];
     $t = new template('template/account_switch.tpl');
     /* se si vuole usare un utente | "Use a User Profile" Action */
     if ($action == 'use_user') {
         /* vedo se esiste l'utente selezionato e se è dell'account che lo ha selezionato | Check existance and proprietary account on selected one
          * TODO Fix filtraggio input
          */
         $cond = $p->d->getrow('SELECT COUNT(id) AS count, account_id FROM users WHERE id="' . mysql_real_escape_string($_POST['pg_id']) . '" GROUP BY id;');
         /* se supera l'if metto nella sessione i dati del pg separati da quelli dell'account, cambio pg_id nella tabella sessioni e mando l'utente alla pagina main |
          * save usre data out of account data, update pg_id in session table, redirect to main page */
         if ($cond->count > 0 && $cond->account_id == $_SESSION['datiaccount']['id']) {
             $_SESSION['datiuser'] = get_object_vars($p->d->getrow('SELECT * FROM users WHERE id="' . $_POST['pg_id'] . '";'));
             $updsess = $p->d->query('UPDATE sessioni SET pg_id="' . $_POST['pg_id'] . '" WHERE session_id="' . session_id() . '";');
             header('Location:' . config::game_dir . '/plugins.php/main');
             /* command to redirect */
         }
     }
     /* se si vuole cambiare la password | Change Password OF FULL ACCOUNT */
     if ($action == 'change_pwd') {
         /* cripto in md5 quella nuova | md5 encript
          * TODO Fix filtraggio input
          */
         $password = md5(mysql_real_escape_string($_POST['password']));
         /* faccio l'update della password sul db | update query */
         $query = 'UPDATE accounts SET password="' . $password . '",last_change_pwd=NOW() WHERE id="' . $account_id . '";';
         if ($p->d->query($query) > 0) {
             $t->block_null('new_password_success');
         } else {
             $t->block_null('new_password_failed');
         }
     }
     /* se si vuole creare un nuovo utente | New User */
     if ($action == 'new_user') {
         /* prendo tutti i dati passati in POST e li passo a mysql_real_escape_string e htmlentities per evitare XSS e SQL injections | Input filtering
          * TODO Fix filtraggio input
          */
         $name = mysql_real_escape_string(htmlentities($_POST['name']));
         $surname = mysql_real_escape_string(htmlentities($_POST['surname']));
         $sex = mysql_real_escape_string(htmlentities($_POST['sex']));
         $race = mysql_real_escape_string(htmlentities($_POST['race']));
         /* vedo se sono stati riempiti tutti i campi | no empty fields */
         if ($name == NULL || ($surname = NULL || $sex == NULL || $race == NULL)) {
             die('Non hai riempito tutti i campi <br/> <a href="javascript:history.back();">torna indietro</a>');
         }
         /* java function to reload form */
         /* controllo che il personaggio non esista già | Check in DB for duplicate entries */
         if ($p->d->getvar('SELECT COUNT(id) as count FROM users WHERE name="' . $name . '";') > 0) {
             die('Il personaggio che vuoi creare esiste gi&agrave;! <br/> <a href="javascript:history.back();">torna indietro</a>');
         }
         /* vedo se l'utente ha già raggiunto il massimo di pg consentiti (settati nel config) | check for max number of users in account */
         if ($p->d->getvar('SELECT COUNT(*) FROM users WHERE account_id="' . $account_id . '";') < config::max_pg) {
             /* creo il pg e lo collego all'account che lo ha creato | add user in db and link it to account */
             $query = 'INSERT INTO users SET account_id="' . $account_id . '",name="' . $name . '",surname="' . $surname . '",sex="' . $sex . '",race="' . $race . '";';
             $p->d->query($query);
             /* faccio un refresh della pagina, per evitare che lo faccia manualmente l'utente creando un'altro utente vuoto | force a refresh so no duplicate entries for hand-made refreshes */
             header('Location:' . config::game_dir . '/plugins.php/account_switch');
         } else {
             echo 'Hai raggiunto il numero massimo di personaggi consentiti... <br/> <a href="javascript:history.back();">torna indietro</a>';
         }
         /* | if already has all slot full display a warning and rollback */
     }
     /* assegno l'account id e il path di questa pagina al template | view init: assign account id and path to template */
     $t->assign_var('ID', $account_id);
     $t->assign_var('ACTION', config::game_dir . '/plugins.php/account_switch');
     /* | Check for last changed password
      * TODO Fix filtraggio input
      */
     $time_password = $p->d->getvar('SELECT COUNT(id) FROM accounts WHERE id="' . $_SESSION['datiaccount']['id'] . '" AND last_change_pwd < (NOW() - INTERVAL 6 MONTH);');
     if ($time_password > 0) {
         $t->block_null('change_password');
     }
     /* seleziono i pg dell'utente | extract from db account's pc */
     $users = $p->d->getresults('SELECT * FROM users WHERE account_id="' . $account_id . '" LIMIT 0,' . config::max_pg . ';');
     /* se ce ne sono li aggiungo al template | if any add it to template */
     if (count($users) > 0) {
         foreach ($users as $user) {
             $t->start_block('user');
             $t->assign_block_vars(array('PG_ID' => $user->id, 'PG_NAME' => $user->name, 'PG_SURNAME' => $user->surname, 'PG_IMAGE' => $user->image, 'PG_DESC' => isset($user->description) ? $user->description : 'nessuna descrizione'));
             $t->end_block('user');
             /* assegnazioni per gli editor in-place per le modifiche dei PG | set editor-in-place for PC mod */
             $t->block_assign('javascript_inplace_row_surname', 'ID', $user->id);
             $t->block_assign('javascript_inplace_row_desc', 'ID', $user->id);
         }
     }
     /* se il numero di utenti è minore del numero massimo consentito visualizzo il form di creazione pg | If 
      * number of current pc is less than max allowed per account, show new PC form */
     if (count($users) < config::max_pg) {
         /* | Use config constant to perform check */
         $query = 'SELECT * FROM razze WHERE evolution!=1;';
         /* TODO implementare uso delle sottorazze e razze avanzate */
         $races = $p->d->getresults($query);
         /* ogni razza a cui sia possibile aggiungere il pg è aggiunta nel template | add any pc's allowed race to template */
         $t->start_block('new_user_form');
//.........这里部分代码省略.........
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:101,代码来源:account.php

示例9: template

 static function edit_post($forum_id = 0, $id = 0)
 {
     $p = plugins::getinst();
     if ($id != 0) {
         $t = new template('template/forum_message.tpl');
         $t->assign_var('FORUM_ID', $forum_id);
         //controllo se la bacheca è riservata al master e in caso controllo che l'utente lo sia
         if ($p->d->getvar('SELECT master FROM forums WHERE id="' . $forum_id . '";') == 1 && control_access(MASTER_ACCESS) != 1) {
             $t->start_block('access_denied');
             $t->end_block('access_denied');
         } else {
             $post = $p->d->getrow('SELECT * FROM posts WHERE id="' . $id . '"');
             if (!$_POST) {
                 $t->start_block('message_form');
                 if ($post->title != NULL && $post->topic_id == 0) {
                     $t->block_assign('is_topic', 'TOPIC_TITLE', $post->title);
                 }
                 $t->assign_block_var('TEXT', $post->text);
                 $t->assign_block_var('SUBMIT_TEXT', 'modifica messaggio');
                 $t->assign_block_var('ACTION', '{ROOT}/plugins.php/edit_post/' . $forum_id . '/' . $id);
                 $t->end_block('message_form');
             } else {
                 if (isset($_POST['title'])) {
                     $title = mysql_real_escape_string(htmlentities($_POST['title']));
                 } else {
                     $title = $post->title;
                 }
                 $text = $p->filter('topic_message_edited', mysql_real_escape_string(htmlentities($_POST['text'])));
                 $query = 'UPDATE posts SET title="' . $title . '",text="' . $text . '" WHERE id="' . $id . '"';
                 $res = $p->d->query($query);
                 if ($res > 0) {
                     $t->block_assign('success', 'TEXT_SUCCESS', 'Messaggio modificato!');
                 } else {
                     $t->block_assign('failed', 'TEXT_FAILED', 'Messaggio NON modificato: ' . mysql_error());
                 }
             }
         }
         $t->out();
     }
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:40,代码来源:forum.php

示例10: logout

 static function logout()
 {
     $p = plugins::getinst();
     $t = new template('template/logout.tpl');
     //Elimino l'utente dalle sessioni
     $query = 'DELETE FROM sessioni WHERE session_id="' . session_id() . '";';
     $p->d->query($query);
     //Elimino le variabili di sessione resettando $_SESSION
     $_SESSION = array();
     $t->start_block('logout');
     //Eseguo l'azione "logout"
     $p->action('logout');
     $t->end_block('logout');
     $t->out();
 }
开发者ID:JeanBS,项目名称:OpenGdr,代码行数:15,代码来源:login.php


注:本文中的template::start_block方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。