Example #1
0
/**
 * This function is beign used to change the users emailaddress info.
 * It will first check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
 * The emailaddress will be validated first. If the checking was successful the email will be updated and the settings template will be reloaded. Errors made by invalid data will be shown
 * also after reloading the template.
 * @author Daan Janssens, mentored by Matthew Lagoe
 */
function userRegistration()
{
    try {
        //if logged in
        if (WebUsers::isLoggedIn()) {
            $dbl = new DBLayer("lib");
            $dbl->update("settings", array('Value' => $_POST['userRegistration']), "`Setting` = 'userRegistration'");
            $result['target_id'] = $_GET['id'];
            global $SITEBASE;
            require_once $SITEBASE . '/inc/settings.php';
            $pageElements = settings();
            $pageElements = array_merge(settings(), $result);
            $pageElements['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
            // pass error and reload template accordingly
            helpers::loadtemplate('settings', $pageElements);
            throw new SystemExit();
        } else {
            //ERROR: user is not logged in
            header("Location: index.php");
            throw new SystemExit();
        }
    } catch (PDOException $e) {
        //go to error page or something, because can't access website db
        print_r($e);
        throw new SystemExit();
    }
}
Example #2
0
/**
 * This function is used in deactivating plugins.
 * This can be done by providing id using $_GET global variable of the plugin which
 * we want to activate. After getting id we update the respective plugin with status
 * deactivate which here means '0'.
 *
 * @author Shubham Meena, mentored by Matthew Lagoe
 */
function deactivate_plugin()
{
    // if logged in
    if (WebUsers::isLoggedIn()) {
        if (isset($_GET['id'])) {
            // id of plugin to deactivate
            $id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
            $db = new DBLayer('lib');
            $result = $db->update("plugins", array('Status' => '0'), "Id = {$id}");
            if ($result) {
                // if result is successfull it redirects and shows success message
                header("Cache-Control: max-age=1");
                header("Location: index.php?page=plugins&result=5");
                throw new SystemExit();
            } else {
                // if result is unsuccessfull it redirects and shows success message
                header("Cache-Control: max-age=1");
                header("Location: index.php?page=plugins&result=6");
                throw new SystemExit();
            }
        } else {
            //if $_GET variable is not set it redirects and shows error
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=plugins&result=6");
            throw new SystemExit();
        }
    }
}
Example #3
0
/**
 * This function is used in deleting plugins.
 * It removes the plugin from the codebase as well as
 * from the Database. When user request to delete a plugin
 * id of that plugin is sent in $_GET global variable.
 *
 * @author Shubham Meena, mentored by Matthew Lagoe
 */
function delete_plugin()
{
    // if logged in
    if (WebUsers::isLoggedIn()) {
        if (isset($_GET['id'])) {
            // id of plugin to delete after filtering
            $id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
            $db = new DBLayer('lib');
            $sth = $db->selectWithParameter("FileName", "plugins", array('id' => $id), "Id=:id");
            $name = $sth->fetch();
            if (is_dir("{$name['FileName']}")) {
                // removing plugin directory from the code base
                if (Plugincache::rrmdir("{$name['FileName']}")) {
                    $db->delete('plugins', array('id' => $id), "Id=:id");
                    //if result	successfull redirect and show success message
                    header("Cache-Control: max-age=1");
                    header("Location: index.php?page=plugins&result=2");
                    throw new SystemExit();
                } else {
                    // if result unsuccessfull redirect and show error message
                    header("Cache-Control: max-age=1");
                    header("Location: index.php?page=plugins&result=0");
                    throw new SystemExit();
                }
            }
        } else {
            // if result unsuccessfull redirect and show error message
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=plugins&result=0");
            throw new SystemExit();
        }
    }
}
Example #4
0
/**
* This function is beign used to load info that's needed for the settings page.
* check if the person who wants to view this page is a mod/admin or the user to whom te settings belong himself, if this is not the case, he will be redirected to an error page.
* it will return a lot of information of that user, that's being used for loading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function settings()
{
    if (WebUsers::isLoggedIn()) {
        //in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
        if (isset($_GET['id'])) {
            if ($_GET['id'] != $_SESSION['id'] && !Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
                //ERROR: No access!
                $_SESSION['error_code'] = "403";
                header("Cache-Control: max-age=1");
                header("Location: index.php?page=error");
                throw new SystemExit();
            } else {
                $webUser = new Webusers($_GET['id']);
                $result = $webUser->getInfo();
                if (Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && $_GET['id'] != $_SESSION['id']) {
                    $result['changesOther'] = "TRUE";
                }
                $result['target_id'] = $_GET['id'];
                $result['current_mail'] = $webUser->getEmail();
                $result['target_username'] = $webUser->getUsername();
            }
        } else {
            $webUser = new Webusers($_SESSION['id']);
            $result = $webUser->getInfo();
            $result['target_id'] = $_SESSION['id'];
            $result['current_mail'] = $webUser->getEmail();
            $result['target_username'] = $webUser->getUsername();
        }
        //Sanitize Data
        $result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
        $result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING);
        $result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
        $result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
        $result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
        $result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
        $result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
        $result['country_array'] = getCountryArray();
        global $INGAME_WEBPATH;
        $result['ingame_webpath'] = $INGAME_WEBPATH;
        $dbl = new DBLayer("lib");
        $statement = $dbl->executeWithoutParams("SELECT * FROM settings");
        $rows = $statement->fetchAll();
        foreach ($rows as &$value) {
            $result[$value['Setting']] = $value['Value'];
        }
        return $result;
    } else {
        //ERROR: not logged in!
        header("Location: index.php");
        header("Cache-Control: max-age=1");
        throw new SystemExit();
    }
}
Example #5
0
function isKnownUser($username, $userpass = null)
{
    global $db, $CNF;
    //    echo $username;
    if (strlen($username) > 0) {
        $db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
        $db->query("SET NAMES utf8");
        $sql_pass = $userpass != null ? "`status_id` !=4 AND `pass`='{$userpass}'" : '`status_id` !=4';
        $query = $db->query("SELECT `uid`,`login`,`lastname`,`firstname`,`middlename` FROM users WHERE `login`='{$username}' AND {$sql_pass}");
        if ($db->num_rows($query) > 0) {
            $auth = $db->fetch_assoc($query);
            return $auth;
        }
    }
    return false;
}
Example #6
0
 private function getTableDescription()
 {
     $tname = $this->__get_entity_name();
     if (!isset($_SESSION['makiavelo']['t_descriptions'][$tname])) {
         $_SESSION['makiavelo']['t_descriptions'][$tname] = DBLayer::describeTable($tname);
     }
     return $_SESSION['makiavelo']['t_descriptions'][$tname];
 }
Example #7
0
 public static function query($sql)
 {
     $db = DBLayer::connect();
     $return = mysql_query($sql, $db);
     if (!$return) {
         Makiavelo::info("Error on MYSQL Query:: " . mysql_error());
     }
     return $return;
 }
Example #8
0
 /**
  * Constructor.
  * will fetch the correct elements that match to a specific page (specified by the $_GET['pagenum'] variable). The query has to be passed as a string to the function
  * that way it will only load the specific elements that are related to the pagenumber. The $params, parameter is optional and is used to pass the parameters for the query.
  * The result class will be used to instantiate the found elements with, their set() function will be called. The class  its getters can be later used to get the info out of the object.
  * @param $query the query to be paginated
  * @param $db the db on which the query should be performed
  * @param $nrDisplayed the amount of elements that should be displayed /page
  * @param $resultClass the elements that should be returned should be of that specific class.
  * @param $params the parameters used by the query (optional)
  */
 function __construct($query, $db, $nrDisplayed, $resultClass, $params = array())
 {
     if (!isset($_GET['pagenum'])) {
         $this->current = 1;
     } else {
         $this->current = $_GET['pagenum'];
     }
     //Here we count the number of results
     $db = new DBLayer($db);
     $rows = $db->execute($query, $params)->rowCount();
     $this->amountOfRows = $rows;
     //the array hat will contain all users
     if ($rows > 0) {
         //This is the number of results displayed per page
         $page_rows = $nrDisplayed;
         //This tells us the page number of our last page
         $this->last = ceil($rows / $page_rows);
         //this makes sure the page number isn't below one, or more than our maximum pages
         if ($this->current < 1) {
             $this->current = 1;
         } else {
             if ($this->current > $this->last) {
                 $this->current = $this->last;
             }
         }
         //This sets the range to display in our query
         $max = 'limit ' . ($this->current - 1) * $page_rows . ',' . $page_rows;
         //This is your query again, the same one... the only difference is we add $max into it
         $data = $db->execute($query . " " . $max, $params);
         $this->element_array = array();
         //This is where we put the results in a resultArray to be sent to smarty
         while ($row = $data->fetch(PDO::FETCH_ASSOC)) {
             $element = new $resultClass();
             $element->set($row);
             $this->element_array[] = $element;
         }
     }
 }
Example #9
0
function checkInputValues()
{
    global $fdb;
    // Check connection
    $conn = @mysql_connect($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password']);
    if (!$conn) {
        myerror('Unable to connect to MySQL server. Please check your settings again.<br><br><a href="?page=settings">Go back to settings</a>');
    }
    // Check databases
    if (!@mysql_select_db($_SESSION['php_db_clean'], $conn)) {
        // Fetch database list
        $list = '';
        $result = @mysql_query('SHOW databases', $conn);
        while ($ob = mysql_fetch_row($result)) {
            $list .= ' &nbsp <a href="?page=settings&newdb=' . $ob[0] . '">' . $ob[0] . '</a><br>' . "\n";
        }
        // Close connection and show message
        mysql_close($conn);
        myerror('Unable to select database.' . '<br><br>Found these databases:<br><font color="gray">' . $list . '</font>' . '<br><a href="?page=settings">Go back to settings</a>');
    }
    mysql_close($conn);
    // Include FORUM's config file
    include './' . $_SESSION['forum'] . '/_config.php';
    // Check prefix
    $fdb = new DBLayer($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password'], $_SESSION['php_db_clean'], $_SESSION['php_prefix'], false);
    $res = $fdb->query('SELECT count(*) FROM ' . $_SESSION['php'] . $tables['Users']);
    if (intval($fdb->result($res, 0)) == 0) {
        // Select a list of tables
        $list = array();
        $res = $fdb->query('SHOW TABLES IN ' . $_SESSION['php_db']);
        while ($ob = $fdb->fetch_row($res)) {
            $list[] = $ob[0];
        }
        // check list size
        sizeof($list) == 0 ? $list[] = 'None' : null;
        // Get list of "proabable" prefixes
        $prefix_list = '';
        $res = $fdb->query('SHOW TABLES FROM ' . $_SESSION['php_db'] . ' LIKE \'%' . $tables['Posts'] . '\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
        //			$res = $fdb->query('SHOW TABLES FROM '.$_SESSION['php_db'].' LIKE \'%'.$tables['Users'].'\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
        while ($ob = $fdb->fetch_row($res)) {
            $prefix = substr($ob[0], 0, strlen($ob[0]) - strlen($tables['Users']));
            $prefix_list .= ' &nbsp; <a href="?page=settings&newprefix=' . $prefix . '">' . $prefix . '</a><br>' . "\n";
        }
        // Print message
        $prefix = $_SESSION['php_prefix'] == '' ? 'no' : '\'' . $_SESSION['php_prefix'] . '\'';
        myerror('Unable to find ' . $_SESSION['forum'] . ' tables! (using prefix: <i>' . $prefix . '</i>)' . '<br><br>Go back to settings and choose another prefix, or select one of these prefixes:<br><font color="gray">' . $prefix_list . '</font>' . '<br>These are the tables in the selected database:<br><font color="gray"> &nbsp; ' . implode("<br> &nbsp; ", $list) . '</font>' . '<br><br><a href="?page=settings">Go back to settings</a>');
    }
}
Example #10
0
/**
 * This function is used in installing updates for plugins.
 * It takes id of the plugin whose update is available using
 * $_GET global variable and then extract the update details
 * from db and then install it in the plugin.
 *
 * @author Shubham Meena, mentored by Matthew Lagoe
 */
function update_plugin()
{
    // if logged in
    if (WebUsers::isLoggedIn()) {
        if (isset($_GET['id'])) {
            // id of plugin to update
            $id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
            $db = new DBLayer('lib');
            $sth = $db->executeWithoutParams("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id={$id}");
            $row = $sth->fetch();
            // replacing update in the  database
            Plugincache::rrmdir($row['FileName']);
            Plugincache::zipExtraction($row['UpdatePath'], rtrim($row['FileName'], strtolower($row['Name'])));
            $db->update("plugins", array('Info' => $row['UpdateInfo']), "Id={$row['Id']}");
            // deleting the previous update
            $db->delete("updates", array('id' => $row['s.no']), "s.no=:id");
            // if update is installed succesffully redirect to show success message
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=plugins&result=8");
            throw new SystemExit();
        }
    }
}
Example #11
0
 public function execute($params)
 {
     Makiavelo::info("Creating Database...");
     $sql_folder_path = ROOT_PATH . Makiavelo::SQL_CREATE_TABLES_FOLDER;
     Makiavelo::puts("Creating database...");
     $conn = DBLayer::connect();
     $db_name = DBLayer::getDBName();
     $sql = "CREATE DATABASE `{$db_name}`";
     if (!mysql_query($sql, $conn)) {
         Makiavelo::info("ERROR creating db: " . mysql_error());
     }
     //We also have to create the migrations table
     $sql_migrations = "CREATE TABLE migrations ( migration INT PRIMARY KEY);";
     mysql_select_db($db_name);
     if (!mysql_query($sql_migrations, $conn)) {
         Makiavelo::info("ERROR creating migrations table:: " . mysql_error());
     }
     DBLayer::disconnect($conn);
 }
Example #12
0
 private function loadEntities()
 {
     $sql_folder_path = ROOT_PATH . Makiavelo::SQL_CREATE_TABLES_FOLDER;
     $d = dir($sql_folder_path);
     while (($item = $d->read()) != false) {
         if ($item != "create_db.sql" && substr($item, 0, 1) != ".") {
             $file_path = $sql_folder_path . "/" . $item;
             $fp = fopen($file_path, "r");
             if ($fp) {
                 Makiavelo::puts("Loading entity: {$item} ...");
                 $conn = DBLayer::connect();
                 $sql = fread($fp, filesize($file_path));
                 fclose($fp);
                 $res = mysql_query($sql, $conn);
                 if (!$res && mysql_errno($conn) == 1050) {
                     Makiavelo::puts("---- Entity already loaded, ignoring");
                 }
                 DBLayer::disconnect($conn);
             }
         }
     }
 }
Example #13
0
 /**
 Allows the dev to modify the structure of a table:
 Supported operations:
 
 - add_field
 - drop_field
 */
 protected function alter_table($tname, $params)
 {
     global $__db_conn;
     foreach ($params as $operation => $parms) {
         switch ($operation) {
             case "add_field":
                 $keys = array_keys($parms);
                 $new_field = $keys[0];
                 $type = $this->sql_types_mapping[$parms[$new_field]];
                 $sql = "ALTER TABLE {$tname} ADD COLUMN {$new_field} {$type}";
                 break;
             case "drop_field":
                 $new_field = $parms;
                 $sql = "ALTER TABLE {$tname} drop column {$new_field} ";
                 break;
             default:
                 break;
         }
         Makiavelo::info("Altering table :: " . $sql);
         DBLayer::query($sql);
     }
 }
Example #14
0
public function saveRecipeWork()
{
$dbl=new DBLayer();
$dbl->setCollectionObj($this->RecipeColname);
$obj=$this->CreateRecipeArray();//prepare_array_Recipework();
$dbl->InsertCollection($obj);
//$cursor = $dbl->get_CollectionObject($this->RecipeColname);//,$this->objID);
}
Example #15
0
        $arr[$i]['cl'] = $result['class'];
        $arr[$i]['race'] = $result['race'];
        $arr[$i]['level'] = $char_data[$UNIT_FIELD_LEVEL];
        $arr[$i]['gender'] = $char_gender[3];
        $arr[$i]['Extention'] = $Extention;
        $arr[$i]['leaderGuid'] = isset($groups[$char_data[0]]) ? $groups[$char_data[0]] : 0;
        $i++;
    }
    $mangos_db->close();
    usort($arr, "sort_players");
    $arr = array_merge($Count, $arr);
    $res['online'] = $arr;
} else {
    $res['online'] = NULL;
}
if ($show_status) {
    $mangos_db = new DBLayer($mangos[$royaume]['host'], $mangos[$royaume]['user'], $mangos[$royaume]['password'], $mangos[$royaume]['db']);
    $mangos_db->query("SET NAMES " . $mangos[$royaume]['encoding'] . "");
    $query = $mangos_db->query("SELECT `starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
    if ($result = $mangos_db->fetch_assoc($query)) {
        $status['uptime'] = time() - $result['starttime'];
        $status['maxplayers'] = $result['maxplayers'];
        $status['online'] = test_realm() ? 1 : 0;
    }
    $mangos_db->close();
} else {
    $status = NULL;
}
unset($mangos_db);
$res['status'] = $status;
$_RESULT = $res;
Example #16
0
 public function SearchThing($parmName, $parmval)
 {
     $dbl = new DBLayer();
     $dbl->setCollectionObj($this->Colname);
     $cursor = $dbl->get_CollectionObjectbysearchParameter($this->Colname, $parmName, $parmval);
     foreach ($cursor as $arr) {
         $this->objID = $arr["_id"];
         $this->name->value = $arr["name"];
         $this->url->value = $arr["url"];
         $this->image->value = $arr["image"];
         $this->description->value = $arr["description"];
     }
     //echo 'Printing';
     echo '<b>Name<b></b> :' . $this->printNameHtmlTag() . '<br>';
     echo '<b>Description</b> :' . $this->printDescriptionHtmlTag() . '<br>';
     echo '<b>URL </b> :' . $this->printUrlHtmlTag() . '<br>';
     echo '<b>Image </b> :' . $this->printImageHtmlTag() . '<br>';
     //$this->printNameHtmlTag();
 }
Example #17
0
spl_autoload_register('__autoload_entities');
spl_autoload_register('__autoload_validator');
spl_autoload_register('__autoload_tasks');
spl_autoload_register('__autoload_lib');
include_once ROOT_PATH . "/core/spyc.php";
include_once ROOT_PATH . "/config/config.php";
//Includes all sql helpers
$sql_helper_folder = ROOT_PATH . Makiavelo::SQL_HELPERS_FOLDER;
$d = dir($sql_helper_folder);
while (false !== ($entry = $d->read())) {
    if ($entry[0] != ".") {
        include $sql_helper_folder . "/" . $entry;
    }
}
//DB connection... simple for now...
$__db_conn = DBLayer::connect();
$parameters = $argv;
if (count($parameters) > 1) {
    $mk = new Makiavelo();
    $action = $mk->getAction($parameters[1]);
    unset($parameters[0]);
    unset($parameters[1]);
    $action->execute(array_values($parameters));
} else {
    echo "Welcome to Makiavelo command line utility";
    echo "\nUsage: makiavelo [COMMAND] [ATTRIBUTES] \n";
    echo "\nValid commands:";
    echo "\n  g: Generator command";
    echo "\n     Attributes:";
    echo "\n     crud: Generates a controller, an entity and a set of views for the CRUD operations. Needs a name for the entity";
    echo "\n     controller: Generates an empty controller. Needs a controller name as parameter";
Example #18
0
<?php

/**
 * Created by PhpStorm.
 * User: megadozz
 * Date: 01.07.2014
 * Time: 10:54
 */
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
//echo "$_SERVER[DOCUMENT_ROOT]";
require_once "{$_SERVER['DOCUMENT_ROOT']}/lib/dblayer.php";
require_once "{$_SERVER['DOCUMENT_ROOT']}/conf.inc.php";
require_once "{$_SERVER['DOCUMENT_ROOT']}/subs.php";
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
function translit($str)
{
    $tr = array("А" => "A", "Б" => "B", "В" => "V", "Г" => "G", "Д" => "D", "Е" => "E", "Ё" => "E", "Ж" => "ZH", "З" => "Z", "И" => "I", "Й" => "Y", "К" => "K", "Л" => "L", "М" => "M", "Н" => "N", "О" => "O", "П" => "P", "Р" => "R", "С" => "S", "Т" => "T", "У" => "U", "Ф" => "F", "Х" => "H", "Ц" => "TS", "Ч" => "CH", "Ш" => "SH", "Щ" => "SCH", "Ъ" => "", "Ы" => "YI", "Ь" => "", "Э" => "E", "Ю" => "YU", "Я" => "YA", "а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "e", "ж" => "zh", "з" => "z", "и" => "i", "й" => "y", "к" => "k", "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f", "х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "y", "ы" => "yi", "ь" => "", "э" => "e", "ю" => "yu", "я" => "ya");
    return strtr($str, $tr);
}
function generate_password($length)
{
    $pass = "";
    $arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
    for ($i = 0; $i < $length; $i++) {
        $index = rand(0, count($arr) - 1);
        // Случайный индекс массива
        $pass .= $arr[$index];
    }
    return $pass;
Example #19
0
    }
} else {
    $lang = $language;
}
$database_encoding = $site_encoding;
$server = $server_arr[$realm_id]["addr"];
$port = $server_arr[$realm_id]["game_port"];
$host = $characters_db[$realm_id]["addr"];
$user = $characters_db[$realm_id]["user"];
$password = $characters_db[$realm_id]["pass"];
$db = $characters_db[$realm_id]["name"];
$hostr = $realm_db["addr"];
$userr = $realm_db["user"];
$passwordr = $realm_db["pass"];
$dbr = $realm_db["name"];
$sql = new DBLayer($hostr, $userr, $passwordr, $dbr);
$query = $sql->query("SELECT name FROM realmlist WHERE id = " . $realm_id);
$realm_name = $sql->fetch_assoc($query);
$realm_name = htmlentities($realm_name["name"]);
$gm_show_online = $gm_online;
$gm_show_online_only_gmoff = $map_gm_show_online_only_gmoff;
$gm_show_online_only_gmvisible = $map_gm_show_online_only_gmvisible;
$gm_add_suffix = $map_gm_add_suffix;
$gm_include_online = $gm_online_count;
$show_status = $map_show_status;
$time_to_show_uptime = $map_time_to_show_uptime;
$time_to_show_maxonline = $map_time_to_show_maxonline;
$time_to_show_gmonline = $map_time_to_show_gmonline;
$status_gm_include_all = $map_status_gm_include_all;
$time = $map_time;
$show_time = $map_show_time;
Example #20
0
 /**
  * workhorse of the website, it loads the template and shows it or returns th html.
  * it uses smarty to load the $template, but before displaying the template it will pass the $vars to smarty. Also based on your language settings a matching
  * array of words & sentences for that page will be loaded. In case the $returnHTML parameter is set to true, it will return the html instead of displaying the template.
  *
  * @param  $template the name of the template(page) that we want to load.
  * @param  $vars an array of variables that should be loaded by smarty before displaying or returning the html.
  * @param  $returnHTML (default=false) if set to true, the html that should have been displayed, will be returned.
  * @return in case $returnHTML=true, it returns the html of the template being loaded.
  */
 public static function loadTemplate($template, $vars = array(), $returnHTML = false)
 {
     //error_log(print_r($_GET,true));
     //error_log(print_r($_POST,true));
     global $AMS_LIB;
     global $SITEBASE;
     global $AMS_TRANS;
     global $INGAME_LAYOUT;
     global $AMS_CACHEDIR;
     global $AMS_PLUGINS;
     // define('SMARTY_SPL_AUTOLOAD',1);
     require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
     spl_autoload_register('__autoload');
     $smarty = new Smarty();
     $smarty->setCompileDir($SITEBASE . '/templates_c/');
     $smarty->setCacheDir($AMS_CACHEDIR);
     $smarty->setConfigDir($SITEBASE . '/configs/');
     // turn smarty debugging on/off
     $smarty->debugging = false;
     // caching must be disabled for multi-language support
     $smarty->caching = false;
     $smarty->cache_lifetime = 300;
     $smarty->addPluginsDir($AMS_PLUGINS);
     if (function_exists('apc_cache_info')) {
         // production
         //$smarty->caching = true;
         //$smarty->setCachingType("apc");
         //$smarty->compile_check = false;
     }
     // needed by smarty.
     helpers::create_folders();
     global $FORCE_INGAME;
     // if ingame, then use the ingame templates
     if (helpers::check_if_game_client() or $FORCE_INGAME) {
         $smarty->template_dir = $AMS_LIB . '/ingame_templates/';
         $smarty->setConfigDir($AMS_LIB . '/configs');
         $variables = parse_ini_file($AMS_LIB . '/configs/ingame_layout.ini', true);
         foreach ($variables[$INGAME_LAYOUT] as $key => $value) {
             $smarty->assign($key, $value);
         }
     } else {
         $smarty->template_dir = $SITEBASE . '/templates/';
         $smarty->setConfigDir($SITEBASE . '/configs');
     }
     foreach ($vars as $key => $value) {
         $smarty->assign($key, $value);
     }
     // load page specific variables that are language dependent
     $variables = Helpers::handle_language();
     if ($template != 'layout_plugin') {
         foreach ($variables[$template] as $key => $value) {
             $smarty->assign($key, $value);
         }
     }
     // load ams content variables that are language dependent
     foreach ($variables['ams_content'] as $key => $value) {
         $smarty->assign($key, $value);
     }
     //load ams content variables that are language dependent
     foreach ($variables['ams_content'] as $key => $value) {
         $smarty->assign($key, $value);
     }
     $id = session_id();
     $smarty->assign("sessionid", $id);
     $dbl = new DBLayer("lib");
     $statement = $dbl->executeWithoutParams("SELECT * FROM settings");
     $rows = $statement->fetchAll();
     foreach ($rows as &$value) {
         $smarty->assign($value['Setting'], $value['Value']);
     }
     // smarty inheritance for loading the matching wrapper layout (with the matching menu bar)
     if (isset($vars['permission']) && $vars['permission'] == 3) {
         $inherited = "extends:layout_admin.tpl|";
     } else {
         if (isset($vars['permission']) && $vars['permission'] == 2) {
             $inherited = "extends:layout_mod.tpl|";
         } else {
             if (isset($vars['permission']) && $vars['permission'] == 1) {
                 $inherited = "extends:layout_user.tpl|";
             } else {
                 $inherited = "";
             }
         }
     }
     // if $returnHTML is set to true, return the html by fetching the template else display the template.
     if ($returnHTML == true) {
         return $smarty->fetch($inherited . $template . '.tpl');
     } else {
         $smarty->display($inherited . $template . '.tpl');
     }
 }
Example #21
0
 /**
  * function that creates a ticket Attachment.
  */
 public static function add_Attachment($TId, $filename, $author, $tempFile)
 {
     global $FILE_STORAGE_PATH;
     $length = mt_rand(20, 25);
     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*\'(),';
     $randomString = '';
     for ($i = 0; $i < $length; $i++) {
         $randomString .= $characters[rand(0, strlen($characters) - 1)];
     }
     $targetFile = $FILE_STORAGE_PATH . $randomString . "/" . $filename;
     if (file_exists($targetFile)) {
         return self::add_Attachment($TId, $filename, $author, $tempFile);
     }
     $ticket = new Ticket();
     $ticket->load_With_TId($TId);
     //create the attachment!
     try {
         $dbl = new DBLayer("lib");
         $dbl->insert("`ticket_attachments`", array('ticket_TId' => $TId, 'Filename' => $filename, 'Filesize' => filesize($tempFile), 'Uploader' => $author, 'Path' => $randomString . "/" . $filename));
     } catch (Exception $e) {
         return $false;
     }
     mkdir($FILE_STORAGE_PATH . $randomString);
     $return = move_uploaded_file($tempFile, $targetFile);
     if ($return == false) {
         $dbl->delete("`ticket_attachments`", array('Path' => $randomString . "/" . $filename), "`Path` = :Path");
     }
     //write a log entry
     Ticket_Log::createLogEntry($TId, $author, 10);
     return $return;
 }
Example #22
0
 public function SearchThing($parmName, $parmval)
 {
     $dbl = new DBLayer();
     $dbl->setCollectionObj($this->Colname);
     $cursor = $dbl->get_CollectionObjectbysearchParameter($this->Colname, $parmName, $parmval);
     if ($cursor->hasNext()) {
         foreach ($cursor as $arr) {
             $this->objID = $arr["_id"];
             $this->name->value = $arr["name"];
             $this->url->value = $arr["url"];
             $this->image->value = $arr["image"];
             $this->description->value = $arr["description"];
         }
         //echo 'Printing';
         echo '<b>Name<b></b> :' . $this->getNameValue() . '<br>';
         echo '<b>Description</b> :' . $this->getDescriptionValue() . '<br>';
         echo '<b>URL </b> :' . $this->getUrlValue() . '<br>';
         echo '<b>Image </b> :' . $this->getImageValue() . '<br>';
         $this->result = 1;
     } else {
         $this->result = 0;
     }
     return $this->result;
 }
Example #23
0
function api_key_management_hook_activate()
{
    $dbl = new DBLayer("lib");
    $sql = "INSERT INTO `settings` (Setting) \n            SELECT 'Domain_Auto_Add' FROM DUAL\n            WHERE NOT EXISTS \n            (SELECT Setting FROM settings WHERE Setting='Domain_Auto_Add');";
    $dbl->executeWithoutParams($sql);
}
Example #24
0
 /**
  * send mail function that will add the email to the db.
  * this function is being used by the send_ticketing_mail() function. It adds the email as an entry to the `email` table in the database, which will be sent later on when we run the cron job.
  * @param $recipient if integer, then it refers to the id of the user to whom we want to mail, if it's a string(email-address) then we will use that.
  * @param $subject the subject of the email
  * @param $body the body of the email
  * @param $ticket_id the id of the ticket
  * @param $from the sending support_group's id (NULL in case the default group is sending))
  */
 public static function send_mail($recipient, $subject, $body, $ticket_id = 0, $from = NULL)
 {
     $id_user = NULL;
     if (is_numeric($recipient)) {
         $id_user = $recipient;
         $recipient = NULL;
     }
     $db = new DBLayer($db);
     $db->insert("email", array('Recipient' => $recipient, 'Subject' => $subject, 'Body' => $body, 'Status' => 'NEW', 'Attempts' => 0, 'Sender' => $from, 'UserId' => $id_user, 'MessageId' => 0, 'TicketId' => $ticket_id));
 }
Example #25
0
//require the pages that are being needed.
require '../../config.php';
require '../../../ams_lib/libinclude.php';
ini_set("display_errors", true);
error_reporting(E_ALL);
//var used to access the DB;
global $cfg;
try {
    //SETUP THE WWW DB
    $dbs = new DBLayer("shard");
    $sql = "SELECT * FROM user";
    $statement = $dbs->executeWithoutParams($sql);
    $users = $statement->fetchAll();
    foreach ($users as $user) {
        //add user to web
        $dbw = new DBLayer("web");
        if (!$dbw->execute("SELECT * FROM ams_user WHERE Login = :name", array('name' => $user['Login']))->rowCount()) {
            $query = "INSERT INTO ams_user (Login, Password, Email, Language) VALUES (:name, :pass, :mail, :lang)";
            global $DEFAULT_LANGUAGE;
            $vars = array('name' => $user['Login'], 'pass' => $user['Password'], 'mail' => $user['Email'], 'lang' => $DEFAULT_LANGUAGE);
            $id = $dbw->executeReturnId($query, $vars);
            $dbl = new DBLayer("lib");
            $query = "INSERT INTO `ticket_user` (Permission, ExternId) VALUES (1, :id)";
            $vars = array('id' => $id);
            $dbl->execute($query, $vars);
        }
    }
    print "The users were imported! ";
} catch (PDOException $e) {
    print "There was an error while creating the admin account! ";
}
Example #26
0
require_once 'pomm_conf.php';
require_once 'func.php';
if (file_exists("map_" . $lang . ".php") && file_exists("zone_names_" . $lang . ".php")) {
    require_once "map_" . $lang . ".php";
} else {
    require_once "map_english.php";
}
$_RESULT = NULL;
$maps_count = count($lang_defs['maps_names']);
$Horde_races = 0x2b2;
$Alliance_races = 0x44d;
$outland_inst = array(540, 542, 543, 544, 545, 546, 547, 548, 550, 552, 553, 554, 555, 556, 557, 558, 559, 562, 564, 565);
$northrend_inst = array(533, 574, 575, 576, 578, 599, 600, 601, 602, 603, 604, 608, 615, 616, 617, 619, 624);
require_once "../libs/js/JsHttpRequest/Php.php";
$JsHttpRequest = new Subsys_JsHttpRequest_Php("utf-8");
$realm_db = new DBLayer($hostr, $userr, $passwordr, $dbr);
if (!$realm_db->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
$realm_db->query("SET NAMES {$database_encoding}");
$gm_online = 0;
$gm_accounts = array();
$query = $realm_db->query("SELECT GROUP_CONCAT(`id` SEPARATOR ' ') FROM `account` WHERE `gmlevel`>'0'");
if ($query) {
    if ($result = $realm_db->fetch_row($query)) {
        $gm_accounts = explode(' ', $result[0]);
    }
}
$groups = array();
$characters_db = new DBLayer($host, $user, $password, $db);
Example #27
0
 /**
  * updates the entry.
  */
 public function update()
 {
     $dbl = new DBLayer("lib");
     $dbl->update("ams_querycache", array('type' => $this->getType(), 'query' => $this->getQuery(), 'db' => $this->getDb(), "SID={$this->getSID}()"));
 }
    require_once "map_english.php";
}
$_RESULT = NULL;
$maps_count = count($lang_defs['maps_names']);
$Horde_races = 0x2b2;
$Alliance_races = 0x44d;
$outland_inst = array(540, 542, 543, 544, 545, 546, 547, 548, 550, 552, 553, 554, 555, 556, 557, 558, 559, 562, 564, 565);
$northrend_inst = array(533, 574, 575, 576, 578, 599, 600, 601, 602, 603, 604, 608, 615, 616, 617, 619, 624);
require_once "../libs/js/JsHttpRequest/Php.php";
$JsHttpRequest = new Subsys_JsHttpRequest_Php("utf-8");
$arcm_db_PM = new DBLayer($hostr, $userr, $passwordr, $dbr);
if (!$arcm_db_PM->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
$logon_db_PM = new DBLayer($hostl, $userl, $passwordl, $dbl);
$arcm_db_PM->query("SET NAMES {$database_encoding}");
$gm_online = 0;
$gm_accounts = array();
$query = $logon_db_PM->query("SELECT GROUP_CONCAT(`acct` SEPARATOR ' ') FROM `accounts` WHERE `gm`<>'0'");
if ($query) {
    if ($result = $logon_db_PM->fetch_row($query)) {
        $gm_accounts = explode(' ', $result[0]);
    }
}
$groups = array();
$characters_db_PM = new DBLayer($host, $user, $password, $db);
if (!$characters_db_PM->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
Example #29
0
 /**
  * loads the object's attributes.
  * loads the object's attributes by giving a ticket_id, it will put the matching user_id and the ticket_id into the attributes.
  * @param $ticket_id the id of the ticket that should be loaded
  */
 public function load($ticket_id)
 {
     $dbl = new DBLayer("lib");
     $statement = $dbl->select("`assigned`", array('ticket_id' => $ticket_id), "`Ticket` = :ticket_id");
     $row = $statement->fetch();
     $this->set($row);
 }
Example #30
0
 /**
  * sets the shards email.
  * in case the shard is offline, the entry will be stored in the ams_querycache.
  * @param $user the usersname of the account of which we want to change the emailaddress.
  * @param $mail the new email address
  * @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
  */
 protected static function setAmsEmail($user, $mail)
 {
     $values = array('Email' => $mail);
     try {
         //make connection with and put into shard db
         $dbs = new DBLayer("shard");
         $dbs->update("user", $values, "Login = '******'");
         return "ok";
     } catch (PDOException $e) {
         //oh noooz, the shard is offline! Put in query queue at ams_lib db!
         try {
             error_log($e);
             $dbl = new DBLayer("lib");
             $dbl->insert("ams_querycache", array("type" => "change_mail", "query" => json_encode(array($user, $mail)), "db" => "shard"));
             return "shardoffline";
         } catch (PDOException $e) {
             return "liboffline";
         }
     }
 }