Example #1
0
<?php

include '../../../lib/sqlquery.class.php';
include '../../../lib/newmodel.class.php';
include '../../../app/models/Query.php';
include '../../../app/models/Settings.php';
include '../../../app/models/User.php';
include '../../../app/models/Utils.php';
$query = new SQLQuery();
$query->connect('localhost', 'root', '', 'boxarcade');
Settings::Init();
include '../../../lang/' . Settings::Get('language') . '.php';
User::sec_session_start();
User::Init();
$userid = intval($_SESSION['user_id']);
if (User::login_check(Query::$mysqli) == true) {
    //$get_comment = Query::query("SELECT * FROM tbl_comments WHERE id='" . $_POST['id'] . "'")->fetch_assoc();
    //Query::query("UPDATE tbl_users SET comments = comments - 1, points = points - $setting[points_comment] WHERE id='" . $get_comment['user'] . "'")->fetch_assoc();
    $result = Query::query("DELETE FROM tbl_comments WHERE id='" . $_POST['id'] . "'");
    echo $_POST['id'];
    echo 'Success';
} else {
    exit;
}
Example #2
0
/** Main Call Function **/
function callHook()
{
    if (isset($_GET['url'])) {
        $url = $_GET['url'];
    } else {
        $url = "index";
    }
    // Create the model factory
    $query = new SQLQuery();
    $query->connect('localhost', 'root', '', 'boxarcade');
    //$modelFactory = new ModelFactory($query);
    $settings = new Settings();
    $login_check = 99;
    User::sec_session_start();
    User::Init();
    if (User::login_check(Query::$mysqli) == true) {
        $xuserid = intval($_SESSION['user_id']);
        $sql = Query::query("SELECT * FROM Players WHERE PlayerID={$xuserid}");
        $get_user_info = $sql->fetch_assoc();
        $user = array('usrLang' => $get_user_info['Language'], 'username' => $get_user_info['Username'], 'id' => intval($_SESSION['user_id']), 'points' => $get_user_info['Points'], 'login_status' => 1, 'messages' => $get_user_info['Messages'], 'seo_url' => $get_user_info['Username']);
        $user['ip'] = User::secure($_SERVER['REMOTE_ADDR']);
        // If not avatar, try to get one from fb or set a default
        if ($get_user_info['AvatarType'] == '') {
            $user['avatar'] = 'uploads/avatars/default.png';
        } else {
            $user['avatar'] = 'uploads/avatars/' . $get_user_info['PlayerID'] . $get_user_info['AvatarType'];
        }
        $user['url'] = '/boxarcade/profile/' . $get_user_info['Username'];
        $user['message_url'] = 'messages';
        $user['admin'] = $get_user_info['Admin'];
        $login_check = 1;
        // Update the user IP if this is a new session
        if (!isset($_COOKIE['ava_iptrack'])) {
            Query::query("UPDATE Players SET LastIP = '{$user['ip']}' WHERE PlayerID = {$user['id']}") or die(mysql_error());
            setcookie("iptrack", '1');
        }
    } else {
        $user['login_status'] = 0;
        $user['admin'] = 0;
    }
    // Prep the controller name and the query string
    $urlArray = explode("/", $url);
    $controller = ucwords($urlArray[0]);
    array_shift($urlArray);
    $queryString = array_merge($urlArray, $_POST, $_GET);
    // Call the header controller
    $h = new Header($modelFactory, [], true);
    call_user_func_array(array($h, 'main'), [$login_check, $user]);
    // Call the page controller
    $dispatch = new $controller($modelFactory, $queryString, false);
    call_user_func_array(array($dispatch, 'main'), [$user]);
    // If an action was sent, call the appropriate function in the controller
    if (isset($queryString['action']) && !empty($queryString['action'])) {
        if (is_string($queryString['action'])) {
            $method = $queryString['action'];
        } else {
            if (is_array($queryString['action'])) {
                list($a_key, $a_val) = each($_POST['action']);
                $method = 'btn' . ucwords($a_key) . '_Clicked';
            }
        }
        if (method_exists($dispatch, $method) && is_callable(array($dispatch, $method))) {
            call_user_func_array(array($dispatch, $method), []);
        } else {
            header("HTTP/1.0 404 Not Found");
        }
    }
    // Call the footer controller
    $f = new Footer($modelFactory, [], true);
    call_user_func_array(array($f, 'main'), []);
}