Ejemplo n.º 1
0
function http_send($_url, $_body)
{
    $errno = 0;
    $errstr = '';
    $timeout = 10;
    $fp = fsockopen(_IP_, _PORT_, $errno, $errstr, $timeout);
    if (!$fp) {
        return FALSE;
    }
    $_head = "POST /" . $_url . " HTTP/1.1\r\n";
    $_head .= "Host: " . _IP_ . ":" . _PORT_ . "\r\n";
    $_head .= "Content-Type: Text/plain\r\n";
    if (!$_body) {
        $body_len = 0;
    } else {
        $body_len = strlen($_body);
    }
    $send_pkg = $_head . "Content-Length:" . $body_len . "\r\n\r\n" . $_body;
    ilog(iLOG_INFO, "    -----> http_send url: " . $_url);
    ilog(iLOG_INFO, "    -----> http_send body: " . $_body);
    if (fputs($fp, $send_pkg) === FALSE) {
        return FALSE;
    }
    //设置3s超时
    stream_set_timeout($fp, 3);
    while (!feof($fp)) {
        ilog(iLOG_INFO, "    -----> rsp: " . fgets($fp, 128));
    }
    if ($fp) {
        fclose($fp);
    }
    return TRUE;
}
Ejemplo n.º 2
0
function sms_general($body_arr)
{
    $resp_arr = exec_procedure($body_arr, 'p_general_code');
    extract($resp_arr);
    if ($status != 0) {
        die_err_code_ret($resp_arr, __LINE__);
    }
    extract($body_arr);
    $code = $data[0]['code'];
    ilog(iLOG_INFO, "contact--->" . $contact, __LINE__);
    $content = '【' . _MESSAGESUBJECT_ . '】,您的验证码为:' . $code . ',有效期为:' . $deadminutes . '分钟!';
    //sendmsg_zx($contact, $content);
    return $resp_arr;
}
Ejemplo n.º 3
0
 public function NotifyProcess($data, &$msg)
 {
     //		Log::DEBUG("call back:" . json_encode($data));
     ilog(iLOG_INFO, 'wxapp/interface/appnotify.php,call back:' . $data, __LINE__);
     $notfiyOutput = array();
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性
     if (!$this->Queryorder($data["transaction_id"])) {
         $msg = "订单查询失败";
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
                //
                $body_arr['alipay_no'] = $trade_no;
                //支付宝流水号
                $body_arr['channel'] = 'alipaybank';
                //
                $ret1 = exec_procedure($body_arr, 'p_order_pay_result');
                if ($ret['status'] == 0 || $ret1['status'] == 1040) {
                    //get方式
                    //            file_get_contents($alipay_config['root_url'] . '/index.php/Home/Trademark/cmpdf?ordernum=' . $realuser_trade_no
                    //                    . '&type=' . $realuser_trade_type . '&jump=0');
                    echo "success";
                    //请不要修改或删除
                } else {
                    //
                    echo $ret['status'];
                }
            } else {
                $info2 = 'alipaybank/notify_url.php,operator failed,session != trade_no,ordernum:' . $user_trade_no . ',alipayno:' . $trade_no;
                echo '订单号有误,如果支付成功,请联系客服!';
            }
        }
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else {
    //验证失败
    $info = 'alipaybank/notify_url.php,operator failed';
    ilog(iLOG_INFO, $info, __LINE__);
    echo "fail";
    //调试用,写文本函数记录程序运行情况是否正常
    //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
}
Ejemplo n.º 5
0
 function write($destination_filepath)
 {
     $this->add_command('interlace', 'line');
     // progressive rendering
     // use 4:2:2 chroma subsampling (reduce file size by 20-30% with "almost" no human perception)
     //
     // option deactivated for Piwigo 2.4.1, it doesn't work fo old versions
     // of ImageMagick, see bug:2672. To reactivate once we have a better way
     // to detect IM version and when we know which version supports this
     // option
     //
     if (version_compare(pwg_image::$ext_imagick_version, '6.6') > 0) {
         $this->add_command('sampling-factor', '4:2:2');
     }
     $exec = $this->imagickdir . 'convert';
     $exec .= ' "' . realpath($this->source_filepath) . '"';
     foreach ($this->commands as $command => $params) {
         $exec .= ' -' . $command;
         if (!empty($params)) {
             $exec .= ' ' . $params;
         }
     }
     $dest = pathinfo($destination_filepath);
     $exec .= ' "' . realpath($dest['dirname']) . '/' . $dest['basename'] . '" 2>&1';
     @exec($exec, $returnarray);
     if (function_exists('ilog')) {
         ilog($exec);
     }
     if (is_array($returnarray) && count($returnarray) > 0) {
         if (function_exists('ilog')) {
             ilog('ERROR', $returnarray);
         }
         foreach ($returnarray as $line) {
             trigger_error($line, E_USER_WARNING);
         }
     }
     return is_array($returnarray);
 }
function getapachemodules()
{
    global $app;
    $cmd = '';
    if (is_installed('apache2ctl')) {
        $cmd = 'apache2ctl -t -D DUMP_MODULES';
    } elseif (is_installed('apachectl')) {
        $cmd = 'apachectl -t -D DUMP_MODULES';
    } else {
        ilog("Could not check apache modules, apachectl not found.");
        return array();
    }
    exec($cmd . ' 2>/dev/null', $output, $return_var);
    if ($return_var != 0 || !$output[0]) {
        ilog("Could not check apache modules, apachectl did not return any data.");
        return array();
    }
    $modules = array();
    for ($i = 0; $i < count($output); $i++) {
        if (preg_match('/^\\s*(\\w+)\\s+\\((shared|static)\\)\\s*$/', $output[$i], $matches)) {
            $modules[] = $matches[1];
        }
    }
    return $modules;
}
Ejemplo n.º 7
0
            rename($old_name, $new_name);
        }
    }
    function do_update_file()
    {
        $file_1 = $this->iTag_logroot . "web.1";
        $file_2 = $this->iTag_logroot . "web.2";
        $file_3 = $this->iTag_logroot . "web.3";
        $file_4 = $this->iTag_logroot . "web.4";
        if (file_exists($file_4)) {
            unlink($file_4);
        }
        $this->rename_file($file_3, $file_4);
        $this->rename_file($file_2, $file_3);
        $this->rename_file($file_1, $file_2);
        $this->rename_file($this->iLog_fpath, $file_1);
    }
}
// 设置全局日志对象
$log = NULL;
// 全局日志对象
// 日志级别(从低到高):iLOG_INFO,iLOG_WARNING,iLOG_ERROR
$api_k = 'QST';
$log = new iLog(0, $api_k, iLOG_INFO);
// 若要关闭日志,只需要把此行注释掉
if ($log) {
    $log->start();
}
//set_ilog(ifile_name(__FILE__));
ilog(iLOG_INFO, "<--------- start --------->", __LINE__);
Ejemplo n.º 8
0
function joinalipayinfo($body_arr)
{
    $order_no = $body_arr['order_no'];
    $randnum = rand(1000, 9999);
    //产生一个4位随机数
    $out_trade_no = $order_no;
    //='1449136260764';//. '-' . $randnum; //记录订单号+_+随机数
    $fee = getfee($body_arr) / 100;
    //支付宝支付,这里需要变换单位:元
    //    $info = 'partner="' . _ALIPAYPARTNER_ . '"&seller_id="' . _ALIPAYSELLEREMIAL_
    //            . '"&out_trade_no="'. $out_trade_no . '"&subject="' . $order_no . '"&body="'
    //            . $order_no . '"&total_fee="' . $fee . '"&notify_url="' . _ALIPAYAPPNTURL_
    //            . '"&service="mobile.securitypay.pay'. '"&payment_type="1"&_input_charset="utf-8'
    //            . '"&it_b_pay="30m';//&show_url='._MAILCALLBACK_;
    $infonew = array('partner' => _ALIPAYPARTNER_, 'seller_id' => _ALIPAYSELLEREMIAL_, 'out_trade_no' => $out_trade_no, 'subject' => $order_no, 'body' => $order_no, 'total_fee' => $fee, 'notify_url' => _ALIPAYAPPNTURL_, 'service' => 'mobile.securitypay.pay', 'payment_type' => '1', '_input_charset' => 'utf-8', 'it_b_pay' => '30m');
    $infonew = creatersanew($infonew);
    //    $info = $info. '"&sign="' . $sign . '"&sign_type="RSA"';
    ilog(3, "RESP:" . $infonew, __LINE__);
    return $infonew;
}
Ejemplo n.º 9
0
function exec_procedure($body_arr, $procedure, $type = 1, $dbconn = 0)
{
    unset($body_arr["inter_num"]);
    //构建存储过程参数
    addsubString($sql, "CALL " . $procedure . "(");
    array2str($body, $body_arr);
    addsubString($sql, $body);
    addsubString($sql, ",@vo_data, @vo_result)");
    ilog(iLOG_INFO, "    -----> " . $sql, __LINE__);
    // 执行存储过程
    $Records = array();
    $result = array();
    if ($type != 1 && $dbconn) {
        db_query_no_conn($dbconn, $sql, $Records, array("@vo_data", "@vo_result"), $result);
    } else {
        db_query($sql, $Records, array("@vo_data", "@vo_result"), $result);
    }
    ilog(iLOG_INFO, " status--->" . $result["@vo_result"], __LINE__);
    #数组转换{"status":"0","desc":"\u6210\u529f"
    //,"out_data":{"id":"33333","appid":"tttt"},"data":[]} 格式的JSON 包
    $resp_arr = clt_json_encode($Records, $result);
    return $resp_arr;
}
Ejemplo n.º 10
0
function ierror($msg, $code)
{
    if ($code == 301 || $code == 302) {
        if (ob_get_length() !== FALSE) {
            ob_clean();
        }
        // default url is on html format
        $url = html_entity_decode($msg);
        header('Request-URI: ' . $url);
        header('Content-Location: ' . $url);
        header('Location: ' . $url);
        ilog('WARN', $code, $url, $_SERVER['REQUEST_URI']);
        exit;
    }
    if ($code >= 400) {
        $protocol = $_SERVER["SERVER_PROTOCOL"];
        if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
            $protocol = 'HTTP/1.0';
        }
        header("{$protocol} {$code} {$msg}", true, $code);
    }
    //todo improve
    echo $msg;
    ilog('ERROR', $code, $msg, $_SERVER['REQUEST_URI']);
    exit;
}
Ejemplo n.º 11
0
function aftsl($file, $content)
{
    if (!($fp = fopen($file, 'ab'))) {
        ilog('WARNING: could not open file ' . $file);
    }
    fwrite($fp, $content);
    fclose($fp);
}
Ejemplo n.º 12
0
<?php

require_once "../libcode/comFun.php";
//根据HTTP BODY JSON包格式进行解析
$body = comFun::getRequestBody();
$body_arr = json_decode($body, true);
comFun::array2str($body, $body_arr);
//构建存储过程参数
comFun::addsubString($sql, "CALL p_clt_info_ext(");
comFun::addsubString($sql, $body);
comFun::addsubString($sql, ",@vo_data,@vo_result)");
ilog(iLOG_INFO, "    -----> " . $sql, __LINE__);
// 执行存储过程
$setRecords = array();
$result = array();
db_query($sql, $setRecords, array("@vo_data", "@vo_result"), $result);
//查询结果集合打包成 JSON 比如 {"status":"0","data":[]}
comFun::clt_json_encode($setRecords, $setRecords, $result["@vo_result"]);
iecho($setRecords, __LINE__);
Ejemplo n.º 13
0
function mergefile($temp_file, $targetFile, $start_byte, $end_byte)
{
    if (file_exists($temp_file)) {
        //非第一个包
        ilog(iLOG_INFO, "  mergefile  -----> curr_filesize:" . filesize($temp_file), __LINE__);
    }
    if (file_exists($targetFile)) {
        //非第一个包
        ilog(iLOG_INFO, "  mergefile  -----> target_filesize:" . filesize($targetFile), __LINE__);
    }
    //存在,读写方式打开,不存在,创建
    if ($start_byte == 0 || !file_exists($targetFile)) {
        $handle = fopen($targetFile, 'wb');
    } else {
        $handle = fopen($targetFile, 'rb+');
    }
    //起始字节不该比之前上传的文件size大
    if ($start_byte > filesize($targetFile)) {
        return false;
    }
    if (fseek($handle, $start_byte) < 0) {
        return false;
    }
    $tem_handle = fopen($temp_file, 'rb');
    $content = fread($tem_handle, filesize($temp_file));
    fclose($tem_handle);
    fwrite($handle, $content);
    fclose($handle);
    unlink($temp_file);
    //删除临时文件
    return true;
}