function login_form() { tpl_set('page_description', 'Login'); $arg1 = arg(0); $arg2 = arg(1); $arg3 = arg(2); if ($arg1[0] == "register") { if (!$arg2[0]) { // Initiate a new form. $form = new forms(array('name' => 'register_form', 'method' => 'post', 'action' => '', 'class' => 'register_form form-horizontal', 'id' => 'register-form')); $form->add_field(array('type' => 'text', 'name' => 'name', 'label' => t('Name & Surname'))); $form->add_field(array('type' => 'text', 'name' => 'email', 'label' => t('Email Address'))); $form->add_field(array('type' => 'password', 'name' => 'password', 'label' => t('Password'))); $form->add_field(array('type' => 'password', 'name' => 'password_again', 'label' => t('Password Again'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'register_button', 'value' => 'Register', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_register_form'); $form->submit('permissions.submit_register_form'); } elseif ($arg2[0] == 2) { $node = new node($arg3); tpl_set('node', objectArray($node)); // Initiate a new form. $form = new forms(array('name' => 'register_form', 'method' => 'post', 'action' => '', 'class' => 'register_form form-horizontal', 'id' => 'register-form')); $form->add_field(array('type' => 'text', 'name' => 'activation_code', 'label' => t('Activation Code'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'register_button', 'value' => 'Activate', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_activation_form'); $form->submit('permissions.submit_activation_form'); } elseif ($arg2[0] == 3) { header('location: ' . base_path()); } } else { if ($arg1[0] == 'lostpassword') { // Initiate a new form. $form = new forms(array('name' => 'register_form', 'method' => 'post', 'action' => '', 'class' => 'register_form form-horizontal', 'id' => 'register-form')); // Now we start to add some fields. $form->add_field(array('type' => 'text', 'name' => 'email', 'label' => t('Email Address'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'register_button', 'value' => 'Retrieve', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_login_form'); $form->submit('permissions.submit_login_form'); } else { // Initiate a new form. $form = new forms(array('name' => 'login_form', 'method' => 'post', 'action' => '', 'class' => 'login_form form-horizontal', 'id' => 'login-form')); // Now we start to add some fields. $form->add_field(array('type' => 'text', 'name' => 'username', 'label' => t('Username'))); $form->add_field(array('type' => 'password', 'name' => 'password', 'label' => t('Password'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'login_button', 'value' => 'Login', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_login_form'); $form->submit('permissions.submit_login_form'); } } // form testing $form->render(); }
function tpl_set($field, $value = false){ if(is_array($field)){ foreach($field as $k => $v) tpl_set($k, $v); return; } global $tpl_sets; $tpl_sets[$field] = $value; }
function view_contact() { $node = new Node(arg(2)); tpl_set('page_title', $node->title); tpl_set('page_description', 'Contact Card'); tpl_set('node', objectArray($node)); tpl_set('keys', array_flip(objectArray($node))); //Get the default contact template $type = node::lookup_type_id('contacts'); $template = node::load_node_template($type); }
function render() { // Use Smarty to create the form HTML because I'm kind of lazy. $smarty = new Smarty(); $smarty->template_dir = SERUM_ROOT . '/core/classes/forms/templates'; $smarty->compile_dir = SERUM_ROOT . '/custom/files/tmp/'; $smarty->config_dir = SERUM_ROOT . '/custom/files/tmp/'; $smarty->cache_dir = SERUM_ROOT . '/custom/files/tmp/'; $smarty->debugging = false; $smarty->caching = false; // Deal with the form meta data. foreach ($this->form['meta'] as $meta_key => $meta_val) { $meta_string .= "{$meta_key}=\"{$meta_val}\" "; } $meta_string = rtrim($meta_string, ' '); // Before we go any further we need to set some default hidden fields. $this->form['fields']['submitted_form'] = array('type' => 'hidden', 'name' => 'submitted_form', 'value' => $this->form['meta']['name']); // Check if the form has already been submitted. if ($_POST['submitted_form']) { // Store the field values. $this->store_values(); // Check if there is a validation callback. if (isset($this->form['callbacks']['validate'])) { // Then we call the validate function. $this->validate_form(); } else { // Otherwise just call the submit function. $this->submit_form(); } } // Assign smarty vars for all the form bits. $smarty->assign('meta', $meta_string); $smarty->assign('fields', $this->form['fields']); $smarty->assign('buttons', $this->form['buttons']); // Use Smarty to make the form. $form_html = $smarty->fetch('form.tpl'); // After creating the form rendering. tpl_set('form', $form_html); // The raw form. tpl_set('form_raw', $this->form); }
$output .= '<div class="chat_block" onCLick="im.open('.$row['peer'].')" id="im_'.$row['peer'].'"> <img src="/img/camera_50.gif" class="fl_l"> <div class="cont"> <div class="name">'.$peer_inf[0].' '.$peer_inf[1].'</div> <div class="msg">'.$row['text'].'</div> <div class="new_cnt" id="msg_new'.$row['peer'].'">'.$row['new'].'</div> <div class="typing" id="typing_'.$row['peer'].'"><img src="/img/typing.gif"/></div> </div>'.$online.' <div class="clear"></div> </div>'; } }else $output = '<div class="info_center">У вас нет ни одного диалога</div>'; tpl_load('im/head'); tpl_set(array( '{dialogs}' => $output )); tpl_make('cont'); $initJS = "$(document).ready(function(){ $('#contacts, #messages_nano').nanoScroller(); $(window).resize(function(){ var wh = Math.max(window.innerHeight-45, 300); if(wh > 600) wh -= 30; $('.im_chats, .im_cont').css('height', wh+'px'); $('#contacts, #contacts_res').css('height', (wh-54)+'px'); var hcont = wh-(parseInt($('.im_send_form').get(0).scrollHeight)+44), mh = $('#message_all_cont').get(0).scrollHeight, margin = hcont > mh ? hcont-mh : 0; $('#messages_bl, #messages_nano_res').css('height', hcont+'px'); $('#messages_bl').css('margin-top', margin+'px');
$sql_ = mysql_query("SELECT uid, name, lname, last_update FROM `users` WHERE uid IN ({$ids})", 1); $ids = false; foreach($sql_ as $row){ tpl_set(array( '{name}' => $row['name'].' '.$row['lname'], '{online}' => $row['last_update'] > $online_time ? 'online' : '', '{id}' => $row['uid'] )); tpl_make('res'); } }else $tpl_res['res'] = '<div class="info_center" style="padding: 100px 0;">У вас нет друзей</div>'; tpl_load('friends/head'); tpl_set(array( '{res}' => $tpl_res['res'], '{cnt}' => $cnt > 0 ? gram($cnt, 'друг', 'друга', 'друзей') : 'нет друзей', '{load_but}' => $cnt > 15 ? '' : ' no_display', '{req_cnt}' => $uinfo['friends_request'] > 0 ? '+'.$uinfo['friends_request'] : '' )); tpl_make('cont'); $initJS = 'friends.uid = '.$get_id.'; friends.tpl = \''.$friends_tpl.'\'; friends.loadFriends(); friends.req_tpl = \'<div class="one_request" id="req{id}"><img src="/img/camera_100.gif" class="fl_l"><div class="cont fl_l"><div class="name"><a href="/">{name}</a></div><div class="online">{online}</div><div class="buttons"><button class="button fl_l" onClick="friends.accept({id});">Принять</button><button class="button inline fl_l" onClick="friends.reject({id});">Откланить</button><div class="clear"></div></div></div><div class="clear"></div></div>\''; } }else{ tpl_load('nolog_err'); tpl_make('cont'); }
<div class="actions fl_r"> <li onClick="im.open('.$row['uid'].');">Отправить сообщение</li> '.$req_btn.' </div> <div class="clear"></div> </div>'; } }else{ if($page == 0) $res = '<div class="info_center">По запросу <b>'.$q.'</b> ничего не найдено</div>'; } if($doload){ echo $res; exit; } tpl_load('people/head'); tpl_set(array( '{res}' => $res, '{load}' => count($sql_) == $limit ? '' : 'no_display' )); tpl_make('cont'); echo json_encode(array( 'cont' => $tpl_res['cont'], 'id' => 'box_people' )); break; } exit;
*/ if(!$uid) die('no_log'); $queue = new Memcache; $queue->connect('127.0.0.1', QUE_PORT); $ip = ip2long($_SERVER['HTTP_X_REAL_IP']); $queue->get("upd_secret{$uid}"); $data = $queue->get("timestamp_key{$uid},{$ip},25(notify{$uid})"); $data = json_decode($data, true); if(isset($_POST['data_only'])){ echo json_encode(array( 'key' => $data['key'], 'ts' => $data['ts'], 'id' => $uid )); exit; } tpl_load('q_frame'); tpl_set(array( '{ts}' => $data['ts'], '{key}' => $data['key'], '{uid}' => $uid )); tpl_make('cont'); echo $tpl_res['cont']; exit;
tpl_set(array( '{my_id}' => $uid, '{name}' => $uinfo['name'].' '.$uinfo['lname'], '{head_req}' => $uinfo['friends_request'] > 0 ? '+'.$uinfo['friends_request'] : '' )); } if($st_files){ $st_res = ''; foreach($st_files as $file){ if(strpos($file, '.js') !== false) $st_res .= '<script type="text/javascript" src="/js/'.$file.'"></script>'; else $st_res .= '<link rel="stylesheet" type="text/css" href="/css/'.$file.'"/>'; } tpl_set('{st_files}', $st_res); }else tpl_set('{st_files}', ''); tpl_set(array( '{cont}' => $tpl_res['cont'], '{title}' => $site_title ? $site_title : 'FastChat', '{init_js}' => $initJS )); if($logged) tpl_set(array('[logged]' => '', '[/logged]' => '')); else tpl_block('logged'); tpl_make('main'); echo $tpl_res['main']; //$time = microtime(true) - $start; //printf('<br>Скрипт выполнялся %.4F сек.', $time);
/** * Render the index page. */ function index() { // At some point we will need to write some code here. tpl_set('page_title', 'Home'); tpl_set('page_description', 'This is the front page and it currently has bugger all on it :P'); }
if($id == $uid) $row = $uinfo; else{ $row = $pmc->get('uinfo'.$id); if(!$row['uid']){ $row = mysql_query("SELECT uid, email, name, lname, photo FROM `users` WHERE uid = '{$id}'"); if($row['uid']) $pmc->set('uinfo'.$id, $row, 3600*24); } } if(!$row['uid']){ tpl_load('profile/not_found'); }else{ if($row['photo']){ $photo = new Memcache; $photo->connect('127.0.0.1', 11233); //$photos = $photo->get("photo{$id},{$row['photo']}(id,locationps)"); //print_r($photos); //exit; }else $ava = '/img/camera_400.gif'; tpl_load('profile/main'); tpl_set(array( '{id}' => $id, '{name}' => $row['name'], '{lname}' => $row['lname'] )); } tpl_make('cont');