Exemplo n.º 1
0
function send_task()
{
    require_once '../../../wp-load.php';
    include_once 'MyDataBase.php';
    global $wpdb;
    // Get the secrete code from the database
    // $config_table = new MyDataBase('sms_config');
    // $result = (array)$config_table->get_by(array('conf_type' => 'Secret'))[0];
    // $Secret_Code = $result['conf_value'];
    $Secret_Code = '123456';
    if (isset($_GET['task']) and $_GET['task'] == 'send') {
        $msgs = array();
        $message_table = new MyDataBase('messages');
        // connect to a table that contains messages to be sent
        $Pending_Messages = $result = (array) $message_table->get_by(array('pending' => 1, 'incoming' => 0));
        foreach ($Pending_Messages as $msg) {
            $the_msg = (array) $msg;
            $Current_Time = date("m-d-y G:i:s");
            if (strtotime($the_msg['expire_date']) > $Current_Time) {
                array_push($msgs, ["to" => $the_msg['sent_to'], "message" => $the_msg['message'], "uuid" => $the_msg['message_id']]);
            }
            //delete all pending messages after sending to SMSSync
            $message_table->update(array('pending' => 0), array('message_id' => $the_msg['message_id']));
        }
        // Send JSON response back to SMSsync
        $response = json_encode(["payload" => ["success" => true, "task" => "send", "secret" => $Secret_Code, "messages" => array_values($msgs)]]);
        write_message_to_file($response);
        send_response($response);
    }
}
Exemplo n.º 2
0
<?php

$we_betatext->put('/:model/:id', function ($model, $id) {
    $model = 'webetatext_' . $model;
    require BBT_restpath . '/models/' . $model . '.php';
    $object = new $model();
    $out = $object->put($id);
    send_response($out);
});
Exemplo n.º 3
0
        // Getting the sent content
        $input = file_get_contents("php://input");
        // Parsing the JSON
        $getContents = json_decode($input, true);
        // Getting the username, the password, the client token, and the agent
        $username = isset($getContents['username']) ? $getContents['username'] : null;
        $password = isset($getContents['password']) ? $getContents['password'] : null;
        $clientToken = isset($getContents['clientToken']) ? $getContents['clientToken'] : null;
        $agent = isset($getContents['agent']) ? $getContents['agent'] : null;
        // If the authentication worked
        if (auth($username, $password)) {
            // If the agent field isn't null
            if (!is_null($agent)) {
                // Sending a response with the agent
                send_response_agent($username, $clientToken, $agent['name'], $agent['version']);
            } else {
                // Sending a response without the agent
                send_response($username, $clientToken);
            }
        } else {
            // Else returning the third error (see functions.php)
            echo error(3);
        }
    } else {
        // Returning the sixth error
        echo error(6);
    }
} else {
    // Returning the first error
    echo error(1);
}
Exemplo n.º 4
0
function metaWeblog_newMediaObject($values)
{
    //2006-12-2 add support for uploading files
    global $config, $defualtcategoryid, $db_prefix, $mbcon, $nowtime;
    $userdetail = check_user($values['username'], $values['password']);
    $struct = $values['struct'];
    //writetofile ('text1.php', $struct['bits']); //debug only
    if ($struct['bits'] && $struct['name']) {
        $writefilecontent = base64_decode($struct['bits']);
        $ext = strtolower(strrchr($struct['name'], '.'));
        $ext = str_replace(".", '', $ext);
        $upload_filename = time() . '_' . rand(1000, 9999) . substr(md5($struct['name']), 0, 4) . '.' . $ext;
        if ($mbcon['uploadfolders'] == '1') {
            $targetfolder_ym = date("Ym") . '/';
            $targetfolder = "attachment/{$targetfolder_ym}";
            if (!is_dir($targetfolder)) {
                $mktargetfolder = @mkdir($targetfolder, 0777);
                if (!$mktargetfolder) {
                    xml_error("Sorry, uploading file ({$struct['name']}) failed because PHP was unable to create a new directory.");
                }
            }
        } else {
            $targetfolder_ym = '';
            $targetfolder = 'attachment';
        }
        $filenum = @fopen("{$targetfolder}/{$upload_filename}", "wb");
        if (!$filenum) {
            xml_error("Sorry, uploading file ({$struct['name']}) failed.");
        }
        flock($filenum, LOCK_EX);
        fwrite($filenum, $writefilecontent);
        fclose($filenum);
        //DB updating, new function in 2.1.0
        $blog = new boblog();
        $blog->query("INSERT INTO `{$db_prefix}upload` (fid,filepath,originalname,uploadtime,uploaduser) VALUES (null, \"attachment/{$targetfolder_ym}{$upload_filename}\", \"{$struct['name']}\", {$nowtime['timestamp']}, {$userdetail['userid']})");
        $currentid = db_insert_id();
        if ($mbcon['wmenable'] == '1') {
            //Add watermark
            $imgext_watermark = array('jpg', 'gif', 'png');
            if (in_array($ext, $imgext_watermark)) {
                create_watermark("attachment/{$targetfolder_ym}{$upload_filename}");
            }
        }
    }
    $xml_content = make_xml_piece("struct", array('url' => "{$config['blogurl']}/attachment.php?fid={$currentid}"));
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}
Exemplo n.º 5
0
/**
 * 处理announce_peer请求
 * @param  array $msg     接收到的announce_peer请求数据
 * @param  array $address 对端链接信息
 * @return void
 */
function on_announce_peer($msg, $address)
{
    global $nid;
    // 获取infohash
    $infohash = $msg['a']['info_hash'];
    // 获取token
    $token = $msg['a']['token'];
    // 获取node id
    $id = $msg['a']['id'];
    // 验证token是否正确
    if (substr($infohash, 0, 2) == $token) {
        /*$txt = array(
              'action' => 'announce_peer',
              'msg' => array(
                  'ip' => $address[0],
                  'port1' => $address[1],
                  'port2' => $msg['a']['port'],
                  'infohash' => $infohash
              )
          );
          var_dump($txt);*/
        $nodeid = bin2hex($id);
        LOGI("(node_id={$nodeid}) 获取到info_hash: " . strtoupper(bin2hex($infohash)));
        logDHTAnnouncePeer($nodeid, bin2hex($infohash));
    }
    // 生成回复数据
    $msg = array('t' => $msg['t'], 'y' => 'r', 'r' => array('id' => $nid));
    // 发送请求回复
    send_response($msg, $address);
}
Exemplo n.º 6
0
    echo line("{");
    // Start
    echo line(' "date_time": "' . $time . '",');
    echo line(' "temp1": "' . $temp1 . '",');
    echo line(' "temp2": "' . $temp2 . '",');
    echo line(' "temp3": "' . $temp3 . '",');
    echo line(' "temp4": "' . $temp4 . '"');
    echo line("}");
    // end
}
$temp_counter = 0;
$sql = "SELECT * FROM (SELECT * FROM tap_sensor ORDER BY date_time DESC) sub ORDER BY date_time ASC";
$result = $connection1->query($sql);
$counter = $result->num_rows;
echo line("[");
while ($row = $result->fetch_object()) {
    $temp_counter = $temp_counter + 1;
    $date_time = $row->date_time;
    $a = $row->highTempMax;
    $b = $row->highTempMin;
    $c = $row->lowTempMax;
    $d = $row->lowTempMin;
    send_response($date_time, $a, $b, $c, $d);
    if ($temp_counter < $counter) {
        echo line(",");
    }
}
echo line("]");
?>

Exemplo n.º 7
0
{
    $line = $data . chr(13) . chr(10);
    return $line;
}
function send_response($temp1, $temp2, $temp3, $temp4)
{
    echo line("{");
    // Start
    echo line(' 	"temp1": "' . $temp1 . '",');
    echo line(' 	"temp2": "' . $temp2 . '",');
    echo line(' 	"temp3": "' . $temp3 . '",');
    echo line(' 	"temp4": "' . $temp4 . '"');
    echo line("}");
    // end
}
$sql = "SELECT * FROM tap_sensor WHERE date_time=(SELECT MAX(date_time) FROM tap_sensor)";
$result = $connection1->query($sql);
if ($result) {
    $row = $result->fetch_object();
    $highTempMax = $row->highTempMax;
    $highTempMin = $row->highTempMin;
    $lowTempMax = $row->lowTempMax;
    $lowTempMin = $row->lowTempMin;
    send_response($highTempMax, $highTempMin, $lowTempMax, $lowTempMin);
} else {
    $highTempMax = 0;
    $highTempMin = 0;
    $lowTempMax = 0;
    $lowTempMin = 0;
    send_response($highTempMax, $highTempMin, $lowTempMax, $lowTempMin);
}
Exemplo n.º 8
0
        $reply = urlencode('Dear Enlightened LK member,
Your suggestion for improvement has been received and will be processed in the distant future (although this is unlikely). 
In the meantime, please be sure to obtain approval from the SL ENL Security Experts Incompetency Group (SESEIG™), 
as there may be unforeseen and unfathomable dangers associated with your change request. 
Thank you!');
        send_curl(build_response($chat_id, $reply));
        $reply = urlencode('New #ChangeRequest
from - @' . $messageobj['message']['from']['username'] . '
' . substr($messageobj['message']['text'], 14));
        send_curl(build_response(-27924249, $reply));
        return;
    }
    if ($request_message == '/help' || $request_message == '/help@SLEnlFarmBot' || $request_message == '/start@SLEnlFarmBot') {
        $reply = urlencode('This is the SL ENL Farming Bot created by @RamdeshLota. Commands:
/createfarm LOCATION DATE TIME - Creates a new farm.
/addmetofarm - Adds you to the current farm.
/removemefromfarm - Removes you from the current farm.
/addfarmer USERNAME - Adds the given username to the farm.
/removefarmer USERNAME - Removes the given username from the farm.
/setfarmlocation LOCATION - Sets the location for the current farm.
/getfarmlocation - Get the location of the current farm.
/setfarmtime DATE TIME - Sets the date and  time for the current farm.(e.g. "Today 6pm")
/deletefarm - Deletes the current farm.
/changerequest - Suggest a change to the bot.        		
/help - Display this help text.');
        send_curl(build_response($chat_id, $reply));
        return;
    }
}
send_response(file_get_contents('php://input'));
Exemplo n.º 9
0
<?php

// application bootstrapping
error_reporting(-1);
date_default_timezone_set('Australia/Brisbane');
// include external libraries
require_once '../vendor/autoload.php';
require_once 'functions.php';
// dispatch a response based on the current request
send_response('<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
    </head>
    <body>
        <video src="video.mp4" controls="controls"></video>
    </body>
</html>');
Exemplo n.º 10
0
function metaWeblog_newMediaObject($values)
{
    //2007-02-01 add support for uploading files
    global $settingInfo, $DMC, $DBPrefix, $defualtcategoryid;
    $userdetail = check_user_pw($values['username'], $values['password']);
    $struct = $values['struct'];
    $foldername = date("Ym");
    //writetofile ('text1.php', $struct['bits']); //debug only
    if ($struct['bits'] && $struct['name']) {
        $type = strtolower(substr($struct['name'], strrpos($struct['name'], ".") + 1));
        if (strpos(";" . $settingInfo['attachType'], $type) > 0 && strpos(";php|phtml|php3|jsp|exe|dll|asp|aspx|asa|cgi|fcgi|pl", $type) < 1) {
            $writefilecontent = base64_decode($struct['bits']);
            if (file_exists("attachments/{$foldername}/{$struct['name']}")) {
                @unlink("attachments/{$foldername}/{$struct['name']}");
            }
            $filenum = @fopen("attachments/{$foldername}/{$struct['name']}", "wb");
            if (!$filenum) {
                xml_error("Sorry, uploading file ({$struct['name']}) failed.");
            }
            flock($filenum, LOCK_EX);
            fwrite($filenum, $writefilecontent);
            fclose($filenum);
            $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}attachments/{$foldername}/{$struct['name']}"));
        } else {
            $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}index.php"));
        }
    } else {
        $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}index.php"));
    }
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}
Exemplo n.º 11
0
/**
 * 处理announce_peer请求
 * @param  array $msg     接收到的announce_peer请求数据
 * @param  array $address 对端链接信息
 * @return void
 */
function on_announce_peer($msg, $address)
{
    global $nid;
    // 获取infohash
    $infohash = $msg['a']['info_hash'];
    // 获取token
    $token = $msg['a']['token'];
    // 获取node id
    $id = $msg['a']['id'];
    // 验证token是否正确
    if (substr($infohash, 0, 2) == $token) {
        /*$txt = array(
              'action' => 'announce_peer',
              'msg' => array(
                  'ip' => $address[0],
                  'port1' => $address[1],
                  'port2' => $msg['a']['port'],
                  'infohash' => $infohash
              )
          );
          var_dump($txt);*/
        write(date('Y-m-d H:i:s', time()) . " 获取到info_hash: " . strtoupper(bin2hex($infohash)) . "\n");
    }
    // 生成回复数据
    $msg = array('t' => $msg['t'], 'y' => 'r', 'r' => array('id' => $nid));
    // 发送请求回复
    send_response($msg, $address);
}
Exemplo n.º 12
0
function metaWeblog_newMediaObject($values)
{
    //2007-02-01 add support for uploading files
    global $settingInfo, $DMC, $DBPrefix, $defualtcategoryid;
    $userdetail = check_user_pw($values['username'], $values['password']);
    $struct = $values['struct'];
    //writetofile ('text1.php', $struct['bits']); //debug only
    if ($struct['bits'] && $struct['name']) {
        $writefilecontent = base64_decode($struct['bits']);
        if (file_exists("attachments/{$struct['name']}")) {
            @unlink("attachments/{$struct['name']}");
        }
        $filenum = @fopen("attachments/{$struct['name']}", "wb");
        if (!$filenum) {
            xml_error("Sorry, uploading file ({$struct['name']}) failed.");
        }
        flock($filenum, LOCK_EX);
        fwrite($filenum, $writefilecontent);
        fclose($filenum);
    }
    $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}/attachments/{$struct['name']}"));
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}
Exemplo n.º 13
0
    if ($response->isError()) {
        $log->addInfo('Error while updating ' . $host['host'] . ':' . $response->getErrorMessage());
    } else {
        $log->addInfo('Successfully updated ' . $host['host']);
    }
    $responses[] = $response;
    $log->addInfo('Finished updating ' . $host['host']);
}
$log->addInfo('Finished updating all hosts');
$updateSuccess = array_reduce($responses, function ($carry, $resp) {
    return $carry && !$resp->isError();
}, true);
if ($updateSuccess) {
    send_response('All hosts updated successfully.', 200);
} else {
    send_response('One or more errors encountered while updating hosts. See log for more information.', 400);
}
/**
 * Sends a message with the HTTP status code respCode to the client
 *
 * @param $message Message
 * @param int $respCode HTTP status code
 */
function send_response($message, $respCode = null)
{
    global $log;
    if (!is_null($respCode)) {
        http_response_code($respCode);
    }
    if ($log) {
        $log->addInfo('Message sent: ' . $message);
Exemplo n.º 14
0
switch ($task) {
    case 'moveBundles':
        $status = move_mautic_bundles($status);
        break;
    case 'moveCore':
        $status = move_mautic_core($status);
        break;
    case 'moveVendors':
        $status = move_mautic_vendors($status);
        break;
    case 'clearCache':
        $status = clear_mautic_cache($status);
        break;
    default:
        $status['error'] = true;
        $status['message'] = 'Invalid task';
        $status['stepStatus'] = 'Failed';
        break;
}
// A way to keep the upgrade from failing if the session is lost after
// the cache is cleared by upgrade.php
$isSSL = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
$cookie_path = isset($localParameters['cookie_path']) ? $localParameters['cookie_path'] : '/';
$cookie_domain = isset($localParameters['cookie_domain']) ? $localParameters['cookie_domain'] : '';
$cookie_secure = isset($localParameters['cookie_secure']) ? $localParameters['cookie_secure'] : $isSSL;
$cookie_httponly = isset($localParameters['cookie_httponly']) ? $localParameters['cookie_httponly'] : false;
setcookie('mautic_update', $task, time() + 300, $cookie_path, $cookie_domain, $cookie_secure, $cookie_httponly);
// Encode the state for the next request
$status['updateState'] = base64_encode(json_encode($status['updateState']));
send_response($status);
Exemplo n.º 15
0
    die("Must pass in an accession number");
}
$raw_metadata = load_provenance_data($cmaan);
$creation_timestamp = time();
$GLOBALS['approved_tags'] = array("i", "em", "b", "strong");
# Start by extracting all citations, footnotes, and provenance from the full
# record
$metadata = extract_metadata($raw_metadata);
$metadata = normalize_metadata($metadata);
$metadata = reorder_by_nid($metadata);
# Renumber and dedupe footnote entries across the entire record
list($metadata, $footnotes) = reindex_footnotes($metadata);
# Renumber and dedupe citations across the entire record
list($metadata, $citations) = reindex_citations($metadata);
$response = array("provenanceEntries" => $metadata, "footnotes" => $footnotes, "citations" => $citations);
send_response($response);
# BEGIN FUNCTION DEFINITIONS
# Determine whether you should pull from the preview or the approved
# metadata as defined in Drupal. Both queries use a Drupal module which could
# eventually be superseded by a custom one if this lasts more than the next few
# months
function load_provenance_data($accession_number)
{
    if (isset($_GET['mode']) && $_GET['mode'] == "preview") {
        $source = "http://cmaweb14.clevelandart.org/export/preview?cmaan={$accession_number}";
    } else {
        $source = "http://cmaweb14.clevelandart.org/export/approved?cmaan={$accession_number}";
    }
    return json_decode(file_get_contents($source), $assoc = TRUE);
}
function extract_metadata($metadata)
Exemplo n.º 16
0
require "../includes/db_connection.php";
function line($data)
{
    $line = $data . chr(13) . chr(10);
    return $line;
}
function send_response($d1, $d2)
{
    echo line("{");
    // Start
    echo line(' 	"date1": "' . $d1 . '",');
    echo line(' 	"date2": "' . $d2 . '"');
    echo line("}");
    // end
}
$sql = "SELECT MIN(date_time) AS date1, MAX(date_time) AS date2 FROM tap_sensor";
$result = $connection1->query($sql);
if ($result) {
    $row = $result->fetch_object();
    $date1 = $row->date1;
    $date2 = $row->date2;
    $date1 = substr($date1, 0, 10);
    $date2 = substr($date2, 0, 10);
    //$date1 = str_replace("-", "/", $date1);
    //$date2 = str_replace("-", "/", $date2);
    send_response($date1, $date2);
} else {
    $date1 = "";
    $date2 = "";
    send_response($date1, $date2);
}
function send_messages_uuids_for_sms_delivery_report()
{
    if (isset($_GET['task']) and $_GET['task'] == 'result') {
        $response = json_encode(["message_uuids" => ['1ba368bd-c467-4374-bf28']]);
        send_response($response);
    }
}
Exemplo n.º 18
0
function handle_confirm_userinfo()
{
    $rpfA = $_SESSION['rpfA'];
    $client_id = $rpfA['client_id'];
    $authorized = false;
    if ($_REQUEST['confirm'] == 'confirmed') {
        if ($_REQUEST['agreed'] == "1") {
            $authorized = true;
        }
    }
    $trusted_site = db_get_user_trusted_client($_SESSION['username'], $client_id);
    if ($_REQUEST['trust'] == 'always') {
        log_debug("Trust = Always for %s", $client_id);
        if (!$trusted_site) {
            db_save_user_trusted_client($_SESSION['username'], $client_id);
        }
    } else {
        if ($trusted_site) {
            db_delete_user_trusted_client($_SESSION['username'], $client_id);
        }
    }
    send_response($_SESSION['username'], $authorized);
}
Exemplo n.º 19
0
     } else {
         $sent_len += send_response($hbuf . $buf, $sck_connected);
     }
     if ($first_chunk) {
         $sent_len -= strlen($hbuf);
         $hbuf = "";
         $first_chunk = false;
     }
     if ($lf->parser_eof() || !$sck_connected || $buf === NULL) {
         break;
     }
 }
 $lf->parser_close();
 if ($chunked) {
     $meta_len = 0;
     send_response("0\r\n\r\n", $sck_connected);
 }
 if (!$sck_connected) {
     $cnx = false;
 }
 if (($sent_content_length = $sent_len - $meta_len) < 0) {
     $sent_content_length = 0;
 }
 if ($conf["global"]["singleprocessmode"][0]) {
     // Increment stats
     ++$stats_resperr[$rq_err];
     ++$stats_vhosts[$conf[$vhost]["servername"][0]];
     ++$stats_hits;
     $stats_xfer += (double) $sent_len;
 } else {
     // Report hit to master