function dok_box_ranked($display_module, $theme_path) { if (DOK_USE_CACHE) { $fname = dok_c_box_filename('ranked', 'ignored'); $cache = dok_c_get($fname); if ($cache) { return $cache; } } $res = mysql_query('select name, id from ' . dok_tn('song') . ' order by hits desc limit 10'); echo mysql_error(); if (!mysql_numrows($res)) { return; } $t = new template($theme_path); $t->set_file('page', 'box_default.tpl'); $t->set_var('BOXTITLE', MSG_TITLE_BOX_RANKED_SONG); $t->set_block('page', 'boxlink', 'boxlinktag'); $t->set_var('boxlinktag', ''); if (!mysql_numrows($res)) { $t->set_var('BOXCONTENT', ''); } while ($row = mysql_fetch_array($res)) { $t->set_var('LINK', $_SERVER['PHP_SELF'] . '?display=view_song&id=' . $row['id']); $t->set_var('LABEL', $row['name']); $t->parse('BOXCONTENT', 'boxlink', 'true'); } $html = $t->parse('out', 'page'); if (DOK_USE_CACHE) { dok_c_write($fname, $html); } return $html; }
function dok_list_users($VARS, $up, $theme_path) { $t = new template($theme_path); $t->set_file('page', 'user_list.tpl'); $t->set_block('page', 'user', 'user_block'); $t->set_block('page', 'next_page', 'next_page_block'); if (!isset($VARS['alpha'])) { $VARS['alpha'] = '-'; } if (!strlen($VARS['offset']) || $VARS['offset'] < 0) { $VARS['offset'] = '0'; } $VARS['alpha'] = mysql_real_escape_string($VARS['alpha']); $query = 'select id, name, editor, admin, disabled, creation, last_login from ' . dok_tn('user') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP; $res = dok_oquery($query); if ($res->numrows()) { //$ids = $res->fetch_col_array('id'); //$n_res = dok_oquery('select album_id, count(*) as c from '.dok_tn('rel_song_album').' where album_id in('.implode(',',$ids).') group by album_id'); //$n_array = $n_res->fetch_col_array('c','album_id'); while ($user = $res->fetch_array()) { if ($user['admin']) { $admin = MSG_YES; } else { $admin = MSG_NO; } if ($user['editor']) { $editor = MSG_YES; } else { $editor = MSG_NO; } if ($user['disabled']) { $disabled = MSG_YES; } else { $disabled = MSG_NO; } if ($user['last_login'] == 0) { $last_login = MSG_USER_NEVER_LOGGED; } else { $last_login = date($THEME_DATE, $user['last_login']); } $t->set_var('USER_LINK', $_SERVER['PHP_SELF'] . '?display=view_user&id=' . $user['id']); $t->set_var(array('USER_NAME' => $user['name'], 'USER_DB_CREATION' => date($THEME_DATE, $user['creation']), 'USER_LAST_LOGIN' => $last_login, 'USER_ADMIN' => $admin, 'USER_EDITOR' => $editor, 'USER_DISABLED' => $disabled)); $t->parse('user_block', 'user', 'true'); } $res = mysql_query('select count(*) as c from ' . dok_tn('user') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\''); $total = mysql_result($res, 0, 'c'); if ($total > $VARS['offset'] + DOK_LIST_EPP) { $t->set_var('NEXT_PAGE_LINK', $_SERVER['PHP_SELF'] . '?display=list_users&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP)); $t->parse('next_page_block', 'next_page'); } else { $t->set_var('next_page_block', ''); } } else { $t->set_var('user_block', MSG_NO_USER); $t->set_var('next_page_block', ''); } return array($t, MSG_TITLE_LIST_USER); }
/** * Carga de mapa para emergencia * @throws Exception */ public function index() { $this->load->helper(array("modulo/visor/visor", "modulo/marea_roja/permiso")); $params = $this->uri->uri_to_assoc(); $emergencia = $this->_emergencia_model->getById($params["id"]); $this->load->model('Permiso_Model', 'PermisoModel'); $this->load->model('Modulo_Model', 'ModuloModel'); if (!is_null($emergencia)) { $this->layout_assets->addMapa(); //$this->layout_assets->addDatatable(); $this->layout_assets->addJs("mapa-visor.js"); $this->layout_assets->addJs("modulo/mapa/formulario.js"); $this->layout_assets->addJs("modulo/evento/form/nuevo.js"); $this->layout_assets->addJs("modulo/evento/form/editar.js"); $this->layout_assets->addJs("library/ckeditor-4.5.7/ckeditor.js"); $regiones_emergencia = $this->_emergencia_model->listarRegionesPorEmergencia($params["id"]); $region_emergencia = $regiones_emergencia[0]['reg_ia_id']; $regiones_usuario = explode(",", $this->session->userdata("session_regiones")); $data = array("id" => $params["id"], "region_emergencia" => $region_emergencia, "regiones_usuario" => $regiones_usuario); $this->layout_assets->addEditorTexto(); $this->template->parse("default", "pages/mapa/index", $data); } else { throw new Exception(__METHOD__ . " - La emergencia no existe"); } }
function dok_view_album($VARS, $update_module, $tpl_path) { global $THEME_DATE, $ARTIST_SONG_LINKS, $USER; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { $t = dok_error_template(MSG_ERR_ALBUM_DISPLAY); return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, '')); } $res = mysql_query('select name, creation from ' . dok_tn('album') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { $t = dok_error_template(MSG_ERR_ALBUM_DISPLAY); return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, '')); } $row = mysql_fetch_assoc($res); $t = new template($tpl_path); $t->set_file('page', 'album_display.tpl'); $t->set_block('page', 'if_albumeditor', 'editor_block'); $t->set_block('page', 'album_songs', 'songs_block'); $t->set_var(array('ALBUM_NAME' => $row['name'], 'ALBUM_DB_CREATION' => date($THEME_DATE, $row['creation']))); if (DOK_ENABLE_USER && !$USER->editor && !$USER->admin) { $t->set_var('editor_block', ''); } else { $t->set_var('ALBUM_EDIT_LINK', $_SERVER['PHP_SELF'] . '?display=edit_album&id=' . $VARS['id']); $t->parse('editor_block', 'if_albumeditor'); } $query = 'select s.id, s.name, s.creation, s.length, s.release, s.comment, r.track from ' . dok_tn('rel_song_album') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where r.album_id = ' . $VARS['id'] . ' order by r.track'; $songs = dok_oquery($query); $album_length = 0; if (!$songs->numrows()) { $t->set_var('songs_block', MSG_NO_SONG); } else { $pager_data = array('related' => 'album', 'related_id' => $VARS['id']); while ($song = $songs->fetch_array()) { $song_data = dok_song_format($song, $pager_data); $song_data['SONG_ARTIST'] = preg_replace('/^' . $ARTIST_SONG_LINKS[0] . '/', '', $song_data['SONG_ARTIST']); $t->set_var($song_data); $t->set_var('SONG_TRACK', $song['track']); $t->parse('songs_block', 'album_songs', 'true'); $album_length += $song['length']; } } $t->set_var('ALBUM_LENGTH', dok_sec2str($album_length)); $t->set_var('ALBUM_SONGS', $songs->numrows()); return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, $row['name'])); }
/** * Renders an entry (icon) for the "Command and Control" center * * @param template $template template to use * @param string $url URL the entry links to * @param string $image URL of the icon * @param string $label text to use under the icon * @return void * */ function render_cc_item(&$template, $url = '', $image = '', $label = '') { if (!empty($url)) { $template->set_var('page_url', $url); $template->set_var('page_image', $image); $template->set_var('option_label', $label); $template->set_var('cell_width', (int) (100 / ICONS_PER_ROW) . '%'); return $template->parse('cc_main_options', 'ccitem', false); } return ''; }
function dok_ask_sound_artist($VARS, $update, $theme_path) { if (!is_array($VARS['soundex']) || !sizeof($VARS['soundex'])) { $t = dok_error_template(MSG_ERR_ARTIST_NOT_FOUND); return array($t, MSG_TITLE_SOUNDEX_TEST); } $t = new template($theme_path); $t->set_file('page', 'artist_soundex.tpl'); $t->set_block('page', 'artists', 'artists_block'); $t->set_var('NEW_ARTIST_NAME', $VARS['name']); $t->set_var('ARTIST_CREATE_FORM', '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"><input type=hidden name="update" value="create_artist"><input type=hidden name="soundex_checked" value="1"><input type=hidden name="name" value="' . str_replace('"', '"', $VARS['name']) . '">'); foreach ($VARS['soundex'] as $id => $name) { $t->set_var('ARTIST_NAME', $name); $t->parse('artists_block', 'artists', 'true'); } return array($t, MSG_TITLE_SOUNDEX_TEST); }
function dok_view_user($VARS, $update, $theme_path) { global $USER, $THEME_DATE; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { $t = dok_error_template(MSG_ERR_USER_DISPLAY); return array($t, sprintf(MSG_TITLE_DISLAY_USER, '')); } $res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { $t = dok_error_template(MSG_ERR_USER_DISPLAY); return array($t, sprintf(MSG_TITLE_DISPLAY_USER, '')); } $user = mysql_fetch_array($res); $t = new template($theme_path); $t->set_file('page', 'user_display.tpl'); $t->set_block('page', 'if_could_edit', 'if_could_edit_block'); if (DOK_ENABLE_USER && ($USER->admin || $USER->id == $user['id']) || !DOK_ENABLE_USER) { $t->parse('if_could_edit_block', 'if_could_edit'); } else { $t->set_var('if_could_edit_block', ''); } if ($user['admin']) { $admin = MSG_YES; } else { $admin = MSG_NO; } if ($user['editor']) { $editor = MSG_YES; } else { $editor = MSG_NO; } if ($user['disabled']) { $disabled = MSG_YES; } else { $disabled = MSG_NO; } if ($user['last_login'] == 0) { $last_login = MSG_USER_NEVER_LOGGED; } else { $last_login = date($THEME_DATE, $user['last_login']); } $t->set_var(array('USER_NAME' => $user['name'], 'USER_DB_CREATION' => date($THEME_DATE, $user['creation']), 'USER_LAST_LOGIN' => $last_login, 'USER_ADMIN' => $admin, 'USER_EDITOR' => $editor, 'USER_DISABLED' => $disabled, 'USER_EDIT_LINK' => $_SERVER['PHP_SELF'] . '?display=edit_user&id=' . $user['id'])); return array($t, sprintf(MSG_TITLE_DISPLAY_USER, $user['name'])); }
function dok_edit_user($VARS, $update_module, $theme_path) { global $USER; if (!$VARS['id'] || !is_numeric($VARS['id']) || $VARS['id'] < 1) { $t = dok_error_template(MSG_ERR_USER_NOT_FOUND); return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN)); } $res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { $t = dok_error_template(MSG_ERR_USER_NOT_FOUND); return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN)); } $row = mysql_fetch_array($res); if (DOK_ENABLE_USER && (!$USER->admin && $USER->id != $row['id'])) { $t = dok_error_template(MSG_ERR_USER_EDITION_NOT_ALLOWED); return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN)); } $t = new template($theme_path); $editor_cb = '<input type="checkbox" name="editor" value="1"'; if ($row['editor']) { $editor_cb .= ' CHECKED'; } $editor_cb .= '>'; $admin_cb = '<input type="checkbox" name="admin" value="1"'; if ($row['admin']) { $admin_cb .= ' CHECKED'; } $admin_cb .= '>'; $disabled_cb = '<input type="checkbox" name="disabled" value="1"'; if ($row['disabled']) { $disabled_cb .= ' CHECKED'; } $disabled_cb .= '>'; $t->set_file('page', 'user_edit.tpl'); $t->set_block('page', 'if_admin', 'if_admin_block'); if (!DOK_ENABLE_USER || $USER->admin) { $t->parse('if_admin_block', 'if_admin'); } else { $t->set_var('if_admin_block', ''); } $t->set_var(array('USER_ID' => $row['id'], 'USER_NAME' => $row['name'], 'USER_NAME_TF' => str_replace('"', '"', $row['name']), 'USER_EDITOR_CB' => $editor_cb, 'USER_DISABLED_CB' => $disabled_cb, 'USER_ADMIN_CB' => $admin_cb)); return array($t, sprintf(MSG_TITLE_EDIT_USER, $row['name'])); }
function error($errno, $errmsg, $errfile, $errline) { if ($errno == 2 && preg_match("/500 Internal Server Error/", $errmsg)) { throw new Exception("Error returned from bitcoin core"); } // Get log file to write to if ($errno == E_WARNING || $errno == E_USER_WARNING) { $logfile = 'warning'; } elseif ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) { $logfile = 'notice'; } elseif ($errno == E_STRICT) { $logfile = 'strict'; } else { $logfile = 'error'; } // Save to logfile $origin = $errno == E_USER_WARNING || $errno == E_USER_NOTICE || $errno == E_USER_ERROR || $errno == E_USER_DEPRECATED ? 'USER' : 'PHP'; $logline = $origin . ' - [' . date('Y-m-d H:i:s') . '] #' . $errno . ' ' . $errmsg . ' in (' . $errfile . ':' . $errline . ')'; file_put_contents(SITE_PATH . '/data/log/' . $logfile, "{$logline}\n", FILE_APPEND); // Return, if not displaying error template if ($logfile != 'error') { return; } // Start template $template = new template('500'); $template->assign('errno', $errno); $template->assign('errmsg', $errmsg); $template->assign('errfile', $errfile); $template->assign('errline', $errline); // Get theme if (preg_match("/^admin/", $_GET['route'])) { $template->theme = 'admin'; } // Display template $template->parse(); exit(0); }
function dok_list_full($VARS, $up, $theme_path) { global $THEME_FULL_LIST_COLUMN; $t = new template($theme_path); $t->set_file('page', 'full_list.tpl'); $t->set_block('page', 'element_letter', 'element_letter_block'); $t->set_block('page', 'element', 'element_block'); $t->set_block('page', 'next_block', 'next_block_block'); $t->set_var('element_letter_block', ''); $t->set_var('next_block_block', ''); if (!isset($VARS['element']) || !in_array($VARS['element'], array('artist', 'song', 'album', 'user'))) { $VARS['element'] = 'song'; } if ($VARS['element'] == 'album') { $msg = MSG_NO_ALBUM; $element_name = MSG_ALBUMS; } elseif ($VARS['element'] == 'artist') { $msg = MSG_NO_ARTIST; $element_name = MSG_ARTISTS; } elseif ($VARS['element'] == 'user') { $msg = MSG_NO_USER; $element_name = MSG_USERS; } else { $msg = MSG_NO_SONG; $element_name = MSG_SONGS; } $t->set_var('LIST_ELEMENT_NAME', $element_name); $where = ''; if (($VARS['element'] == 'album' || $VARS['element'] == 'song') && isset($VARS['artist_id']) && is_numeric($VARS['artist_id']) && $VARS['artist_id'] > 0) { $res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist_id']); if (mysql_numrows($res)) { $row = mysql_fetch_array($res); $t->set_var('ARTIST_NAME', $row['name']); $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $VARS['artist_id']); if ($VARS['element'] == 'song') { $where = 'left join ' . dok_tn('rel_song_artist') . ' as r on a.id=r.song_id where r.artist_id = ' . $VARS['artist_id']; } else { $where = 'left join ' . dok_tn('rel_song_album') . ' as r on a.id=r.album_id left join ' . dok_tn('rel_song_artist') . ' as r2 on r.song_id=r2.song_id where r2.artist_id = ' . $VARS['artist_id'] . ' group by a.id'; } } } else { $t->set_var('ARTIST_NAME', ''); $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF']); } $query = 'select a.id, a.name, substring(a.name from 1 for 1) as letter from ' . dok_tn($VARS['element']) . ' as a ' . $where . ' order by a.name'; //echo $query.'<BR>'; $res = dok_oquery($query); //echo mysql_error(); if ($res->numrows()) { $letter = false; $count = -1; $div = 1; if ($res->numrows() <= reset($THEME_FULL_LIST_COLUMN)) { $el_per_block = $res->numrows(); $div = 1; } elseif ($res->numrows() >= end($THEME_FULL_LIST_COLUMN)) { $div = key($THEME_FULL_LIST_COLUMN); $el_per_block = ceil($res->numrows() / $div); } else { $ak = array_keys($THEME_FULL_LIST_COLUMN); $i = 1; foreach ($THEME_FULL_LIST_COLUMN as $key => $val) { if ($res->numrows() >= $val && $res->numrows() <= $THEME_FULL_LIST_COLUMN[$ak[$i]]) { $div = $key; $el_per_block = ceil($res->numrows() / $key); break; } $i++; } } $t->set_var('BLOCK_PERCENT', (int) (100 / $div)); //if ( $res->numrows() < $THEME_FULL_LIST_COLUMN[0] && $res->numrows() < $THEME_FULL_LIST_COLUMN[0] //$el_per_block = ceil($res->numrows() /3); while ($row = $res->fetch_array()) { $count++; if ($count && !($count % $el_per_block)) { $t->parse('element_block', 'next_block', 'true'); } if (!$letter || $letter != $row['letter']) { $letter = $row['letter']; $t->set_var('LIST_LETTER', strtoupper($letter)); $t->parse('element_block', 'element_letter', 'true'); } $t->set_var('LIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_' . $VARS['element'] . '&id=' . $row['id']); $t->set_var('LIST_NAME', $row['name']); $t->parse('element_block', 'element', 'true'); } } else { $t->set_var('element_block', $msg); } return array($t, $element_name . MSG_TITLE_LIST_FULL); }
function print_orders($sourceid) { /* name: print_orders($sourceid) returns: 0 - no error 1 - no orders to be printed 2 - template parsing error 3 - error setting orders printed other - mysql error number */ $sourceid = $_SESSION['sourceid']; debug_msg(__FILE__, __LINE__, "BEGIN PRINTING"); $query = "SELECT * FROM `orders` WHERE `sourceid`='{$sourceid}' AND `printed` IS NULL AND `suspend`='0' ORDER BY dest_id ASC, priority ASC, associated_id ASC, id ASC"; $res = common_query($query, __FILE__, __LINE__); if (!$res) { return mysql_errno(); } if (!mysql_num_rows($res)) { return ERR_ORDER_NOT_FOUND; } $newassociated_id = ""; $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $sourceid); $tpl_print = new template(); $output['orders'] = ''; $msg = ""; while ($arr = mysql_fetch_array($res)) { $oldassociated_id = $newassociated_id; $newassociated_id = $arr['associated_id']; if (isset($priority)) { $oldpriority = $priority; } else { $oldpriority = 0; } $priority = $arr['priority']; if ($oldassociated_id != "") { $olddestid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $oldassociated_id)); $olddest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $olddestid); $olddestname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $olddestid); } else { $olddestid = 0; } $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id)); $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid); $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid); $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid); if ($destid != $olddestid || $priority != $oldpriority) { if ($destid != $olddestid && $olddestid != "") { $tpl_print->assign("date", printer_print_date()); $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language)); $tpl_print->assign("page_cut", printer_print_cut()); // strips the last newline that has been put $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1); if (table_is_takeaway($sourceid)) { $print_tpl_file = 'ticket_takeaway'; } else { $print_tpl_file = 'ticket'; } if ($err = $tpl_print->set_print_template_file($olddestid, $print_tpl_file)) { return $err; } if ($err = $tpl_print->parse()) { $msg = "Error in " . __FUNCTION__ . " - "; $msg .= 'error: ' . $err . "\n"; echo nl2br($msg) . "\n"; error_msg(__FILE__, __LINE__, $msg); return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $tpl_print->reset_vars(); $output['orders'] = ''; $msg = str_replace("'", "", $msg); if ($outerr = print_line($olddestid, $msg)) { return $outerr; } } elseif ($priority != $oldpriority && $oldpriority != "") { $tpl_print->assign("date", printer_print_date()); $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language)); $tpl_print->assign("page_cut", printer_print_cut()); // strips the last newline that has been put $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1); if (table_is_takeaway($sourceid)) { $print_tpl_file = 'ticket_takeaway'; } else { $print_tpl_file = 'ticket'; } if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) { return $err; } if ($err = $tpl_print->parse()) { $msg = "Error in " . __FUNCTION__ . " - "; $msg .= 'error: ' . $err . "\n"; error_msg(__FILE__, __LINE__, $msg); echo nl2br($msg) . "\n"; return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $tpl_print->reset_vars(); $output['orders'] = ''; $msg = str_replace("'", "", $msg); if ($outerr = print_line($destid, $msg)) { return $outerr; } } if (table_is_takeaway($sourceid)) { $takeaway_data = takeaway_get_customer_data($sourceid); $output['takeaway'] = ucfirst(lang_get($dest_language, 'PRINTS_TAKEAWAY')) . " - "; $output['takeaway'] .= $takeaway_data['takeaway_hour'] . ":" . $takeaway_data['takeaway_minute'] . "\n"; $output['takeaway'] .= $takeaway_data['takeaway_surname'] . "\n"; $tpl_print->assign("takeaway", $output['takeaway']); } $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . ": " . $tablenum; $tpl_print->assign("table", $output['table']); $user = new user($_SESSION['userid']); $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name']; $tpl_print->assign("waiter", $output['waiter']); $output['priority'] = ucfirst(lang_get($dest_language, 'PRINTS_PRIORITY')) . ": " . $priority . "\n"; $tpl_print->assign("priority", $output['priority']); $output['people'] = ucfirst(lang_get($dest_language, 'PRINTS_PEOPLE')) . ": " . table_people_number($sourceid) . "\n"; $tpl_print->assign("people", $output['people']); $table = new table($sourceid); $table->fetch_data(true); if ($cust_id = $table->data['customer']) { $cust = new customer($cust_id); $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name']; $tpl_print->assign("customer_name", $output['customer']); $output['customer'] = $cust->data['address']; $tpl_print->assign("customer_address", $output['customer']); $output['customer'] = $cust->data['zip']; $tpl_print->assign("customer_zip_code", $output['customer']); $output['customer'] = $cust->data['city']; $tpl_print->assign("customer_city", $output['customer']); $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account']; $tpl_print->assign("customer_vat_account", $output['customer']); } } $output['orders'] .= printer_print_row($arr, $destid); $printed_orders[] = $arr['id']; if ($newassociated_id != $oldassociated_id) { // if we're in this function, it means that we changed associated_id id // and also that mods have been printed on the same sheet if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) { $output['orders'] .= print_barcode($newassociated_id); } } if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) { $output['orders'] .= print_barcode($newassociated_id); } $tpl_print->assign("orders", $output['orders']); } $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id)); $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid); $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid); $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid); if (CONF_PRINT_BARCODES) { $tpl_print->assign("barcode", print_barcode($newassociated_id)); } $tpl_print->assign("date", printer_print_date()); $tpl_print->assign("gonow", printer_print_gonow($priority, $dest_language)); $tpl_print->assign("page_cut", printer_print_cut()); // strips the last newline that has been put $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1); if (table_is_takeaway($sourceid)) { $print_tpl_file = 'ticket_takeaway'; } else { $print_tpl_file = 'ticket'; } if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) { return $err; } if ($err = $tpl_print->parse()) { $err_msg = "Error in " . __FUNCTION__ . " - "; $err_msg .= 'error: ' . $err . "\n"; error_msg(__FILE__, __LINE__, $err_msg); echo nl2br($err_msg) . "\n"; return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $tpl_print->reset_vars(); $output['orders'] = ''; $msg = str_replace("'", "", $msg); if ($outerr = print_line($destid, $msg)) { return $outerr; } foreach ($printed_orders as $val) { if ($err = print_set_printed($val)) { return $err; } } // there was an error setting orders as printed if ($err) { return ERR_ORDER_NOT_SET_AS_PRINTED; } return 0; }
function dok_ask_dup_song($VARS, $update, $theme_path) { global $SONGS_LABELS; if (!is_array($VARS['duplicates']) || !sizeof($VARS['duplicates'])) { $t = dok_error_template(MSG_ERR_NO_DUP_SONG); return array($t, sprintf(MSG_TITLE_DUP_SONG, '')); } if (!$VARS['label'] || $VARS['label'] == 0) { $new_song_label = MSG_LABEL_NONE; } else { $new_song_label = $SONGS_LABELS[$VARS['label']]['label']; } if (!$VARS['track'] || $VARS['track'] == 0) { $new_song_track = MSG_ALBUM_NEXT_TRACK; } else { $new_song_track = $VARS['track']; } /* *find related songs * */ //$res = dok_oquery('select * from '.dok_tn('rel_songs').' where song_id1 = $t = new template($theme_path); $t->set_file('page', 'song_dup.tpl'); $t->set_block('page', 'duplicate', 'dup_block'); $query = 'select * from ' . dok_tn('song') . ' where id in(' . implode(',', $VARS['duplicates']) . ')'; $res = mysql_query($query); $relations = dok_songs_links_array(); while ($row = mysql_fetch_array($res)) { $t->set_var(dok_song_format($row)); $relations_select = '<select name="link[' . $row['id'] . ']"><option value="" SELECTED>' . MSG_RELATION_NONE . '</option>' . "\n"; foreach ($relations as $key => $val) { $relations_select .= '<option value="' . $key . '">' . $val . '</option>' . "\n"; } $relations_select .= '</select>'; $t->set_var('SONG_RELATION_SELECT', $relations_select); $t->parse('dup_block', 'duplicate', 'true'); } if ($update == 'create_song') { $res = mysql_query('select name from ' . dok_tn('album') . ' where id = ' . $VARS['album']); if (!mysql_numrows($res)) { $album = MSG_UNKNOWN; } else { $album = mysql_result($res, 0, 'name'); } $res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']); if (!mysql_numrows($res)) { $artist = MSG_UNKNOWN; } else { $artist = mysql_result($res, 0, 'name'); } $t->set_var(array('NEW_SONG_NAME' => $VARS['name'], 'NEW_SONG_COMMENT' => dok_textarea_2_db($VARS['comment']), 'NEW_SONG_TRACK' => $new_song_track, 'NEW_SONG_LENGTH' => $VARS['length'], 'NEW_SONG_LABEL' => $new_song_label, 'NEW_SONG_ARTIST' => $artist, 'NEW_SONG_ALBUM' => $album, 'NEW_SONG_GENRE' => dok_genre_name($VARS['genre']), 'NEW_SONG_RELEASE' => dok_year2str($VARS['release']))); } else { $t->set_var(array('NEW_SONG_NAME' => $VARS['name'], 'NEW_SONG_COMMENT' => dok_textarea_2_db($VARS['comment']), 'NEW_SONG_TRACK' => $new_song_track, 'NEW_SONG_LENGTH' => dok_sec2str($VARS['length']), 'NEW_SONG_GENRE' => dok_genre_name($VARS['genre']), 'NEW_SONG_LABEL' => $new_song_label, 'NEW_SONG_ARTIST' => '', 'NEW_SONG_ALBUM' => '', 'NEW_SONG_RELEASE' => dok_year2str($VARS['release']))); } $yes_form = '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"><input type=hidden name="update" value="' . $update . '">'; $yes_form .= '<input type=hidden name="dup_checked" value="1">'; if ($update == 'update_song') { $yes_form .= '<input type=hidden name="id" value="' . $VARS['id'] . '">'; } $yes_form .= '<input type=hidden name="artist" value="' . $VARS['artist'] . '">'; $yes_form .= '<input type=hidden name="album" value="' . $VARS['album'] . '">'; $yes_form .= '<input type=hidden name="track" value="' . str_replace('"', '"', $VARS['track']) . '">'; $yes_form .= '<input type=hidden name="name" value="' . str_replace('"', '"', $VARS['name']) . '">'; $yes_form .= '<input type=hidden name="length" value="' . str_replace('"', '"', $VARS['length']) . '">'; $yes_form .= '<input type=hidden name="release" value="' . str_replace('"', '"', $VARS['release']) . '">'; $yes_form .= '<input type=hidden name="comment" value="' . str_replace('"', '"', $VARS['comment']) . '">'; $yes_form .= '<input type=hidden name="label" value="' . str_replace('"', '"', $VARS['label']) . '">'; $yes_form .= '<input type=hidden name="genre" value="' . $VARS['genre'] . '">'; $t->set_var('SONG_RECORD_FORM', $yes_form); return array($t, MSG_TITLE_DUP_SONG); }
function display_form($template = false) { global $CONFIG, $Sql, $LANG, $Session; $note = !empty($_POST['note']) ? numeric($_POST['note']) : 0; $path_redirect = $this->path . sprintf(str_replace('&', '&', $this->script_path), 0); if ($this->_note_loaded()) { if (!is_object($template) || strtolower(get_class($template)) != 'template') { $template = new template('framework/note.tpl'); } ###########################Insertion############################## if (!empty($_POST['valid_note'])) { if (!empty($note)) { $this->add($note); } redirect($path_redirect); } else { ###########################Affichage############################## $row_note = $Sql->query_array(PREFIX . $this->sql_table, 'users_note', 'nbrnote', 'note', "WHERE id = '" . $this->idprov . "'", __LINE__, __FILE__); $select = '<option value="-1" selected="selected">' . $LANG['note'] . '</option>'; for ($i = 0; $i <= $this->notation_scale; $i++) { $select .= '<option value="' . $i . '">' . $i . '</option>'; } ### Notation Ajax ### $row_note['note'] = round($row_note['note'] / 0.25) * 0.25; $l_note = ($this->options & NOTE_DISPLAY_NOTE) !== 0 ? '<strong>' . $LANG['note'] . ':</strong> ' : ''; $display = ($this->options & NOTE_DISPLAY_BLOCK) !== 0 ? 'block' : 'inline'; $width = ($this->options & NOTE_DISPLAY_BLOCK) !== 0 ? 'width:' . $this->notation_scale * 16 . 'px;margin:auto;' : ''; $ajax_note = '<div style="' . $width . 'display:none" id="note_stars' . $this->idprov . '" onmouseout="out_div(' . $this->idprov . ', array_note[' . $this->idprov . '])" onmouseover="over_div()">'; for ($i = 1; $i <= $this->notation_scale; $i++) { $star_img = 'stars.png'; if ($row_note['note'] < $i) { $decimal = $i - $row_note['note']; if ($decimal >= 1) { $star_img = 'stars0.png'; } elseif ($decimal >= 0.75) { $star_img = 'stars1.png'; } elseif ($decimal >= 0.5) { $star_img = 'stars2.png'; } else { $star_img = 'stars3.png'; } } $ajax_note .= '<a href="javascript:send_note(' . $this->idprov . ', ' . $i . ', \'' . $Session->get_token() . '\')" onmouseover="select_stars(' . $this->idprov . ', ' . $i . ');"><img src="../templates/' . get_utheme() . '/images/' . $star_img . '" alt="" class="valign_middle" id="n' . $this->idprov . '_stars' . $i . '" /></a>'; } if (($this->options & NOTE_NODISPLAY_NBRNOTES) !== 0) { $ajax_note .= '</div> <span id="noteloading' . $this->idprov . '"></span>'; } else { $ajax_note .= '</div> <span id="noteloading' . $this->idprov . '"></span> <div style="display:' . $display . '" id="nbrnote' . $this->idprov . '">(' . $row_note['nbrnote'] . ' ' . ($row_note['nbrnote'] > 1 ? strtolower($LANG['notes']) : strtolower($LANG['note'])) . ')</div>'; } $template->assign_vars(array('C_JS_NOTE' => !defined('HANDLE_NOTE'), 'ID' => $this->idprov, 'NOTE_MAX' => $this->notation_scale, 'SELECT' => $select, 'NOTE' => $l_note . '<span id="note_value' . $this->idprov . '">' . ($row_note['nbrnote'] > 0 ? '<strong>' . $row_note['note'] . '</strong>' : '<em>' . $LANG['no_note'] . '</em>') . '</span>' . $ajax_note, 'ARRAY_NOTE' => 'array_note[' . $this->idprov . '] = \'' . $row_note['note'] . '\';', 'DISPLAY' => $display, 'L_AUTH_ERROR' => addslashes($LANG['e_auth']), 'L_ALERT_ALREADY_VOTE' => addslashes($LANG['already_vote']), 'L_ALREADY_VOTE' => '', 'L_NOTE' => addslashes($LANG['note']), 'L_NOTES' => addslashes($LANG['notes']), 'L_VALID_NOTE' => $LANG['valid_note'])); } if (!defined('HANDLE_NOTE')) { define('HANDLE_NOTE', true); } return $template->parse(TEMPLATE_STRING_MODE); } else { global $Errorh; $Errorh->handler('e_unexist_page', E_USER_REDIRECT); } }
function dok_list_songs($VARS, $up, $theme_path) { $t = new template($theme_path); $t->set_file('page', 'song_list.tpl'); $t->set_block('page', 'song', 'song_block'); $t->set_block('page', 'next_page', 'next_page_block'); $t->set_block('page', 'if_artist', 'if_artist_block'); if (!isset($VARS['alpha'])) { $VARS['alpha'] = '-'; } if (!strlen($VARS['offset']) || $VARS['offset'] < 0) { $VARS['offset'] = '0'; } $VARS['alpha'] = mysql_real_escape_string($VARS['alpha']); if (isset($VARS['artist']) && is_numeric($VARS['artist']) && $VARS['artist'] > 0) { $query = 'select s.* from ' . dok_tn('rel_song_artist') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where substring(s.name from 1 for 1) >= \'' . $VARS['alpha'] . '\' and r.artist_id = ' . $VARS['artist'] . ' order by s.name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP; $total_query = 'select count(*) as c from ' . dok_tn('rel_song_artist') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where substring(s.name from 1 for 1) >= \'' . $VARS['alpha'] . '\' and r.artist_id = ' . $VARS['artist']; $res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']); if (!mysql_numrows($res)) { $t->set_var('ARTIST_NAME', ''); $t->set_var('ARTIST_LINK', ''); $t->set_var('ARTIST_ID', ''); } else { $t->set_var('ARTIST_NAME', mysql_result($res, 0, 'name')); $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $VARS['artist']); $t->set_var('ARTIST_ID', $VARS['artist']); } $t->parse('if_artist_block', 'if_artist'); $pager_infos = array('related' => 'artist', 'related_id' => $VARS['artist']); } else { $query = 'select * from ' . dok_tn('song') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP; $total_query = 'select count(*) as c from ' . dok_tn('song') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\''; $t->set_var('if_artist_block', ''); $t->set_var('ARTIST_ID', ''); $t->set_var('ARTIST_NAME', ''); $t->set_var('ARTIST_LINK', ''); $pager_infos = ''; } $res = dok_oquery($query); if ($res->numrows()) { $ids = $res->fetch_col_array('id'); while ($row = $res->fetch_array()) { $t->set_var(dok_song_format($row, $pager_infos)); $t->parse('song_block', 'song', 'true'); } $res = mysql_query($total_query); $total = mysql_result($res, 0, 'c'); if ($total > $VARS['offset'] + DOK_LIST_EPP) { $lnk = $_SERVER['PHP_SELF'] . '?display=list_songs&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP); if ($t->get_var('ARTIST_ID')) { $lnk .= '&artist=' . $t->get_var('ARTIST_ID'); } $t->set_var('NEXT_PAGE_LINK', $lnk); $t->parse('next_page_block', 'next_page'); } else { $t->set_var('next_page_block', ''); } } else { $t->set_var('song_block', MSG_NO_SONG); $t->set_var('next_page_block', ''); } return array($t, MSG_TITLE_LIST_SONG); }
public function checkRender($view_path, $check_view = '', $time = 0) { static $tplrefresh = null; if (is_null($tplrefresh)) { $tplrefresh = g('_config/view/tplrefresh'); } $cache_file = $this->getCache($view_path); $tpl_file = $this->getTpl($view_path); $check_file = $check_view ? $this->getTpl($check_view) : 0; if (!file_exists($cache_file) || $tplrefresh == 1 || $tplrefresh == 2 && filemtime($tpl_file) > filemtime($cache_file) || $check_file && filemtime($check_file) > $time) { $this->checkCss(); $template = new template(); $content = $template->parse($tpl_file, $view_path, $this->_script_path); $fp = fopen($cache_file, 'wb'); if ($fp) { fwrite($fp, $content); fclose($fp); } else { throw new error("{$view_path} template cache file can't write!"); } //return $content; } else { //return file_get_contents($cache_file); } return $cache_file; }
function bill_print() { /* name: bill_print() returns: 0 - no error 1 - Printer not found for output tyoe 2 - No order selected 3 - Printing error other - mysql error number */ // type: 0: reserved // 1: bill // 2. invoice // 3. receipt // we have to translate them to the mgmt_type values in order to be correctely // written and read in the log // mgmt_type: 3: invoice // 4: bill // 5: receipt global $tpl; global $output_page; $output['orders'] = ''; $output_page = ''; //connect to printer by client IP $clientip = ""; if (isset($clientip)) { unset($clientip); } $clientip = getenv('REMOTE_ADDR'); //end:connect to printer by client IP if ($_SESSION['bill_printed']) { return 0; } $_SESSION['bill_printed'] = 1; $type = $_SESSION['type']; $keep_separated = bill_check_keep_separated(); $type = receipt_type_waiter2mgmt($type); // CRYPTO if (!bill_check_empty()) { $receipt_id = receipt_insert($_SESSION['account'], $type); } $printing_enabled = $arr['print_bill']; $tpl_print = new template(); switch ($_SESSION['type']) { case 1: $query = "SELECT * FROM `dests` WHERE `bill`='1' AND `deleted`='0'"; $template_type = 'bill'; break; case 2: $query = "SELECT * FROM `dests` WHERE `invoice`='1' AND `deleted`='0'"; $template_type = 'invoice'; break; case 3: $query = "SELECT * FROM `dests` WHERE `receipt`='1' AND `deleted`='0'"; $template_type = 'receipt'; break; default: $query = "SELECT * FROM `dests` WHERE `bill`='1' AND `deleted`='0'"; $template_type = 'bill'; } $res = common_query($query, __FILE__, __LINE__); if (!$res) { return ERR_MYSQL; } //connect to printer by client IP while ($row = mysql_fetch_array($res)) { if ($row['dest_ip'] == '') { if ($row['dest'] != '') { $destid = $row['id']; $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid); } else { return ERR_PRINTER_NOT_FOUND_FOR_SELECTED_TYPE; } } elseif ($row['dest'] != '' && $row['dest_ip'] != '') { $ippart = explode("|", $row['dest_ip']); if (in_array($clientip, $ippart)) { $destid = $row['id']; break; } $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid); } else { return ERR_PRINTER_NOT_FOUND_FOR_SELECTED_TYPE; } } if ($err = $tpl_print->set_print_template_file($destid, $template_type)) { return $err; } // reset the counter and the message to be sent to the printer $total = 0; $msg = ""; $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $_SESSION['sourceid']); $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . " {$tablenum} \n"; $tpl_print->assign("table", $output['table']); // writes the table num to video $output_page .= ucfirst(phr('TABLE_NUMBER')) . ": {$tablenum} "; $table = new table($_SESSION['sourceid']); $table->fetch_data(true); if ($cust_id = $table->data['customer']) { $cust = new customer($cust_id); $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name']; $tpl_print->assign("customer_name", $output['customer']); $output['customer'] = $cust->data['address']; $tpl_print->assign("customer_address", $output['customer']); $output['customer'] = $cust->data['zip']; $tpl_print->assign("customer_zip_code", $output['customer']); $output['customer'] = $cust->data['city']; $tpl_print->assign("customer_city", $output['customer']); $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account']; $tpl_print->assign("customer_vat_account", $output['customer']); } if (bill_check_empty()) { return ERR_NO_ORDER_SELECTED; } //mizuko : swap qty with name $output_page .= "<table bgcolor=\"" . COLOR_TABLE_GENERAL . "\">\r\n\t<thead>\r\n\t<tr>\r\n\t<th scope=col>" . ucfirst(phr('NAME')) . "</th>\r\n\t<th scope=col>" . ucfirst(phr('QUANTITY_ABBR')) . "</th>\r\n\t<th scope=col>" . ucfirst(phr('PRICE')) . "</th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>"; $class = COLOR_ORDER_PRINTED; ksort($_SESSION['separated']); // the next for prints the list and the chosen dishes for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) { $output['orders'] .= bill_print_row($key, $value, $destid); } $tpl_print->assign("orders", $output['orders']); if ($_SESSION['discount']['type'] == "amount" || $_SESSION['discount']['type'] == "percent") { $output['discount'] = bill_print_discount($receipt_id, $destid); $tpl_print->assign("discount", $output['discount']); } $total = bill_calc_vat(); $total_discounted = bill_calc_discount($total); // updates the receipt value, has to be before print totals! receipt_update_amounts($_SESSION['account'], $total_discounted, $receipt_id); $output['total'] = bill_print_total($receipt_id, $destid); $tpl_print->assign("total", $output['total']); if (SHOW_CHANGE == 1) { $output['change'] = bill_print_change($total_discounted['total']); $tpl_print->assign("change", $output['change']); } //mizuko $user = new user($_SESSION['userid']); $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name']; $tpl_print->assign("waiter", $output['waiter']); $tpl_print->assign("date", printer_print_date()); //end mizuko $output_page .= "\r\n\t</tbody>\r\n\t</table>"; $output['receipt_id'] = bill_print_receipt_id($receipt_id, $destid); $tpl_print->assign("receipt_id", $output['receipt_id']); $output['taxes'] = bill_print_taxes($receipt_id, $destid); $tpl_print->assign("taxes", $output['taxes']); if ($err = $tpl_print->parse()) { $msg = "Error in " . __FUNCTION__ . " - "; $msg .= 'error: ' . $err . "\n"; error_msg(__FILE__, __LINE__, $msg); echo nl2br($msg) . "\n"; return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $msg = str_replace("'", "", $msg); if ($printing_enabled) { if ($err = print_line($arr['id'], $msg)) { // the process is stopped so we delete the created receipt receipt_delete($_SESSION['account'], $receipt_id); return $err; } } ksort($_SESSION['separated']); // sets the log for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) { if ($err_logger = bill_logger($key, $receipt_id)) { debug_msg(__FILE__, __LINE__, __FUNCTION__ . ' - receipt_id: ' . $receipt_id . ' - logger return code: ' . $err_logger); } else { debug_msg(__FILE__, __LINE__, __FUNCTION__ . ' - receipt_id: ' . $receipt_id . ' - logged'); } } return 0; }
function dok_link_songs($VARS, $update, $theme_path) { if (!is_numeric($VARS['id']) || $VARS['id'] < 1) { $VARS['id'] = 0; } $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { $t = dok_error_template(MSG_ERR_SONG_NOT_FOUND); return array($t, MSG_TITLE_ADD_SONG_ALBUM); } $song = mysql_fetch_array($res); if (!isset($VARS['alpha'])) { $VARS['alpha'] = ' '; } if (!isset($VARS['alpha'])) { $VARS['alpha'] = 'a'; //could change again later with $letters array } /** $res = dok_oquery('select distinct(album_id) as aid from '.dok_tn('rel_song_album').' where song_id = '.$song['id']); $current_albums = $res->fetch_col_array('aid'); $where = ''; if ( sizeof($current_albums) ) $where = ' where id not in('.implode(',',$current_albums).')';*/ $t = new template($theme_path); $t->set_file('page', 'song_song_link.tpl'); $t->set_block('page', 'alphalink', 'alphalink_block'); $t->set_block('page', 'song', 'song_block'); //make alphalinks $letters = dok_letter_array('song'); if (!sizeof($letters)) { $t->set_var('alphalink_block', ''); } else { if (!isset($VARS['alpha'])) { $VARS['alpha'] = reset($letters); } foreach ($letters as $letter) { $lnk = $_SERVER['PHP_SELF'] . '?display=link_songs&id=' . $VARS['id']; if ($VARS['link']) { $lnk .= '&link=' . urlencode($VARS['link']); } $lnk .= '&alpha=' . urlencode($letter); $t->set_var('ALPHALINK_LINK', $lnk); $t->set_var('ALPHALINK_LETTER', $letter); $t->parse('alphalink_block', 'alphalink', 'true'); } } $where = ' where substring(name from 1 for 1) = \'' . addslashes($VARS['alpha']) . '\' and id != ' . $VARS['id']; $res = mysql_query('select * from ' . dok_tn('song') . $where . ' order by name'); while ($row = mysql_fetch_array($res)) { $t->set_var('SONG_CB', '<input type=radio name="other_id" value="' . $row['id'] . '">'); $t->set_var(dok_song_format($row)); $t->parse('song_block', 'song', 'true'); } $la = dok_songs_links_array(); $options = ''; foreach ($la as $value => $legend) { $options .= '<option value="' . str_replace('"', '"', $value) . '">' . $legend . '</option>' . "\n"; } $t->set_var('RELATION_OPTIONS', $options); $t->set_var(dok_song_format($song)); $t->set_var('ALBUM_SELECT', $a_select); $t->set_var('SONG_ID', $song['id']); return array($t, MSG_TITLE_ADD_SONG_LINK); }
foreach ($privkeys as $private_key) { if ($public_key == $b32->extended_private_to_public($private_key)) { $found = true; break; } } if ($found === false) { array_push($no_keys, array('num' => $num, 'public_key' => $public_key)); $num++; } } // Print response if (count($no_keys) > 0) { $template = new template('admin/setup/invalid_bip32_keys'); $template->assign('keys', $no_keys); $template->parse(); exit(0); } else { $template->add_message('Successfully verified public keys, and all private keys match appropriately.'); } } // Initialize $bip32 = new bip32(); // Get wallets $first = true; $bip32_key_fields = ''; $required_sigs = 0; $wallet_id = 0; $wallet_javascript = ''; $wallet_options = ''; $rows = DB::query("SELECT * FROM coin_wallets WHERE status = 'active' ORDER BY display_name");
** Filename.....: seperate-script.php ** Author.......: Richard Heyes ** Version......: 1.0 ** Notes........: This shows how you can ** use multiple template files. ** Last changed.: 23/05/00 ** Last change..: ***************************************/ include 'class.template.inc'; /*************************************** ** Set a couple of example variables. ***************************************/ $test_var = 'Hello world!'; $page_title = 'Template Class'; /*************************************** ** Set a couple of example arrays. ***************************************/ $table_rows = array(); $table_rows[] = array('column_1' => 'This is column one on row one!', 'column_2' => 'This is column two on row one!', 'column_3' => 'This is column three on row one!'); $table_rows[] = array('column_1' => 'This is column one on row two!', 'column_2' => 'This is column two on row two!', 'column_3' => 'This is column three on row two!'); /*************************************** ** The template goodies. ***************************************/ $tpl = new template(); $tpl->load_file('header', 'header-template.html'); $tpl->load_file('main', 'main-template.html'); $tpl->load_file('footer', 'footer-template.html'); $tpl->register('header', 'test_var, page_title'); $tpl->parse('header, main, footer'); $tpl->parse_loop('main', 'table_rows'); $tpl->print_file('header, main, footer');
function dok_view_song($VARS, $update, $theme_path) { global $THEME_DATE, $USER, $SONGS_LINKS; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { $t = dok_error_template(MSG_ERR_SONG_DISPLAY); return array($t, sprintf(MSG_TITLE_DISPLAY_SONG, '')); } $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { $t = dok_error_template(MSG_ERR_SONG_DISPLAY); return array($t, sprintf(MSG_TITLE_DISPLAY_SONG, '')); } $row = mysql_fetch_assoc($res); $fields = array_keys($row); $t = new template($theme_path); $t->set_file('page', 'song_display.tpl'); $t->set_block('page', 'song', 'song_block'); $t->set_block('page', 'relation', 'relation_block'); $t->set_block('page', 'if_relation', 'if_relation_block'); $t->set_block('page', 'if_songeditor', 'songeditor_block'); $t->set_block('page', 'if_label', 'label_block'); if (DOK_ENABLE_USER && !$USER->editor && !$USER->admin) { $t->set_var('songeditor_block', ''); } else { $t->parse('songeditor_block', 'if_songeditor'); $t->set_var('SONG_EDIT_LINK', $_SERVER['PHP_SELF'] . '?display=edit_song&id=' . $row['id']); } $t->set_block('page', 'song_albums', 'albums_block'); $query = 'select a.name, a.creation, a.id, r.track from ' . dok_tn('rel_song_album') . ' as r left join ' . dok_tn('album') . ' as a on r.album_id = a.id where r.song_id = ' . $VARS['id'] . ' order by a.name'; $res = mysql_query($query); if (!mysql_numrows($res)) { $t->set_var('albums_block', MSG_NO_ALBUM); } else { while ($a_row = mysql_fetch_array($res)) { $t->set_var(array('ALBUM_LINK' => $_SERVER['PHP_SELF'] . '?display=view_album&id=' . $a_row['id'], 'ALBUM_NAME' => $a_row['name'], 'ALBUM_TRACK' => $a_row['track'])); $t->parse('albums_block', 'song_albums', 'true'); } } // song relations $rel = 0; $query = 'select '; foreach ($fields as $field) { $query .= ' s1.' . $field . ' as s1' . $field . ', s2.' . $field . ' as s2' . $field . ','; } $query .= 'r.link from ' . dok_tn('rel_songs') . ' as r left join ' . dok_tn('song') . ' as s1 on r.song_id1=s1.id left join ' . dok_tn('song') . ' as s2 on r.song_id2=s2.id where song_id1=' . $row['id'] . ' or song_id2=' . $row['id'] . ' order by link'; //echo $query; $res = mysql_query($query); $link = false; $relations = array(); while ($subrow = mysql_fetch_assoc($res)) { if ($subrow['s1id'] == $row['id']) { if (is_array($SONGS_LINKS[$subrow['link']]) && $SONGS_LINKS[$subrow['link']][0]) { $good_song = 's2'; $good_link = $SONGS_LINKS[$subrow['link']][0]; } else { unset($good_song); unset($good_link); } } else { if (is_array($SONGS_LINKS[$subrow['link']]) && $SONGS_LINKS[$subrow['link']][1]) { $good_song = 's1'; $good_link = $SONGS_LINKS[$subrow['link']][1]; } else { unset($good_song); unset($good_link); } } if (isset($good_song)) { $myrow = array(); foreach ($fields as $field) { $myrow[$field] = $subrow[$good_song . $field]; } $relations[$good_link][] = $myrow; } } $related_ids = array($row['id']); if (sizeof($relations)) { foreach ($relations as $relation => $songs) { $t->set_var('song_block', ''); $t->set_var('SONG_RELATION', $relation); foreach ($songs as $song) { $rel++; $t->set_var(dok_song_format($song)); $t->parse('song_block', 'song', 'true'); $related_ids[] = $song['id']; } $t->parse('relation_block', 'relation', 'true'); } } //same title $res = mysql_query('select * from ' . dok_tn('song') . ' where id not in(' . implode(', ', $related_ids) . ') and name = \'' . mysql_real_escape_string($row['name']) . '\''); if (mysql_numrows($res)) { $t->set_var('song_block', ''); $t->set_var('SONG_RELATION', MSG_SONG_LINK_SAME_TITLE); while ($dup_row = mysql_fetch_array($res)) { $rel++; $t->set_var(dok_song_format($dup_row)); $t->parse('song_block', 'song', 'true'); } $t->parse('relation_block', 'relation', 'true'); } if ($rel) { $t->parse('if_relation_block', 'if_relation'); } else { $t->set_var('if_relation_block', ''); } $t->set_var('SONG_RELATIONS', $rel); $t->set_var(dok_song_format($row)); if ($row['label'] > 0) { $t->parse('label_block', 'if_label'); } else { $t->set_var('label_block', ''); } //pager related if (DOK_ENABLE_PAGER) { global $THEME_PAGER_TYPE; if (isset($VARS['pager_related'])) { if ($VARS['pager_related'] == 'artist') { include_once 'php/pager_song_artist.php'; } elseif ($VARS['pager_related'] == 'album') { include_once 'php/pager_song_album.php'; } else { $t = dok_pager_clean($t); } } else { $t = dok_pager_clean($t); } } else { $t = dok_pager_clean($t); } if (!isset($VARS['nohit'])) { $res = mysql_query('update ' . dok_tn('song') . ' set hits = hits + 1 where id = ' . $VARS['id']); } return array($t, sprintf(MSG_TITLE_DISPLAY_SONG, $row['name'])); }
function dok_search($VARS, $update, $theme_path) { $t = new template($theme_path); $t->set_file('page', 'search.tpl'); $t->set_block('page', 'song_result', 'song_block'); $t->set_block('page', 'artist_result', 'artist_block'); $t->set_block('page', 'album_result', 'album_block'); $query = mysql_real_escape_string($VARS['query']); $query = str_replace(array('%', '_'), array('\\%', '\\_'), $query); if (!$VARS['exact_word'] && !strpos($query, ' ')) { $query = $query . '*'; } //echo "Final query: $query <BR>"; $target = $VARS['target']; $total = 0; if ($target != 'album' && $target != 'artist' && $target != 'song') { $target = 'all'; } if ($target == 'all' || $target == 'song') { $matching = dok_search_song($query); if (!sizeof($matching)) { $t->set_var('song_block', MSG_SEARCH_NO_RESULT_SONG); } else { $total += sizeof($matching); foreach ($matching as $vars) { $t->set_var($vars); $t->parse('song_block', 'song_result', 'true'); } } } else { $t->set_var('song_block', ''); } if ($target == 'all' || $target == 'album') { $matching = dok_search_album($query); if (!sizeof($matching)) { $t->set_var('album_block', MSG_SEARCH_NO_RESULT_ALBUM); } else { $total += sizeof($matching); foreach ($matching as $vars) { $t->set_var($vars); $t->parse('album_block', 'album_result', 'true'); } } } else { $t->set_var('album_block', ''); } if ($target == 'all' || $target == 'artist') { $matching = dok_search_artist($query); if (!sizeof($matching)) { $t->set_var('artist_block', MSG_SEARCH_NO_RESULT_ARTIST); } else { $total += sizeof($matching); foreach ($matching as $vars) { $t->set_var($vars); $t->parse('artist_block', 'artist_result', 'true'); } } } else { $t->set_var('artist_block', ''); } $t->set_var('SEARCH_RESULTS', $total); $t->set_var('SEARCH_QUERY', str_replace('"', '"', $VARS['query'])); return array($t, sprintf(MSG_TITLE_SEARCH, $VARS['query'])); }
/***************************************************** ** Load template *****************************************************/ $tpl = new template(); $tpl->load_file('global', './templates/test.tpl.html'); /***************************************************** ** Parse global template (mostly for user debugging) *****************************************************/ if (isset($add_text) and is_array($add_text)) { reset($add_text); foreach ($add_text as $key => $val) { ${$key} = $val; $tpl->register('global', $key); } } if (isset($extension_list) and !empty($extension_list) and is_array($extension_list)) { for ($i = 0; $i < count($extension_list); $i++) { $extensions[] = array('EXT' => strtoupper($extension_list[$i]), 'ext' => strtolower($extension_list[$i])); } } $tpl->parse_loop('global', 'system_message'); $tpl->parse_loop('global', 'extensions'); if (isset($txt) and is_array($txt)) { reset($txt); foreach ($txt as $key => $val) { ${$key} = $val; $tpl->register('global', $key); } } $tpl->parse('global'); $tpl->print_file('global');
function dok_list_albums($VARS, $up, $theme_path) { $orders = array('hits', 'length'); $t = new template($theme_path); $t->set_file('page', 'album_list.tpl'); $t->set_block('page', 'if_artist', 'artist_block'); $t->set_block('page', 'if_artist_2', 'artist_2_block'); $t->set_block('page', 'album', 'album_block'); $t->set_block('page', 'next_page', 'next_page_block'); if (!isset($VARS['alpha'])) { $VARS['alpha'] = '-'; } if (!strlen($VARS['offset']) || $VARS['offset'] < 0) { $VARS['offset'] = '0'; } $VARS['alpha'] = mysql_real_escape_string($VARS['alpha']); //$query = 'select id, name from '.dok_tn('album').' where substring(name from 1 for 1) >= \''.$VARS['alpha'].'\' order by name limit '.$VARS['offset'].', '.DOK_LIST_EPP; $query = 'select sum(s.length) as length, count(s.id) as c, sum(s.hits) as hits, a.id, a.name from ' . dok_tn('song') . ' as s left join ' . dok_tn('rel_song_album') . ' as r on s.id=r.song_id left join ' . dok_tn('album') . ' as a on r.album_id=a.id '; $where = array(); if (isset($VARS['sort']) && !in_array($VARS['sort'], $orders) || !isset($VARS['sort'])) { unset($VARS['sort']); $where[] = 'substring(a.name from 1 for 1) >= \'' . $VARS['alpha'] . '\' '; } if (isset($VARS['artist']) && is_numeric($VARS['artist']) && $VARS['artist'] > 0) { $res = mysql_query('select * from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']); if (mysql_numrows($res)) { $row = mysql_fetch_assoc($res); $t->set_var('ARTIST_NAME', $row['name']); $t->set_var('ARTIST_ID', $row['id']); $t->parse('artist_block', 'if_artist'); $res = dok_oquery('select distinct(r.album_id) from ' . dok_tn('rel_song_album') . ' as r left join ' . dok_tn('rel_song_artist') . ' as r2 on r.song_id=r2.song_id where r2.artist_id = ' . $VARS['artist']); $al_ids = $res->fetch_col_array('album_id'); if (sizeof($al_ids)) { $where[] = 'a.id in(' . implode(', ', $al_ids) . ')'; } } else { unset($VARS['artist']); $t->set_var('artist_block', ''); } } else { unset($VARS['artist']); $t->set_var('artist_block', ''); } if (sizeof($where)) { $query .= ' where ' . implode(' AND ', $where); } $query .= 'group by r.album_id '; if (isset($VARS['sort'])) { $query .= 'order by ' . $VARS['sort'] . ' desc '; } else { $query .= 'order by a.name '; } $query .= 'limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP; $res = dok_oquery($query); echo mysql_error(); if ($res->numrows()) { //$ids = $res->fetch_col_array('id'); //$n_res = dok_oquery('select album_id, count(*) as c from '.dok_tn('rel_song_album').' where album_id in('.implode(',',$ids).') group by album_id'); //$n_array = $n_res->fetch_col_array('c','album_id'); while ($row = $res->fetch_array()) { $t->set_var('ALBUM_LINK', $_SERVER['PHP_SELF'] . '?display=view_album&id=' . $row['id']); $t->set_var('ALBUM_NAME', $row['name']); $t->set_var('ALBUM_HITS', $row['hits']); $t->set_var('ALBUM_LENGTH', dok_sec2str($row['length'])); if ($row['c'] > 0) { $t->set_var('ALBUM_SONGS', $row['c']); } else { $t->set_var('ALBUM_SONGS', 0); } $t->parse('album_block', 'album', 'true'); } $t_query = 'select count(*) as c from ' . dok_tn('album') . ' as a'; if (sizeof($where)) { $t_query .= ' where ' . implode(' AND ', $where); } $res = mysql_query($t_query); $total = mysql_result($res, 0, 'c'); if ($total > $VARS['offset'] + DOK_LIST_EPP) { $link = $_SERVER['PHP_SELF'] . '?display=list_albums&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP . '&artist=' . $VARS['artist']); if (isset($VARS['sort'])) { $link .= '&sort=' . $VARS['sort']; } $t->set_var('NEXT_PAGE_LINK', $link); $t->parse('next_page_block', 'next_page'); } else { $t->set_var('next_page_block', ''); } } else { $t->set_var('album_block', MSG_NO_ALBUM); $t->set_var('next_page_block', ''); } return array($t, MSG_TITLE_LIST_ALBUM); }
private function invalid_login($type = 'public') { // Init template if ($type == 'admin') { $template = new template('admin/login'); } else { $template = new template('login'); } // User message $template->add_message("Incorrect username or password specified. Please try again.", 'error'); $template->parse(); exit(0); }
$ratio = $width_source / $height_source; $width = $width_max; $height = $width / $ratio; } else { $ratio = $height_source / $width_source; $height = $height_max; $width = $height / $ratio; } } else { $width = $width_source; $height = $height_source; } $img = '<img src="' . PATH_TO_ROOT . '/images/smileys/' . $url_smile . '" height="' . $height . '" width="' . $width . '" alt="' . $code_smile . '" title="' . $code_smile . '" />'; $multiple_x = $j / $smile_by_line; $tr_start = is_int($multiple_x) ? '<tr>' : ''; $j++; $multiple_x = $j / $smile_by_line; $tr_end = is_int($multiple_x) ? '</tr>' : ''; if ($nbr_smile == $j) { $tr_end = '</tr>'; } $tpl_smileys->assign_block_vars('smiley', array('IMG' => $img, 'CODE' => addslashes($code_smile), 'TR_START' => $tr_start, 'TR_END' => $tr_end)); if ($nbr_smile == $j && $nbr_smile > $smile_by_line) { while (!is_int($j / $smile_by_line)) { $tpl_smileys->assign_block_vars('smiley.td', array('TD' => '<td> </td>')); $j++; } } } $tpl_smileys->parse();
public function add_wallet() { // Initialize global $template; $enc_client = new encrypt(); // Set variables $required_sigs = $_POST['address_type'] == 'standard' ? 1 : $_POST['multisig_sig_required']; $total_sigs = $_POST['address_type'] == 'standard' ? 1 : $_POST['multisig_sig_total']; // Validate public keys if ($_POST['autogen_keys'] == 0) { for ($x = 1; $x <= $total_sigs; $x++) { if (!($import = $this->import($_POST['bip32_key' . $x]))) { $template->add_message("The #{$x} BIP32 key you specified is an invalid BIP32 key.", 'error'); } elseif ($import['type'] != 'public') { $template->add_message("The #{$x} BIP32 key you specified is an invalid BIP32 key.", 'error'); } } } // Create wallet, if no errors $wallet_id = 0; if ($template->has_errors != 1) { // Add to DB DB::insert('coin_wallets', array('address_type' => $_POST['address_type'], 'sigs_required' => $required_sigs, 'sigs_total' => $total_sigs, 'display_name' => $_POST['wallet_name'])); $wallet_id = DB::insertId(); // Gather BIP32 keys $keys = array(); for ($x = 1; $x <= $total_sigs; $x++) { // Auto-generate, if needed if ($_POST['autogen_keys'] == 1) { $private_key = $this->generate_master_key(); $public_key = $this->extended_private_to_public($private_key); array_push($keys, array('num' => $x, 'private_key' => $private_key, 'public_key' => $public_key)); } else { $public_key = $_POST['bip32_key' . $x]; } // Add key to db DB::insert('coin_wallets_keys', array('wallet_id' => $wallet_id, 'public_key' => $enc_client->encrypt($public_key))); } // User message if ($_POST['autogen_keys'] == 1) { $template = new template('admin/setup/bip32_keys'); $template->assign('keys', $keys); $template->parse(); exit(0); } else { $template->add_message("Successfully added new wallet, {$_POST['wallet_name']}"); } } // Return return $wallet_id; }
function dok_list_artists($VARS, $up, $theme_path) { $orders = array('count', 'length', 'albums'); $t = new template($theme_path); $t->set_file('page', 'artist_list.tpl'); $t->set_block('page', 'artist', 'artist_block'); $t->set_block('page', 'next_page', 'next_page_block'); if (!isset($VARS['alpha'])) { $VARS['alpha'] = '-'; } $VARS['alpha'] = mysql_real_escape_string($VARS['alpha']); if (isset($VARS['sort']) && !in_array($VARS['sort'], $orders)) { unset($VARS['sort']); } if (!strlen($VARS['offset']) || $VARS['offset'] < 0) { $VARS['offset'] = '0'; } $display = array(); // here we do 2 queries: it's better than 1 for mysql if (isset($VARS['sort'])) { $my_display = array(); $query = "select r.artist_id as id, count(distinct r.song_id) as count, sum(s.length) as length, count(distinct al.album_id) as albums from " . dok_tn("rel_song_artist") . ' as r left join ' . dok_tn('song') . ' as s on r.song_id=s.id left join ' . dok_tn('rel_song_album') . ' as al on r.song_id=al.song_id group by r.artist_id order by ' . $VARS['sort'] . ' desc limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP; //echo $query; $res = dok_oquery($query); while ($row = $res->fetch_array()) { $my_display[$row['id']] = array('id' => $row['id'], 'count' => $row['count'], 'length' => $row['length'], 'albums' => $row['albums']); } if (sizeof($my_display)) { $query = 'select name,id from ' . dok_tn('artist') . ' where id in(' . implode(', ', array_keys($my_display)) . ')'; $res = dok_oquery($query); while ($row = $res->fetch_array()) { $my_display[$row['id']]['name'] = $row['name']; } foreach ($my_display as $one) { $display[] = $one; } } } else { $my_display = array(); $query = 'select name,id from ' . dok_tn('artist') . ' where LEFT(name,1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP; $res = dok_oquery($query); while ($row = $res->fetch_array()) { $my_display[$row['id']] = array('name' => $row['name'], 'id' => $row['id']); } if (sizeof($my_display)) { $query = "select r.artist_id as id, count(DISTINCT r.song_id) as count, sum(s.length) as length, count(distinct al.album_id) as albums from " . dok_tn("rel_song_artist") . ' as r left join ' . dok_tn('song') . ' as s on r.song_id=s.id left join ' . dok_tn('rel_song_album') . ' as al on r.song_id=al.song_id where r.artist_id in(' . implode(', ', array_keys($my_display)) . ') group by r.artist_id'; $res = dok_oquery($query); while ($row = $res->fetch_array()) { $my_display[$row['id']]['count'] = $row['count']; $my_display[$row['id']]['length'] = $row['length']; $my_display[$row['id']]['albums'] = $row['albums']; } foreach ($my_display as $one) { $display[] = $one; } } } if (sizeof($display)) { $display_first = $VARS['offset'] + 1; $display_last = $display_first - 1; foreach ($display as $row) { $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $row['id']); $t->set_var('ARTIST_NAME', $row['name']); $t->set_var('ARTIST_SONGS', $row['count']); $t->set_var('ARTIST_ALBUMS', $row['albums']); $t->set_var('ARTIST_LENGTH', dok_sec2str($row['length'])); $t->parse('artist_block', 'artist', 'true'); $display_last++; } if (isset($VARS['sort'])) { $t_query = 'select count(*) as c from ' . dok_tn('rel_song_artist') . ' as r group by r.artist_id'; } else { $t_query = 'select id from ' . dok_tn('artist') . ' where LEFT(name,1) >= \'' . $VARS['alpha'] . '\''; //$t_query='select count(*) as c from '.dok_tn('rel_song_artist').' as r left join '.dok_tn('artist').' as a on r.artist_id = a.id where substring(a.name from 1 for 1) >= \''.$VARS['alpha'].'\' group by r.artist_id'; //echo $t_query; } $res = mysql_query($t_query); $total = mysql_numrows($res); if ($total > $VARS['offset'] + DOK_LIST_EPP) { $t->set_var('NEXT_PAGE_LINK', $_SERVER['PHP_SELF'] . '?display=list_artists&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP) . '&sort=' . $VARS['sort']); $t->parse('next_page_block', 'next_page'); } else { $t->set_var('next_page_block', ''); } } else { $t->set_var('artist_block', MSG_NO_ARTIST); $t->set_var('next_page_block', ''); } return array($t, MSG_TITLE_LIST_ARTIST); }
<?php $link_tpl = new template($DOK_THEME_PATH); $link_tpl->set_file('page', 'box/links.tpl'); $link_tpl->set_block('page', 'if_editor', 'editor_block'); $link_tpl->set_block('page', 'if_admin', 'admin_block'); $link_tpl->set_block('page', 'if_logged', 'logged_block'); if (!DOK_ENABLE_USER || $USER->admin) { $link_tpl->parse('admin_block', 'if_admin'); $link_tpl->parse('editor_block', 'if_editor'); dok_add_tpl_var('LIST_USER', $THEME_LIST_USER); } elseif ($USER->editor) { $link_tpl->parse('editor_block', 'if_editor'); $link_tpl->set_var('admin_block', ''); dok_add_tpl_var('LIST_USER', ''); } else { $link_tpl->set_var('admin_block', ''); $link_tpl->set_var('editor_block', ''); dok_add_tpl_var('LIST_USER', ''); } if (!DOK_ENABLE_USER || $USER->id < 1) { $link_tpl->set_var('logged_block', ''); } else { $link_tpl->set_var('USER_ID', $USER->id); $link_tpl->parse('logged_block', 'if_logged'); } $link_tpl->set_var('DOK', $_SERVER['PHP_SELF']); dok_add_tpl_var('ACTION_BOX', $link_tpl->parse('out', 'page'));
public function __construct($parts = array()) { // Initialize global $config, $template; // Set variables if ($config['is_setup'] == 1 && preg_match("/^admin/", trim($_GET['route'], '/'))) { $panel = 'admin'; $require_login = true; } else { $panel = 'public'; $require_login = false; } // Check IP restrictions if ($panel == 'admin' && isset($config['ipallow']) && $config['ipallow'] != '') { $ok = false; $ips = explode("\n", $config['ipallow']); foreach ($ips as $ip) { if (preg_match("/^{$ip}/", $_SERVER['REMOTE_ADDR'])) { $ok = true; break; } } if ($ok === false) { echo "Access dened by IP restrictions."; exit(0); } } // Continue setup, if needed if (DBNAME == '' && isset($_POST['submit']) && $_POST['submit'] == tr('Continue to Next Step')) { // Initialize $template = new template('admin/setup/first_time2'); require_once SITE_PATH . '/data/lib/sqlparser.php'; // Check database connection if (!mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname'], $_POST['dbport'])) { $template->add_message("Unable to connect to mySQL database using information supplied. Please double check the mySQL information, and try again.", 'error'); } if (!is_writeable(SITE_PATH . '/data/config.php')) { $template->add_message("Unable to write to file at /data/config.php. Please change file permissions appropriately, and reload the page.", 'error'); } if (!is_writeable(SITE_PATH . '/data/backups')) { $template->add_message("Unable to write to directory at /data/backups/. Please change directory permissions appropriately, and reload the page.", 'error'); } if (!is_writeable(SITE_PATH . '/data/log')) { $template->add_message("Unable to write to directory at /data/log/. Please change directory permissions appropriately, and reload the page.", 'error'); } if (!is_writeable(SITE_PATH . '/data/tpl_c')) { $template->add_message("Unable to write to directory at /data/tpl_c/. Please change directory permissions appropriately, and reload the page.", 'error'); } // Check for errors if ($template->has_errors == 1) { $template->route = 'admin/setup/first_time'; echo $template->parse(); exit(0); } // Define MeekroDB settings DB::$dbName = $_POST['dbname']; DB::$user = $_POST['dbuser']; DB::$password = $_POST['dbpass']; DB::$host = $_POST['dbhost']; DB::$port = $_POST['dbport']; // Parse sql $sql_lines = SqlParser::parse(file_get_contents(SITE_PATH . '/data/sql/install.sql')); foreach ($sql_lines as $line) { DB::query($line); } // Save config.php file $conf = "<?php\n"; $conf .= "define('DBNAME', '" . $_POST['dbname'] . "');\n"; $conf .= "define('DBUSER', '" . $_POST['dbuser'] . "');\n"; $conf .= "define('DBPASS', '" . $_POST['dbpass'] . "');\n"; $conf .= "define('DBHOST', '" . $_POST['dbhost'] . "');\n"; $conf .= "define('DBPORT', '" . $_POST['dbport'] . "');\n"; $conf .= "define('COOKIE_NAME', '" . generate_random_string(6) . "');\n"; $conf .= "define('ENCRYPT_PASS', '" . generate_random_string(32) . "');\n"; $conf .= "define('TESTNET', 0);\n"; $conf .= "?>\n"; // Save config file file_put_contents(SITE_PATH . '/data/config.php', $conf); // Parse template echo $template->parse(); exit(0); } elseif ($config['is_setup'] != '1' && isset($_POST['_setup_step']) && $_POST['_setup_step'] == '2') { // Initialize $template = new template('admin/setup/first_time3'); if (strlen($_POST['username']) < 4) { $template->add_message('Administrator username must be at least 4 characters in length.', 'error'); } // Create user $user = new user(); $user->create(1); // Update config vars update_config_var('site_name', $_POST['site_name']); update_config_var('company_name', $_POST['company_name']); // Check for errors if ($template->has_errors == 1) { $template->route = 'admin/setup/first_time2'; } else { // Login $auth = new auth(); $auth->login('admin', false); } echo $template->parse(); exit(0); } elseif ($config['is_setup'] != '1' && isset($_POST['_setup_step']) && $_POST['_setup_step'] == '3') { // Initialize $template = new template('admin/setup/first_time4'); // Update config vars update_config_var('btc_rpc_host', $_POST['btc_rpc_host']); update_config_var('btc_rpc_user', $_POST['btc_rpc_user']); update_config_var('btc_rpc_pass', $_POST['btc_rpc_pass']); update_config_var('btc_rpc_port', $_POST['btc_rpc_port']); // Test connection $client = new transaction(); if (!$client->get_info()) { $template->route = 'admin/setup/first_time3'; $template->add_message('Unable to connect to RPC using the provided settings. Please check the connection information, restart bitcoind, and try again. If you have just started bitcoind for the first time, you will need to wait a while for all blocks to download before continuing.', 'error'); $template->parse(); exit(0); } // Parse template echo $template->parse(); exit(0); // Complete setup, if needed } elseif ($config['is_setup'] != '1' && isset($_POST['_setup_step']) && $_POST['_setup_step'] == '4') { // Initialize $template = new template('admin/setup/first_time5'); // Update config vars update_config_var('is_setup', '1'); // Get exchange date $rate = get_coin_exchange_rate($config['currency']); if ($rate != 0) { update_config_var('exchange_rate', $rate); } // Add wallet $bip32 = new bip32(); $bip32->add_wallet(); // Display template if ($template->has_errors != 1) { //$template->add_message("Successfully completed first time setup."); } echo $template->parse(); exit(0); } // Check if setup if ($config['is_setup'] == 0) { $template = new template('admin/setup/first_time'); echo $template->parse(); exit(0); } // Check login $auth = new auth(); if ($userid = $auth->check_login($panel, $require_login)) { define('LOGIN', true); $GLOBALS['userid'] = $userid; } else { define('LOGIN', false); $GLOBALS['userid'] = 0; } // Check admin permission, if needed if ($panel == 'admin') { $group_id = DB::queryFirstField("SELECT group_id FROM users WHERE id = %d", $GLOBALS['userid']); if ($group_id != 1) { trigger_error("You do not have permission to access this area.", E_USER_ERROR); } } // Parse template $template = new template(); echo $template->parse(); // Exit exit(0); }
/** *get PHPlib variables for a song * * */ function dok_song_format($data, $pager_infos = '') { global $THEME_DATE, $THEME_SONG_LABEL; $label = dok_song_label_vars($data['label']); $ret = $label; $ret['SONG_NAME'] = $data['name']; $ret['SONG_ID'] = $data['id']; $ret['SONG_HITS'] = $data['hits']; $ret['SONG_LINK'] = $_SERVER['PHP_SELF'] . '?display=view_song&id=' . $data['id']; if (is_array($pager_infos)) { $ret['SONG_LINK'] .= '&pager_related=' . $pager_infos['related'] . '&pager_related_id=' . $pager_infos['related_id']; } $ret['SONG_ARTIST'] = dok_get_artists_string($data['id'], $data['ignore_artist']); $ret['SONG_LENGTH'] = dok_sec2str($data['length']); $ret['SONG_RELEASE'] = dok_year2str($data['release']); $ret['SONG_COMMENT'] = $data['comment']; $ret['SONG_DB_CREATION'] = date($THEME_DATE, $data['creation']); $ret['SONG_GENRE'] = dok_genre_name($data['genre']); if ($data['label'] > 0) { $t = new template(getcwd()); $t->set_var('song_label', $THEME_SONG_LABEL); $t->set_var($label); $ret['SONG_LABEL_LINE'] = $t->finish($t->parse('out', 'song_label')); } else { $ret['SONG_LABEL_LINE'] = ''; } //print_r($ret); return $ret; }