diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000..1c983b59 --- /dev/null +++ b/.htaccess @@ -0,0 +1,16 @@ +php_flag display_startup_errors on +php_flag display_errors on +php_flag html_errors on +php_flag ignore_repeated_errors off +php_flag ignore_repeated_source off +php_flag report_memleaks on +php_flag track_errors on +php_value docref_root 0 +php_value docref_ext 0 +php_value error_reporting -1 + +AuthType Basic +AuthName "queXS CATI: Authentication Required" +AuthUserFile /var/opt/quexs/htpasswd +AuthGroupFile /var/opt/quexs/htgroup +require group interviewers diff --git a/admin/.htaccess b/admin/.htaccess new file mode 100644 index 00000000..416f0f13 --- /dev/null +++ b/admin/.htaccess @@ -0,0 +1,5 @@ +AuthType Basic +AuthName "queXS CATI: Authentication Required" +AuthUserFile /var/opt/quexs/htpasswd +AuthGroupFile /var/opt/quexs/htgroup +require group admin diff --git a/admin/clients.php b/admin/clients.php index 83b8bdf9..dd60c45f 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -66,15 +66,34 @@ if (isset($_POST['client'])) VALUES (NULL , $client, $firstname , $lastname, $time_zone_name);"; if ($db->Execute($sql)) + { + if (HTPASSWD_PATH !== false && HTGROUP_PATH !== false) + { + //Get password and add it to the configured htpassword + include_once("../functions/functions.htpasswd.php"); + $htp = New Htpasswd(HTPASSWD_PATH); + $htg = New Htgroup(HTGROUP_PATH); + + $htp->addUser($_POST['client'],$_POST['password']); + $htg->addUserToGroup($_POST['client'],HTGROUP_CLIENT); + } + $a = T_("Added: $client"); + } else - $a = T_("Could not add") . " " . $client . ". " . T_("There may already be an client of this name"); + $a = T_("Could not add") . " " . $client . ". " . T_("There may already be a client of this name"); } } xhtml_head(T_("Add a client")); +$sql = "SELECT Time_zone_name as value, Time_zone_name as description + FROM timezone_template"; + +$rs = $db->GetAll($sql); + + if ($a) { ?> @@ -86,10 +105,13 @@ if ($a)
echo T_("Adding a client here will allow them to access project information in the client subdirectory. You can assign a client to a particular project using the"); ?> echo T_("Assign client to Questionnaire"); ?> echo T_("tool."); ?>
echo T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here."); ?>
diff --git a/admin/operators.php b/admin/operators.php index 843929e6..2d51c1d1 100644 --- a/admin/operators.php +++ b/admin/operators.php @@ -55,8 +55,45 @@ if (isset($_POST['operator'])) $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); $time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc()); - $extension = $db->qstr($_POST['extension'],get_magic_quotes_gpc()); - $extensionp = $db->qstr($_POST['extensionp'],get_magic_quotes_gpc()); + $extension = 1000; + $extensionp = ""; + if (FREEPBX_PATH == false) + { + //Manually add extension information + $extension = $db->qstr($_POST['extension'],get_magic_quotes_gpc()); + $extensionp = $db->qstr($_POST['extensionp'],get_magic_quotes_gpc()); + } + else + { + //Generate new extension from last one in database and random password + $sql = "SELECT SUBSTRING_INDEX(extension, '/', -1) as ext + FROM operator + ORDER BY ext DESC + LIMIT 1"; + + $laste = $db->GetRow($sql); + + $extensionn = "1000"; + $extension = "'IAX2/1000'"; + + //increment if exists + if (!empty($laste)) + { + $extensionn = $laste['ext'] + 1; + $extension = "'IAX2/$extensionn'"; + } + + //generate random 8 length password + $extensionnp = ""; + $length = 12; + $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; + for ($i = 0; $i < $length; $i++) + $extensionnp .= $chars[(rand() % strlen($chars))]; + + //quote for SQL + $extensionp = "'$extensionnp'"; + + } $supervisor = 0; $temporary = 0; $refusal = 0; @@ -65,6 +102,7 @@ if (isset($_POST['operator'])) if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1; if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1; if (isset($_POST['voip']) && $_POST['voip'] == "on") $voip = 1; + if (!empty($_POST['operator'])) { $sql = "INSERT INTO operator @@ -73,7 +111,31 @@ if (isset($_POST['operator'])) if ($db->Execute($sql)) { - $a = "Added: $operator"; + if (FREEPBX_PATH !== false) + { + //Generate new extension in freepbx + include_once("../functions/functions.freepbx.php"); + freepbx_add_extension($extensionn, $_POST["firstname"] . " " . $_POST["lastname"], $extensionnp); + } + + if (HTPASSWD_PATH !== false && HTGROUP_PATH !== false) + { + //Get password and add it to the configured htpassword + include_once("../functions/functions.htpasswd.php"); + $htp = New Htpasswd(HTPASSWD_PATH); + $htg = New Htgroup(HTGROUP_PATH); + + $htp->addUser($_POST['operator'],$_POST['password']); + $htg->addUserToGroup($_POST['operator'],HTGROUP_INTERVIEWER); + + if ($supervisor) + $htg->addUserGroup(HTGROUP_ADMIN); + } + + $a = T_("Added:") . " " . $operator; + + if (FREEPBX_PATH !== false) + $a .= "echo T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here."); ?>