function initDB() { // Set "Stop List" words. $stopList = array('a', 'able', 'about', 'across', 'after', 'all', 'almost', 'also', 'am', 'among', 'an', 'and', 'any', 'are', 'as', 'at', 'be', 'because', 'been', 'but', 'by', 'can', 'cannot', 'could', 'dear', 'did', 'do', 'does', 'either', 'else', 'ever', 'every', 'for', 'from', 'get', 'got', 'had', 'has', 'have', 'he', 'her', 'hers', 'him', 'his', 'how', 'however', 'i', 'if', 'in', 'into', 'is', 'it', 'its', 'just', 'least', 'let', 'like', 'likely', 'may', 'me', 'might', 'most', 'must', 'my', 'neither', 'no', 'nor', 'not', 'of', 'off', 'often', 'on', 'only', 'or', 'other', 'our', 'own', 'rather', 'said', 'say', 'says', 'she', 'should', 'since', 'so', 'some', 'than', 'that', 'the', 'their', 'them', 'then', 'there', 'these', 'they', 'this', 'tis', 'to', 'too', 'twas', 'us', 'wants', 'was', 'we', 'were', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'would', 'yet', 'you', 'your'); // If DB exists - Load it. If not, create a new DB. if (existsDB()) { $db = loadDB(); } else { foreach ($stopList as $stopWord) { $db['STOPLIST'][$stopWord] = 1; } } return $db; }
if (!is_writable($pw_file)) { echo 'Error: cannot write machine file (' . $pw_file . ')'; return; } // be more careful here, we need to write first to a new file, make sure that this // works and copy the result over to the pw_file $testfn = $pw_file . '_test'; file_put_contents($testfn, json_encode($d)); if (filesize($testfn) > 0) { // seems to have worked, now rename this file to pw_file rename($testfn, $pw_file); } else { syslog(LOG_EMERG, 'ERROR: could not write machine data into ' . $testfn); } } $data = loadDB(); $action = ""; if (isset($_GET['action'])) { $action = $_GET['action']; } if ($action == "create") { $name = uniqid('invention'); if (isset($_GET['name'])) { $name = $_GET['name']; } // create a docker image with shellinabox (needs to be done by processing user) $id = uniqid('machine'); touch('inventions/create_' . $id); // should start the creation from the processing user echo "{ \"message\": \"Done\", \"id\": \"{$id}\" }"; // start checking for this container, should come up soon
* cli toools to import flysprays stuff to projectpier * version of flyspray : 0.9.9.6.dev * version of projectpier : 0.8.6 * * requirement * - PHP 5.? * - PDO * - ticket plugins activate on PP */ require_once 'convert.php'; $convert_source = 'flyspray'; $convert_path = ucfirst($convert_source); $DB = loadDB($config, $convert_source); // first import users $modUsers = loadModule('Users', $convert_path, $DB, $config); $modUsers->convert(); // projects $modProjects = loadModule('Projects', $convert_path, $DB, $config); $modProjects->setUsersConverter($modUsers); $modProjects->convert(); $modCategories = loadModule('Categories', $convert_path, $DB, $config); $modCategories->setProjectsConverter($modProjects); $modCategories->convert(); // tickets
function list_permissions_for_user($user_in) { global $_SESSION; // read the permissions database $d = loadDB(); // check if the current user $user_name = $_SESSION["logged"]; // is allowed to use permission $roles = array(); foreach ($d["users"] as $key => $value) { if ($value["name"] == $user_name) { $roles = array_merge($roles, $value["roles"]); } } // for each role find the list of permissions $userpermissions = array(); foreach ($d["roles"] as $key => $value) { // all known roles foreach ($roles as $role) { // roles of the current user if ($value["id"] == $role) { $userpermissions = array_merge($userpermissions, $value["permissions"]); } } } // for each found permission find the name $userpermissions_str = array(); // array name instead of id foreach ($userpermissions as $perm) { foreach ($d["permissions"] as $key => $value) { if ($perm == $value["id"]) { $userpermissions_str[] = $value["name"]; } } } return $userpermissions_str; }
<?php //insert_json_db.php //require $_SERVER['DOCUMENT_ROOT']."/modules/stranger_go_login.php"; // get the data from the POST $postedData = $HTTP_RAW_POST_DATA; $cleanData = json_decode($postedData, true); // $marble_bag_name = $_POST['marble_bag_name']; // $marble_amount = $_POST['marble_amount']; // $marble_color = $_POST['marble_color']; // $marble_size = $_POST['marble_size']; require 'load_db.php'; try { $db = loadDB(); $query = 'INSERT INTO marbles(marble_bag) VALUES(:marble_bag)'; $statement = $db->prepare($query); $statement->bindParam(':marble_bag', $cleanData["marbleBagName"]); $statement->execute(); } catch (Exception $ex) { echo "Error with DB. "; //.$ex; die; } echo "Success! Inserted marble bag: " . $cleanData["marbleBagName"]; die;