echo "<br> Task :: {$task}";
}
if ($task == 'upload') {
    //---------------------------------------------------------
    //		 Effacer tout les fichiers du repertoire cache.
    //---------------------------------------------------------
    $the_file_name = $_FILES['the_file']['name'];
    $the_file_type = $_FILES['the_file']['type'];
    $the_file = $_FILES['the_file']['tmp_name'];
    if (count($_FILES) > 0) {
        $errortext = validate_upload($the_file, $the_file_type);
        if ($errortext != "" || $errortext != false) {
            echo $errortext;
            exit;
        }
        $new_filename = "/tmp/" . MDP(6) . ".csv";
        if (file_exists($new_filename)) {
            echo $_FILES["file"]["name"] . " already exists. ";
        } else {
            if (!move_uploaded_file($_FILES["the_file"]["tmp_name"], $new_filename)) {
                echo gettext("File Save Failed, FILE=" . $new_filename);
            }
        }
        $the_file = $new_filename;
    } else {
        $the_file_type = $uploadedfile_type;
        $the_file = $uploadedfile_name;
    }
    if ($FG_DEBUG == 1) {
        echo "<br> FILE  ::> " . $the_file_name;
    }
Exemplo n.º 2
0
function gen_card_with_alias($table = "cc_card", $api = 0, $length_cardnumber = LEN_CARDNUMBER, $DBHandle = null)
{
    if (!isset($DBHandle)) {
        $DBHandle = DbConnect();
    }
    for ($k = 0; $k <= 200; $k++) {
        $card_gen = MDP($length_cardnumber);
        $alias_gen = MDP(LEN_ALIASNUMBER);
        if ($k == 200) {
            if ($api) {
                global $mail_content, $email_alarm, $logfile;
                mail($email_alarm, "ALARM : API (gen_card_with_alias - CODE_ERROR 8)", $mail_content);
                error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . "[gen_card_with_alias] - CODE_ERROR 8" . "\n", 3, $logfile);
                echo "500 Internal server error";
                exit;
            } else {
                echo "ERROR : Impossible to generate a Cardnumber & Aliasnumber not yet used!<br>Perhaps check the LEN_CARDNUMBER  (value:" . LEN_CARDNUMBER . ") & LEN_ALIASNUMBER (value:" . LEN_ALIASNUMBER . ")";
                exit;
            }
        }
        $query = "SELECT username FROM " . $table . " where username='******' OR useralias='{$alias_gen}'";
        $numrow = 0;
        $resmax = $DBHandle->Execute($query);
        if ($resmax) {
            $numrow = $resmax->RecordCount();
        }
        if ($numrow != 0) {
            continue;
        }
        $arr_val[0] = $card_gen;
        $arr_val[1] = $alias_gen;
        return $arr_val;
    }
}
Exemplo n.º 3
0
function Service_Callback($security_key, $phone_number, $callerid, $transaction_id, $callback_time, $id_server_group)
{
    $uniqueid = MDP(10) . '-' . $transaction_id;
    $status = 'PENDING';
    $server_ip = 'localhost';
    $num_attempt = 0;
    $exten = $phone_number;
    $context = 'a2billing-callback';
    $priority = 1;
    //$timeout	callerid
    // USE RATE_ENGINE_FINDRATES - RATE_ENGINE_ALL_CALCULTIMEOUT - CALL PLAN BY DEFAULT TO FIND OUT THE CORRECT CHANNEL
    $channel = 'SIP/' . $phone_number . '@toreplace';
    $variable = "mode=callback|phonenumber={$phone_number}|callerid={$callerid}|transaction_id={$transaction_id}|id_server_group={$id_server_group}";
    $FG_regular[] = array("^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})\$", "(YYYY-MM-DD HH:MM:SS)");
    // The wrapper variables for security
    // $security_key = API_SECURITY_KEY;
    write_log(LOGFILE_API_CALLBACK, "Service_Callback( security_key={$security_key}, transaction_id={$transaction_id}, phonenumber={$phone_number}, callerid={$callerid}, callerid={$callerid}, callback_time={$callback_time}, id_server_group={$id_server_group})");
    $mysecurity_key = API_SECURITY_KEY;
    $mail_content = "[" . date("Y/m/d G:i:s", mktime()) . "] " . " API - Request asked: Callback [security_key={$security_key}, transaction_id={$transaction_id}, phonenumber={$phone_number}, callerid={$callerid}, callerid={$callerid}, callback_time={$callback_time}, id_server_group={$id_server_group}]";
    if (!is_numeric($id_server_group)) {
        $id_server_group = 1;
    }
    // CHECK CALLERID
    if (strlen($callerid) < 1) {
        write_log(LOGFILE_API_CALLBACK, basename(__FILE__) . ' line:' . __LINE__ . " ERROR FORMAT CALLERID AT LEAST 1 DIGIT ");
        sleep(2);
        return array($transaction_id, '400 -- malformed query', " ERROR - FORMAT CALLERID AT LEAST 1 DIGIT ");
    }
    // CHECK PHONE_NUMBER
    if (strlen($phone_number) < 10) {
        write_log(LOGFILE_API_CALLBACK, basename(__FILE__) . ' line:' . __LINE__ . " ERROR FORMAT PHONENUMBER AT LEAST 10 DIGITS ");
        sleep(2);
        return array($transaction_id, '400 -- malformed query', " ERROR - FORMAT PHONENUMBER AT LEAST 10 DIGITS ");
    }
    // CHECK CALLBACK TIME
    if (strlen($callback_time) > 1 && !ereg($FG_regular[0][0], $callback_time)) {
        write_log(LOGFILE_API_CALLBACK, basename(__FILE__) . ' line:' . __LINE__ . " ERROR FORMAT CALLBACKTIME : " . $FG_regular[0][0]);
        sleep(2);
        return array($transaction_id, '400 -- malformed query', " ERROR - FORMAT CALLBACKTIME : " . $FG_regular[0][0]);
    }
    // CHECK SECURITY KEY
    if (md5($mysecurity_key) !== $security_key || strlen($security_key) == 0) {
        write_log(LOGFILE_API_CALLBACK, basename(__FILE__) . ' line:' . __LINE__ . " CODE_ERROR SECURITY_KEY");
        sleep(2);
        return array($transaction_id, '400 -- malformed query', ' KEY - BAD PARAMETER ');
    }
    $DBHandle = DbConnect();
    if (!$DBHandle) {
        write_log(LOGFILE_API_CALLBACK, basename(__FILE__) . ' line:' . __LINE__ . " ERROR CONNECT DB");
        sleep(2);
        return array($transaction_id, '500 -- error processing query or fetching data', ' ERROR - CONNECT DB ');
    }
    if (strlen($callback_time) > 1) {
        $QUERY = " INSERT INTO cc_callback_spool (uniqueid, status, server_ip, num_attempt, channel, exten, context, priority, variable, callback_time, id_server_group ) VALUES ('{$uniqueid}', '{$status}', '{$server_ip}', '{$num_attempt}', '{$channel}', '{$exten}', '{$context}', '{$priority}', '{$variable}', '{$callback_time}', '{$id_server_group}')";
    } else {
        $QUERY = " INSERT INTO cc_callback_spool (uniqueid, status, server_ip, num_attempt, channel, exten, context, priority, variable, id_server_group ) " . " VALUES ('{$uniqueid}', '{$status}', '{$server_ip}', '{$num_attempt}', '{$channel}', '{$exten}', '{$context}', '{$priority}', '{$variable}', '{$id_server_group}')";
    }
    $res = $DBHandle->Execute($QUERY);
    if (!$res) {
        write_log(LOGFILE_API_CALLBACK, basename(__FILE__) . ' line:' . __LINE__ . " ERROR INSERT INTO DB");
        sleep(2);
        return array($transaction_id, '500 -- error processing query or fetching data', ' ERROR - INSERT CALLBACK INTO DB');
    }
    return array($transaction_id, '200 -- successful query', " Success - Callback request has been accepted ");
}