本文整理汇总了PHP中smarty类的典型用法代码示例。如果您正苦于以下问题:PHP smarty类的具体用法?PHP smarty怎么用?PHP smarty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了smarty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_teams
function get_teams()
{
global $db;
$tpl = new smarty();
if (@$_GET['ajax']) {
ob_end_clean();
}
$teams = array();
$result = $db->query('SELECT tname, tID, info FROM ' . DB_PRE . 'ecp_teams ORDER BY posi ASC');
while ($row = mysql_fetch_assoc($result)) {
$members = array();
$subresult = $db->query('SELECT `username`, `mID`, `userID`, `name`, `aufgabe`, `aktiv`, country FROM ' . DB_PRE . 'ecp_members LEFT JOIN ' . DB_PRE . 'ecp_user ON (ID = userID) WHERE teamID = ' . $row['tID'] . ' ORDER BY posi ASC');
while ($subrow = mysql_fetch_assoc($subresult)) {
$subrow['aktiv'] ? $subrow['aktiv'] = '<span class="member_aktiv" style="cursor:pointer" onclick="member_switch_status(' . $row['tID'] . ', ' . $subrow['userID'] . ');">' . AKTIV . '</span>' : ($subrow['aktiv'] = '<span style="cursor:pointer" class="member_inaktiv" onclick="member_switch_status(' . $row['tID'] . ', ' . $subrow['userID'] . ');">' . INAKTIV . '</span>');
if ($subrow['name'] != '') {
$subrow['username'] = $subrow['name'];
}
$members[] = $subrow;
}
$row['members'] = $members;
$teams[] = $row;
}
$tpl->assign('teams', $teams);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/teams_overview.html');
$content = ob_get_contents();
ob_end_clean();
if (@$_GET['ajax']) {
echo html_ajax_convert($content);
die;
}
main_content(OVERVIEW, '<div id="teams_overview">' . $content . '</div>', '', 1);
}
示例2: get_links
function get_links()
{
global $db;
if (!isset($_SESSION['rights']['admin']['links']) and !isset($_SESSION['rights']['superadmin'])) {
echo NO_ADMIN_RIGHTS;
} else {
$tpl = new smarty();
if (@$_GET['ajax']) {
ob_end_clean();
}
$links = array();
$result = $db->query('SELECT `linkID`, `name`, `url`, `bannerurl`, `beschreibung`, `hits` FROM ' . DB_PRE . 'ecp_links ORDER BY name ASC');
while ($row = mysql_fetch_assoc($result)) {
$links[] = $row;
}
$tpl->assign('links', $links);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/links_overview.html');
$content = ob_get_contents();
ob_end_clean();
if (@$_GET['ajax']) {
echo html_ajax_convert($content);
die;
}
main_content(OVERVIEW, '<div id="links_overview">' . $content . '</div>', '', 1);
}
}
示例3: shoutbox
function shoutbox()
{
global $db, $countries;
$tpl = new smarty();
$anzahl = $db->result(DB_PRE . 'ecp_comments', 'COUNT(comID)', 'bereich="shoutbox"');
if ($anzahl) {
$limits = get_sql_limit($anzahl, LIMIT_SHOUTBOX);
$shouts = array();
$db->query('SELECT comID, country, username, userID, author, datum, beitrag FROM ' . DB_PRE . 'ecp_comments LEFT JOIN ' . DB_PRE . 'ecp_user ON userID = ID WHERE bereich="shoutbox" ORDER BY datum DESC LIMIT ' . $limits[1] . ',' . LIMIT_SHOUTBOX);
$anzahl -= $limits[1];
while ($row = $db->fetch_assoc()) {
$row['nr'] = format_nr($anzahl--, 0);
$row['countryname'] = @$countries[$row['country']];
$row['datum'] = date(LONG_DATE, $row['datum']);
$shouts[] = $row;
}
$tpl->assign('shoutbox', $shouts);
if ($limits[0] > 1) {
$tpl->assign('seiten', makepagelink_ajax('?section=shoutbox', 'return load_shout_page({nr});', @$_GET['page'], $limits[0]));
}
ob_start();
$tpl->display(DESIGN . '/tpl/shoutbox/shoutbox.html');
$content = ob_get_contents();
ob_end_clean();
main_content(SHOUTBOX, '<div id="shout_overview">' . $content . '</div>', '', 1);
} else {
table(INFO, NO_ENTRIES);
}
}
示例4: get_server
function get_server()
{
global $db;
if (!isset($_SESSION['rights']['admin']['server']) and !isset($_SESSION['rights']['superadmin'])) {
echo NO_ADMIN_RIGHTS;
} else {
$tpl = new smarty();
if (@$_GET['ajax']) {
ob_end_clean();
}
$server = array();
$result = $db->query('SELECT `serverID`, `gamename`, response, `gametype`, `aktiv`, `displaymenu`, `ip`, `port`, `queryport`, `stat` FROM ' . DB_PRE . 'ecp_server ORDER BY posi ASC');
while ($row = mysql_fetch_assoc($result)) {
$data = unserialize($row['response']);
$row['path'] = 'images/server/maps/' . $row['gametype'] . '/' . $data['s']['game'] . '/' . $data['s']['map'] . '.jpg';
$server[] = $row;
}
$tpl->assign('server', $server);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/server_overview.html');
$content = ob_get_contents();
ob_end_clean();
if (@$_GET['ajax']) {
echo html_ajax_convert($content);
die;
}
main_content(OVERVIEW, '<div id="server_overview">' . $content . '</div>', '', 1);
}
}
示例5: admin_texte
function admin_texte()
{
global $db, $countries;
if (isset($_POST['submit'])) {
foreach ($_POST as $key => $value) {
if (strpos($key, '_h_')) {
$lang = substr($key, 0, strpos($key, '_'));
$name = substr($key, strpos($key, '_') + 3);
$sql = sprintf('UPDATE ' . DB_PRE . 'ecp_texte SET content = \'%s\', content2 = \'%s\' WHERE name= \'%s\' AND lang = \'%s\';', strsave($_POST[$lang . '_' . $name]), strsave($value), strsave($name), strsave($lang));
$db->query($sql);
}
}
header('Location: ?section=admin&site=texte');
} else {
$tpl = new smarty();
$lang = get_languages();
$db->query('SELECT * FROM ' . DB_PRE . 'ecp_texte ORDER BY lang ASC');
while ($row = $db->fetch_assoc()) {
foreach ($lang as $key => $value) {
if ($value['lang'] == $row['lang']) {
$lang[$key]['data'][$row['name']] = htmlspecialchars($row['content']);
$lang[$key]['headline'][$row['name']] = htmlspecialchars($row['content2']);
}
}
}
$tpl->assign('lang', $lang);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/texte.html');
$content = ob_get_contents();
ob_end_clean();
main_content(TEXTE, $content, '', 1);
}
}
示例6: admin_joinus
function admin_joinus()
{
global $db, $countries;
$tpl = new smarty();
$db->query('SELECT tname, `joinID`, `name`, b.username, b.email, b.icq, b.msn, `age`, b.country, `teamID`, `comment`, `IP`, `datum`, `closed`, `closedby`, a.username as closedby_username FROM ' . DB_PRE . 'ecp_joinus as b LEFT JOIN ' . DB_PRE . 'ecp_teams ON (teamID = tID) LEFT JOIN ' . DB_PRE . 'ecp_user as a ON (ID=closedby) ORDER BY closed ASC, datum ASC');
$joinus = array();
while ($row = $db->fetch_assoc()) {
$row['datum'] = date(SHORT_DATE, $row['datum']);
if ($row['joinID'] == (int) @$_GET['id']) {
$spe = $row;
}
$joinus[] = $row;
}
if (@$spe) {
ob_start();
$tpl1 = new Smarty();
foreach ($spe as $key => $value) {
$tpl1->assign($key, $value);
}
$tpl1->assign('countryname', $countries[$spe['country']]);
$tpl1->assign('id', $row['joinID']);
$tpl1->display(DESIGN . '/tpl/admin/joinus_view.html');
$tpl->assign('details', ob_get_contents());
ob_end_clean();
}
$tpl->assign('joinus', $joinus);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/joinus.html');
$content = ob_get_contents();
ob_end_clean();
main_content(JOINUS, $content, '', 1);
}
示例7: smarty
public function smarty()
{
$smarty = new smarty();
//实例化smarty
$smarty->settemplatedir(BASE_PATH . '/views/default/');
//设置模板文件存放目录
$smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/');
//设置生成文件存放目录
$smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/');
//设置缓存文件存放目录
$this->smarty = $smarty;
return $smarty;
}
示例8: get_matchtypes
function get_matchtypes()
{
global $db;
$db->query('SELECT matchtypeID, matchtypename, fightus FROM ' . DB_PRE . 'ecp_wars_matchtype ORDER BY matchtypename');
$match = array();
while ($row = $db->fetch_assoc()) {
$match[] = $row;
}
$tpl = new smarty();
$tpl->assign('matchtype', $match);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/matchtype_overview.html');
$content = ob_get_contents();
ob_end_clean();
return $content;
}
示例9: admin_settings
function admin_settings()
{
global $db, $countries;
if (isset($_POST['submit'])) {
unset($_POST['submit']);
$_POST['SITE_URL'] = strrpos($_POST['SITE_URL'], '/') !== strlen($_POST['SITE_URL']) - 1 ? check_url($_POST['SITE_URL'] . '/') : check_url($_POST['SITE_URL']);
$sql = 'UPDATE ' . DB_PRE . 'ecp_settings SET ';
foreach ($_POST as $key => $value) {
$sql .= $key . ' = "' . strsave($value) . '", ';
}
$sql = substr($sql, 0, strlen($sql) - 2);
if ($db->query($sql)) {
header('Location: ?section=admin&site=settings');
}
} else {
$dir = scan_dir('templates', true);
$designs = '';
foreach ($dir as $value) {
if (is_dir('templates/' . $value)) {
$designs .= '<option ' . ($value == DESIGN ? 'selected="selected"' : '') . ' value="' . $value . '">' . $value . '</option>';
}
}
$tpl = new smarty();
$tpl->assign('designs', $designs);
$tpl->assign('langs', get_languages());
$dir = scan_dir('module', true);
$start = '';
foreach ($dir as $value) {
if (is_dir('module/' . $value)) {
$start .= '<option ' . ('modul|' . $value == STARTSEITE ? 'selected="selected"' : '') . ' value="modul|' . $value . '">' . $value . '</option>';
}
}
$start .= '<option value="">-----' . OWN_SITES . '----</option>';
$db->query('SELECT headline, cmsID FROM ' . DB_PRE . 'ecp_cms ORDER BY headline ASC');
while ($row = $db->fetch_assoc()) {
$title = json_decode($row['headline'], true);
isset($title[LANGUAGE]) ? $title = $title[LANGUAGE] : ($title = $title[DEFAULT_LANG]);
$start .= '<option ' . ('cms|' . $row['cmsID'] == STARTSEITE ? 'selected="selected"' : '') . ' value="cms|' . $row['cmsID'] . '">' . $title . '</option>';
}
$tpl->assign('startseite', $start);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/settings.html');
$content = ob_get_contents();
ob_end_clean();
main_content(SETTINGS, $content, '', 1);
}
}
示例10: admin_fightus
function admin_fightus()
{
global $db;
$tpl = new smarty();
$db->query('SELECT tname, gamename, icon, matchtypename, a.homepage, `fightusID`, a.clanname, `wardatum`, `bearbeitet`, `vonID`, username FROM ' . DB_PRE . 'ecp_fightus as a LEFT JOIN ' . DB_PRE . 'ecp_teams ON (teamID = tID) LEFT JOIN ' . DB_PRE . 'ecp_wars_games ON (gID=gameID) LEFT JOIN ' . DB_PRE . 'ecp_wars_matchtype ON (mID= matchtypeID) LEFT JOIN ' . DB_PRE . 'ecp_user ON (ID=vonID) ORDER BY bearbeitet ASC, wardatum ASC');
$fightus = array();
while ($row = $db->fetch_assoc()) {
$row['wardatum'] = date(SHORT_DATE, $row['wardatum']);
$fightus[] = $row;
}
$tpl->assign('fightus', $fightus);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/fightus.html');
$content = ob_get_contents();
ob_end_clean();
main_content(FIGHTUS, $content, '', 1);
}
示例11: clankasse
function clankasse()
{
global $db;
$tpl = new smarty();
$konto = $db->fetch_assoc('SELECT * FROM ' . DB_PRE . 'ecp_clankasse');
$konto['kontostand'] = number_format($konto['kontostand'], 2, ',', '');
foreach ($konto as $key => $value) {
$tpl->assign($key, $value);
}
ob_start();
$anzahl = $db->result(DB_PRE . 'ecp_clankasse_transaktion', 'COUNT(ID)', '1');
$limits = get_sql_limit($anzahl, LIMIT_CLANKASSE_TRANS);
$db->query('SELECT a.*, b.username, c.username as buchusername FROM ' . DB_PRE . 'ecp_clankasse_transaktion as a LEFT JOIN ' . DB_PRE . 'ecp_user as b ON b.ID = vonuser LEFT JOIN ' . DB_PRE . 'ecp_user as c ON c.ID = userID ORDER BY datum DESC LIMIT ' . $limits[1] . ',' . LIMIT_CLANKASSE_TRANS);
$buchung = array();
while ($row = $db->fetch_assoc()) {
$row['datum'] = date(LONG_DATE, $row['datum']);
if ($row['vonuser']) {
$row['verwendung'] .= ' ' . FROM . ' ' . $row['username'];
}
$row['geld'] = number_format($row['geld'], 2, ',', '.');
$buchung[] = $row;
}
if ($limits[0] > 1) {
$tpl->assign('seiten', makepagelink_ajax('?section=clankasse', 'return load_clankasse_page({nr});', @$_GET['page'], $limits[0]));
}
$tpl->assign('buchung', $buchung);
$tpl->display(DESIGN . '/tpl/clankasse/kontodaten.html');
$content = ob_get_contents();
ob_end_clean();
main_content(FINANCES, $content, '', 1);
if (date('m') > 3) {
clankasse_buchungen(date('m') - 2, date('Y'));
} elseif (date('m') == 2) {
clankasse_buchungen(12, date('Y') - 1);
} elseif (date('m') == 1) {
clankasse_buchungen(11, date('Y') - 1);
} else {
clankasse_buchungen(1, date('Y'));
}
}
示例12: genHtml
/**
* @param $template
* @param $ary
* @return mixed
*/
public static function genHtml($template, $ary)
{
$smarty = new smarty();
$smarty->settemplatedir(BASE_PATH . '/resources/email/');
$smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/');
$smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/');
// add config
$smarty->assign('config', Config::getPublicConfig());
$smarty->assign('analyticsCode', DbConfig::get('analytics-code'));
foreach ($ary as $key => $value) {
$smarty->assign($key, $value);
}
return $smarty->fetch($template);
}
示例13: admin_smilies_add
function admin_smilies_add()
{
global $db;
if (!isset($_SESSION['rights']['admin']['smilies']['add']) and !isset($_SESSION['rights']['superadmin'])) {
echo NO_ADMIN_RIGHTS;
} else {
if (@$_FILES['smilie']['tmp_name'] == '') {
table(ERROR, NOT_NEED_ALL_INPUTS);
$tpl = new smarty();
ob_start();
$tpl->display(DESIGN . '/tpl/admin/smilies.html');
$content = ob_get_contents();
ob_end_clean();
main_content(SMILIES, $content, '', 1);
get_smilies();
} elseif ($_FILES['smilie']['type'] != 'image/jpg' and $_FILES['smilie']['type'] != 'image/gif' and $_FILES['smilie']['type'] != 'image/png' and $_FILES['smilie']['type'] != 'image/jpeg') {
table(ERROR, WRONG_FILE_TYPE);
$tpl = new smarty();
ob_start();
$tpl->display(DESIGN . '/tpl/admin/smilies.html');
$content = ob_get_contents();
ob_end_clean();
main_content(SMILIES, $content, '', 1);
get_smilies();
} else {
ajax_convert_array($_POST);
ajax_convert_array($_FILES);
if (move_uploaded_file($_FILES['smilie']['tmp_name'], 'images/smilies/' . str_replace(' ', '_', $_FILES['smilie']['name']))) {
umask(0);
chmod('images/smilies/' . str_replace(' ', '_', $_FILES['smilie']['name']), CHMOD);
$sql = sprintf('INSERT INTO ' . DB_PRE . 'ecp_smilies (`bedeutung`, `filename`)
VALUES (\'%s\', \'%s\')', strsave($_POST['bedeutung']), strsave(str_replace(' ', '_', $_FILES['smilie']['name'])));
if ($db->query($sql)) {
header1('?section=admin&site=smilies');
}
}
}
}
}
示例14: awards_view
function awards_view($id)
{
global $db;
$row = $db->fetch_assoc('SELECT `awardID`, `eventname`, `eventdatum`, `url`, `platz`, `teamID`, `gID`, `preis`, spieler, bericht, tname, icon, gamename FROM `' . DB_PRE . 'ecp_awards` LEFT JOIN ' . DB_PRE . 'ecp_teams ON tID = teamID LEFT JOIN ' . DB_PRE . 'ecp_wars_games ON gameID = gID WHERE awardID = ' . $id);
if (@$row['eventname']) {
$tpl = new smarty();
$row['eventdatum'] = date('d.m.Y', $row['eventdatum']);
$report = json_decode($row['bericht'], true);
$spieler = explode(',', $row['spieler']);
$row['preis'] = htmlentities($row['preis'], ENT_QUOTES, "UTF-8");
$row['eventname'] = htmlentities($row['eventname'], ENT_QUOTES, "UTF-8");
foreach ($spieler as $value) {
if ((int) $value) {
@($ids .= ' OR ID = ' . $value);
}
}
$db->query('SELECT username, ID FROM ' . DB_PRE . 'ecp_user WHERE ID = 0' . @$ids);
while ($sub = $db->fetch_assoc()) {
@($players .= ', <a href="?section=user&id=' . $sub['ID'] . '" >' . $sub['username'] . '</a>');
}
$tpl->assign('players', substr(@$players, 2));
if (isset($report[LANGUAGE])) {
$row['bericht'] = $report[LANGUAGE];
} else {
$row['bericht'] = @$report['de'];
}
foreach ($row as $key => $value) {
$tpl->assign($key, $value);
}
ob_start();
$tpl->display(DESIGN . '/tpl/awards/view.html');
$content = ob_get_contents();
ob_end_clean();
main_content(AWARDS, $content, '', 1);
} else {
table(ERROR, NO_ENTRIES_ID);
}
}
示例15: lotto_winlist
function lotto_winlist($id)
{
global $db, $countries;
$runde = $db->fetch_assoc('SELECT `anfang`, `ende`, `rundenjackpot`, `auszahlung`, a.zahl1, a.zahl2, a.zahl3, a.zahl4, `4er`, `3er`, `2er`, `geld4er`, `geld3er`, `geld2er`, COUNT(scheinID) as scheine FROM ' . DB_PRE . 'ecp_lotto_runden as a LEFT JOIN ' . DB_PRE . 'ecp_lotto_scheine as b ON (a.rundenID = b.rundenID) WHERE a.rundenID = ' . $id . ' GROUP BY a.rundenID');
if (isset($runde['rundenjackpot'])) {
$tpl = new smarty();
$runde['anfang'] = date(LONG_DATE, $runde['anfang']);
$runde['ende'] = date(LONG_DATE, $runde['ende']);
$runde['winner'] = format_nr($runde['4er'] + $runde['3er'] + $runde['2er']);
$runde['geld4eruser'] = format_nr($runde['geld4er'] / ($runde['4er'] == 0 ? 1 : $runde['4er']), 2);
$runde['geld3eruser'] = format_nr($runde['geld3er'] / ($runde['3er'] == 0 ? 1 : $runde['3er']), 2);
$runde['geld2eruser'] = format_nr($runde['geld2er'] / ($runde['2er'] == 0 ? 1 : $runde['2er']), 2);
$runde['quote'] = format_nr($runde['winner'] / ($runde['scheine'] == 0 ? 1 : $runde['scheine']) * 100, 1);
foreach ($runde as $key => $value) {
if ($key == 'rundenjackpot' or $key == 'auszahlung' or $key == 'geld4er' or $key == 'geld3er' or $key == 'geld2er') {
$value = format_nr($value, 2);
}
$tpl->assign($key, $value);
}
if ($runde['winner']) {
$db->query('SELECT gewinn, art, COUNT(scheinID) as scheine, username, a.userID, country, uID as online FROM ' . DB_PRE . 'ecp_lotto_gewinner as a LEFT JOIN ' . DB_PRE . 'ecp_user ON (a.userID = ID) LEFT JOIN ' . DB_PRE . 'ecp_online ON (uID = a.userID) LEFT JOIN ' . DB_PRE . 'ecp_lotto_scheine as b ON (rundenID = ' . $id . ' AND b.userID = a.userID) WHERE a.rID = ' . $id . ' GROUP BY gewinnID ORDER BY art DESC, username ASC');
$gewinner = array();
while ($row = $db->fetch_assoc()) {
$row['gewinn'] = format_nr($row['gewinn'], 2);
$row['countryname'] = $countries[$row['country']];
$gewinner[] = $row;
}
$tpl->assign('gewinner', $gewinner);
}
ob_start();
$tpl->display(DESIGN . '/tpl/lotto/winlist.html');
$content = ob_get_contents();
ob_end_clean();
main_content(LOTTO_ROUND, $content, '', 1);
} else {
table(ERROR, NO_ENTRIES_ID);
}
}