<?php require 'path.php'; init_cobalt(); $page_title = 'Barangay System'; $stylesheet_link = 'style'; require 'header.php'; $data_con = new data_abstraction(); $data_con->set_fields('skin_name, header, footer, master_css, colors_css, fonts_css, override_css, icon_set'); $data_con->set_table('system_skins'); $data_con->set_where("skin_id=1"); $data_con->exec_fetch('single'); if ($data_con->num_rows == 1) { extract($data_con->dump); $_SESSION['header'] = $header; $_SESSION['footer'] = $footer; $_SESSION['skin'] = $skin_name; $_SESSION['master_css'] = $master_css; $_SESSION['colors_css'] = $colors_css; $_SESSION['fonts_css'] = $fonts_css; $_SESSION['override_css'] = $override_css; $_SESSION['icon_set'] = $icon_set; if (trim($_SESSION['icon_set'] == '')) { $_SESSION['icon_set'] = 'cobalt'; } } $data_con->close_db(); require 'components/get_listview_referrer.php'; init_var($arr_error); init_var($first_field); init_var($goto_region);
$_SESSION['override_css'] = $override_css; $_SESSION['icon_set'] = $icon_set; if (trim($_SESSION['icon_set'] == '')) { $_SESSION['icon_set'] = 'cobalt'; } } $data_con->close_db(); log_action('Logged in'); //check if user must rehash his password due to updated method or work factor/iterations if (cobalt_password_must_rehash($username)) { $hashed_password = cobalt_password_hash('NEW', $password, $username, $new_salt, $new_iteration, $new_method); $data_con = new data_abstraction(); $data_con->set_query_type('UPDATE'); $data_con->set_table('user'); $data_con->set_update("`password`=?, `salt`=?, `iteration`=?, `method`=?"); $data_con->set_where("username=?"); $bind_params = array('ssiss', $hashed_password, $new_salt, $new_iteration, $new_method, $username); $data_con->stmt_prepare($bind_params); $data_con->stmt_execute(); } redirect('start.php'); } else { $error_message = "Check username and password."; } } else { die($mysqli->error); } $data_con->close_db(); } } $html = new html();
$password = ''; } //check if user exists if ($dbh_user->check_user($username)->user_exists) { //Good } else { $message = 'Specified username does not exist.'; } if ($message == "") { require 'password_crypto.php'; $hashed_password = cobalt_password_hash('NEW', $password, $username, $new_salt, $new_iteration, $new_method); $data_con = new data_abstraction(); $data_con->set_query_type('UPDATE'); $data_con->set_table('user'); $data_con->set_update("`password`='{$hashed_password}', `salt`='{$new_salt}', `iteration`='{$new_iteration}', `method`='{$new_method}'"); $data_con->set_where("username='******'"); $data_con->make_query(); $message = 'The password has been successfully reset.'; $message_type = 'SYSTEM'; $password = ''; } } } require 'subclasses/user_html.php'; $html = new user_html(); $html->draw_header('Reset Password', $message, $message_type); $html->fields['password']['control_type'] = 'password'; $html->fields['password']['label'] = 'Temporary Password'; $html->exception = array('person_id', 'role_id', 'skin_id'); $html->draw_controls('add', 'Password Reset Form'); $html->draw_footer();
$TimeStart = cobalt_htmlentities($TimeStart); $TimeEnd = cobalt_htmlentities($TimeEnd); $Username = cobalt_htmlentities($Username); $Module = cobalt_htmlentities($Module); $Keyword = cobalt_htmlentities($Keyword); $IPAddress = cobalt_htmlentities($IPAddress); } if (!isset($start)) { $start = 0; } //Pagination **************************** //->Query to get total number of records. $data_con = new data_abstraction(); $data_con->set_fields("entry_id, ip_address, user, datetime, action, module"); $data_con->set_table("`system_log`"); $data_con->set_where("{$TimeFilter} AND {$UserFilter} AND {$ModuleFilter} AND {$KeywordFilter} AND {$IPAddressFilter}"); $data_con->set_order("entry_id"); if ($result = $data_con->make_query()->result) { $total_records = $data_con->num_rows; } else { die("Error getting log entries: " . $data_con->QUERY); } //-> Now instantiate the pagination class and feed it the necessary information. require 'paged_result_class.php'; $results_per_page = 50; $pager = new paged_result($total_records, $results_per_page); $pager->get_page_data($result_pager, $current_page); $current_page = $pager->current_page; $data_con->set_limit($pager->offset, $pager->records_per_page); $html_writer = new html(); $html_writer->draw_header('Security Monitor', $message, $message_type);
function check_if_unique($db, $table, $where, $errMsg) { $error_message = ''; $data_con = new data_abstraction(); $data_con->set_database($db); $data_con->set_table($table); $data_con->set_where($where); $data_con->make_query(); if ($data_con->Num_Rows > 0) { $error_message = $errMsg; } return $error_message; }
$data_con->set_table('user_passport'); $data_con->set_where("username='******' AND link_id='{$link_id}'"); $data_con->make_query(); $checked = ''; if ($data_con->num_rows == 1) { $checked = 'checked'; } echo "<TR class={$class}><td class=\"listCell\"><label style=\"display: block;\" for='checkfield[{$a}]'><input type=checkbox ID='checkfield[{$a}]' name=\"link[]\" value='{$link_id}' {$checked}> {$Module_Name}</label></td>"; $data_con->close_db(); if ($a + 1 < $numrows) { $info = $result->fetch_assoc(); extract($info); $data_con = new data_abstraction(); $data_con->set_fields('username'); $data_con->set_table('user_passport'); $data_con->set_where("username='******' AND link_id='{$link_id}'"); $data_con->make_query(); if ($data_con->num_rows == 0) { echo "<td class='listCell'><label style=\"display: block;\" for=\"checkfield[" . ($a + 1) . "]\"><input type=checkbox ID='checkfield[" . ($a + 1) . "]' name=\"link[]\" value='{$link_id}'> {$Module_Name}</label></td></tr>"; } elseif ($data_con->num_rows == 1) { echo "<td class='listCell'><label style=\"display: block;\" for=\"checkfield[" . ($a + 1) . "]\"><input type=checkbox ID='checkfield[" . ($a + 1) . "]' name=\"link[]\" value='{$link_id}' checked> {$Module_Name}</label></td></tr>"; } $data_con->close_db(); } else { echo "<td class='listCell'> </td></tr>"; } } if ($numrows > 0) { echo '<tr><td colspan=2 align=center> <br /> <input type="submit" name="btn_submit" value="SUBMIT" class="submit">
$dbh->make_query(); $dbh->close_db(); //Get the role permissions require_once 'subclasses/user_role_links.php'; $obj_role = new user_role_links(); $obj_role->get_user_role_links($role); $arrLink = $obj_role->dump['link_id']; $numLinks = $obj_role->num_rows; $obj_role->close_db(); //Assign permissions to user $dbh = new data_abstraction(); foreach ($arrLink as $link_id) { $dbh->set_query_type('SELECT'); $dbh->set_table('user_passport'); $dbh->set_fields('username, link_id'); $dbh->set_where("username='******' AND link_id='" . quote_smart($link_id) . "'"); $dbh->make_query(); if ($dbh->num_rows == 0) { $dbh->set_query_type('INSERT'); $dbh->set_values("'" . quote_smart($Username) . "','" . quote_smart($link_id) . "'"); $dbh->make_query(); } } $dbh->close_db(); } $message = 'Success! User passport has been updated.'; $message_type = 'system'; } } $html_writer = new html(); $html_writer->draw_header('Set User Passports', $message, $message_type);
redirect(HOME_PAGE); } if ($_POST['btn_submit']) { $skin_id = quote_smart($_POST['skin_id']); $data_con = new data_abstraction(); $data_con->set_query_type('UPDATE'); $data_con->set_table('user'); $data_con->set_update("skin_id='{$skin_id}'"); $data_con->set_where("username='******'user']) . "'"); $data_con->make_query(); $data_con->close_db(); //If the update went ok, we should update the session variables for this. $data_con = new data_abstraction(); $data_con->set_fields('skin_name, header, footer, master_css, colors_css, fonts_css, override_css, icon_set'); $data_con->set_table('system_skins'); $data_con->set_where("skin_id='{$skin_id}'"); $result = $data_con->make_query()->result; $numrows = $data_con->num_rows; $data_con->close_db(); if ($numrows == 1) { $data = $result->fetch_assoc(); extract($data); $_SESSION['header'] = $header; $_SESSION['footer'] = $footer; $_SESSION['skin'] = $skin_name; $_SESSION['master_css'] = $master_css; $_SESSION['colors_css'] = $colors_css; $_SESSION['fonts_css'] = $fonts_css; $_SESSION['override_css'] = $override_css; $_SESSION['icon_set'] = $icon_set; if (trim($_SESSION['icon_set'] == '')) {
$data_con->set_table('user_passport'); $data_con->set_where("username='******' AND link_id='" . quote_smart($module) . "'"); $data_con->make_query(); $obj_role->set_where("username='******'"); $obj_role->make_query(); } $data_con->close_db(); $obj_role->close_db(); } else { $message = "Please select at least one user."; } } $data_con = new data_abstraction(); $data_con->set_fields('username'); $data_con->set_table('user_passport'); $data_con->set_where("link_id='" . quote_smart($module) . "'"); $data_con->set_order('username'); if ($result = $data_con->make_query()->result) { $arrUser = array(); $showUsers = TRUE; $numUsers = $data_con->num_rows; for ($a = 0; $a < $numUsers; $a++) { $data = $result->fetch_assoc(); extract($data); $arrUser[] = $username; } } } $html_writer = new html(); $html_writer->draw_header('Set User Passports', $message, $message_type); ?>
function check_link($link, $user = '') { if ($user == '') { $user = $_SESSION['user']; } $user = quote_smart($user); $in_passport = FALSE; $data_con = new data_abstraction(); $data_con->set_fields('a.status'); $data_con->set_table('user_links a LEFT JOIN user_passport b ON a.link_id = b.link_id'); $data_con->set_where("a.name='{$link}' AND\n b.username='******' AND\n a.status='On'"); $data_con->exec_fetch('single'); $numrows = $data_con->num_rows; if ($numrows == 1) { $in_passport = TRUE; } return $in_passport; }
require_once 'subclasses/citizen.php'; $dbh_citizen = new request(); $dbh_citizen->execute_query("SELECT status FROM validate WHERE status = 'wait list'"); $result2 = $dbh_citizen->result; $hi = array(); while ($row2 = $result2->fetch_assoc()) { extract($row2); $hi[] = $row1['status']; } $results = count($hi); $html->display_tip('There are: ' . $results . ' Wait listed citizen'); $menu_links = ''; $data_con = new data_abstraction(); $data_con->set_fields('a.link_id, a.descriptive_title, a.target, a.description, c.passport_group, a.icon as link_icon, c.icon as `group_icon`'); $data_con->set_table('user_links a, user_passport b, user_passport_groups c'); $data_con->set_where("a.link_id=b.link_id AND b.username='******'user']) . "' AND a.passport_group_id=c.passport_group_id AND a.show_in_tasklist='Yes' AND a.status='On'"); $data_con->set_order('c.priority DESC, c.passport_group, a.priority DESC, a.descriptive_title'); if ($result = $data_con->make_query()->result) { while ($data = $result->fetch_assoc()) { extract($data); $menu_links[$passport_group]['title'][] = $descriptive_title; $menu_links[$passport_group]['target'][] = $target; $menu_links[$passport_group]['link_id'][] = $link_id; $menu_links[$passport_group]['description'][] = $description; $menu_links[$passport_group]['link_icon'][] = $link_icon; $menu_links[$passport_group]['group_icon'][] = $group_icon; } $result->close(); } else { die("Fatal error: cannot retrieve modules"); }
<td colspan=2> <table width="900" class="listView"> <tr class=listRowHead> <td colspan="2"><?php echo $active_passport_group; ?> Modules</td> </tr> <?php init_var($filter); $a = 0; $data_con = new data_abstraction(); $data_con->connect_db(); $data_con->set_fields('a.link_id, a.descriptive_title as `title`, a.status, b.passport_group'); $data_con->set_table('user_links a, user_passport_groups b'); $data_con->set_where("a.passport_group_id = b.passport_group_id AND a.name!='Module Control' {$filter}"); $data_con->set_order('a.descriptive_title'); if ($result = $data_con->make_query()->result) { while ($data = $result->fetch_assoc()) { extract($data); if ($a % 4 == 0) { $class = 'listRowOddNoHighlight'; } else { $class = 'listRowEvenNoHighlight'; } echo "<tr class={$class}>\n <td class=\"listCell\"><label style=\"display: block;\" for=\"checkfield[{$link_id}]\">"; $checked = ''; if ($status == "On") { $checked = 'checked'; } echo "<input type=\"checkbox\" ID=\"checkfield[{$link_id}]\" name=\"module[]\" value=\"{$link_id}\" {$checked}>";
$message = 'Report saved successfully!'; $message_type = 'system'; } else { $message = 'Please enter a Report Name in order to save the report'; } } if ($_POST['btn_delete']) { if (trim($_POST['chosen_report']) != '') { log_action('Pressed delete button'); $reporter_mod_name = $reporter->session_array_name; $chosen_report = $_POST['chosen_report']; //Delete any existing report with the same report_name + module_name in order to effectively overwrite similarly named reports $dbh = new data_abstraction(); $dbh->set_query_type('DELETE'); $dbh->set_table('cobalt_reporter'); $dbh->set_where('module_name = ? AND report_name = ?'); $bind_params = array('ss', $reporter_mod_name, $chosen_report); $dbh->stmt_prepare($bind_params); $dbh->stmt_execute(); } else { $message = 'Please choose a saved report to delete'; } } if ($_POST['btn_submit']) { log_action('Pressed submit button'); if (!isset($_POST['show_field']) || !is_array($_POST['show_field'])) { $message = 'Please check at least one column to be used for the report.'; $show_field = array(); } else { $show_field = $_POST['show_field']; }
$result->close(); require 'core/password_crypto.php'; //Hash old password using default Cobalt password hashing technique $hashed_old_password = cobalt_password_hash('RECREATE', $old_password, $_SESSION['user']); if ($hashed_old_password != $data['password']) { $message .= "The password you entered in 'Old Password' does not match the password in your records. <BR>"; } } if ($message == '') { //Hash the password using default Cobalt password hashing technique $hashed_password = cobalt_password_hash('NEW', $password1, $_SESSION['user'], $new_salt, $new_iteration, $new_method); $data_con = new data_abstraction(); $data_con->set_query_type('UPDATE'); $data_con->set_table('user'); $data_con->set_update("`password`='{$hashed_password}', `salt`='{$new_salt}', `iteration`='{$new_iteration}', `method`='{$new_method}'"); $data_con->set_where("username='******'user']) . "'"); $data_con->make_query(); $message = 'Your password has been successfully updated! You can <a href="main.php"> click here </a> to go back to your control center or use the menu above.'; $message_type = 'SYSTEM'; $old_password = ''; $password1 = ''; $password2 = ''; } } } $html = new html(); $html->draw_header('Change Password', $message, $message_type); echo '<div class="container"> <fieldset class="container_invisible"> <fieldset class="top"> Password Management </fieldset>
function cobalt_password_must_rehash($username) { $must_rehash = FALSE; $dbh = new data_abstraction(); $dbh->set_table('user'); $dbh->set_fields('`iteration`, `method` AS `current_method`'); $dbh->set_where("`username`= ?"); $bind_params = array('s', $username); $dbh->stmt_prepare($bind_params); $dbh->stmt_fetch('single'); if ($dbh->num_rows == 1) { extract($dbh->dump); } $method = cobalt_password_set_method(); if ($method == $current_method) { if ($method == 'blowfish') { $blowfish_cost_factor = AUTH_BLOWFISH_COST_FACTOR; if ((int) $iteration != (int) $blowfish_cost_factor) { $must_rehash = TRUE; } } else { $min = constant('AUTH_' . strtoupper($method) . '_MIN_ROUNDS'); $max = constant('AUTH_' . strtoupper($method) . '_MAX_ROUNDS'); if ($max < $min) { $max = $min; } if ($iteration < $min || $iteration > $max) { $must_rehash = TRUE; } } } else { $must_rehash = TRUE; } return $must_rehash; }
$data_con->set_table('user_role_links'); $data_con->set_where("role_id='{$role_id}' AND link_id='{$link_id}'"); $data_con->make_query(); $checked = ''; if ($data_con->num_rows == 1) { $checked = 'checked'; } echo "<TR class={$class}><TD class=\"listCell\"><label style=\"display: block;\" for='checkfield[{$a}]'><input type=checkbox ID='checkfield[{$a}]' name=\"link[]\" value='{$link_id}' {$checked}> {$Module_Name}</label></TD>"; $data_con->close_db(); if ($a + 1 < $numrows) { $info = $result->fetch_assoc(); extract($info); $data_con = new data_abstraction(); $data_con->set_fields('role_id'); $data_con->set_table('user_role_links'); $data_con->set_where("role_id='{$role_id}' AND link_id='{$link_id}'"); $data_con->make_query(); if ($data_con->num_rows == 0) { echo "<TD class='listCell'><label style=\"display: block;\" for=\"checkfield[" . ($a + 1) . "]\"><input type=checkbox ID='checkfield[" . ($a + 1) . "]' name=\"link[]\" value='{$link_id}'> {$Module_Name}</label></TD></TR>"; } elseif ($data_con->num_rows == 1) { echo "<TD class='listCell'><label style=\"display: block;\" for=\"checkfield[" . ($a + 1) . "]\"><input type=checkbox ID='checkfield[" . ($a + 1) . "]' name=\"link[]\" value='{$link_id}' checked> {$Module_Name}</label></TD></TR>"; } $data_con->close_db(); } else { echo "<TD class='listCell'> </TD></TR>"; } } if ($numrows > 0) { echo "<TR><TD colspan=2 align=center>\n <input type=submit name=btn_submit value='SUBMIT' class=submit>\n <input type=submit name=btn_cancel value='BACK' class=cancel>"; } else { echo "<TR><TD colspan=2> No modules found for this passport group. Please choose a different passport group.";