Exemple #1
0
 /**
  * ページを表示する。
  *
  * @param	array(string => string)	$value	スキンに渡す値。bodyとtitleは必須。
  */
 function render($value)
 {
     $command = array();
     foreach (Command::getCommands() as $c) {
         $html = $c->getbody();
         if ($html != '') {
             $command[substr(get_class($c), 8)] = $html;
         }
     }
     $plugin = array();
     foreach (Plugin::getPlugins() as $c) {
         $html = $c->getbody();
         if ($html != '') {
             $plugin[substr(get_class($c), 7)] = $html;
         }
     }
     $this->smarty->assign('command', $command);
     $this->smarty->assign('plugin', $plugin);
     $this->smarty->assign('option', $this->option);
     $this->smarty->assign('headeroption', $this->headeroption);
     $this->smarty->assign('theme', $this->theme);
     $this->smarty->assign($value);
     header('Content-Type: text/html; charset=UTF-8');
     $this->smarty->assign('runningtime', sprintf('%.3f', mtime() - STARTTIME));
     $this->smarty->display(SKINFILE);
 }
Exemple #2
0
**
*/
error_reporting(E_ALL);
if (!$included_from_index) {
    header("Location: {$SITE_URL}");
    exit;
}
require_once 'mysmarty.php';
require_once 'system/db.sqlite.php';
define('PAGE_NAME', 'page-item');
define('CACHE_TIME', 3600);
$sane_item_title = $HandlerMatches[1];
$unique_page_name = PAGE_NAME . "{$sane_item_title}";
$smarty = new MySmarty();
if ($smarty->is_cached('index.tpl.html', $unique_page_name)) {
    $smarty->display('index.tpl.html', $unique_page_name);
    exit;
}
$db = new SQLite($SQLITE_DB_PATH);
$comment_error = false;
$add_comment = 0;
if (isset($_POST['sane_title'])) {
    if (!preg_match("#^[a-z0-9-]+\$#", $_POST['sane_title']) || $_POST['sane_title'] != $sane_item_title) {
        # Title must be well formatted and must match the requested URL
        $comment_error = "The item title was invalid. Is there some hackery going on?!";
        $smarty->assign('comment_error', $comment_error);
        $smarty->assign('existing_comment', isset($_POST['comment']) ? $_POST['comment'] : '');
    } else {
        if (!isset($_POST['comment']) || empty($_POST['comment'])) {
            $comment_error = "No comment was typed. Please type what you wished and submit it again!";
            $smarty->assign('comment_error', $comment_error);
<?php

require_once '../includes/config.inc';
require_once 'user.inc';
require_once 'factory.inc';
require_once 'view.inc';
require_once 'access.inc';
require_once 'transaction.inc';
require_once 'toomanyfailedloginexception.inc';
$smarty = new MySmarty($SMARTY_CONFIG);
if (!empty($_POST)) {
    if ($_POST['new_password'] != $_POST['verify_new_password']) {
        $smarty->assign('err_message', 'The two passwords must match');
        $smarty->display('reset_password.tpl');
    }
    if (!preg_match("/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9\\s]).{8,})/", $_POST['new_password'])) {
        $smarty->assign('err_message', 'Password Invalid! Must be at least 8 characters and have one lowercase, one uppercase, one number, and one special character.');
        $smarty->display('reset_password.tpl');
    }
    try {
        $username = $_GET['username'];
        $pid = $_GET['pid'];
        $result = User::checkAuthentication($username, $pid, true);
        if ($result) {
            $transaction = new Transaction(new MySqlDB());
            $transaction->start();
            $user = User::getUserByUserName($username);
            $user->setPassword($_POST['new_password'], false);
            $transaction->commit();
            $access = new Access();
            if ($access->authenticate($username, $_POST['new_password'])) {
            $category->setName($categoryName);
            $transaction->commit();
        } elseif ($action === "remove") {
            try {
                $key = htmlentities($_POST['key']);
                $transaction = new Transaction(new MySqlDB());
                $transaction->start();
                $categoryItem = Factory::getView(new CategoryKey($key));
                $categoryItem->setActive(0);
                $transaction->commit();
            } catch (Exception $e) {
                print_r($e);
            }
        }
    }
    $userCategories = Category::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
    $allCategories = Category::getOptions(array("ACTIVE" => 1));
    $smarty->assign('allCategories', $allCategories);
    $smarty->assign('userCategories', $userCategories);
    if ($fullPage) {
        $smarty->assign('user', $user);
        $smarty->assign('left_menu', true);
        $smarty->display('category.tpl');
    } else {
        echo $smarty->fetch('category_list.tpl');
    }
} catch (AccessDeniedException $e) {
    trigger_error('Access Denied');
} catch (Exception $e) {
    trigger_error('An error has occurred, please try again in a few minutes');
}
<?php

require_once '../includes/config.inc';
require_once '../includes/access.inc';
$requestedUrl = isset($_REQUEST['ref']) ? base64_decode(htmlentities($_REQUEST['ref'])) : $BASE_URL . '/dashboard.php';
$submitted = isset($_REQUEST['submitted']);
$username = isset($_REQUEST['username']) ? htmlentities($_REQUEST['username']) : false;
$password = isset($_REQUEST['password']) ? htmlentities($_REQUEST['password']) : false;
$smarty = new MySmarty($SMARTY_CONFIG);
if ($submitted) {
    try {
        $access = new Access();
        if ($access->authenticate($username, $password)) {
            header("Location: " . $requestedUrl);
            exit;
        } else {
            $smarty->assign('errorMessage', 'Username or Password is incorrect. Please try logging in again.');
        }
    } catch (AccessDeniedException $e) {
        header('HTTP/1.1 401 Access Denied');
        echo "AccessDeniedException: " . $e->getMessage();
    } catch (Exception $e) {
        header('HTTP/1.1 500 Internal Server Error');
        echo "Exception: " . $e->getMessage();
    }
}
$smarty->assign('login', 'login');
$smarty->display('login.tpl');
Exemple #6
0
<?php

/**
* ondesign.pl
*
* @package	ondesign.pl home page
* @author	Radek Lewandowski <*****@*****.**>
*/
require_once 'constants.php';
require_once 'config.php';
require_once 'MySmarty.php';
$smarty = new MySmarty();
$smarty->display('construction.tpl');
//$smarty->display('index.tpl');
<?php

require_once '../includes/config.inc';
require_once 'access.inc';
require_once 'accessdeniedexception.inc';
$smarty = new MySmarty($SMARTY_CONFIG);
try {
    $access = new Access();
    $access->authenticate(null, null, false);
    $user = $access->getUser();
    $smarty->assign('user', $user);
} catch (AccessDeniedException $e) {
    // Don't need to do anything, This just means user is not logged in.
}
$smarty->assign('left_menu', true);
$smarty->assign('about', 'about');
$smarty->display('about.tpl');
Exemple #8
0
<?php

/**
 * smarty循环数组
 */
require '../Smarty3/libs/Smarty.class.php';
require './MySmarty.php';
$smarty = new MySmarty();
$smarty->caching = true;
$smarty->cache_lifetime = 3600;
$liubei = array('name' => '刘备', 'age' => '28', 'wespon' => '双剑');
if (!$smarty->isCached('02.html')) {
    echo '11111111';
}
$smarty->assign('liubei', $liubei);
$zf = array('name' => '张飞', 'age' => '28', 'wespon' => '丈八蛇矛');
$smarty->assign('zf', $zf);
class human
{
    public $name = 'macao';
    public $age = 29;
    public function say()
    {
        echo 'hello!';
    }
}
$macao = new human();
$smarty->assign('man', $macao);
$smarty->display();
        if (sizeof($user) > 1) {
            // This is an error where we have more than 1 user with the same email, should never happen
            $err_message = 'Internal Error occurred, please email administrator for further assistance.';
        } else {
            if (sizeof($user) === 0) {
                // This is when we can't find the user
                $err_message = 'User with username: '******' was not found';
            } else {
                $transaction = new Transaction(new MySqlDB());
                $transaction->start();
                $new_password_hash = $user->generateNewPassword();
                $user->setPassword($new_password_hash, true);
                $transaction->commit();
                $to = $user->getUsername();
                $subject = '.:iBudget:. Please reset your password';
                $message = "Hey, we heard you forgot your iBudget password. \r\n\r\nUse the following link within the next 24 hours to reset your password:\r\n\r\n<a href={$BASE_URL}/reset_password.php?username={$to}&pid={$new_password_hash}>click here to reset your password.</a>\r\n\r\nThanks,\r\nThe iBudget Team";
                // echo $message; exit;
                mail($to, $subject, $message);
            }
        }
    } catch (Exception $e) {
        if ($transaction && !$transaction->isComplete()) {
            $transaction->rollBack();
        }
        $err_message = 'Internal Error occurred, please email administrator for further assistance.';
    }
}
$smarty = new MySmarty($SMARTY_CONFIG);
$smarty->assign('err_message', $err_message);
$smarty->display('forgot_password.tpl');
<?php

require_once '../includes/config.inc';
require_once 'user.inc';
require_once 'access.inc';
require_once 'accessdeniedexception.inc';
try {
    $access = new Access();
    $access->authenticate();
    $user = $access->getUser();
    $activities_amount = $user->getActivitiesAmount();
    //print_r($activities_amount); exit;
    $smarty = new MySmarty($SMARTY_CONFIG);
    $smarty->assign('debit', $activities_amount['debit']);
    $smarty->assign('credit', $activities_amount['credit']);
    $smarty->assign('user', $user);
    $smarty->assign('dashboard', 'dashboard');
    $smarty->assign('left_menu', true);
    $smarty->display('dashboard.tpl');
} catch (AccessDeniedException $e) {
    trigger_error('Access Denied');
} catch (Exception $e) {
    trigger_error('An error has occurred, please try again in a few minutes');
}
        $transaction = new Transaction(new MySqlDB());
        $transaction->start();
        if (!$user) {
            // User is not logged in, so trying to find user by his provided email
            $temp = User::getUserByUserName($email);
            if ($temp !== null) {
                $user = $temp;
            }
        }
        $contact = Factory::createView(new ContactKey());
        if ($user) {
            $contact->setUser($user);
        }
        $contact->setName($name);
        $contact->setEmail($email);
        $contact->setContent($message);
        $contact->setDateSubmitted(new Date());
        $transaction->commit();
        $smarty->assign('message', 'Message sent to iBudget successfully.');
    } catch (Exception $e) {
        if ($transaction && !$transaction->isComplete()) {
            $transaction->rollBack();
        }
        $smarty->assign('message', 'An error had occurred, please try again in a few minutes.');
        // echo "<PRE>A error had occured: " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n</PRE>";
    }
}
$smarty->assign('left_menu', true);
$smarty->assign('contact', 'contact');
$smarty->display('contact.tpl');
Exemple #12
0
        header('Location: ' . WEB_JACPHP . 'index.php');
        exit;
}
$DB = new DB1($DBc);
$DB->OpenConnection();
//==================================================================
//Fetch car dara ----------------------------
$fetchParams = array('table' => 'records', 'select_items' => array($get, 'year', 'maker', 'model', 'cartype', 'img'), 'order_by' => $get . ' ASC', 'limit' => '0,10');
$fetch = $DB->FetchRow($fetchParams);
//Build array of Cars --------------------------
$A = array();
foreach ($fetch as $row) {
    $choice = $row[$get];
    $year = $row['year'];
    $model = $row['model'];
    $maker = $row['maker'];
    $cartype = $row['cartype'];
    if (empty($row['img'])) {
        $img = WEB_CONTENT . 'images/missing_car.png';
    } else {
        $img = $row['img'];
    }
    $A[$choice . $cartype . $make . $model . $year] = [$get => $choice, 'year' => $year, 'model' => $model, 'maker' => $maker, 'cartype' => $cartype, 'img' => $img];
}
//SERVER::dump($A);
$smarty = new MySmarty();
$smarty->assign('header', 'head_start.tpl');
$smarty->assign('question', $question);
$smarty->assign('results', $A);
$smarty->display('preset.tpl');
Exemple #13
0
<?php

require_once __DIR__ . '/include/globals.php';
require_once SERVER_CLASS;
//Paste to unlock
require_once DB1_CLASS;
require_once MYSMARTY_CLASS;
if (!isset($_POST['submit'])) {
    $field = 'annualfuel';
} elseif ($_POST['layout'] == 'annual') {
    $field = 'annualfuel';
} elseif ($_POST['layout'] == 'emmit') {
    $field = 'emission';
} elseif ($_POST['layout'] == 'high') {
    $field = 'hwylpkw';
} elseif ($_POST['layout'] == 'city') {
    $field = 'citylpkw';
}
$smarty = new MySmarty();
$smarty->assign('field', $field);
$smarty->display('tree.tpl');
Exemple #14
0
<?php

/**
 * 多重缓存页面缓存
 */
require '../Smarty3/libs/Smarty.class.php';
require './MySmarty.php';
$smarty = new MySmarty();
$smarty->caching = Smarty::CACHING_LIFETIME_CURRENT;
$smarty->cache_lifetime = 3600;
$gid = isset($_GET['gid']) ? $_GET['gid'] + 0 : 0;
if (!$smarty->isCached('03.html', $gid)) {
    $conn = mysql_connect('127.0.0.1', 'root', '752992807080');
    mysql_query('use bool', $conn);
    mysql_query('set names utf8');
    $sql = "SELECT goods_id,goods_name,shop_price FROM goods WHERE goods_id={$gid}";
    $result = mysql_query($sql, $conn);
    $rs = mysql_fetch_assoc($result);
    $smarty->assign('goods', $rs);
    echo '3333';
}
$smarty->display('03.html', $gid);
Exemple #15
0
<?php

/**
 * Created by PhpStorm.
 * User: Kate
 * Date: 03.02.2016
 * Time: 19:26
 */
//Подключаем дочерний класс шаблонизатора Смарти.
require 'smarty_config.php';
//До создания объекта, установим временную зону, чтобы Варнинг не появлялся в Индекс пхп при подключении шаблона
date_default_timezone_set('UTC');
//Создаем объект из Майсмарти (дочернего, расширенного нами, класса Смарти).
$smarty = new MySmarty();
//Мы в нашем объекте создали 2 переменные тайтл со значением... и нейм со значением...
//По синтаксису метода класса смарти Ассигн, в этих кавычках - первый параметр здесь обозначает имя переменной в шаблоне - в файле индекс.тпл
//А второй параметр обозначает то, на что мы хотим поменять значение переменной
$smarty->assign('title', 'Пизда');
$smarty->assign('name', 'Вася');
//Пост - это ассоциированный массив ключ имя а значение - содержание формы.
if (isset($_POST['imya']) && !empty($_POST['imya'])) {
    //Если да, то мы присваиваем переменной Форм (здесь же и создали) в шаблоне значение содержания Пост, по ключу имя.
    $smarty->assign('form', $_POST['imya']);
}
$users = array(array('name' => 'Эдуард', 'surname' => 'Хуев'), array('name' => 'Пэдро', 'surname' => 'Нехуяев'));
$smarty->assign('users', $users);
$read = file_get_contents('bla.txt');
$smarty->assign('text', $read);
//Выводим (рендерим наш шаблон) на экран нашу страницу.
$smarty->display('index.tpl');
Exemple #16
0
error_reporting(E_ERROR | E_PARSE);
//Easy Code No warings/notices errors
require_once __DIR__ . '/include/globals.php';
require_once INCLUDES . 'TransTranslate.func.php';
require_once INCLUDES . 'FuelTranslate.func.php';
require_once SERVER_CLASS;
//Paste to unlock
require_once DB1_CLASS;
require_once MYSMARTY_CLASS;
if (!isset($_GET['cartype']) || !isset($_GET['maker']) || !isset($_GET['model']) || !isset($_GET['year'])) {
    header('Location: ' . WEB_JACPHP . 'index.php');
    exit;
}
$DB = new DB1($DBc);
$DB->OpenConnection();
//accociative select all
$fetchParams = array('table' => 'records', 'select_items' => ['year', 'maker', 'model', 'cartype', 'engine', 'cylinders', 'transmission', 'fueltype', 'citylpkw', 'hwylpkw', 'annualfuel', 'emission', 'img'], 'where_items' => ['cartype' => filter_input(INPUT_GET, 'cartype'), 'maker' => filter_input(INPUT_GET, 'maker'), 'model' => filter_input(INPUT_GET, 'model'), 'year' => filter_input(INPUT_GET, 'year')]);
$result = $DB->FetchRow($fetchParams);
foreach ($result as $key => $item) {
    $result[$key]['transmission'] = TransTranslate($item['transmission']);
    $result[$key]['fueltype'] = FuelTranslate($item['fueltype']);
    if (empty($result[$key]['img'])) {
        $result[$key]['img'] = WEB_CONTENT . 'images/missing_car.png';
    }
}
$smarty = new MySmarty();
//$smarty->assign('param', '?cartype='.$cartype.'&maker='.$maker.'&model='.$model.'&year='.$year);
$smarty->assign('res', $result);
$smarty->display('result.tpl');
<?php

require_once '../includes/config.inc';
session_start();
session_destroy();
$smarty = new MySmarty($SMARTY_CONFIG);
//$smarty->assign('left_menu', true);
$smarty->display('logout.tpl');
            $amountCol = isset($_REQUEST['amount']) ? htmlentities($_REQUEST['amount']) : false;
            if ($amountCol === false) {
                throw new Exception('Missing required parameter amount column');
            }
            $transaction = new Transaction(new MySqlDB());
            $transaction->start();
            $mapping = Factory::createView(new MappingKey());
            $mapping->setUser($user);
            $mapping->setStartingRow($startingRow);
            $mapping->setName($name);
            $mapping->addMappingDetail(new MappingDetail($mapping, MappingDetail::$MAPPING_TRANSACTION_DATE, $transactionDateCol));
            $mapping->addMappingDetail(new MappingDetail($mapping, MappingDetail::$MAPPING_AMOUNT, $amountCol));
            $mapping->addMappingDetail(new MappingDetail($mapping, MappingDetail::$MAPPING_NAME, $descriptionCol));
            $transaction->commit();
        } else {
            $smarty = new MySmarty($SMARTY_CONFIG);
            $smarty->assign('user', $user);
            $smarty->assign('left_menu', true);
            $smarty->display('custommapping.tpl');
        }
    }
} catch (AccessDeniedException $e) {
    header('HTTP/1.1 401 Access Denied');
    echo "AccessDeniedException: " . $e->getMessage();
} catch (Exception $e) {
    if ($transaction && !$transaction->isComplete()) {
        $transaction->rollback();
    }
    header('HTTP/1.1 500 Internal Server Error');
    echo "Exception: " . $e->getMessage();
}
                            break;
                        case MappingDetail::$MAPPING_AMOUNT:
                            // We may have Credit / Debit Column, so at one time there is one column have value one doesn't
                            if (trim($data[$map->getCsvColumnNumber()])) {
                                $activity->setAmount(trim($data[$map->getCsvColumnNumber()]));
                            }
                            break;
                        case MappingDetail::$MAPPING_NAME:
                            $activity->setName($data[$map->getCsvColumnNumber()]);
                            break;
                    }
                }
            }
            fclose($handle);
        }
        $transaction->commit();
        $smarty->assign('message', "Imported CSV successfully");
    }
    $smarty->assign('left_menu', true);
    $smarty->assign('mappingTypes', Mapping::getOptions(array('USER_ID' => $user->getId())) + Mapping::getOptions());
    $smarty->display('process.tpl');
} catch (AccessDeniedException $e) {
    header('HTTP/1.1 401 Access Denied');
    echo "AccessDeniedException: " . $e->getMessage();
} catch (Exception $e) {
    if ($transaction && !$transaction->isComplete()) {
        $transaction->rollback();
    }
    header('HTTP/1.1 500 Internal Server Error');
    echo "Exception: " . $e->getMessage();
}
<?php

error_reporting(E_ERROR | E_PARSE);
//Easy Code No warings/notices errors
require_once __DIR__ . '/include/globals.php';
require_once SERVER_CLASS;
//Paste to unlock
require_once DB1_CLASS;
require_once MYSMARTY_CLASS;
session_start();
if (!isset($_SESSION['carinfo']) || !isset($_GET['cartype']) || !isset($_GET['maker']) || !isset($_GET['model']) || !isset($_GET['year'])) {
    header('Location: ' . WEB_JACPHP . 'select_cartype.php');
}
$cartype = filter_input(INPUT_GET, 'cartype');
$maker = filter_input(INPUT_GET, 'maker');
$model = filter_input(INPUT_GET, 'model');
$year = filter_input(INPUT_GET, 'year');
$smarty = new MySmarty();
$smarty->assign('header', '_no-sidebar.tpl');
$smarty->assign('question', '5. Select a transmisson');
$smarty->assign('next_question', 'tyler.php');
$smarty->assign('param', '?cartype=' . $cartype . '&maker=' . $maker . '&model=' . $model . '&year=' . $year . '&transmission=');
$smarty->assign('answers', $_SESSION['carinfo'][$cartype][$maker][$model][$year]);
$smarty->display('question.tpl');
$smarty = new MySmarty($SMARTY_CONFIG);
if (!empty($_POST)) {
    try {
        $action = htmlentities($_POST['action']);
        $username = htmlentities($_POST['username']);
        if ($action === "checkuser") {
            echo json_encode(User::isUsernameTaken($username));
            return;
        } elseif ($action === "adduser") {
            $password = htmlentities($_POST['password']);
            $passwordRepeat = htmlentities($_POST['password_repeat']);
            $firstname = htmlentities($_POST['firstname']);
            $lastname = htmlentities($_POST['lastname']);
            //check passwords are equal
            if ($passwordRepeat !== $password) {
                $smarty->display('error.tpl');
                return;
            }
            //check username is available
            if (User::isUsernameTaken($username)) {
                $smarty->display('error.tpl');
                return;
            }
            //check username is email
            if (!preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\$/i", $username)) {
                $smarty->display('error.tpl');
                return;
            }
            //check password meets standards
            if (!preg_match("/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9\\s]).{8,})/", $password)) {
                $smarty->display('error.tpl');
                    $activity->setCategory(Factory::getView(new CategoryKey(trim($data['category']))));
                }
                $transaction->commit();
                break;
        }
        echo json_encode(array('success' => 'true'));
    } else {
        $smarty = new MySmarty($SMARTY_CONFIG);
        $smarty->assign('res', $user->getActivities());
        $userCategories = Category::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
        $allCategories = Category::getOptions(array("ACTIVE" => 1));
        $categories = '';
        foreach ($userCategories as $index => $value) {
            $categories .= "{\"value\": \"{$index}\", \"label\": \"{$value}\"},";
        }
        $smarty->assign('allCategories', $categories);
        $smarty->assign('user', $user);
        $smarty->assign('left_menu', true);
        //$smarty->assign('BASE_URL', $BASE_URL);
        $smarty->display('transactions.tpl');
    }
} catch (AccessDeniedException $e) {
    header('HTTP/1.1 401 Access Denied');
    echo "AccessDeniedException: " . $e->getMessage();
} catch (Exception $e) {
    if ($transaction && !$transaction->isComplete()) {
        $transaction->rollback();
    }
    header('HTTP/1.1 500 Internal Server Error');
    echo "Exception: " . $e->getMessage();
}
    $budgets = Budget::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
    $spent = array();
    $budgetLeft = array();
    foreach ($budgets as $key => $item) {
        $activities = Activity::getOptions(array("USER_ID" => $user->getId(), "CATEGORY_ID" => $item['category_id'], "TRANSACTION_DATE_START" => Date::firstOfMonth()));
        $value = 0;
        foreach ($activities as $activityKey => $activityItem) {
            $value += $activityItem['amount'];
        }
        $spent[$key] = 0 - $value;
        $budgetLeft[$key] = $item['amount'] + $value;
    }
    $smarty->assign('spent', $spent);
    $smarty->assign('budgets', $budgets);
    $smarty->assign('budgetLeft', $budgetLeft);
    if ($fullPage) {
        $userCategories = Category::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
        $allCategories = Category::getOptions(array("ACTIVE" => 1));
        $smarty->assign('allCategories', $allCategories);
        $smarty->assign('userCategories', $userCategories);
        $smarty->assign('user', $user);
        $smarty->assign('left_menu', true);
        $smarty->display('budget.tpl');
    } else {
        echo $smarty->fetch('budget_table.tpl');
    }
} catch (AccessDeniedException $e) {
    trigger_error('Access Denied');
} catch (Exception $e) {
    trigger_error('An error has occurred, please try again in a few minutes');
}
Exemple #24
0
**
*/
error_reporting(E_ALL);
if (!$included_from_index) {
    header("Location: {$SITE_URL}");
    exit;
}
require_once 'mysmarty.php';
require_once 'system/db.sqlite.php';
$smarty = new MySmarty();
$smarty->assign('tpl_content', 'content-login-register.tpl.html');
$smarty->assign('page_style', 'style-login.css');
if ($_SERVER['REQUEST_METHOD'] != "POST") {
    $smarty->assign('page_title', 'login into picurls!');
    $smarty->assign('page_description', 'Login into picurls, buzziest pics on the net website!');
    $smarty->display('index.tpl.html');
    exit;
}
$error = false;
if (!isset($_POST['username'])) {
    $error = "No username was specified!";
} else {
    if (!isset($_POST['password'])) {
        $error = "No password was specified!";
    } else {
        if (empty($_POST['username'])) {
            $error = "Username was left blank!";
        } else {
            if (!preg_match("#^[a-zA-Z0-9]+\$#", $_POST['username'])) {
                $error = "Username should consist only of upper or lower case letters and digits!";
                $smarty->assign('login_username', $_POST['username']);
                    //$user = User::getUserByUserName($username);
                    $user->setPassword($_POST['new_password'], false);
                    $transaction->commit();
                } catch (Exception $e) {
                    if ($transaction && !$transaction->isComplete()) {
                        $transaction->rollback();
                    }
                    header('HTTP/1.1 500 Internal Server Error');
                    echo "Exception: " . $e->getMessage();
                }
            }
        }
    }
}
if (isset($_POST['update_name'])) {
    $transaction = new Transaction(new MySqlDB());
    $transaction->start();
    if (empty($_POST['firstName'])) {
        $smarty->assign('err_message', 'Firstname cannot be empty.');
    } else {
        $user->setFirstName($_POST['firstName']);
    }
    if (empty($_POST['lastName'])) {
        $smarty->assign('err_message', 'Lastname cannot be empty.');
    } else {
        $user->setLastName($_POST['lastName']);
    }
    $transaction->commit();
}
$smarty->display('account.tpl');