Exemplo n.º 1
0
function put_sql($import_handle)
{
    global $db_link, $import_handle, $sql, $allow_compression, $temporary_dir, $errors, $delete_tmpfile_after_post;
    $dump = new cMySQLBackUp($temporary_dir, '', $allow_compression);
    $f_name = tempnam($temporary_dir, 'm1bridge_');
    if (!$f_name) {
        generate_error($errors['create_tmp_file']);
    }
    $import_handle = fopen($f_name, "w+");
    $ind = $import_handle;
    if (!$ind) {
        generate_error($errors['open_tmp_file']);
    }
    if ($ind) {
        $ind = (bool) fputs($import_handle, $sql);
        $ind &= fclose($import_handle);
    }
    $import_handle = fopen($f_name, "r");
    if (!$import_handle) {
        generate_error($errors['open_tmp_file']);
    }
    if (!$ind) {
        generate_error($errors['put_tmp_file']);
    }
    $content = running($import_handle);
    if (strlen($content) > 0) {
        echo $content;
    } else {
        echo "0\r\n";
    }
    fclose($import_handle);
    if ($delete_tmpfile_after_post) {
        @unlink($f_name);
        $dump->_clearAll("m1bridge_");
        $dump->_clearAll("m1bridgetmp_");
        $dump->_exit();
    } else {
        @chmod($f_name, 0777);
    }
}
Exemplo n.º 2
0
$w = new WhatsProt($username, 0, "WhatsApi AJAX Demo", true);
$w->eventManager()->bind("onGetImage", "onGetImage");
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->connect();
$w->loginWithPassword($password);
$initial = @$_POST["initial"];
if ($initial == "true" && $target != null) {
    //request contact picture only on first call
    $w->sendGetProfilePicture($target);
}
//subscribe contact status
$w->SendPresenceSubscription($target);
//TODO: presense handling (online/offline/typing/last seen)
while (running($time)) {
    $w->pollMessages();
    running($time);
    //check again if timestamp has been updated
    //check for outbound messages to send:
    session_start();
    $outbound = $_SESSION["outbound"];
    $_SESSION["outbound"] = array();
    session_write_close();
    if (count($outbound) > 0) {
        foreach ($outbound as $message) {
            //send messages
            $w->sendMessage($message["target"], $message["body"]);
            $w->pollMessages();
        }
    }
    //check for received messages:
    $messages = $w->getMessages();
Exemplo n.º 3
0
    if (file_exists("{$query['pname']}.out")) {
        rename("{$query['pname']}.out", "{$query['pname']}{$i}.out");
    }
    echo array_encode($tmp);
}
$now = read();
$stt = read();
switch ($query['action']) {
    case "state":
        $tmp['state'] = $now;
        $tmp['name'] = $cfg['Name'];
        $tmp['ver'] = $cfg['Ver'];
        $tmp['cnt'] = read_cnt();
        $run = getrunning();
        if ($run < 0) {
            running(0, 'abs');
            $run = 0;
        } else {
            if ($run == 0) {
                write("free");
                $tmp['state'] = "free";
            }
        }
        echo array_encode($tmp);
        break;
    case "lock":
        do {
            write("locked");
            $stt = read();
        } while ($stt != "locked");
        $tmp['state'] = "successful";