/** * Comment-me! */ function saveLastCID($sensorid, $cid, $con) { if (DEBUG) { echo "Save last CID\n"; } $sql[] = "update sensor set last_cid='{$cid}',events_count=(select count(*) from event where sid='{$sensorid}') where sid='{$sensorid}';"; saveDB($sql, $con); }
function removePermissionFromRole($roleName, $name) { $d = loadDB(); $id = -1; // what is the number of the permission? foreach ($d['permissions'] as $key => $perm) { if ($perm['name'] == $name) { $id = $perm['id']; break; } } if ($id == -1) { return; } $found = false; foreach ($d['roles'] as $key => $role) { if ($role['name'] != $roleName) { continue; } syslog(LOG_EMERG, 'try to remove permission ' . $name . ' (' . $id . ') from ' . $role['name']); if (in_array($id, $role['permissions'])) { $d['roles'][$key]['permissions'] = array_diff($d['roles'][$key]['permissions'], array($id)); //unset($d['roles'][$name]); $found = true; } } if ($found) { saveDB($d); audit("removePermissionFromRole", $roleName . " " . $name); } }
function addDocToDB(&$db, $filename) { if (isset($db['FILES'][$filename]['ACTIVE'])) { // If the file was ever in the database, set it as active without parsing. echo "<script type=\"text/javascript\">"; echo "\twindow.alert(\"The file \\\"{$filename}\\\" has already been scanned into the database! If it was made inactive, it will be made active again.\")"; echo "</script>"; $db['FILES'][$filename]['ACTIVE'] = 1; return; } $fileToRead = "upload/" . $filename; $lines = file($fileToRead); // Get file content. $separators = " ,\n\t\"\\'\\\r/<>;=!().:&*|@#\$%^~`?"; // Set in file separators. $db['FILES'][$filename]['ACTIVE'] = 1; // Set the file as active. foreach ($lines as $line_num => $line) { // Look for the HTML head. $word = strtolower(strtok($line, $separators)); // Get the first word of each line. if ($word == 'head') { // If the head starts, go to head parsing. array_shift($lines); // Remove the line with the head tag. parseHead($db, $lines, $filename); break; } array_shift($lines); // Remove line after parsing it. } foreach ($lines as $line_num => $line) { // HTML head ended, look for the main div. $word = strtolower(strtok($line, $separators)); // Get the first word of each line. if ($word == 'div') { // If the div starts, go to main parsing. array_shift($lines); // Remove the line with the div tag. $wordCount = parseMain($db, $lines, $filename); $db['FILES'][$filename]['WCOUNT'] = $wordCount; // Set the total word count. break; } array_shift($lines); // Remove line after parsing it. } saveDB($db); }