Beispiel #1
0
 function delete($id)
 {
     // Let the file-model deal with the deletion
     model::factory('file')->delete($id);
     // and send the user back to the filelist
     header('location: ' . model::factory('renderer')->url('/admin/file/'));
 }
Beispiel #2
0
 function logout()
 {
     // Unset the session!
     unset($_SESSION['user']);
     // And send the user to the frontpage
     header('Location: ' . model::factory('renderer')->url('/'));
 }
Beispiel #3
0
 function test()
 {
     $database = model::factory('database');
     $r = $database->safe_query('select * from user where user_id in :user_id', array('user_id' => array(329, 339)));
     var_Dump($r);
     var_dump($r->fetchAll());
 }
Beispiel #4
0
 function page($page)
 {
     list($id, $null) = explode(':', $page);
     $sql = 'select * from page where idpage="' . $id . '"';
     list($page) = model::factory('database')->query($sql);
     $page_renderer = model::factory('renderer', 'pages');
     $page_renderer->page = $page;
     model::factory('renderer')->content = $page_renderer->render('template/page.php');
 }
Beispiel #5
0
 function get_all()
 {
     $settings = array();
     $r = model::factory('database')->query('select * from conf order by name asc');
     foreach ($r as $s) {
         $settings[] = $s;
     }
     return $settings;
 }
Beispiel #6
0
 function post($post)
 {
     list($id, $null) = explode(':', $post);
     $sql = 'select * from post where idpost="' . $id . '"';
     $post = model::factory('database')->query($sql)->fetch_assoc();
     $post_renderer = model::factory('renderer', 'post');
     $post_renderer->post = $post;
     model::factory('renderer')->title = $post['title'];
     model::factory('renderer')->content = $post_renderer->render('template/post.php', true);
 }
Beispiel #7
0
 function index()
 {
     if (isset($_POST) && !empty($_POST)) {
         foreach ($_POST as $key => $p) {
             model::factory('conf')->set($key, $p);
         }
     }
     $renderer = model::factory('renderer', 'settings');
     $renderer->settings = model::factory('conf')->get_all();
     return model::factory('renderer')->admin_content = $renderer->render('template/admin/settings/index.php', true);
 }
Beispiel #8
0
 function roll()
 {
     $roll = model::factory('kmom2_randomize')->roll_dice(6);
     $rounds = $this->get_data($this->gamename);
     $current_round = count($rounds['players'][$rounds['current_player']]['rounds']);
     if ($current_round == 0 && !isset($rounds['players'][$rounds['current_player']]['rounds'][$current_round])) {
         $rounds['players'][$rounds['current_player']]['rounds'][] = array();
     }
     if ($roll != 1) {
         $rounds['players'][$rounds['current_player']]['rounds'][count($rounds['players'][$rounds['current_player']]['rounds']) - 1][] = $roll;
     } else {
         $rounds['players'][$rounds['current_player']]['rounds'][count($rounds['players'][$rounds['current_player']]['rounds']) - 1] = array();
         $rounds['players'][$rounds['current_player']]['rounds'][count($rounds['players'][$rounds['current_player']]['rounds'])] = array();
     }
     $this->last_roll = $roll;
     $this->set_data($this->gamename, $rounds);
 }
Beispiel #9
0
 function safe_query($sql, $parameters = array())
 {
     if (!is_array($parameters)) {
         $parameters = array($parameters);
     }
     $statement = $this->database->prepare($sql);
     $statement->setFetchMode(PDO::FETCH_ASSOC);
     $statement->execute($parameters);
     if ($statement->errorCode() != '00000') {
         model::debug()->print_backtrace();
         model::factory('log')->warning('PDO errorcode: ' . $statement->errorCode());
         model::factory('log')->warning('PDO errorinfo: ' . json_encode($statement->errorInfo()));
         model::factory('log')->warning('PDO sql: ' . $sql);
         model::factory('log')->warning('PDO parameters: ' . json_encode($parameters));
     }
     return $statement->fetchAll();
 }
Beispiel #10
0
 function get($file)
 {
     if (is_numeric($file)) {
         $sql = "select path, filename, type from file where idfile = '" . $file . "'";
     } else {
         $sql = "select path, filename, type from file where filename = '" . $file . "'";
     }
     list($data) = model::factory('database')->query($sql);
     header('Content-Description: File Transfer');
     header('Content-Type: ' . $data['type']);
     $mime = explode('/', $data['type']);
     if ($mime[0] != 'image') {
         header('Content-Disposition: attachment; filename=' . $data['filename']);
     }
     header('Pragma: public');
     header('Content-Length: ' . filesize(UPLOAD . $data['path']));
     readfile(UPLOAD . $data['path']);
     die;
 }
Beispiel #11
0
function resolv($url)
{
    // get_parts splits the url by '/' and returns an array with the parts or a single element array with ''
    $parts = model::factory('url')->get_parts();
    if ($parts[0] == 'admin') {
        // Admin... Always requiring special attention...
        // Set the controller to be used if none is set
        if (!isset($parts[1]) || $parts[1] == '') {
            $parts[1] = 'welcome';
        }
        // Prepare the parameters
        if (isset($parts[3])) {
            $params = explode('/', $parts[3]);
        } else {
            $params = array();
        }
        // Instantiate the class
        $class_name = 'controller_' . $parts[0] . '_' . $parts[1];
        $class = new $class_name();
        // And finish with the method
        $method = isset($parts[2]) && !empty($parts[2]) ? $parts[2] : 'index';
    } else {
        // if parts is empty, use the default welcome-controller
        if ($parts[0] == '') {
            $parts[0] = 'welcome';
        }
        // Prepare the parameters
        if (isset($parts[2])) {
            $params = explode('/', $parts[2]);
        } else {
            $params = array();
        }
        // Instantiate the class
        $class_name = 'controller_' . $parts[0];
        $class = new $class_name();
        // And finish with the method
        $method = isset($parts[1]) && !empty($parts[1]) ? $parts[1] : 'index';
    }
    // Once done. return an array with the stuff
    return array('class' => $class, 'params' => $params, 'method' => $method);
}
Beispiel #12
0
 function clear()
 {
     $this->gamedata->clear();
     header('Location: ' . model::factory('renderer')->url('/kmom2/'));
 }
Beispiel #13
0
 function delete($id)
 {
     $sql = 'delete from movie where movie_id=?';
     model::factory('database')->safe_query($sql, $id);
 }
Beispiel #14
0
 function index()
 {
     model::factory('renderer')->set('admin_content', 'hi');
 }
Beispiel #15
0
 static function check_password($userid, $password)
 {
     $count = model::factory('database')->safe_query('select user_id from user where user_id = :user_id and where password = :password', array('user_id' => $userid, 'password' => $password));
     if (count($count) == 1) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #16
0
<h1><?php 
echo $page['title'];
?>
</h1>
<div><?php 
echo $page['content'];
?>
</div>
<div id="page_info">Senast ändrad <?php 
echo date('Y m d H:i', $page['timestamp']);
?>
 av <?php 
echo model::factory('user')->get_username_by_id($page['author']);
?>
</div>

Beispiel #17
0
 function title($id)
 {
     $sql = "select title from page where idpage = '" . $id . "'";
     list($data) = model::factory('database')->query($sql);
     if (!empty($data)) {
         return $data['title'];
     } else {
         return 'no page with that id';
     }
 }
Beispiel #18
0
<?php

/*
 * Debugger
 * This is still just a stub and will be extended in the future
 */
if (!defined('key')) {
    define('key', '');
}
require_once 'init.php';
register_shutdown_function(array(model::factory('debug'), 'shutdown'));
Beispiel #19
0
 function index()
 {
     model::factory('renderer', 'temp')->posts = model::factory('post')->get_all();
 }
Beispiel #20
0
<?php

$parts = model::factory('url')->get_parts();
$parts[1] = isset($parts[1]) ? $parts[1] : '';
$parts[2] = isset($parts[2]) ? $parts[2] : '';
switch ($parts[0]) {
    case 'admin':
        switch ($parts[1]) {
            case 'user':
                switch ($parts[2]) {
                    default:
                        break;
                }
                break;
        }
        break;
}
echo 'content';
Beispiel #21
0
        // Login then
        // Split the url by a bit of magic
        $parts = resolv($_GET);
        // Change the requested method if needed
        $parts['method'] = $parts['method'] == 'index' ? 'login' : $parts['method'];
        // Instantiate the controller
        $login_class = new controller_login();
        // Call the controller and method
        call_user_func_array(array($login_class, $parts['method']), $parts['params']);
        // Echo back any results
        echo model::factory('renderer')->render('template/login.html');
        break;
    default:
        // Default? Boring! anyways...
        // resolve the parts
        $parts = resolv($_GET);
        // start the class
        $class = new $parts['class']();
        // do the thing
        if (method_exists($class, 'before')) {
            $class->before();
        }
        // twist it
        call_user_func_array(array($class, $parts['method']), $parts['params']);
        // do the other thing
        if (method_exists($class, 'after')) {
            $class->after();
        }
        // Shoutout to my homeboys!
        echo model::factory('renderer')->render('template/main.html');
}
Beispiel #22
0
 function before()
 {
     model::factory('renderer')->admin_mainhead = 'Adminpanel för ' . model::factory('conf')->get_value('site_name');
 }
Beispiel #23
0
<?php

if (model::factory('message')->get()) {
    $str = "<ul>\r\n";
    foreach (model::factory('message')->get() as $class => $cont) {
        foreach ($cont as $m) {
            $str .= '<li class="' . $class . '">' . $m . '</li>';
        }
    }
    $str .= "</ul>";
    model::factory('message')->clear();
    echo $str;
} else {
}
Beispiel #24
0
<h1><a href=":::url:/:::"><?php 
echo model::factory('conf')->get_value('site_name');
?>
</a></h1>
Beispiel #25
0
 function delete($id)
 {
     $sql = 'delete from file where idfile = "' . $id . '"';
     model::factory('database')->query($sql);
 }
Beispiel #26
0
 function delete($id)
 {
     model:
     factory('user')->delete($id);
     header('location: ' . model::factory('renderer')->url('/admin/user/'));
 }
Beispiel #27
0
 function index()
 {
     model::factory('renderer')->content = model::factory('renderer')->render('template/csource.php');
 }