private static function setupSQL() { global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax, $db_connections, $db_last_inserted_id; self::includeFile('config_db.php'); self::includeFile('includes/db/connect_db.inc'); self::includeFile('includes/db/sql_functions.inc'); self::includeFile('includes/errors.inc'); set_global_connection(); }
protected function syncUserToFA($ldap, $username, $password, $primaryGroup) { // FIXME: these should probably be fetched from the configuration variables // default user settings for LDAP-based users $language = 'en_GB'; $profile = ''; $rep_popup = '1'; $pos = '1'; $isActive = '1'; $userArray = ''; // settings available from LDAP $uid = $ldap->getAttribute('uid'); $name = $ldap->getAttribute('sn') . " " . $ldap->getAttribute('givenname'); $mobilephone = $ldap->getAttribute('mobile'); $email = $ldap->getAttribute('mail'); // connect to FA database set_global_connection(); // get role ID from primary group $map = $this->getConfigValue('group_role_map'); $userRole = $map[$primaryGroup]; // FIXME: should error if empty $sql = "SELECT id FROM " . TB_PREF . "security_roles WHERE role = " . db_escape($userRole); $query = db_query($sql, "could not get user role for {$userRole}"); $ret = db_fetch($query); // FIXME: should error if empty $role_id = $ret[0]; // check for existing user in FA $user = get_user_by_login($username); // if user exists if ($user) { // update FA user from LDAP $dbid = $user[0]; // FIXME: LDAP attribute IDs could be supplied in config for site-specific LDAP compatibility update_user($dbid, $uid, $name, $mobilephone, $email, $role_id, $language, $profile, $rep_popup, $pos); // FIXME: update password hash? what about re-auth requests? // else } else { // prepare to create FA user from LDAP // FIXME: LDAP attribute IDs could be supplied in config for site-specific LDAP compatibility add_user($uid, $name, md5($password), $mobilephone, $email, $role_id, $language, $profile, $rep_popup, $pos); // endif } }
function handle_submit() { global $db_connections, $def_coy, $tb_pref_counter, $db, $comp_subdirs, $path_to_root, $selected_id; $error = false; if (!check_data()) { return false; } if ($selected_id == -1) { $selected_id = count($db_connections); } $new = !isset($db_connections[$selected_id]); if ((bool) $_POST['def'] == true) { $def_coy = $selected_id; } $db_connections[$selected_id]['name'] = $_POST['name']; if ($new) { $db_connections[$selected_id]['host'] = $_POST['host']; $db_connections[$selected_id]['dbuser'] = $_POST['dbuser']; $db_connections[$selected_id]['dbpassword'] = $_POST['dbpassword']; $db_connections[$selected_id]['dbname'] = $_POST['dbname']; if (is_numeric($_POST['tbpref'])) { $db_connections[$selected_id]['tbpref'] = $_POST['tbpref'] == 1 ? $tb_pref_counter . "_" : ''; } else { if ($_POST['tbpref'] != "") { $db_connections[$selected_id]['tbpref'] = $_POST['tbpref']; } else { $db_connections[$selected_id]['tbpref'] = ""; } } $conn = $db_connections[$selected_id]; if (($db = db_create_db($conn)) == 0) { display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually")); $error = true; } else { if (!db_import($path_to_root . '/sql/' . get_post('coa'), $conn, $selected_id)) { display_error(_('Cannot create new company due to bugs in sql file.')); $error = true; } else { if (!isset($_POST['admpassword']) || $_POST['admpassword'] == "") { $_POST['admpassword'] = "******"; } update_admin_password($conn, md5($_POST['admpassword'])); } } set_global_connection(); if ($error) { remove_connection($selected_id); return false; } } $error = write_config_db($new); if ($error == -1) { display_error(_("Cannot open the configuration file - ") . $path_to_root . "/config_db.php"); } else { if ($error == -2) { display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php"); } else { if ($error == -3) { display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation.")); } } } if ($error != 0) { return false; } if ($new) { create_comp_dirs(company_path($selected_id), $comp_subdirs); } $exts = get_company_extensions(); write_extensions($exts, $selected_id); display_notification($new ? _('New company has been created.') : _('Company has been updated.')); return true; }
* Configure Log file * param1 - Logfile Name * param2 - true - Log * false - No log */ $log = new Log($path_to_root . "/logs/mobile_" . $company . ".log", $debugMode); $resp = array(); //Check if the module is empty if ($module == '') { $error = "Invalid Module Name"; $resp = array("success" => false, "message" => $error); echo Zend_Json::encode($resp); exit; } //Retrieve company database information $db = set_global_connection($company); $return = true; //This method is to perform Login or Logout only if ($method == 'login' || $method == 'logout') { $message = ''; if ($method == 'login') { $return = $_SESSION["wa_current_user"]->login($company, $username, $password); if (!$return) { $message = "Invalid Username or Password!!!"; } else { $message = "User Login Successfully."; } } else { if ($method == 'logout') { session_unset(); session_destroy();
function handle_submit() { global $db_connections, $def_coy, $tb_pref_counter, $db, $comp_path, $comp_subdirs; $new = false; if (!check_data()) { return false; } $id = $_GET['id']; $db_connections[$id]['name'] = $_POST['name']; $db_connections[$id]['host'] = $_POST['host']; $db_connections[$id]['dbuser'] = $_POST['dbuser']; $db_connections[$id]['dbpassword'] = $_POST['dbpassword']; $db_connections[$id]['dbname'] = $_POST['dbname']; if ((bool) $_POST['def'] == true) { $def_coy = $id; } if (isset($_GET['ul']) && $_GET['ul'] == 1) { $conn = $db_connections[$id]; if (($db = db_create_db($conn)) == 0) { display_error(tr("Error creating Database: ") . $conn['dbname'] . tr(", Please create it manually")); remove_connection($id); set_global_connection(); return false; } $filename = $_FILES['uploadfile']['tmp_name']; if (is_uploaded_file($filename)) { db_import($filename, $conn, $id); if (isset($_POST['admpassword']) && $_POST['admpassword'] != "") { db_query("UPDATE users set password = '******'admpassword']) . "' WHERE user_id = 'admin'"); } } else { display_error(tr("Error uploading Database Script, please upload it manually")); set_global_connection(); return false; } set_global_connection(); } $error = write_config_db($new); if ($error == -1) { display_error(tr("Cannot open the configuration file - ") . $path_to_root . "/config_db.php"); } else { if ($error == -2) { display_error(tr("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php"); } else { if ($error == -3) { display_error(tr("The configuration file ") . $path_to_root . "/config_db.php" . tr(" is not writable. Change its permissions so it is, then re-run the operation.")); } } } if ($error != 0) { return false; } $index = "<?php\nheader(\"Location: ../../index.php\");\n?>"; if ($new) { $cdir = $comp_path . '/' . $id; @mkdir($cdir); save_to_file($cdir . '/' . 'index.php', 0, $index); foreach ($comp_subdirs as $dir) { @mkdir($cdir . '/' . $dir); save_to_file($cdir . '/' . $dir . '/' . 'index.php', 0, $index); } } return true; }
} // create security backup db_backup($conn, 'no', 'Security backup before upgrade', $conn['tbpref']); // apply all upgrade data foreach ($installers as $i => $inst) { $ret = upgrade_step($i, $conn); if (!$ret) { display_error(sprintf(_("Database upgrade to version %s failed for company '%s'."), $inst->version, $conn['name']) . '<br>' . _('You should restore company database from latest backup file')); } } // db_close($conn); ? if (!$ret) { break; } } set_global_connection(); if ($ret) { // re-read the prefs global $path_to_root; include_once $path_to_root . "/admin/db/users_db.inc"; $user = get_user_by_login($_SESSION["wa_current_user"]->username); $_SESSION["wa_current_user"]->prefs = new user_prefs($user); display_notification(_('All companies data has been successfully updated')); } refresh_sys_prefs(); // re-read system setup $Ajax->activate('_page_body'); } start_form(); start_table(TABLESTYLE); $th = array(_("Version"), _("Description"), _("Sql file"), _("Install"), _("Force upgrade"));