Example #1
0
<?php

include_once 'includes/connect.php';
include_once 'includes/config.php';
include_once 'includes/functions.php';
if (isset($_GET['original_url']) and isset($_GET['short_url']) and isset($_GET['api_key'])) {
    $original_url = mysql_real_escape_string($_GET['original_url']);
    $short_url = mysql_real_escape_string($_GET['short_url']);
    $api_key = mysql_real_escape_string($_GET['api_key']);
    $api_key_real = mysql_query("SELECT * FROM users WHERE user_api_key='{$api_key}'");
    if (mysql_num_rows($api_key_real) !== 0) {
        $user_row = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE user_api_key='{$api_key}'"));
        $url_owner = $user_row['user_id'];
        if (short_url_exist($short_url) == TRUE) {
            echo 'Please choose another short URL, the one you tried has already been used.';
        } else {
            if (substr($original_url, 0, 7) == 'http://') {
                mysql_query("INSERT INTO urls (url_owner, url_original, url_short) VALUES ('{$url_owner}', '{$original_url}', '{$short_url}')");
                echo 'Your URL has been shortened. :D';
            } else {
                $original_url = 'http://' . $original_url;
                if (url_exist($original_url)) {
                    mysql_query("INSERT INTO urls (url_owner, url_original, url_short) VALUES ('{$url_owner}', '{$original_url}', '{$short_url}')");
                    echo 'Your URL has been shortened. :D';
                } else {
                    echo 'The URL you entered doesn\'t exist.<br />Please go back and try again.';
                }
            }
        }
    }
}
global $savant;
$msg = new Message($savant);
?>

<?php 
$url_r = trim($_POST['url']);
//get repository URL
$cron_v = intval(trim($_POST['cron']));
//get CRON interval
//if cron interval is negative or repository URL is blank then return
//error and redirect to admin panel.
if ($cron_v < 0) {
    $msg->addError('OL_CRON_NOT_VAL');
    header('Location: index_admin.php');
} else {
    if ($cron_v != 0 && ($url_r == null || $url_r == "") || $cron_v != 0 && !url_exist($url_r)) {
        $msg->addError('OL_URL_NOT_VAL');
        header('Location: index_admin.php');
    } else {
        if (isset($_POST['submit'])) {
            global $db;
            //Updtae URL and cron interval of module
            $qry = "UPDATE " . TABLE_PREFIX . "config SET value='" . $url_r . "' WHERE name='ol_url'";
            mysql_query($qry, $db);
            $qry = "UPDATE " . TABLE_PREFIX . "modules SET cron_interval=" . $cron_v . " WHERE dir_name='ol_search_open_learn'";
            mysql_query($qry, $db);
            $msg->addFeedback('SETTINGS_CHANGED');
            //Redirect back to the form
            header('Location: index_admin.php');
        }
    }
Example #3
0
20160116 - Improvements and code cleanup
*/
$client = ereg_replace("[^0-9]", "", $_GET['client_ip']);
$file_name = ereg_replace("[^-a-zA-Z0-9\\_]", "", $_GET['file_name']) . '.gsm';
$cwd = getcwd() . "/{$client}";
if (!file_exists("{$cwd}")) {
    system("mkdir -m 0777 {$cwd}");
}
exec("rm -f {$cwd}/*.mp3");
$arr_server_details = array("Infin8|http://192.168.1.9/recorder/infin8", "PraBel|http://192.168.1.9/recorder/prabel", "MAV|http://192.168.1.9/recorder/mav", "iConcept|http://192.168.1.9/recorder/iconcept", "LanBPO|http://192.168.1.9/recorder/lanbpo", "RSC|http://192.168.1.9/recorder/rsc", "e-Solutions|http://192.168.1.9/recorder/esolutions", "JSG|http://192.168.1.9/recorder/jsg");
foreach ($arr_server_details as $server_detail) {
    $arr_server_details = explode("|", $server_detail);
    $server_name = $arr_server_details[0];
    $server_path = $arr_server_details[1];
    $url = "{$server_path}/{$file_name}";
    if (url_exist($url)) {
        $baseName = basename($file_name);
        $mp3Name = str_replace('.gsm', '.mp3', $baseName);
        $mp3Path = "{$cwd}/{$mp3Name}";
        exec("/usr/bin/sox -t gsm {$url} {$mp3Path}");
        stream_file($mp3Path);
    } else {
        continue;
    }
}
//=====================FUNCTIONS==============================
function stream_file($filePath)
{
    // check that file exists and is readable
    $err = 'File not found';
    if (file_exists($filePath) && is_readable($filePath)) {