本文整理汇总了PHP中prefix_table函数的典型用法代码示例。如果您正苦于以下问题:PHP prefix_table函数的具体用法?PHP prefix_table怎么用?PHP prefix_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prefix_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSettings
function updateSettings($setting, $val, $type = '')
{
global $server, $user, $pass, $database, $pre, $port, $encoding;
if (empty($type)) {
$type = 'admin';
}
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/main.functions.php';
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/SplClassLoader.php';
// Connect to database
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$encoding = $encoding;
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
// Check if setting is already in DB. If NO then insert, if YES then update.
$data = DB::query("SELECT * FROM " . prefix_table("misc") . "\n WHERE type = %s AND intitule = %s", $type, $setting);
$counter = DB::count();
if ($counter == 0) {
DB::insert(prefix_table("misc"), array('valeur' => $val, 'type' => $type, 'intitule' => $setting));
// in case of stats enabled, add the actual time
if ($setting == 'send_stats') {
DB::insert(prefix_table("misc"), array('valeur' => time(), 'type' => $type, 'intitule' => $setting . '_time'));
}
} else {
DB::update(prefix_table("misc"), array('valeur' => $val), "type = %s AND intitule = %s", $type, $setting);
// in case of stats enabled, update the actual time
if ($setting == 'send_stats') {
// Check if previous time exists, if not them insert this value in DB
$data_time = DB::query("SELECT * FROM " . prefix_table("misc") . "\n WHERE type = %s AND intitule = %s", $type, $setting . '_time');
$counter = DB::count();
if ($counter == 0) {
DB::insert(prefix_table("misc"), array('valeur' => 0, 'type' => $type, 'intitule' => $setting . '_time'));
} else {
DB::update(prefix_table("misc"), array('valeur' => 0), "type = %s AND intitule = %s", $type, $setting);
}
}
}
$_SESSION['settings'][$setting] = $val;
}
示例2: checkUser
function checkUser($userId, $userKey, $pageVisited)
{
global $pagesRights;
if (empty($userId) || empty($pageVisited) || empty($userKey)) {
return false;
}
if (!is_array($pageVisited)) {
$pageVisited = array($pageVisited);
}
include $_SESSION['settings']['cpassman_dir'] . '/includes/settings.php';
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/language/' . $_SESSION['user_language'] . '.php';
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/SplClassLoader.php';
require_once 'main.functions.php';
// Connect to mysql server
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$encoding = $encoding;
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
// load user's data
$data = DB::queryfirstrow("SELECT login, key_tempo, admin, gestionnaire FROM " . prefix_table("users") . " WHERE id = %i", $userId);
// check if user exists and tempo key is coherant
if (empty($data['login']) || empty($data['key_tempo']) || $data['key_tempo'] != $userKey) {
return false;
}
// check if user is allowed to see this page
if (empty($data['admin']) && empty($data['gestionnaire']) && !IsInArray($pageVisited, $pagesRights['user'])) {
return false;
} else {
if (empty($data['admin']) && !empty($data['gestionnaire']) && !IsInArray($pageVisited, $pagesRights['manager'])) {
return false;
} else {
if (!empty($data['admin']) && !IsInArray($pageVisited, $pagesRights['admin'])) {
return false;
}
}
}
return true;
}
示例3: array
<input type="radio" id="modify_kb_no" name="modify_kb" value="0" /><label for="modify_kb_no">' . $LANG['no'] . '</label>
</span>
</div>
</div>
<div style="float:left;width:100%;">
<label for="kb_description" class="label">' . $LANG['description'] . '</label>
<textarea rows="5" name="kb_description" id="kb_description" class="input"></textarea>
</div>
<div style="float:left;width:100%;margin-top:15px;">
<label for="kb_associated_to" class="label">' . $LANG['associate_kb_to_items'] . '</label>
<select id="kb_associated_to" class="multiselect" multiple="multiple" name="kb_associated_to[]" style="width: 860px; height: 150px;">';
//get list of available items
$items_id_list = array();
$rows = DB::query("SELECT i.id as id, i.restricted_to as restricted_to, i.perso as perso, i.label as label, i.description as description, i.pw as pw, i.login as login, i.anyone_can_modify as anyone_can_modify,\n l.date as date,\n n.renewal_period as renewal_period\n FROM " . prefix_table("items") . " as i\n INNER JOIN " . prefix_table("nested_tree") . " as n ON (i.id_tree = n.id)\n INNER JOIN " . prefix_table("log_items") . " as l ON (i.id = l.id_item)\n WHERE i.inactif = %i\n AND (l.action = %s OR (l.action = %s AND l.raison LIKE %s))\n ORDER BY i.label ASC, l.date DESC", '0', 'at_creation', 'at_modification', 'at_pw :%');
foreach ($rows as $reccord) {
if (!in_array($reccord['id'], $items_id_list) && !empty($reccord['label'])) {
echo '
<option value="' . $reccord['id'] . '">' . $reccord['label'] . '</option>';
array_push($items_id_list, $reccord['id']);
}
}
echo '
</select>
</div>
</div>';
//DELETE DIALOG
echo '
<div id="div_kb_delete" style="display:none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"> </span>' . $LANG['confirm_deletion'] . '</p>
示例4: mysqli_connect
DB::$encoding = $encoding;
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
// check session validity
$data = DB::queryfirstrow("SELECT timestamp, code, item_id FROM " . prefix_table("otv") . "\n WHERE id = %i", intval($_GET['otv_id']));
if ($data['timestamp'] == $_GET['stamp'] && $data['code'] == $_GET['code'] && $data['item_id'] == $_GET['item_id']) {
// otv is too old
if ($data['timestamp'] < time() - $_SESSION['settings']['otv_expiration_period'] * 86400) {
$html = "Link is too old!";
} else {
$dataItem = DB::queryfirstrow("SELECT *\n FROM " . prefix_table("items") . " as i\n INNER JOIN " . prefix_table("log_items") . " as l ON (l.id_item = i.id)\n WHERE i.id = %i AND l.action = %s", intval($_GET['item_id']), 'at_creation');
// get data
$pw = cryption($dataItem['pw'], SALT, $dataItem['pw_iv'], "decrypt");
// get key for original pw
$originalKey = DB::queryfirstrow("SELECT rand_key FROM `" . prefix_table("keys") . "`\n WHERE `sql_table` = %s AND `id` = %i", 'items', intval($_GET['item_id']));
// unsalt previous pw
$pw = substr($pw, strlen($originalKey['rand_key']));
$label = $dataItem['label'];
$email = $dataItem['email'];
$url = $dataItem['url'];
$description = preg_replace('/(?<!\\r)\\n+(?!\\r)/', '', strip_tags($dataItem['description'], $k['allowedTags']));
$login = str_replace('"', '"', $dataItem['login']);
// display data
$html = "<div style='margin:30px;'>" . "<div style='font-size:20px;font-weight:bold;'>Welcome to One-Time item view page.</div>" . "<div style='font-style:italic;'>Here are the details of the Item that has been shared to you</div>" . "<div style='margin-top:10px;'><table>" . "<tr><td>Label:</td><td>" . $label . "</td</tr>" . "<tr><td>Password:</td><td>" . $pw . "</td</tr>" . "<tr><td>Description:</td><td>" . $description . "</td</tr>" . "<tr><td>login:</td><td>" . $login . "</td</tr>" . "<tr><td>URL:</td><td>" . $url . "</td</tr>" . "</table></div>" . "<div style='margin-top:30px;'>Copy carefully the data you need. This page is only visible once.</div>" . "</div>";
// delete entry
//DB::delete(prefix_table("otv"), "id = %i", intval($_GET['otv_id']));
// display
echo $html;
}
} else {
示例5: mysqli_connect
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
//load main functions needed
require_once 'sources/main.functions.php';
// Load CORE
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/core.php';
/* DEFINE WHAT LANGUAGE TO USE */
if (!isset($_SESSION['user_id']) && isset($_GET['language'])) {
// case of user has change language in the login page
$dataLanguage = DB::queryFirstRow("SELECT flag, name\n FROM " . prefix_table("languages") . "\n WHERE name = %s", $_GET['language']);
$_SESSION['user_language'] = $dataLanguage['name'];
$_SESSION['user_language_flag'] = $dataLanguage['flag'];
} elseif (!isset($_SESSION['user_id']) && !isset($_POST['language']) && !isset($_SESSION['user_language'])) {
//get default language
$dataLanguage = DB::queryFirstRow("SELECT m.valeur AS valeur, l.flag AS flag\n FROM " . prefix_table("misc") . " AS m\n INNER JOIN " . prefix_table("languages") . " AS l ON (m.valeur = l.name)\n WHERE m.type=%s_type AND m.intitule=%s_intitule", array('type' => "admin", 'intitule' => "default_language"));
if (empty($dataLanguage['valeur'])) {
$_SESSION['user_language'] = "english";
$_SESSION['user_language_flag'] = "us.png";
} else {
$_SESSION['user_language'] = $dataLanguage['valeur'];
$_SESSION['user_language_flag'] = $dataLanguage['flag'];
}
} elseif (isset($_SESSION['settings']['default_language']) && !isset($_SESSION['user_language'])) {
$_SESSION['user_language'] = $_SESSION['settings']['default_language'];
} elseif (isset($_POST['language'])) {
$_SESSION['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING);
} elseif (!isset($_SESSION['user_language']) || empty($_SESSION['user_language'])) {
if (isset($_POST['language'])) {
$_SESSION['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING);
} elseif (isset($_SESSION['settings']['default_language'])) {
示例6: mysqli_connect
} else {
require_once 'main.functions.php';
// connect to DB
include $_SESSION['settings']['cpassman_dir'] . '/includes/config/settings.php';
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$encoding = $encoding;
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
// get file key
$result = DB::queryfirstrow("SELECT file FROM " . prefix_table("files") . " WHERE id=%i", $_GET['fileid']);
// Open the file
$fp = fopen($_SESSION['settings']['path_to_upload_folder'] . '/' . $result['file'], 'rb');
// should we decrypt the attachment?
if (isset($_SESSION['settings']['enable_attachment_encryption']) && $_SESSION['settings']['enable_attachment_encryption'] == 1) {
include $_SESSION['settings']['cpassman_dir'] . '/includes/config/settings.php';
// Prepare encryption options
$iv = substr(md5("<X" . SALT, true), 0, 8);
$key = substr(md5("-üØ" . SALT, true) . md5("-üÙ" . SALT, true), 0, 24);
$opts = array('iv' => $iv, 'key' => $key);
// Add the Mcrypt stream filter
stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts);
}
// Read the file contents
fpassthru($fp);
}
示例7: array
*/
case "user_edit_login":
// Check KEY
if ($_POST['key'] != $_SESSION['key']) {
// error
exit;
}
DB::update(prefix_table("users"), array('login' => $_POST['login'], 'name' => $_POST['name'], 'lastname' => $_POST['lastname']), "id = %i", $_POST['id']);
break;
}
} elseif (!empty($_POST['newValue'])) {
$value = explode('_', $_POST['id']);
DB::update(prefix_table("users"), array($value[0] => $_POST['newValue']), "id = %i", $value[1]);
// update LOG
logEvents('user_mngt', 'at_user_new_' . $value[0] . ':' . $value[1], $_SESSION['user_id'], $_SESSION['login'], $_POST['id']);
// refresh SESSION if requested
if ($value[0] == "treeloadstrategy") {
$_SESSION['user_settings']['treeloadstrategy'] = $_POST['newValue'];
}
// Display info
echo $_POST['newValue'];
} elseif (isset($_POST['newadmin'])) {
$id = explode('_', $_POST['id']);
DB::update(prefix_table("users"), array('admin' => $_POST['newadmin']), "id = %i", $id[1]);
// Display info
if ($_POST['newadmin'] == "1") {
echo "Oui";
} else {
echo "Non";
}
}
示例8: cryption
} else {
$encrypt = cryption($pw, SALT, "", "encrypt");
}
//ADD item
DB::insert(prefix_table("items"), array('label' => stripslashes($item[KP_TITLE]), 'description' => stripslashes(str_replace($lineEndSeparator, '<br />', $item[KP_NOTES])), 'pw' => $encrypt['string'], 'pw_iv' => $encrypt['iv'], 'url' => stripslashes($item[KP_URL]), 'id_tree' => $folderId, 'login' => stripslashes($item[KP_USERNAME]), 'anyone_can_modify' => $_POST['import_kps_anyone_can_modify'] == "true" ? 1 : 0));
$newId = DB::insertId();
//if asked, anyone in role can modify
if (isset($_POST['import_kps_anyone_can_modify_in_role']) && $_POST['import_kps_anyone_can_modify_in_role'] == "true") {
foreach ($_SESSION['arr_roles'] as $role) {
DB::insert(prefix_table("restriction_to_roles"), array('role_id' => $role['id'], 'item_id' => $newId));
}
}
//Add log
DB::insert(prefix_table("log_items"), array('id_item' => $newId, 'date' => time(), 'id_user' => $_SESSION['user_id'], 'action' => 'at_creation', 'raison' => 'at_import'));
//Add entry to cache table
DB::insert(prefix_table("cache"), array('id' => $newId, 'label' => stripslashes($item[KP_TITLE]), 'description' => stripslashes(str_replace($lineEndSeparator, '<br />', $item[KP_NOTES])), 'id_tree' => $folderId, 'perso' => $personalFolder == 0 ? 0 : 1, 'login' => stripslashes($item[KP_USERNAME]), 'folder' => $data['title'], 'author' => $_SESSION['user_id']));
//show
//$text .= '- '.addslashes($item[2]).'<br />';
//increment number of imported items
$nbItemsImported++;
} else {
$results .= " - Skipped\n";
}
}
}
//if no new items them inform
/*if ($nbItemsImported == 0) {
$text .= $LANG['none'].'<br />';
}*/
//SHow finished
$text .= "Folders imported: {$nbFoldersImported}<br />";
示例9: isset
<th title="' . $LANG['gestionnaire'] . '"><img src="includes/images/user-worker.png" /></th>
<th title="' . $LANG['read_only_account'] . '"><img src="includes/images/user_read_only.png" /></th>
<th title="' . $LANG['can_create_root_folder'] . '"><img src="includes/images/folder-network.png" /></th>
', isset($_SESSION['settings']['enable_pf_feature']) && $_SESSION['settings']['enable_pf_feature'] == 1 ? '<th title="' . $LANG['enable_personal_folder'] . '"><img src="includes/images/folder-open-document-text.png" /></th>' : '', '
<th title="' . $LANG['user_action'] . '"><img src="includes/images/user-locked.png" /></th>
<th title="' . $LANG['pw_change'] . '"><img src="includes/images/lock__pencil.png" /></th>
<th title="' . $LANG['email_change'] . '"><img src="includes/images/mail.png" /></th>
<th title="' . $LANG['logs'] . '"><img src="includes/images/log.png" /></th>
', isset($_SESSION['settings']['2factors_authentication']) && $_SESSION['settings']['2factors_authentication'] == 1 ? '<th title="' . $LANG['send_ga_code'] . '"><img src="includes/images/telephone.png" /></th>' : '', '
</tr>
</thead>
<tbody>';
$listAvailableUsers = $listAdmins = "";
$x = 0;
// Get through all users
$rows = DB::query("SELECT * FROM " . prefix_table("users") . " ORDER BY login ASC");
foreach ($rows as $reccord) {
// Get list of allowed functions
$listAlloFcts = "";
if ($reccord['admin'] != 1) {
if (count($rolesList) > 0) {
foreach ($rolesList as $fonction) {
if (in_array($fonction['id'], explode(";", $reccord['fonction_id']))) {
$listAlloFcts .= '<img src="includes/images/arrow-000-small.png" />' . @htmlspecialchars($fonction['title'], ENT_COMPAT, "UTF-8") . '<br />';
}
}
}
if (empty($listAlloFcts)) {
$listAlloFcts = '<img src="includes/images/error.png" title="' . $LANG['user_alarm_no_function'] . '" />';
}
}
示例10: recursiveTree
function recursiveTree($nodeId)
{
global $completTree, $ret_json, $listFoldersLimitedKeys, $listRestrictedFoldersForItemsKeys, $tree, $LANG;
// Be sure that user can only see folders he/she is allowed to
if (!in_array($completTree[$nodeId]->id, $_SESSION['forbiden_pfs']) || in_array($completTree[$nodeId]->id, $_SESSION['groupes_visibles']) || in_array($completTree[$nodeId]->id, $listFoldersLimitedKeys) || in_array($completTree[$nodeId]->id, $listRestrictedFoldersForItemsKeys)) {
$displayThisNode = false;
$hide_node = false;
$nbChildrenItems = 0;
// Check if any allowed folder is part of the descendants of this node
$nodeDescendants = $tree->getDescendants($completTree[$nodeId]->id, true, false, true);
foreach ($nodeDescendants as $node) {
// manage tree counters
if (isset($_SESSION['settings']['tree_counters']) && $_SESSION['settings']['tree_counters'] == 1) {
DB::query("SELECT * FROM " . prefix_table("items") . "\n WHERE inactif=%i AND id_tree = %i", 0, $node);
$nbChildrenItems += DB::count();
}
if (in_array($node, array_merge($_SESSION['groupes_visibles'], $_SESSION['list_restricted_folders_for_items'])) || @in_array($node, $listFoldersLimitedKeys) || @in_array($node, $listRestrictedFoldersForItemsKeys)) {
$displayThisNode = true;
}
}
if ($displayThisNode == true) {
$hide_node = $show_but_block = $eye_icon = false;
$text = $title = "";
// get info about current folder
DB::query("SELECT * FROM " . prefix_table("items") . "\n WHERE inactif=%i AND id_tree = %i", 0, $completTree[$nodeId]->id);
$itemsNb = DB::count();
// If personal Folder, convert id into user name
if ($completTree[$nodeId]->title == $_SESSION['user_id'] && $completTree[$nodeId]->nlevel == 1) {
$completTree[$nodeId]->title = $_SESSION['login'];
}
// if required, separate the json answer for each folder
if (!empty($ret_json)) {
$ret_json .= ", ";
}
// prepare json return for current node
if ($completTree[$nodeId]->parent_id == 0) {
$parent = "#";
} else {
$parent = "li_" . $completTree[$nodeId]->parent_id;
}
// special case for READ-ONLY folder
if ($_SESSION['user_read_only'] == true && !in_array($completTree[$nodeId]->id, $_SESSION['personal_folders'])) {
$eye_icon = true;
$title = $LANG['read_only_account'];
}
$text .= str_replace("&", "&", $completTree[$nodeId]->title);
$restricted = "0";
$folderClass = "folder";
if (in_array($completTree[$nodeId]->id, $_SESSION['groupes_visibles'])) {
if (in_array($completTree[$nodeId]->id, $_SESSION['read_only_folders'])) {
$text = "<i class='fa fa-eye'></i> " . $text;
$title = $LANG['read_only_account'];
$restricted = 1;
$folderClass = "folder_not_droppable";
}
$text .= ' (<span class=\'items_count\' id=\'itcount_' . $completTree[$nodeId]->id . '\'>' . $itemsNb . '</span>';
// display tree counters
if (isset($_SESSION['settings']['tree_counters']) && $_SESSION['settings']['tree_counters'] == 1) {
$text .= '|' . $nbChildrenItems . '|' . (count($nodeDescendants) - 1);
}
$text .= ')';
} elseif (in_array($completTree[$nodeId]->id, $listFoldersLimitedKeys)) {
$restricted = "1";
$text .= ' (<span class=\'items_count\' id=\'itcount_' . $completTree[$nodeId]->id . '">' . count($_SESSION['list_folders_limited'][$completTree[$nodeId]->id]) . '</span>';
} elseif (in_array($completTree[$nodeId]->id, $listRestrictedFoldersForItemsKeys)) {
$restricted = "1";
$text .= ' (<span class=\'items_count\' id=\'itcount_' . $completTree[$nodeId]->id . '">' . count($_SESSION['list_restricted_folders_for_items'][$completTree[$nodeId]->id]) . '</span>';
} else {
$restricted = "1";
$folderClass = "folder_not_droppable";
if (isset($_SESSION['settings']['show_only_accessible_folders']) && $_SESSION['settings']['show_only_accessible_folders'] == 1) {
// folder is not visible
$hide_node = true;
} else {
// folder is visible but not accessible by user
$show_but_block = true;
}
}
// json
if ($hide_node == false && $show_but_block == false) {
$ret_json .= '{' . '"id":"li_' . $completTree[$nodeId]->id . '"' . ', "parent":"' . $parent . '"' . ', "text":"' . ($eye_icon == true ? "<i class='fa fa-eye'></i> " : "") . $text . '"' . ', "li_attr":{"class":"jstreeopen", "title":"ID [' . $completTree[$nodeId]->id . '] ' . $title . '"}' . ', "a_attr":{"id":"fld_' . $completTree[$nodeId]->id . '", "class":"' . $folderClass . '" , "onclick":"ListerItems(\'' . $completTree[$nodeId]->id . '\', \'' . $restricted . '\', 0)", "ondblclick":"LoadTreeNode(\'' . $completTree[$nodeId]->id . '\')"}' . '}';
} else {
if ($show_but_block == true) {
$ret_json .= '{' . '"id":"li_' . $completTree[$nodeId]->id . '"' . ', "parent":"' . $parent . '"' . ', "text":"<i class=\'fa fa-close mi-red\'></i> ' . $text . '"' . ', "li_attr":{"class":"", "title":"ID [' . $completTree[$nodeId]->id . '] ' . $LANG['no_access'] . '"}' . '}';
}
}
foreach ($completTree[$nodeId]->children as $child) {
recursiveTree($child);
}
}
}
}
示例11: array_push
array_push($arrFields, array($field['id'], addslashes($field['title'])));
}
}
// store the categories
array_push($_SESSION['item_fields'], array($record['id'], addslashes($record['title']), $arrFields));
}
}
/*
* CHECK IF SENDING ANONYMOUS STATS
*/
if (isset($_SESSION['settings']['send_stats']) && $_SESSION['settings']['send_stats'] == 1 && isset($_SESSION['settings']['send_stats_time']) && !isset($_SESSION['temporary']['send_stats_done'])) {
if ($_SESSION['settings']['send_stats_time'] + $k['one_month_seconds'] <= time()) {
teampassStats();
$_SESSION['temporary']['send_stats_done'] = true;
//permits to test only once by session
}
}
/*
**
*/
$_SESSION['temporary']['user_can_printout'] = false;
if (isset($_SESSION['settings']['roles_allowed_to_print']) && isset($_SESSION['user_roles']) && (!isset($_SESSION['temporary']['user_can_printout']) || empty($_SESSION['temporary']['user_can_printout']))) {
foreach (explode(";", $_SESSION['settings']['roles_allowed_to_print']) as $role) {
if (in_array($role, $_SESSION['user_roles'])) {
$_SESSION['temporary']['user_can_printout'] = true;
}
}
}
/* CHECK NUMBER OF USER ONLINE */
DB::query("SELECT * FROM " . prefix_table("users") . " WHERE timestamp>=%i", time() - 600);
$_SESSION['nb_users_online'] = DB::count();
示例12: prefix_table
if ($_POST['key'] != $_SESSION['key']) {
echo '[ { "error" : "key_not_conform" } ]';
break;
}
$ret = DB::queryfirstrow("SELECT k.id AS id, k.label AS label, k.description AS description, k.category_id AScategory_id, k.author_id AS author_id, k.anyone_can_modify AS anyone_can_modify, u.login AS login, c.category AS category\n FROM " . prefix_table("kb") . " AS k\n INNER JOIN " . prefix_table("kb_categories") . " AS c ON (c.id = k.category_id)\n INNER JOIN " . prefix_table("users") . " AS u ON (u.id = k.author_id)\n WHERE k.id = %i", $_POST['id']);
//select associated items
$rows = DB::query("SELECT item_id FROM " . prefix_table("kb") . "_items WHERE kb_id = %i", $_POST['id']);
$arrOptions = array();
foreach ($rows as $record) {
//echo '$("#kb_associated_to option[value='.$record['item_id'].']").attr("selected","selected");';
array_push($arrOptions, $record['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;
/**
* Delete the KB
*/
/**
* Delete the KB
*/
case "delete_kb":
// Check KEY
if ($_POST['key'] != $_SESSION['key']) {
echo '[ { "error" : "key_not_conform" } ]';
break;
}
DB::delete(prefix_table("kb"), "id=%i", $_POST['id']);
break;
}
}
示例13: array
break;
// CASE where to authorize an ITEM creation without respecting the complexity
// CASE where to authorize an ITEM creation without respecting the complexity
case "modif_droit_autorisation_sans_complexite":
/* do checks */
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/checks.php';
if (!checkUser($_SESSION['user_id'], $_SESSION['key'], "manage_folders")) {
$_SESSION['error']['code'] = ERR_NOT_ALLOWED;
//not allowed page
include $_SESSION['settings']['cpassman_dir'] . '/error.php';
exit;
}
// send query
DB::update(prefix_table("nested_tree"), array('bloquer_creation' => $_POST['droit']), "id = %i", $_POST['id']);
break;
// CASE where to authorize an ITEM modification without respecting the complexity
// CASE where to authorize an ITEM modification without respecting the complexity
case "modif_droit_modification_sans_complexite":
/* do checks */
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/checks.php';
if (!checkUser($_SESSION['user_id'], $_SESSION['key'], "manage_folders")) {
$_SESSION['error']['code'] = ERR_NOT_ALLOWED;
//not allowed page
include $_SESSION['settings']['cpassman_dir'] . '/error.php';
exit;
}
// send query
DB::update(prefix_table("nested_tree"), array('bloquer_modification' => $_POST['droit']), "id = %i", $_POST['id']);
break;
}
}
示例14: teampassStats
/**
* send statistics about your usage of cPassMan.
* This helps the creator to evaluate the usage you have of the tool.
*/
function teampassStats()
{
global $server, $user, $pass, $database, $pre, $port, $encoding;
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/settings.php';
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/SplClassLoader.php';
// connect to the server
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$encoding = $encoding;
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
// Prepare stats to be sent
// Count no FOLDERS
DB::query("SELECT * FROM " . prefix_table("nested_tree") . "");
$dataFolders = DB::count();
// Count no USERS
$dataUsers = DB::query("SELECT * FROM " . $pre . "users");
$dataUsers = DB::count();
// Count no ITEMS
$dataItems = DB::query("SELECT * FROM " . $pre . "items");
$dataItems = DB::count();
// Get info about installation
$dataSystem = array();
$rows = DB::query("SELECT valeur,intitule FROM " . $pre . "misc\n WHERE type = %s\n AND intitule = %ls", 'admin', array('enable_pf_feature', 'log_connections', 'cpassman_version'));
foreach ($rows as $record) {
if ($record['intitule'] == 'enable_pf_feature') {
$dataSystem['enable_pf_feature'] = $record['valeur'];
} elseif ($record['intitule'] == 'cpassman_version') {
$dataSystem['cpassman_version'] = $record['valeur'];
} elseif ($record['intitule'] == 'log_connections') {
$dataSystem['log_connections'] = $record['valeur'];
}
}
// Get the actual stats.
$statsToSend = array('uid' => md5(SALT), 'time_added' => time(), 'users' => $dataUsers[0], 'folders' => $dataFolders[0], 'items' => $dataItems[0], 'cpm_version' => $dataSystem['cpassman_version'], 'enable_pf_feature' => $dataSystem['enable_pf_feature'], 'log_connections' => $dataSystem['log_connections']);
// Encode all the data, for security.
foreach ($statsToSend as $k => $v) {
$statsToSend[$k] = urlencode($k) . '=' . urlencode($v);
}
// Turn this into the query string!
$statsToSend = implode('&', $statsToSend);
fopen("http://www.teampass.net/files/cpm_stats/collect_stats.php?" . $statsToSend, 'r');
// update the actual time
DB::update($pre . "misc", array('valeur' => time()), "type = %s AND intitule = %s", 'admin', 'send_stats_time');
}
示例15: SplClassLoader
<div id="tabs-2">
<!-- Prepare a list of all folders that the user can choose -->
<div style="margin-top:10px;" id="keypass_import_options">
<label><b>' . $LANG['import_keepass_to_folder'] . '</b></label>
<select id="import_keepass_items_to">
<option value="0">' . $LANG['root'] . '</option>';
//Load Tree
$tree = new SplClassLoader('Tree\\NestedTree', './includes/libraries');
$tree->register();
$tree = new Tree\NestedTree\NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
$folders = $tree->getDescendants();
// show list of all folders
foreach ($folders as $t) {
if (in_array($t->id, $_SESSION['groupes_visibles'])) {
if (is_numeric($t->title)) {
$user = DB::queryfirstrow("SELECT login FROM " . prefix_table("users") . " WHERE id = %i", $t->title);
$t->title = $user['login'];
$t->id = $t->id . "-perso";
}
$ident = " ";
for ($x = 1; $x < $t->nlevel; $x++) {
$ident .= " ";
}
if (isset($_GET['folder_id']) && $_GET['folder_id'] == $t->id) {
$selected = " selected";
} else {
$selected = "";
}
if ($prevLevel < $t->nlevel) {
echo '<option value="' . $t->id . '"' . $selected . '>' . $ident . $t->title . '</option>';
} elseif ($prevLevel == $t->nlevel) {