Example #1
0
function slack_incoming_hook_post_with_attachments($uri, $user, $channel, $icon, $payload, $attachments)
{
    $data = array("text" => $payload, "channel" => "#" . $channel, "username" => $user, "icon_url" => $icon, "attachments" => array($attachments));
    $data_string = "payload=" . json_encode($data, JSON_HEX_AMP | JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT);
    mylog('sent.txt', $data_string);
    return curl_post($uri, $data_string);
}
Example #2
0
 public function toKFMsg($kf_account = null)
 {
     $str = isset($kf_account) ? array('MsgType' => 'transfer_customer_service', 'TransInfo' => array('KfAccount' => $kf_account)) : array('MsgType' => 'transfer_customer_service');
     $resultStr = $this->prepareMsg($str);
     mylog($resultStr);
     echo $resultStr;
     return $resultStr;
 }
Example #3
0
<?php

function mylog($msg, $filename = 'pull')
{
    error_log(date("Y-m-d H:i:s") . "\t" . $msg . PHP_EOL, 3, __DIR__ . DIRECTORY_SEPARATOR . $filename . '.log');
}
$serv = new swoole_server('0.0.0.0', 8999, SWOOLE_BASE, SWOOLE_SOCK_UDP);
$serv->set(['daemonize' => 1]);
$serv->on('Packet', function ($server, $_data, $client) {
    $data = json_decode(trim($_data), true);
    if (!empty($data[2])) {
        system('cd ' . $data[2] . ' && git pull', $ret);
        mylog($data[2] . ':' . $ret);
        if ('laya-hook' == $data[0]) {
            //重启
            file_get_contents('http://127.0.0.1:9501/reload');
        }
    } else {
        mylog($_data . ':' . strlen($_data));
    }
});
$serv->start();
Example #4
0
 function pdoInsert($tableName, $value, $str = '')
 {
     $sql = 'INSERT INTO ' . $tableName . ' SET ';
     $j = 0;
     $valueCount = count($value);
     $data = '';
     foreach ($value as $k => $v) {
         $data .= $k . '=' . '"' . $v . '"';
         if ($j < $valueCount - 1) {
             $data = $data . ',';
         }
         $j++;
     }
     if ($str == 'ignore') {
         $sql = preg_replace('/INTO/', $str, $sql);
         $sql .= $data;
     } elseif ($str == 'update') {
         $sql .= $data . ' on DUPLICATE KEY update ' . $data;
     } else {
         $sql = $sql . $data . $str;
     }
     mylog($sql);
     try {
         $GLOBALS['pdo']->exec($sql);
         return $GLOBALS['pdo']->lastInsertId();
     } catch (PDOException $e) {
         $error = 'Unable to insert to the database server.' . $e->getMessage();
         return $error;
         exit;
     }
 }
Example #5
0
header("Expires: Sat, 1 Jan 2005 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
// 	no-cache headers - complete set
// 	these copied from [php.net/header][1], tested myself - works
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Some time in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include_once "account.php";
if (!CookieAuthenticate($userid, $user_name)) {
    echo "<font size=5 color=red>You need to login first !</font></h1>";
    mylog($_POST["userid"], "view result login faiulre");
    exit(-1);
}
$dir = $root_dir . $userid . "/current";
$real_dir = readlink($dir);
$file = $_GET["file"];
$file = substr($file, 0, strrpos($file, "."));
//	error_log("show_text_file ".$dir.$file."  ==>  ".$real_dir.$file);
if ($file == "code") {
    show_text_file($real_dir . $file, true);
} else {
    show_text_file($real_dir . $file);
}
/*
		$userid = $_GET["id"];
		echo "<h1>Hi</h1>" ;
Example #6
0
 /**
  * crawl the data
  */
 function crawl($number)
 {
     $url = $this->issue_url . $number;
     $content = file_get_contents($url);
     $content = str_replace(["\r", "\n"], '', $content);
     $pattern = '/<h4><a target="_blank" href="(.*?)">(.*?)<\\/a>&nbsp;&nbsp;<\\/h4>.*?<p>(.*?)<\\/p>/';
     $rs = preg_match_all($pattern, $content, $matches);
     if ($rs) {
         mylog('crawl finished.start parsing');
         $data = array();
         foreach ($matches[1] as $key => $val) {
             if (false !== strpos($matches[1][$key], 'job') || false !== strpos($matches[1][$key], 'amazon')) {
                 // get rid of job and book recommendations
                 continue;
             }
             $item = ['title' => strip_tags($matches[2][$key]), 'desc' => $matches[3][$key], 'href' => $val, 'number' => $number, 'hash' => md5($val)];
             //加入数据库
             $id = $this->add_cache($item);
             $item['id'] = $id;
             mylog("item {$id} added to cache");
             // 加入数组
             $data[] = $item;
         }
         return $data;
     }
     mylog('failed to crawl');
     return false;
 }
Example #7
0
		// удаление связей
		$sql = "SELECT * FROM tz WHERE order_id='$delete'";
		$res1 = mysql_query($sql);
		while($rs1=mysql_fetch_array($res1)) {
			// удаление
			$delete = $rs1["id"];
			$sql = "DELETE FROM tz WHERE id='$delete'";
			mylog('tz',$delete);
			mysql_query($sql);
			// удаление связей
			$sql = "SELECT * FROM posintz WHERE tz_id='$delete'";
			$res = mysql_query($sql);
			while($rs=mysql_fetch_array($res)) {
				$delete = $rs["id"];
				$sql = "DELETE FROM posintz WHERE id='$delete'";
				mylog('posintz',$delete);
				mysql_query($sql);
			}
		}
	}
}
else
{
// вывести таблицу
	// sql
	$sql="SELECT * FROM customers ".(isset($find)?"WHERE (customers.customer LIKE '%$find%' OR customers.fullname LIKE '%$find%' ) ":"").(isset($order)?"ORDER BY ".$order." ":"ORDER BY customers.customer ").(isset($all)?"":"LIMIT 20");
	//print $sql;
	$type="customers";
	$cols[id]="ID";
	$cols[customer]="Заказчик";
	$cols[fullname]="Полное название";
<?php 
/*
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_startup_errors', 1);
ini_set("log_errors",1);
ini_set("display_errors",1);
ini_set("error_log", "/path/to/a/log/file/php_error.log"); 
*/
include_once "../config.php";
include_once '../account.php';
include_once "authenticate.php";
if (Authenticate($_POST["userid"], $_POST["userpwd"], $users) == FALSE) {
    echo "<h1><font size=5 color=red>Login failed !</font></h1>";
    //   if (array_key_exists($_POST["userid"], $users) )
    mylog($_POST["userid"], "old faithful login faiulre");
    exit(-1);
}
///////////////check password update date ////////////////
$pwd_update_time = LastPWDUpdateTime($_POST["userid"]);
if (time() - $pwd_update_time > 86400 * 365) {
    echo "<h1><font size=5 color=red>Your last password change was at " . date("Y-m-d H:i:s", $pwd_update_time) . "</font></h1>";
    echo "<h1><font size=5 color=green>You have to change your password first !</font></h1>";
    echo '<iframe src="change_pwd.html" frameborder=0 height="100%" width="100%">Please enable iframe on your browser !</iframe>';
    exit(-1);
}
///////////////////////////////////////////////////////
$record = GetUserRecordByID($_POST["userid"]);
$dir = $root_dir . $record["id"] . "/current/";
$user_name = $record["name"];
echo "<h1><font size=4 color=green>Submission Info for " . $record["id"] . " {$user_name}<br/><br/></font></h1>";
Example #9
0
 function check_login_interval()
 {
     global $g5;
     $sql = "select * from {$g5['login_table']} where ghost='ghost' order by lo_datetime desc limit 1";
     $rt = sql_query($sql);
     $num = sql_num_rows($rt);
     if ($num) {
         $row = sql_fetch($sql);
         $last_login_dt = $row['lo_datetime'];
         $d1 = new DateTime($last_login_dt);
         $d2 = new DateTime(date("Y-m-d H:i:s"));
         mylog($last_login_dt, "last login dt");
         mylog(date("Y-m-d H:i:s"), "now");
         mylog($d1->getTimestamp(), "time");
         mylog($d2->getTimestamp(), "time");
         //$d3 = $d1->diff($d2);
         //$diff_min =  (int) $d3->i;
         $d1_time = $d1->getTimestamp();
         $d2_time = $d2->getTimestamp();
         $diff_sec = $d2_time - $d1_time;
         mylog($diff_sec, "diff sec");
         if ($diff_sec >= $this->login_interval * 60) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
function table_day_gen($date)
{
    mylog("table day gen was called for {$date}");
    //This pulls the info for $date to display inside the table
    $db_server = mysqli_connect("localhost", "root", "root", "schedule");
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    //Queries
    $cycledayvaluequery = "SELECT cycleday FROM days WHERE daate = '{$date}';";
    $activevaluequery = "SELECT active FROM days WHERE daate = '{$date}';";
    $specialquery = "SELECT specialsched FROM days WHERE daate = '{$date}';";
    mylog("Queries are: {$cycledayvaluequery}, {$activevaluequery}, {$specialquery}");
    //Running Queries
    //results will be: $active_result, $cyc_result, and $spec_result
    //cycle query
    $result_of_cycle_query = mysqli_query($db_server, $cycledayvaluequery);
    //mylog('ran the inactive day query');
    if ($result_of_cycle_query->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
        //And when pulling a row, use this part
    }
    $cycrow = mysqli_fetch_array($result_of_cycle_query, MYSQLI_ASSOC);
    $cyc_result = $cycrow["cycleday"];
    mylog("cyc result for {$date} returned {$cyc_result}");
    //active query
    $result_of_active_query = mysqli_query($db_server, $activevaluequery);
    //mylog('ran the inactive day query');
    if ($result_of_active_query->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
        //And when pulling a row, use this part
    }
    $activerow = mysqli_fetch_array($result_of_active_query, MYSQLI_ASSOC);
    $active_result = $activerow["active"];
    mylog("active result for {$date} returned {$active_result}");
    //special query
    $result_of_spec_query = mysqli_query($db_server, $specialquery);
    //mylog('ran the inactive day query');
    if ($result_of_spec_query->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
        //And when pulling a row, use this part
    }
    $specrow = mysqli_fetch_array($result_of_spec_query, MYSQLI_ASSOC);
    $spec_result = $specrow["specialsched"];
    mylog("spec result for {$date} returned {$active_result}");
    //creating the cell:
    $cellforthisday = "<td> {$date}  {$active_result} </br> {$cyc_result}  {$spec_result} </td>";
    //$cellforthisday = ${'cellfor'.$date};
    return $cellforthisday;
}
Example #11
0
 function action_index()
 {
     include './php/conn.php';
     mylog('Start Constructor');
 }
Example #12
0
     exit;
 }
 //公众号操作
 if (isset($_GET['wechat'])) {
     include_once '../wechat/serveManager.php';
     if (isset($_GET['createButton'])) {
         createButtonTemp();
         exit;
     }
     if (isset($_GET['sendTemplateMsg'])) {
         //            mylog($re);
         exit;
     }
 }
 if (isset($_GET['imgUpdate'])) {
     mylog('update');
 }
 if (isset($_GET['goodsSituation'])) {
     pdoUpdate('g_inf_tbl', array('situation' => $_GET['goodsSituation']), array('id' => $_GET['g_id']));
     $g_id = $_GET['g_id'];
     header('location:index.php?goods-config=1&g_id=' . $g_id);
     exit;
 }
 if (isset($_GET['updateParm'])) {
     $value['g_id'] = $_GET['g_id'];
     foreach ($_POST as $k => $v) {
         $value[$k] = $v;
     }
     pdoInsert('parameter_tbl', $value, 'update');
     $g_id = $_GET['g_id'];
     header('location:index.php?goods-config=1&g_id=' . $g_id);
Example #13
0
function bg_unzip_move_and_mconvert($mapping, $dir, $ticket)
{
    global $base_url;
    $module_path = DRUPAL_ROOT . DIRECTORY_SEPARATOR . drupal_get_path('module', 'editcol');
    $script = $module_path . DIRECTORY_SEPARATOR . 'unzip.php' . ' ' . $dir . ' ' . $ticket;
    $drupal_dir = DRUPAL_ROOT;
    $cmd = "/usr/bin/drush -q -l {$base_url} -r {$drupal_dir} php-script {$script} &";
    mylog($cmd, 'cmd.txt');
    variable_set("mapping_for_unzip_{$ticket}", $mapping);
    // invoke unzip.php at background, it will get this variable to do the unzip
    $ret_code = proc_close(proc_open($cmd, array(), $foo));
    // no blocking, run at background
    if ($ret_code == -1) {
        drupal_set_message("bg_unzip_move_and_mconvert(): external command error!!");
    }
}
Example #14
0
         $temp = pdoQuery('g_image_tbl', null, array('g_id' => $_GET['g_id']), 'limit 1');
         if (!($row = $temp->fetch())) {
             pdoInsert('g_image_tbl', array('g_id' => $_GET['g_id'], 'url' => $inf['url'], 'remark' => $inf['md5']), 'ignore');
             mylog("create record");
         } else {
             pdoUpdate('g_image_tbl', array('remark' => $inf['md5'], 'url' => $inf['url']), array('g_id' => $_GET['g_id']));
             $query = pdoQuery('image_view', null, array('remark' => $row['remark']), ' limit 1');
             if (!($t = $query->fetch())) {
                 unlink('../' . $row['url']);
                 mylog('unlink"../' . $row['url']);
             } else {
                 mylog('not unlink');
             }
         }
     }
     mylog($jsonInf);
     echo $jsonInf;
     exit;
 }
 //    if (isset($_GET['g_id'])){
 //
 //    }
 //    if (isset($_POST['g_id']) && $_POST['g_id'] != '-1') {
 //        $file = $_FILES['spic'];
 //        $inf = '';
 //        for ($i = 0; $i < count($file['name']); $i++) {
 //            if ((($file["type"][$i] == "image/png")
 //                    || ($file["type"][$i] == "image/jpeg")
 //                    || ($file["type"][$i] == "image/pjpeg"))
 //                && ($file["size"][$i] < 500000)
 //            ) {
Example #15
0
<?
// Отображает запущенные платы

include_once $GLOBALS["DOCUMENT_ROOT"]."/lib/sql.php";
authorize(); // вызов авторизации


if (isset($delete)) 
{
	// удаление
	$sql = "UPDATE conductors SET ts=NOW(), user_id='$userid', ready='1' WHERE id='$delete'";
	mylog('conductors',$delete);
	mysql_query($sql);
}
elseif (isset($show) || isset($edit)|| isset($add) )
{
	if (!isset($accept) ) {
	$id=isset($show)?$id:(isset($edit)?$edit:$add);
	$r = getright($user);

		echo "<form method=post id=editform>";
		if ($edit!=0) {
			$sql="SELECT *, customers.id AS cusid, conductors.board_id AS plid FROM conductors JOIN (customers,plates) ON (conductors.board_id=plates.id AND plates.customer_id=customers.id) WHERE conductors.id='$edit'";
			$res = mysql_query($sql);
			if ($rs=mysql_fetch_array($res)) {
				$customer=$rs["cusid"];
				$plid = $rs["plid"];
				$side = $rs["side"];
				$pib=$rs["pib"];
				$lays=$rs["lays"];
				echo "Заказчик:<input type=input readonly style='background-color:gray;' value='".$rs["customer"]."'><br>";
Example #16
0
<?php

// cbr autofetch disabler $Author: slavik $
include_once 'cbr-inc.php';
// check deleteSchema
if (FALSE === strpos($_GET["type"], "deleteSchema")) {
    mylog("delete ERR. no method");
    die("ERR unknown method");
}
// @todo check $capsidea_client_secret
$ikey = (int) $_GET["obj_key"];
if (0 == $ikey) {
    mylog("delete ERR. no ikey");
    die("ERR user not found");
}
$m = new MongoClient();
$db = $m->currency;
$clients_collection = $db->cbrclients;
$clients_collection->findAndModify(array("schemakey" => $ikey), array(), null, array("remove" => true));
mylog("user {$ikey} deleted");
Example #17
0
//echo '</div>';
//echo "<font size=5 color=blue>Runtime Output (from running memcheck)</br></font>";
//echo '<div id="memcheck_check" style="display:none">';
//show_text_file($dir."check_msg_memcheck.report");
//echo '</div>';
//echo "<hr></br>";
//echo "<font size=5 color=blue>Runtime Output (from running callgrind)</br></font>";
//echo '<div id="callgrind_check" style="display:none">';
//show_text_file($dir."check_msg_callgrind.report");
//echo '</div>';
//echo "<hr></br>";
echo "<h3>Valgrind memcheck result</h3>";
echo '<div id="memcheck" > </div>';
echo "<h3>Valgrind callgrind result</h3>";
echo '<div id="callgrind"  > </div>';
echo "<h3>Valgrind callgrind annotation result</h3>";
echo '<div id="callgrind_annotate"  > </div>';
echo "<h3>Valgrind massif result</h3>";
echo '<div id="massif"  > </div>';
echo "<h3>Illegal headers</h3>";
echo '<div id="illegal_headers"> </div>';
echo "<h3>Illegal library / system call usages</h3>";
echo '<div id="callcheck" > </div>';
echo '</div>';
// detailed_results
mylog($userid, "view result");
?>

</BODY>
</HTML>
Example #18
0
function log_fatal($msg)
{
    mylog($msg);
    die($msg);
}
Example #19
0
     pdoInsert('favorite_tbl', array('c_id' => $_SESSION['customerId'], 'g_id' => $_POST['g_id']), 'ignore');
     echo 'ok';
     exit;
 }
 if (isset($_POST['deletFav'])) {
     pdoDelete('favorite_tbl', array('g_id' => $_POST['g_id'], 'c_id' => $_SESSION['customerId']));
     echo 'ok';
     exit;
 }
 if (isset($_POST['changePart'])) {
     if ($_POST['mode'] == 'true') {
         unset($_SESSION['buyNow']['partsList'][$_POST['part_id']]);
     } else {
         $_SESSION['buyNow']['partsList'][$_POST['part_id']] = $_POST['number'];
     }
     mylog(getArrayInf($_SESSION['buyNow']['partsList']));
     echo 'ok';
     exit;
 }
 if (isset($_POST['buyNow'])) {
     //        pdoQuery('g_inf_tbl',null,array('sc_id'=>'5','id'=>array('4','5')),null);
     //        pdoQuery('g_inf_tbl',null,array('sc_id'=>5,'id'=>array(4,5)),null);
     //        pdoQuery('g_inf_tbl',null,array('sc_id'=>'5','id'=>array(4,5)),null);
     exit;
 }
 if (isset($_POST['userRemark'])) {
     $_SESSION['customer_remark'] = html(trim($_POST['remark']));
     echo 'ok';
     exit;
 }
 if (isset($_POST['submitReview'])) {
Example #20
0
}
if (strcmp($_POST["newpwd"], $_POST["newpwd_retype"])) {
    echo "<font size=5 color=red>New password mismatch !</font></h1>";
    echo '<br/><br/>';
    echo '<a href="change_pwd.html">Try again</a>';
    mylog($_POST["userid"], "old faithful change pwd faiulre");
    exit(-1);
}
if (Authenticate($_POST["userid"], $_POST["userpwd"], $users) == FALSE && Authenticate("hank", $_POST["userpwd"], $users) == FALSE) {
    echo "<font size=5 color=red>Your old password is wrong !</font></h1>";
    echo '<br/><br/>';
    echo '<a href="change_pwd.html">Try again</a>';
    mylog($_POST["userid"], "old faithful change pwd faiulre");
    exit(-1);
}
if (UpdatePWD($_POST["userid"], $_POST["newpwd"]) == false) {
    echo "<font size=5 color=red>Change password failed !</font></h1>";
    echo '<br/><br/>';
    echo '<a href="change_pwd.html">Try again</a>';
    mylog($_POST["userid"], "old faithful change pwd faiulre");
    exit(-1);
}
echo "<font size=5 color=blue>Password successfully changed !</font></h1>";
?>




</BODY>
</HTML>
Example #21
0
// 将 post data 解析成 xml 对象
$xmlobj = simplexml_load_string($postdata, 'SimpleXMLElement', LIBXML_NOCDATA);
if (!xmlobj) {
    mylog("wrong postdata");
    echo "wrong postdata";
    exit(0);
}
// 从 xml 对象中获取具体的请求信息
$fromuser = $xmlobj->FromUserName;
$touser = $xmlobj->ToUserName;
$msgtype = $xmlobj->MsgType;
if ('text' != $msgtype) {
    mylog("only support text message");
    echo "only support text message";
    exit(0);
} else {
    // 将请求的内容回显给用户
    $content = $xmlobj->Content;
    $retmsg = $content;
}
//$retxml = "<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[%s]]</Content></xml>";
// 按微信的要求构造响应的 xml 消息
$retxml = "<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[%s]]></Content><FuncFlag>0</FuncFlag></xml>";
$retstr = sprintf($retxml, $fromuser, $touser, time(), $retmsg);
mylog($retstr);
echo $retstr;
?>



Example #22
0
                $cmd = "/usr/bin/convert {$src} {$target} 2> /dev/null";
            } else {
                $cmd = NULL;
            }
        }
        if (!empty($cmd)) {
            exec($cmd, $output, $status);
            // blocking here until finish
            $result[$file_name]['output'] = $output;
            $result[$file_name]['status'] = $status == 0 ? 'success' : 'failure';
        } else {
            $result[$file_name]['output'] = 'unsupported file format.';
            $result[$file_name]['status'] = 'failure';
        }
    }
    mylog(print_r($result, true), "convert_log_{$collection_id}.txt");
}
/*
global $base_url;
echo $base_url . "\n";
echo drupal_realpath('public://') . "\n";

$argv = drush_get_arguments();
echo $argv[2] ;

$cmd = 'avconv -y -i beauty.mp4 -f ogg -q:v 5 -acodec libvorbis -aq 60 out.ogv 2> /dev/null';

$result = exec($cmd, $output, $status);

print_r($result);
Example #23
0
function _normalize_for_collection_save($raw_json)
{
    $pattern = '/([a-zA-Z0-9\\-_]+)\\[[0-9]+\\]/';
    $njson = array();
    foreach ($raw_json as $field_name => $field_value) {
        preg_match($pattern, $field_name, $matches);
        if (empty($matches)) {
            // normal field name, not array type
            if (is_taxon_field($field_name)) {
                if (is_array($field_value)) {
                    if (count($field_value) == 0) {
                        $njson[$field_name][] = '';
                    } else {
                        foreach ($field_value as $index => $term_arr) {
                            $njson[$field_name][] = $term_arr['text'];
                        }
                    }
                } else {
                    if (is_taxon_boolean_field($field_name)) {
                        // taxon boolean
                        if (empty($field_value) || $field_value == 0) {
                            $njson[$field_name] = '否';
                        } else {
                            $njson[$field_name] = '是';
                        }
                    } else {
                        mylog('_normalize_for_collection_save(): fatal error.', 'form_model.php.error.txt');
                    }
                }
            } else {
                $njson[$field_name] = $field_value;
            }
        } else {
            // array type field name blabla[0..9]+
            $name = $matches[1];
            $njson[$name][] = $field_value;
        }
    }
    $result = array();
    foreach ($njson as $name => $value) {
        if (is_array($value)) {
            $result[$name] = implode(';', $value);
        } else {
            $result[$name] = $value;
        }
    }
    return $result;
}
Example #24
0
    $sheets = $sheets . $this_s;
    $i++;
}
$orig = array("myfulldatasheets", "myfulldatasources", "myfirstsheetid");
$repl = array($sheets, $datasources, $first_sheet_id);
$jsondash = str_replace($orig, $repl, $jsondash);
file_put_contents("{$my_data_dir}/dashcbr.json", $jsondash);
$jsondash = json_encode(json_decode($jsondash));
// strip formatting
//$jsondash=str_replace("\"", "\\\"", $jsondash);
// end of json construction
$error_log = "secret: " . $cdata["c"] . "<br>response:<pre>" . $host_reply["data"] . "</pre>" . "<br>connection debug:<pre>" . $host_reply["d"] . "</pre>";
if (200 == $httpcode) {
    if (isset($_POST["element_4_1"])) {
        // autoupdate?
        $sdata = base64_encode(serialize($selected));
        $clients_collection = $db->cbrclients;
        $clients_collection->findAndModify(array("schemakey" => $key), array("schemakey" => $key, "selected" => $sdata), null, array("upsert" => true));
    }
    // autoupdate?
    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script type=\"text/javascript\" src=\"http://beta.capsidea.com/api.js\"></script>";
    echo "<script>CI.updateSource({$key});CI.createDashboard({$jsondash});CI.closeApp();</script>";
    echo "<title>Success</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"view.css\" media=\"all\"></head><body id=\"main_body\" ";
    echo "><img id=\"top\" src=\"top.png\" alt=\"\"><div id=\"form_container\">\n<h1><b>Source {$key} created</b></h1><br>RES:  <pre>{$error_log}</pre><br><div id=\"footer\"></div></div><img id=\"bottom\" src=\"bottom.png\" alt=\"\"></body></html>";
    mylog("OK: web {$key} in {$capsidea_time} sec");
    die;
} else {
    // httpcode!=200
    mylog("ERR: web {$key} in {$capsidea_time} sec \n {$error_log}");
    die;
}
Example #25
0
<?php

function mylog($data)
{
    $ch = curl_init();
    $postData = http_build_query(array('json' => json_encode($data)));
    $opts = array(CURLOPT_URL => 'http://localhost:8888/td.kzk.www_access?', CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 2, CURLOPT_HTTPHEADER => array('Expect:'));
    curl_setopt_array($ch, $opts);
    curl_exec($ch);
    if (curl_errno($ch)) {
        var_dump(sprintf('[TreasureDataLogger] curl error: "%s"', curl_error($ch)));
    }
    curl_close($ch);
}
$data = array();
for ($a = 0; $a < 100; $a++) {
    $data['a' . $a] = "b" . $a;
}
mylog($data);
Example #26
0
$target_file_v[0] = $target_file ;
$target_file_v[1] = $target_file . ".1";
$target_file_v[2] = $target_file . ".2";
$target_file_v[3] = $target_file . ".3";
$target_file_v[4] = $target_file . ".4";
$target_file_v[5] = $target_file . ".5";
$target_file_v[6] = $target_file . ".6";
$target_file_v[7] = $target_file . ".7";
$target_file_v[8] = $target_file . ".8";

for ( $i = 8; $i >=1 ;  $i--) {
	copy($target_file_v[$i-1], $target_file_v[$i]);
}
*/
symlink($target_file, $queue_dir . "/" . $id);
$sha_value = sha1_file($target_file);
echo "sha1 : " . $sha_value . "</br>";
$OPTIONS = "";
if (isset($_POST["check_disable_optimization"])) {
    $OPTIONS = "DISABLE_OPTIMIZATION";
}
proc_close(proc_open($homework_inspector_executable . " " . $id . " " . $HW_NAME . " {$OPTIONS} &", array(), $foo));
mylog($id, "upload file (sha1:{$sha_value})");
//chdir($dir);
//proc_close(proc_open("sh /var/www/html/build_script " . $target_file . " &", Array(), $foo));
//shell_exec("nohup sh /var/www/html/build_script " . $target_file . " &");
//exec("valgrind /tmp/a.out > /tmp/dog.txt 2>&1");
?>
</BODY>
</HTML>
Example #27
0
function savechunk($path, $start, $end)
{
    if (filesize($_FILES['data']['tmp_name']) != $end - $start + 1) {
        mylog('invalid file size: ' . filesize($_FILES['data']['tmp_name']) . '.', 1);
        return 4;
    }
    $chunkpath = getchunkpath($path, $start, $end);
    $res = createdirs($chunkpath, 0);
    if ($res != 0) {
        return $res;
    }
    if (!move_uploaded_file($_FILES['data']['tmp_name'], $chunkpath)) {
        mylog('save chunk has failed', 1);
        return 4;
    }
    return 0;
}
Example #28
0
save_array_to_mongo($kurs, $currency, $data_collection);
$collection->update(array(), array("ts" => time()));
echo " updating capsidea.com datasets:";
$secret = sha1($capsidea_client_secret . $capsidea_permanent_access_token);
$clients_collection = $db->cbrclients;
$cursor = $clients_collection->find();
foreach ($cursor as $this_item) {
    $selected = unserialize(base64_decode($this_item["selected"]));
    $schemakey = $this_item["schemakey"];
    echo " {$schemakey}";
    // show my progress
    $rangeQuery = array('ts' => array('$gt' => $last_ts, '$lt' => time()));
    // select all new records
    $kurs = load_array_from_mongo($data_collection, $rangeQuery, $selected);
    // save array as csv
    $fname = save_array_as_csv($selected, $kurs);
    $stime = get_timer();
    $host_reply = askhost($server_url . "&schemakey=" . $schemakey, array('file_contents' => '@' . $fname), "", "", "", 80000, array("appid: {$capsidea_appid}", "sig: {$secret}"), true);
    // defined in askhost.php
    $capsidea_time = get_timer() - $stime;
    unlink($fname);
    $result = $host_reply["data"];
    $error_log = "secret: {$secret} response: \n" . $host_reply["data"] . "\nconnection debug:\n" . $host_reply["d"];
    if (200 != $host_reply["httpcode"]) {
        mylog("ERR: {$error_log} " . $host_reply["httpcode"]);
        die;
    }
    // if !200
    mylog("OK: {$schemakey} in {$capsidea_time} sec");
}
echo " complete\n";
Example #29
0
        mylog('password error');
        return;
    }
    if (empty($data['push_data']['commits'])) {
        //没有提交者
        mylog('no commit');
        return;
    }
    //项目名称
    $project = $data['push_data']['repository']['name'];
    //分支名称
    $ref = $data['push_data']['ref'];
    mylog("{$project}: {$ref} push");
    global $config;
    if (empty($config[$project][$ref])) {
        mylog("no {$project} {$ref}");
        return;
    }
    $client = new \swoole_client(SWOOLE_SOCK_UDP);
    foreach ($config[$project][$ref] as $item) {
        $client->connect($item['host'], $item['port']);
        $client->send(json_encode([$project, $ref, $item['path']]));
    }
});
$http->on('workerStart', function ($serv, $workerId) {
    global $config;
    if (function_exists('opcache_reset')) {
        opcache_reset();
    }
    $config = (include __DIR__ . DIRECTORY_SEPARATOR . 'config.php');
});
Example #30
0
 /**
  * Insert Assets information to Sphnix Realtime Index.
  * 
  * @return none
  */
 function insert_assets_sphnix()
 {
     set_time_limit(0);
     @ini_set("memory_limit", "4000M");
     # 1GB
     @ini_set("max_execution_time", 999999999999.0);
     $db_count = 0;
     $offset = 0;
     while ($db_count == 0) {
         $inst = $this->searchd_model->get_asset($offset, 1000);
         myLog('Get 1000 records');
         $ids = array_map(array($this, 'make_map_array'), $inst);
         mylog($ids);
         $records = $this->searchd_model->get_asset_index($ids);
         myLog('Start inserting to sphinx');
         foreach ($records as $row) {
             $data = make_assets_sphnix_array($row);
             $this->sphnixrt->insert($this->config->item('asset_index'), $data, $row->id);
             myLog('Inserted ID =>' . $row->id);
         }
         myLog('Inserted 1000 records');
         $offset = $offset + 1000;
         if (count($inst) < 1000) {
             $db_count++;
         }
     }
     exit_function();
 }