Exemplo n.º 1
0
 public function all()
 {
     $db = new Database();
     $db->connect();
     $obj = $db->fetch_all_array("select * from " . $this->table_name_full);
     $db->close();
     return new response(array('body' => $obj));
 }
Exemplo n.º 2
0
 public function getAllTransferForEvent($eventId, $mode)
 {
     $sql = "select * from transfer where event_id=" . $eventId . " and mode='" . $mode . "'";
     $db = new Database();
     $db->connect();
     $allTransfer = $db->fetch_all_array($sql);
     $db->close();
     return $allTransfer;
 }
Exemplo n.º 3
0
 public function getAllCentres()
 {
     $sql = "select * from centre";
     $db = new Database();
     $db->connect();
     $allCentres = $db->fetch_all_array($sql);
     $db->close();
     return $allCentres;
 }
Exemplo n.º 4
0
 public function getEventsByCentreIdent($centreIdent)
 {
     $sql = "select * from event where centre_fk='{$centreIdent}'order by ev_date asc";
     $db = new Database();
     $db->connect();
     $events = $db->fetch_all_array($sql);
     $db->close();
     return $events;
 }
Exemplo n.º 5
0
function numBadReviews()
{
    $db = new Database(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    $numReviews = 0;
    for ($i = 1; $i <= 100; $i++) {
        // First we select a random film from the first 1000
        $db->connect();
        $result = $db->query("SELECT * FROM films WHERE position = " . $i);
        $film = $db->fetch_array_assoc($result);
        if (!$film) {
            continue;
        }
        echo $film['name'] . PHP_EOL;
        // Let's get film's bad reviews
        $db->connect();
        $reviews = $db->fetch_all_array("SELECT * FROM reviews WHERE id = '" . $film['id'] . "' AND rating <= 2");
        foreach ($reviews as $review) {
            echo $review['title'] . PHP_EOL;
        }
        $numReviews += count($reviews);
        echo "Num reviews: " . $numReviews . PHP_EOL;
    }
    echo "Total reviews: " . $numReviews;
}
Exemplo n.º 6
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
session_start();
if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1) {
    die('Hacking attempt...');
}
global $k, $settings;
include '../includes/settings.php';
header("Content-type: text/x-json; charset=" . $k['charset']);
require_once "class.database.php";
$db = new Database($server, $user, $pass, $database, $pre);
$db->connect();
$sql = "SELECT id, category FROM " . $pre . "kb_categories";
//manage filtering
if (!empty($_GET['term'])) {
    $sql .= " WHERE category LIKE '%" . $_GET['term'] . "%'";
}
$sql .= " ORDER BY category ASC";
$sOutput = '';
$rows = $db->fetch_all_array($sql);
if ($rows[0] > 0) {
    foreach ($rows as $reccord) {
        if (empty($sOutput)) {
            $sOutput = '"' . $reccord['category'] . '"';
        } else {
            $sOutput .= ', "' . $reccord['category'] . '"';
        }
    }
    //Finish the line
    echo '[ ' . $sOutput . ' ]';
}
Exemplo n.º 7
0
 //Add font for utf-8
 $pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.ttf', true);
 $pdf->AliasNbPages();
 $pdf->AddPage();
 $pdf->SetFont('DejaVu', '', 16);
 $pdf->Cell(0, 10, $txt['pdf_del_title'], 0, 1, 'C', false);
 $pdf->SetFont('DejaVu', '', 12);
 $pdf->Cell(0, 10, $txt['pdf_del_date'] . date($_SESSION['settings']['date_format'] . " " . $_SESSION['settings']['time_format'], mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"))), 0, 1, 'C', false);
 $pdf->SetFont('DejaVu', '', 10);
 $pdf->SetFillColor(15, 86, 145);
 $pdf->cell(80, 6, $txt['label'], 1, 0, "C", 1);
 $pdf->cell(75, 6, $txt['group'], 1, 0, "C", 1);
 $pdf->cell(21, 6, $txt['date'], 1, 0, "C", 1);
 $pdf->cell(15, 6, $txt['author'], 1, 1, "C", 1);
 $pdf->SetFont('DejaVu', '', 10);
 $rows = $db->fetch_all_array("\r\n            SELECT u.login AS login, i.label AS label, i.id_tree AS id_tree\r\n            FROM " . $pre . "log_items AS l\r\n            INNER JOIN " . $pre . "users AS u ON (u.id=l.id_user)\r\n            INNER JOIN " . $pre . "items AS i ON (i.id=l.id_item)\r\n            WHERE l.action = 'Modification'\r\n            AND l.raison = 'Mot de passe chang?'\r\n        ");
 foreach ($rows as $reccord) {
     if (date($_SESSION['settings']['date_format'], $reccord['date']) == $_POST['date']) {
         //information about the pw creator
         $res_user = mysql_query("SELECT login FROM " . $pre . "users WHERE id = '" . $reccord['id_user'] . "'");
         $data_user = mysql_fetch_row($res_user);
         //information about the pw itself
         $res_item = mysql_query("SELECT label, id_tree FROM " . $pre . "items WHERE id = '" . $reccord['id_item'] . "'");
         $data_item = mysql_fetch_row($res_item);
         //get the tree grid
         $arbo = $tree->getPath($reccord['id_tree'], true);
         $arboTxt = "";
         foreach ($arbo as $elem) {
             if (empty($arboTxt)) {
                 $arboTxt = $elem->title;
             } else {
Exemplo n.º 8
0
 if (isset($_POST['type'])) {
     switch ($_POST['type']) {
         // CASE where DELETING a group
         case "delete_folder":
             $folders_deleted = "";
             // this will delete all sub folders and items associated
             $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
             // Get through each subfolder
             $folders = $tree->getDescendants($_POST['id'], true);
             foreach ($folders as $folder) {
                 //Store the deleted folder (recycled bin)
                 $db->query_insert('misc', array('type' => 'folder_deleted', 'intitule' => "f" . $_POST['id'], 'valeur' => $folder->id . ',' . $folder->parent_id . ',' . $folder->title . ',' . $folder->nleft . ',' . $folder->nright . ',' . $folder->nlevel . ',0,0,0,0'));
                 //delete folder
                 $db->query("DELETE FROM " . $pre . "nested_tree WHERE id = " . $folder->id);
                 //delete items & logs
                 $items = $db->fetch_all_array("SELECT id FROM " . $pre . "items WHERE id_tree='" . $folder->id . "'");
                 foreach ($items as $item) {
                     //Delete item
                     //$db->query("DELETE FROM ".$pre."items WHERE id = ".$item['id']);
                     //$db->query("DELETE FROM ".$pre."log_items WHERE id_item = ".$item['id']);
                     $db->query_update("items", array('inactif' => '1'), "id = " . $item['id']);
                     //log
                     $db->query_insert("log_items", array('id_item' => $item['id'], 'date' => mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('y')), 'id_user' => $_SESSION['user_id'], 'action' => 'at_delete'));
                 }
                 //Actualize the variable
                 $_SESSION['nb_folders']--;
             }
             //rebuild tree
             $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
             $tree->rebuild();
             //Update CACHE table
Exemplo n.º 9
0
<?php

require '../common/database.php';
require '../config/config.php';
$db = new Database($db_host, $db_username, $db_password, $db_name);
$db->connect();
$sql = "SELECT * from " . $TABLE_EYO_MAP . " where status=1";
$map_result = $db->fetch_all_array($sql);
?>
<!DOCTYPE html>
<html>
	<head>
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
	<meta charset="utf-8">
	<title>Eyo Map Plugin</title>
	<meta name="description" content="A demo of maps with multiple markers and infowindow" />
	<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
	<style>
html, body, #map-canvas {
	height: 100%;
	margin: 0px;
	padding: 0px
}
</style>
	<script type="text/javascript">

var LocationData = [
	<?php 
foreach ($map_result as $map) {
    ?>
	[<?php 
Exemplo n.º 10
0
     #-------------------------------------------
     #CASE refresh the matrix
 #-------------------------------------------
 #CASE refresh the matrix
 case "rafraichir_matrice":
     echo 'document.getElementById(\'matrice_droits\').innerHTML = "";';
     require_once "NestedTree.class.php";
     $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
     $tree = $tree->getDescendants();
     $texte = '<table><thead><tr><th>' . $txt['group'] . 's</th>';
     $gpes_ok = array();
     $gpes_nok = array();
     $tab_fonctions = array();
     $arrRoles = array();
     //Display table header
     $rows = $db->fetch_all_array("SELECT title,id FROM " . $pre . "roles_title ORDER BY title ASC");
     foreach ($rows as $reccord) {
         $texte .= '<th style="font-size:10px;" class="edit_role">' . $reccord['title'] . '<br><img src=\'includes/images/ui-tab--pencil.png\' onclick=\'edit_this_role(' . $reccord['id'] . ',"' . $reccord['title'] . '")\' style=\'cursor:pointer;\' \\>&nbsp;<img src=\'includes/images/ui-tab--minus.png\' onclick=\'delete_this_role(' . $reccord['id'] . ',"' . $reccord['title'] . '")\' style=\'cursor:pointer;\' \\></th>';
         array_push($arrRoles, $reccord['id']);
     }
     $texte .= '</tr></thead><tbody>';
     //Display each folder with associated rights by role
     $i = 0;
     foreach ($tree as $node) {
         if (in_array($node->id, $_SESSION['groupes_visibles']) && !in_array($node->id, $_SESSION['personal_visible_groups'])) {
             $ident = "";
             for ($a = 1; $a < $node->nlevel; $a++) {
                 $ident .= "&nbsp;&nbsp;";
             }
             //display 1st cell of the line
             $texte .= '<tr><td style="font-size:10px; font-family:arial;">' . $ident . $node->title . '</td>';
Exemplo n.º 11
0
 case "admin":
     $db->query_update("users", array('admin' => $_POST['value']), "id = " . $_POST['id']);
     break;
     ## UPDATE PERSONNAL FOLDER FOR USER ##
 ## UPDATE PERSONNAL FOLDER FOR USER ##
 case "personal_folder":
     $db->query_update("users", array('personal_folder' => $_POST['value']), "id = " . $_POST['id']);
     break;
     //CHANGE USER FUNCTIONS
 //CHANGE USER FUNCTIONS
 case "open_div_functions":
     $text = "";
     //Refresh list of existing functions
     $data_user = $db->fetch_row("SELECT fonction_id FROM " . $pre . "users WHERE id = " . $_POST['id']);
     $users_functions = explode(';', $data_user[0]);
     $rows = $db->fetch_all_array("SELECT id,title FROM " . $pre . "roles_title");
     foreach ($rows as $reccord) {
         $text .= '<input type=\\"checkbox\\" id=\\"cb_change_function-' . $reccord['id'] . '\\"';
         if (in_array($reccord['id'], $users_functions)) {
             $text .= ' checked';
         }
         $text .= '>&nbsp;' . $reccord['title'] . '<br />';
     }
     //update page
     echo 'document.getElementById("change_user_functions_list").innerHTML = "' . $text . '";';
     echo 'document.getElementById("selected_user").value = "' . $_POST['id'] . '";';
     //display dialogbox
     echo '$("#change_user_functions").dialog("open");';
     echo '$("#div_loading").hide()';
     //hide loading div
     break;
Exemplo n.º 12
0
/**
 * The plugin control panel, you can manage the plugins activity in this page.
 */
include_once 'phphooks.class.php';
include_once 'includes/database.class.php';
require_once 'config.php';
$db = new Database($mysql_db_host, $mysql_db_user, $mysql_db_passwd, $mysql_db_name, $table_prefix);
$db->connect();
switch ($_GET['action']) {
    case "deactivate":
        $data['action'] = 0;
        $db->query_update("plugins", $data, "filename='" . $_GET['filename'] . "'");
        break;
    case "activate":
        $sql = "SELECT * FROM " . $table_prefix . "plugins WHERE filename = '" . $db->escape($_GET['filename']) . "'";
        $count = count($db->fetch_all_array($sql));
        if ($count < 1) {
            $data['filename'] = $_GET['filename'];
            $data['action'] = 1;
            $db->query_insert("plugins", $data);
        } else {
            $data['action'] = 1;
            $db->query_update("plugins", $data, "filename='" . $_GET['filename'] . "'");
        }
        break;
}
$sql = "SELECT filename, action FROM " . $table_prefix . "plugins WHERE action = '" . $db->escape(1) . "'";
$result_rows = $db->fetch_all_array($sql);
$plugin_list = new phphooks();
$plugin_headers = $plugin_list->get_plugins_header();
?>
Exemplo n.º 13
0
 include '../includes/libraries/fpdf/pdf.fonctions.php';
 $pdf = new FPDF();
 $pdf->AliasNbPages();
 $pdf->AddPage();
 $pdf->SetFont('Arial', 'B', 16);
 $pdf->Cell(0, 10, $txt['pdf_del_title'], 0, 1, 'C', false);
 $pdf->SetFont('Arial', 'I', 12);
 $pdf->Cell(0, 10, $txt['pdf_del_date'] . date($_SESSION['settings']['date_format'] . " " . $_SESSION['settings']['time_format'], mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"))), 0, 1, 'C', false);
 $pdf->SetFont('Arial', 'B', 10);
 $pdf->SetFillColor(15, 86, 145);
 $pdf->cell(80, 6, $txt['label'], 1, 0, "C", 1);
 $pdf->cell(75, 6, $txt['group'], 1, 0, "C", 1);
 $pdf->cell(21, 6, $txt['date'], 1, 0, "C", 1);
 $pdf->cell(15, 6, $txt['author'], 1, 1, "C", 1);
 $pdf->SetFont('Arial', '', 10);
 $rows = $db->fetch_all_array("\r\n            SELECT u.login AS login, i.label AS label, i.id_tree AS id_tree \r\n            FROM " . $pre . "log_items AS l \r\n            INNER JOIN " . $pre . "users AS u ON (u.id=l.id_user) \r\n            INNER JOIN " . $pre . "items AS i ON (i.id=l.id_item) \r\n            WHERE l.action = 'Modification' \r\n            AND l.raison = 'Mot de passe changé'\r\n        ");
 foreach ($rows as $reccord) {
     if (date($_SESSION['settings']['date_format'], $reccord['date']) == $_POST['date']) {
         //information about the pw creator
         $res_user = mysql_query("SELECT login FROM " . $pre . "users WHERE id = '" . $reccord['id_user'] . "'");
         $data_user = mysql_fetch_row($res_user);
         //information about the pw itself
         $res_item = mysql_query("SELECT label, id_tree FROM " . $pre . "items WHERE id = '" . $reccord['id_item'] . "'");
         $data_item = mysql_fetch_row($res_item);
         //get the tree grid
         $arbo = $tree->getPath($reccord['id_tree'], true);
         $arboTxt = "";
         foreach ($arbo as $elem) {
             if (empty($arboTxt)) {
                 $arboTxt = $elem->title;
             } else {
Exemplo n.º 14
0
 $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
 if (strlen($app_token) <= 0) {
     echo '<html>';
     echo '<body>';
     echo 'App token is required.';
     echo '</body>';
     echo '</html>';
     exit(0);
 }
 $app = null;
 $app_files = null;
 $db->connect();
 $tokens = $db->query_first("SELECT appid FROM app_tokens WHERE token = '{$app_token}'");
 if ($tokens && isset($tokens["appid"])) {
     $app_id = $tokens["appid"];
     $user_app = $db->fetch_all_array("SELECT * FROM user_app WHERE privacy = 'private' AND appid = {$app_id}");
     if ($user_app && count($user_app)) {
         if (!$user_token) {
             // not authorized error
             $error = array("senchafiddle" => array("error" => "Unauthorized access. User token is required."));
             echo json_encode($error);
             $db->close();
             exit(0);
         }
         //take uid from token
         $user = $db->query_first("SELECT uid FROM user_tokens WHERE token = '{$user_token}'");
         if (!$user || !isset($user["uid"])) {
             // not authorized error
             $error = array("senchafiddle" => array("error" => "Unauthorized access. User token is invalid."));
             echo json_encode($error);
             $db->close();
Exemplo n.º 15
0
 }
 //ADD item
 $new_id = $db->query_insert('items', array('label' => stripslashes($_POST['label']), 'description' => addslashes($_POST['desc']), 'pw' => $pw, 'url' => mysql_real_escape_string(stripslashes($_POST['url'])), 'id_tree' => $_POST['categorie'], 'login' => stripslashes($_POST['login']), 'inactif' => '0', 'restricted_to' => $resticted_to, 'perso' => $_POST['salt_key_set'] == 1 && isset($_POST['salt_key_set']) && $_POST['if_pf'] == 1 && isset($_POST['if_pf']) ? '1' : '0', 'anyone_can_modify' => $_POST['anyone_can_modify'] == "on" ? '1' : '0'));
 //log
 $db->query_insert('log_items', array('id_item' => $new_id, 'date' => mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('y')), 'id_user' => $_SESSION['user_id'], 'action' => 'at_creation'));
 //Add tags
 $tags = explode(' ', $_POST['tags']);
 foreach ($tags as $tag) {
     if (!empty($tag)) {
         $db->query_insert('tags', array('item_id' => $new_id, 'tag' => strtolower($tag)));
     }
 }
 // Check if any files have been added
 if (!empty($_POST['random_id_from_files'])) {
     $sql = "SELECT id\r\n                            FROM " . $pre . "files\r\n                            WHERE id_item=" . $_POST['random_id_from_files'];
     $rows = $db->fetch_all_array($sql);
     foreach ($rows as $reccord) {
         //update item_id in files table
         $db->query_update('files', array('id_item' => $new_id), "id='" . $reccord['id'] . "'");
     }
 }
 //Update CACHE table
 UpdateCacheTable("add_value", $new_id);
 //Announce by email?
 if ($_POST['annonce'] == 1) {
     require_once "class.phpmailer.php";
     //envoyer email
     $destinataire = explode(';', $_POST['diffusion']);
     foreach ($destinataire as $mail_destinataire) {
         //envoyer ay destinataire
         $mail = new PHPMailer();
Exemplo n.º 16
0
                }
                //delete all associated items to this KB
                $db->query_delete("kb_items", array('kb_id' => $new_id));
                //add all items associated to this KB
                foreach (explode(',', $kb_associated_to) as $item_id) {
                    $db->query_insert("kb_items", array('kb_id' => $new_id, 'item_id' => $item_id));
                }
                echo '[ { "status" : "done" } ]';
            } else {
                echo '[ { "status" : "none" } ]';
            }
            break;
        case "open_kb":
            $row = $db->query("SELECT k.id AS id, k.label AS label, k.description AS description, k.category_id AS category_id, k.author_id AS author_id, k.anyone_can_modify AS anyone_can_modify,\r\n\t\t\t\t\t\t\tu.login AS login, c.category AS category\r\n\t\t\t\t\t\t\tFROM " . $pre . "kb AS k\r\n\t\t\t\t\t\t\tINNER JOIN " . $pre . "kb_categories AS c ON (c.id = k.category_id)\r\n\t\t\t\t\t\t\tINNER JOIN " . $pre . "users AS u ON (u.id = k.author_id)\r\n\t\t\t\t\t\t\tWHERE k.id = '" . $_POST['id'] . "'\r\n\t\t\t");
            $ret = $db->fetch_array($row);
            //select associated items
            $rows = $db->fetch_all_array("SELECT item_id\r\n                            FROM " . $pre . "kb_items\r\n                            WHERE kb_id = '" . $_POST['id'] . "'\r\n            ");
            $arrOptions = array();
            foreach ($rows as $reccord) {
                //echo '$("#kb_associated_to option[value='.$reccord['item_id'].']").attr("selected","selected");';
                array_push($arrOptions, $reccord['item_id']);
            }
            $arrOutput = array("label" => $ret['label'], "category" => $ret['category'], "description" => $ret['description'], "anyone_can_modify" => $ret['anyone_can_modify'], "options" => $arrOptions);
            echo json_encode($arrOutput, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
            break;
        case "delete_kb":
            $db->query_delete("kb", array('id' => $_POST['id']));
            //echo 'oTable = $("#t_kb").dataTable();LoadingPage();oTable.fnDraw();';
            break;
    }
}
Exemplo n.º 17
0
 public function allXtype($idT)
 {
     $db = new Database();
     $q = "select * from marker where tipo = {$idT}";
     return $db->fetch_all_array($q);
     $db->close();
 }
Exemplo n.º 18
0
         $error = "connection";
     }
     // Fermeture de la connexion et du pointeur de fichier
     ftp_close($conn_id);
     fclose($handle);
     //DELETE FILE
     unlink($local_file);
     echo '[{"error":"' . $error . '" , "output":"' . $text . '"}]';
     break;
     ###########################################################
     #CASE for refreshing all Personal Folders
 ###########################################################
 #CASE for refreshing all Personal Folders
 case "admin_action_check_pf":
     //get through all users
     $rows = $db->fetch_all_array("SELECT id,login,email FROM " . $pre . "users ORDER BY login ASC");
     foreach ($rows as $record) {
         //update PF field for user
         $db->query_update('users', array('personal_folder' => '1'), "id='" . $record['id'] . "'");
         //if folder doesn't exist then create it
         $data = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "nested_tree WHERE title = '" . $record['id'] . "' AND parent_id = 0");
         if ($data[0] == 0) {
             //If not exist then add it
             $db->query_insert("nested_tree", array('parent_id' => '0', 'title' => $record['id'], 'personal_folder' => '1'));
         } else {
             //If exists then update it
             $db->query_update('nested_tree', array('personal_folder' => '1'), array("title" => $record['id'], 'parent_id' => '0'));
         }
     }
     //Delete PF for deleted users
     $db->query("\r\n\t\t\tDELETE " . $pre . "nested_tree\r\n    \t\tFROM " . $pre . "nested_tree\r\n    \t\tLEFT JOIN " . $pre . "users\r\n    \t\tON " . $pre . "nested_tree.title = " . $pre . "users.id\r\n    \t\tWHERE " . $pre . "users.id IS NULL  AND " . $pre . "nested_tree.parent_id=0 AND " . $pre . "nested_tree.title REGEXP ('[0-9]')\r\n    \t");
Exemplo n.º 19
0
function CPMStats()
{
    global $server, $user, $pass, $database, $pre;
    require_once 'includes/settings.php';
    // connect to the server
    require_once "class.database.php";
    $db = new Database($server, $user, $pass, $database, $pre);
    $db->connect();
    // Prepare stats to be sent
    // Count no FOLDERS
    $data_folders = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "nested_tree");
    // Count no USERS
    $data_users = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "users");
    // Count no ITEMS
    $data_items = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "items");
    // Get info about installation
    $data_system = array();
    $rows = $db->fetch_all_array("SELECT valeur,intitule FROM " . $pre . "misc WHERE type = 'admin' AND intitule IN ('enable_pf_feature','log_connections','cpassman_version')");
    foreach ($rows as $reccord) {
        if ($reccord['intitule'] == 'enable_pf_feature') {
            $data_system['enable_pf_feature'] = $reccord['valeur'];
        } else {
            if ($reccord['intitule'] == 'cpassman_version') {
                $data_system['cpassman_version'] = $reccord['valeur'];
            } else {
                if ($reccord['intitule'] == 'log_connections') {
                    $data_system['log_connections'] = $reccord['valeur'];
                }
            }
        }
    }
    // Get the actual stats.
    $stats_to_send = array('uid' => md5(SALT), 'time_added' => time(), 'users' => $data_users[0], 'folders' => $data_folders[0], 'items' => $data_items[0], 'cpm_version' => $data_system['cpassman_version'], 'enable_pf_feature' => $data_system['enable_pf_feature'], 'log_connections' => $data_system['log_connections']);
    // Encode all the data, for security.
    foreach ($stats_to_send as $k => $v) {
        $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
    }
    // Turn this into the query string!
    $stats_to_send = implode('&', $stats_to_send);
    fopen("http://www.vag-technique.fr/divers/cpm_stats/collect_stats.php?" . $stats_to_send, 'r');
    // update the actual time
    $db->query_update("misc", array('valeur' => time()), "type='admin' AND intitule = 'send_stats_time'");
}
Exemplo n.º 20
0
     $_SESSION['groupes_interdits'] = @implode(';', $data['groupes_interdits']);
 } else {
     $_SESSION['groupes_interdits'] = array();
 }
 //User's roles
 $_SESSION['fonction_id'] = $data['fonction_id'];
 $_SESSION['user_roles'] = explode(";", $data['fonction_id']);
 //build array of roles
 $_SESSION['arr_roles'] = array();
 foreach (array_filter(explode(';', $_SESSION['fonction_id'])) as $role) {
     $res_roles = $db->query_first("SELECT title FROM " . $pre . "roles_title WHERE id = " . $role);
     $_SESSION['arr_roles'][$role] = array('id' => $role, 'title' => $res_roles['title']);
 }
 //build complete array of roles
 $_SESSION['arr_roles_full'] = array();
 $rows = $db->fetch_all_array("\r\n\t\t\t\t\t\t\t\tSELECT id, title\r\n\t\t\t\t\t\t\t\tFROM " . $pre . "roles_title A\r\n\t\t\t\t\t\t\t\tORDER BY title ASC");
 foreach ($rows as $reccord) {
     $_SESSION['arr_roles_full'][$reccord['id']] = array('id' => $reccord['id'], 'title' => $reccord['title']);
 }
 //Set some settings
 $_SESSION['user']['find_cookie'] = false;
 $_SESSION['settings']['update_needed'] = "";
 // Update table
 $db->query_update("users", array('key_tempo' => $_SESSION['key'], 'last_connexion' => mktime(date("h"), date("i"), date("s"), date("m"), date("d"), date("Y")), 'timestamp' => mktime(date("h"), date("i"), date("s"), date("m"), date("d"), date("Y")), 'disabled' => 0, 'no_bad_attempts' => 0), "id=" . $data['id']);
 //Get user's rights
 IdentifyUserRights($data['groupes_visibles'], $_SESSION['groupes_interdits'], $data['admin'], $data['fonction_id'], false);
 //Get some more elements
 $_SESSION['hauteur_ecran'] = $data_received['hauteur_ecran'];
 //Get last seen items
 $_SESSION['latest_items_tab'][] = "";
 foreach ($_SESSION['latest_items'] as $item) {
Exemplo n.º 21
0
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
include '../includes/settings.php';
header("Content-type: text/html; charset=utf-8");
require_once '../includes/libraries/crypt/aes.class.php';
// AES PHP implementation
require_once '../includes/libraries/crypt/aesctr.class.php';
// AES Counter Mode implementation
// connect to the server
require_once "../sources/class.database.php";
$db = new Database($server, $user, $pass, $database, $pre);
$db->connect();
//get backups infos
$rows = $db->fetch_all_array("SELECT * FROM " . $pre . "misc WHERE type = 'settings'");
foreach ($rows as $reccord) {
    $settings[$reccord['intitule']] = $reccord['valeur'];
}
if (!empty($settings['bck_script_filename']) && !empty($settings['bck_script_path'])) {
    //get all of the tables
    $tables = array();
    $result = mysql_query('SHOW TABLES');
    while ($row = mysql_fetch_row($result)) {
        $tables[] = $row[0];
    }
    $return = "";
    //cycle through each table and format the data
    foreach ($tables as $table) {
        $result = mysql_query('SELECT * FROM ' . $table);
        $num_fields = mysql_num_fields($result);
Exemplo n.º 22
0
 public function allEventTypes()
 {
     $db = new Database();
     $q = "select id,nombre from tipoE";
     return $db->fetch_all_array($q);
     $db->close();
 }
Exemplo n.º 23
0
 if ($_POST['action'] == "delete") {
     //delete user in database
     $db->query_delete('users', array('id' => $_POST['id']));
     //delete personal folder and subfolders
     require_once "NestedTree.class.php";
     $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
     //Get personal folder ID
     $data = $db->fetch_row("SELECT id FROM " . $pre . "nested_tree WHERE title = '" . $_POST['id'] . "' AND personal_folder = 1");
     // Get through each subfolder
     if (!empty($data[0])) {
         $folders = $tree->getDescendants($data[0], true);
         foreach ($folders as $folder) {
             //delete folder
             $db->query("DELETE FROM " . $pre . "nested_tree WHERE id = '" . $folder->id . "' AND personal_folder = 1");
             //delete items & logs
             $items = $db->fetch_all_array("SELECT id FROM " . $pre . "items WHERE id_tree='" . $folder->id . "' AND perso = 1");
             foreach ($items as $item) {
                 //Delete item
                 $db->query("DELETE FROM " . $pre . "items WHERE id = " . $item['id']);
                 //log
                 $db->query("DELETE FROM " . $pre . "log_items WHERE id_item = " . $item['id']);
             }
         }
         //rebuild tree
         $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
         $tree->rebuild();
     }
 } else {
     //lock user in database
     $db->query_update('users', array('disabled' => 1, 'key_tempo' => ""), "id=" . $_POST['id']);
 }
Exemplo n.º 24
0
         $db->query_insert('restriction_to_roles', array('role_id' => $role, 'item_id' => $new_id));
     }
 }
 //log
 $db->query_insert('log_items', array('id_item' => $new_id, 'date' => mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('y')), 'id_user' => $_SESSION['user_id'], 'action' => 'at_creation'));
 //Add tags
 $tags = explode(' ', $tags);
 foreach ($tags as $tag) {
     if (!empty($tag)) {
         $db->query_insert('tags', array('item_id' => $new_id, 'tag' => strtolower($tag)));
     }
 }
 // Check if any files have been added
 if (!empty($data_received['random_id_from_files'])) {
     $sql = "SELECT id\r\n\t\t                        FROM " . $pre . "files\r\n\t\t                        WHERE id_item=" . $data_received['random_id_from_files'];
     $rows = $db->fetch_all_array($sql);
     foreach ($rows as $reccord) {
         //update item_id in files table
         $db->query_update('files', array('id_item' => $new_id), "id='" . $reccord['id'] . "'");
     }
 }
 //Update CACHE table
 UpdateCacheTable("add_value", $new_id);
 //Announce by email?
 if ($data_received['annonce'] == 1) {
     require_once "class.phpmailer.php";
     //envoyer email
     $destinataire = explode(';', $data_received['diffusion']);
     foreach ($destinataire as $mail_destinataire) {
         //envoyer ay destinataire
         $mail = new PHPMailer();
Exemplo n.º 25
0
     $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
     $tree->rebuild();
 } else {
     if (isset($_POST['type'])) {
         switch ($_POST['type']) {
             // CASE where DELETING a group
             case "supprimer_groupe":
                 // this will delete all sub folders and items associated
                 $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
                 // Get through each subfolder
                 $folders = $tree->getDescendants($_POST['id'], true);
                 foreach ($folders as $folder) {
                     //delete folder
                     $db->query("DELETE FROM " . $pre . "nested_tree WHERE id = " . $folder->id);
                     //delete items & logs
                     $items = $db->fetch_all_array("SELECT id FROM " . $pre . "items WHERE id_tree='" . $folder->id . "'");
                     foreach ($items as $item) {
                         //Delete item
                         $db->query("DELETE FROM " . $pre . "items WHERE id = " . $item['id']);
                         //log
                         $db->query("DELETE FROM " . $pre . "log_items WHERE id_item = " . $item['id']);
                     }
                 }
                 //rebuild tree
                 $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
                 $tree->rebuild();
                 //Actualize the variable
                 $_SESSION['nb_folders']--;
                 //Refresh the page
                 echo 'RefreshPage("form_groupes");';
                 break;
Exemplo n.º 26
0
 $display_nb = 8;
 //count nb of roles
 $roles_count = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "roles_title");
 if ($roles_count > $display_nb) {
     if (!isset($_POST['start']) || $_POST['start'] == 0) {
         $start = 0;
         $previous = 0;
     } else {
         $start = intval($_POST['start']);
         $previous = $start - $display_nb;
     }
     $sql_limit = " LIMIT {$start}, {$display_nb}";
     $next = $start + $display_nb;
 }
 //Display table header
 $rows = $db->fetch_all_array("\r\n\t\t\t\tSELECT id, title, allow_pw_change\r\n\t\t\t\tFROM " . $pre . "roles_title\r\n\t\t\t\tORDER BY title ASC" . $sql_limit);
 foreach ($rows as $reccord) {
     if ($reccord['allow_pw_change'] == 1) {
         $allow_pw_change = '&nbsp;<img id=\'img_apcfr_' . $reccord['id'] . '\' src=\'includes/images/ui-text-field-password-green.png\' onclick=\'allow_pw_change_for_role(' . $reccord['id'] . ', 0)\' style=\'cursor:pointer;\' title=\'' . $txt['role_cannot_modify_all_seen_items'] . '\'>';
     } else {
         $allow_pw_change = '&nbsp;<img id=\'img_apcfr_' . $reccord['id'] . '\' src=\'includes/images/ui-text-field-password-red.png\' onclick=\'allow_pw_change_for_role(' . $reccord['id'] . ', 1)\' style=\'cursor:pointer;\' title=\'' . $txt['role_can_modify_all_seen_items'] . '\'>';
     }
     $texte .= '<th style=\'font-size:10px;min-width:60px;\' class=\'edit_role\'>' . $reccord['title'] . '<br><img src=\'includes/images/ui-tab--pencil.png\' onclick=\'edit_this_role(' . $reccord['id'] . ',"' . htmlentities($reccord['title'], ENT_QUOTES) . '")\' style=\'cursor:pointer;\'>&nbsp;<img src=\'includes/images/ui-tab--minus.png\' style=\'cursor:pointer;\' onclick=\'delete_this_role(' . $reccord['id'] . ',"' . htmlentities($reccord['title'], ENT_QUOTES) . '")\'>' . $allow_pw_change . '</th>';
     array_push($arrRoles, $reccord['id']);
 }
 $texte .= '</tr></thead><tbody>';
 //Display each folder with associated rights by role
 $i = 0;
 foreach ($tree as $node) {
     if (in_array($node->id, $_SESSION['groupes_visibles']) && !in_array($node->id, $_SESSION['personal_visible_groups'])) {
         $ident = "";
Exemplo n.º 27
0
global $k, $settings;
include '../includes/settings.php';
header("Content-type: text/html; charset==utf-8");
require_once "class.database.php";
$db = new Database($server, $user, $pass, $database, $pre);
$db->connect();
//Columns name
$aColumns = array('id', 'label', 'description', 'tags', 'id_tree', 'folder', 'login');
//init SQL variables
$sOrder = $sLimit = "";
$sWhere = "id_tree IN(" . implode(',', $_SESSION['groupes_visibles']) . ")";
//limit search to the visible folders
//get list of personal folders
$array_pf = array();
$list_pf = "";
$rows = $db->fetch_all_array("SELECT id FROM " . $pre . "nested_tree WHERE personal_folder=1 AND NOT title = " . $_SESSION['user_id']);
foreach ($rows as $reccord) {
    if (!in_array($reccord['id'], $array_pf)) {
        //build an array of personal folders ids
        array_push($array_pf, $reccord['id']);
        //build also a string with those ids
        if (empty($list_pf)) {
            $list_pf = $reccord['id'];
        } else {
            $list_pf .= ',' . $reccord['id'];
        }
    }
}
/* BUILD QUERY */
//Paging
$sLimit = "";
Exemplo n.º 28
0
<?php

if (isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    include_once '../Database.php';
    //$host, $user, $pass, $name
    $db = new Database("pdb10.runhosting.com", "998905_mx", "mxmichigan1234", "998905_mx");
    $q = "SELECT * FROM users WHERE username = '******' AND password = '******'";
    $r = $db->query($q);
    $results = $db->fetch_all_array($q);
    if (count($results) == 1) {
        if (isset($_SESSION['mxmichigan'])) {
            session_unset();
            session_destroy();
        }
        include_once 'session.php';
        $_SESSION['mxmichigan']['username'] = $results[0]['username'];
        $_SESSION['mxmichigan']['type'] = $results[0]['type'];
        $_SESSION['mxmichigan']['AUTH'] = "true";
        if ($_SESSION['mxmichigan']['type'] == 1) {
            header("Location: ../../admin/dashboard.php");
        } else {
            if ($_SESSION['mxmichigan']['type'] == 1) {
                header("Location: ../../my/account");
            }
        }
        print_r($results);
        print_r($_SESSION['mxmichigan']);
        //header("Location: dashboard.php");
    } else {
Exemplo n.º 29
0
    {
        return $this->mymenu;
    }
}
$menu = new menu();
include "../config.php";
//include PHP HOOKS Class
include_once "engine/phphooks.class.php";
//create instance of class
$hook = new Phphooks();
//fetch the active plugins name form db. store in array $plugins.
include_once 'engine/database.class.php';
$db = new Database($hostname, $usename, $password, $database, '');
$db->connect();
$sql = "SELECT filename FROM Plugins WHERE action = '" . $db->escape(1) . "'";
$result_rows = $db->fetch_all_array($sql);
foreach ($result_rows as $result_rows) {
    $plugins[] = $result_rows['filename'];
}
//unset means load all plugins in the plugin fold. set it, just load the plugins in this array.
$hook->active_plugins = $plugins;
//set hook to which plugin developers can assign functions
$hook->set_hook('test');
//load plugins from folder, if no argument is supplied, a 'plugins/' constant will be used
//trailing slash at the end is REQUIRED!
//this method will load all *.plugin.php files from given directory, INCLUDING subdirectories
$hook->load_plugins();
//now, this is a workaround because plugins, when included, can't access $hook variable, so we
//as developers have to basically redefine functions which can be called from plugin files
function add_hook($tag, $function, $priority = 10)
{
Exemplo n.º 30
0
 public function allFriendNotifications()
 {
     $db = new Database();
     //Trae las notificaciones de idJ2 que sean de amistad
     $q = "select n.id as id, n.idJ as j1, jn.idJ as j2, j.nombre as jugador, j.foto as Imagen, n.idTN as tipo from notificacion n \n\t\t\t\tinner join jugadorNotificacion jn on (n.id = jn.idN)\n\t\t\t\tinner join jugador j on (n.idJ = j.id)\n\t\t\t\twhere jn.idJ = {$this->idJ2} \n\t\t\t\tand n.idTN in (1,2)\n\t\t\t\torder by jn.visto, n.fecha limit 10";
     $r = $db->query($q);
     if ($db->num_rows($r) > 0) {
         return $db->fetch_all_array($q);
     } else {
         return 0;
     }
     $db->close();
 }