mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Set downloading voip client as the default
Use same tmp dir as Limesurvey Check if tmp dir writable before using to avoid server overloading
This commit is contained in:
@@ -92,9 +92,9 @@ if (is_voip_enabled($operator_id))
|
||||
$exta = $exts[1];
|
||||
$extp = get_extension_password($operator_id);
|
||||
if (get_extension_status($operator_id))
|
||||
print "<div class='online statusbutton'><a href='news://turnvoipoff'>" . T_("VoIP On") . "</a></div>";
|
||||
print "<div class='online statusbutton'>" . T_("VoIP On") . "</div>";
|
||||
else
|
||||
print "<div class='offline statusbutton'><a href='irc://$exta:$extp@" . VOIP_SERVER . "/'>" . T_("VoIP Off") . "</a></div>";
|
||||
print "<div class='offline statusbutton'><a href='voip/downloadvoipclient.php'>" . T_("VoIP Off") . "</a></div>";
|
||||
}
|
||||
else
|
||||
print "<div class='online statusbutton'>" . T_("No VoIP") . "</div>";
|
||||
|
||||
@@ -47,7 +47,7 @@ function tempdir($dir, $prefix='', $mode=0700)
|
||||
return $path;
|
||||
}
|
||||
|
||||
$tempdir = realpath(dirname(__FILE__) . '/tmp');
|
||||
$tempdir = realpath(dirname(__FILE__) . '/../include/limesurvey/tmp');
|
||||
$operator_id = get_operator_id();
|
||||
|
||||
if ($operator_id)
|
||||
@@ -61,42 +61,45 @@ if ($operator_id)
|
||||
|
||||
if (!empty($rs))
|
||||
{
|
||||
$zipdir=tempdir($tempdir);
|
||||
|
||||
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
if (preg_match('/linux/', $userAgent)) {
|
||||
//assume linux
|
||||
copy(realpath(dirname(__FILE__) . '/../voipclient'),"$zipdir/voipclient");
|
||||
$f1 = "$zipdir/voipclient";
|
||||
$f2 = "$zipdir/startvoip";
|
||||
file_put_contents($f2, "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']);
|
||||
|
||||
}
|
||||
else
|
||||
if (is_writable($tempdir))
|
||||
{
|
||||
//assume windows
|
||||
copy(realpath(dirname(__FILE__) . '/../voipclient.exe'),"$zipdir/voipclient.exe");
|
||||
$f1 = "$zipdir/voipclient.exe";
|
||||
$f2 = "$zipdir/startvoip.bat";
|
||||
file_put_contents($f2, "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']);
|
||||
$zipdir=tempdir($tempdir);
|
||||
|
||||
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
if (preg_match('/linux/', $userAgent)) {
|
||||
//assume linux
|
||||
copy(realpath(dirname(__FILE__) . '/../voipclient'),"$zipdir/voipclient");
|
||||
$f1 = "$zipdir/voipclient";
|
||||
$f2 = "$zipdir/startvoip";
|
||||
file_put_contents($f2, "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//assume windows
|
||||
copy(realpath(dirname(__FILE__) . '/../voipclient.exe'),"$zipdir/voipclient.exe");
|
||||
$f1 = "$zipdir/voipclient.exe";
|
||||
$f2 = "$zipdir/startvoip.bat";
|
||||
file_put_contents($f2, "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']);
|
||||
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__) . "/../include/limesurvey/admin/classes/phpzip/phpzip.inc.php");
|
||||
$z = new PHPZip();
|
||||
$zipfile="$tempdir/voipclient.zip";
|
||||
$z->Zip($zipdir, $zipfile);
|
||||
|
||||
unlink($f1);
|
||||
unlink($f2);
|
||||
rmdir($zipdir);
|
||||
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="voipclient.zip"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
// load the file to send:
|
||||
readfile($zipfile);
|
||||
unlink($zipfile);
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__) . "/../include/limesurvey/admin/classes/phpzip/phpzip.inc.php");
|
||||
$z = new PHPZip();
|
||||
$zipfile="$tempdir/voipclient.zip";
|
||||
$z->Zip($zipdir, $zipfile);
|
||||
|
||||
unlink($f1);
|
||||
unlink($f2);
|
||||
rmdir($zipdir);
|
||||
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="voipclient.zip"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
// load the file to send:
|
||||
readfile($zipfile);
|
||||
unlink($zipfile);
|
||||
}
|
||||
}
|
||||
exit();
|
||||
|
||||
Reference in New Issue
Block a user