public function map()
 {
     $dirty_type = @$_REQUEST["se_account_type"];
     switch ($dirty_type) {
         case "vo_transfer_volume":
             $urlbase = config()->gratiaweb . "/status_graphs/status_vo";
             $sub_title = "Transfer volume (Grouped by VO)";
             $ylabel = "Transfer Volume (GB)";
             break;
         case "user_transfer_volume":
             $urlbase = config()->gratiaweb . "/transfer_graphs/user_transfer_volume";
             $sub_title = "Transfer Volumn (Grouped by Username)";
             $ylabel = "Transfer Volume (GB)";
             break;
         case "se_space":
             $urlbase = config()->gratiaweb . "/status_graphs/status_se_bar";
             $sub_title = "Total Space";
             $ylabel = "GB";
             break;
         case "se_space_free":
             $urlbase = config()->gratiaweb . "/status_graphs/status_se_free_bar";
             $sub_title = "Total Free Space";
             $ylabel = "GB";
             break;
         default:
             slog("unknown account_type (rgse) - maybe a bot");
             exit;
     }
     return array($urlbase, $sub_title, $ylabel);
 }
 public function map()
 {
     $dirty_type = @$_REQUEST["ce_account_type"];
     switch ($dirty_type) {
         case "gip_vo":
             $urlbase = config()->gratiaweb . "/status_graphs/status_vo";
             $sub_title = "Running Jobs by VO";
             $ylabel = "Jobs";
             break;
         case "gip_vo_waiting":
             $urlbase = config()->gratiaweb . "/status_graphs/status_vo_waiting";
             $sub_title = "Queued Jobs by VO";
             $ylabel = "Jobs";
             break;
         case "rsv_metric_quality":
             $urlbase = config()->gratiaweb . "/rsv_graphs/rsv_metric_quality";
             $sub_title = "RSV Data";
             $ylabel = "Probe Names";
             break;
         default:
             slog("unknown account_type (rgce) - maybe bot?");
             exit;
     }
     return array($urlbase, $sub_title, $ylabel);
 }
 protected function upload($params)
 {
     slog($params);
     /* 返回标准数据 */
     $return = array('status' => 1, 'info' => '上传成功', 'data' => '');
     $model = $params['model'] == 'Picture' ? 'Picture' : 'File';
     /* 调用文件上传组件上传文件 */
     $table = D($model);
     $driver = C("{$model}_UPLOAD_DRIVER");
     d_f('upload', $driver);
     $upload_config = C("{$model}_UPLOAD");
     d_f('upload', $upload_config);
     if (isset($params['rootPath'])) {
         $upload_config['rootPath'] = $params['rootPath'];
     }
     $info = $table->upload($_FILES, $upload_config, $driver, C("UPLOAD_{$driver}_CONFIG"));
     d_f('upload', $info);
     /* 记录图片信息 */
     if ($info) {
         $return['status'] = 1;
         $return = array_merge($info[$params['field']], $return);
         if (method_exists($this, 'after_upload')) {
             $this->after_upload(CONTROLLER_NAME, $info, $result);
         }
     } else {
         $return['status'] = 0;
         $return['info'] = $table->getError();
     }
     d_f('upload', $return);
     return $return;
 }
function uget($url, $opts = null)
{
    $t = -microtime(true);
    $rs = odie_get($url, $opts);
    $t += microtime(true);
    $t = intval($t * 1000);
    slog("{$url} [{$rs['0']}]\t{$t} ms");
    return $rs;
}
 public function parseMusic()
 {
     $query_res = curl('http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.search.common&page_size=999', array('query' => I('query')));
     $query = json_decode($query_res, 1);
     if (false !== $query) {
         $this->ajaxReturn($query);
     } else {
         slog('curl失败');
         $this->error('查询失败');
     }
 }
 public function index()
 {
     $wechatauth = new WechatAuth(C('WEIXIN.APPID'), C('WEIXIN.SECRET'), C(''));
     $access_token = $wechatauth->getAccessToken();
     $result = $wechatauth->getServerIp($access_token);
     if (isset($result['errcode'])) {
         $this->error($result['errmsg']);
     }
     slog($result);
     $this->assign('ip', $result['ip_list']);
     $this->display();
 }
 public function __construct()
 {
     if (APP_DEBUG) {
         slog(array('error_handler' => true, 'optimize' => false, 'show_included_files' => true, 'force_client_id' => C('MY_DEBUG'), 'allow_client_ids' => C('DENUG_ARRAY')), 'set_config');
     }
     $this->weixinTool = D('WeixinTool', 'Service');
     $this->weixin = new WechatAuth(C('appid'), C('appsecret'), $this->weixinTool->getToken());
     //是否更新创建菜单
     if (C('wx_ismenu') == 100) {
         $this->weixinTool->createMenu();
     }
 }
Exemple #8
0
 /**
  * 日志
  * @param \Yaf\Dispatcher $dispatcher
  */
 public function _initLogger(\Yaf\Dispatcher $dispatcher)
 {
     //SocketLog
     if (Yaf\ENVIRON === 'develop') {
         if ($this->config->socketlog->enable) {
             //载入
             \Yaf\Loader::import('Common/Logger/slog.function.php');
             //配置SocketLog
             slog($this->config->socketlog->toArray(), 'config');
         }
     }
 }
Exemple #9
0
function StopAttack($StrFiltKey, $StrFiltValue, $ArrFiltReq)
{
    $StrFiltValue = arr_foreach($StrFiltValue);
    if (preg_match("/" . $ArrFiltReq . "/is", $StrFiltValue) == 1) {
        slog("<br><br>操作IP: " . $_SERVER["REMOTE_ADDR"] . "<br>操作时间: " . strftime("%Y-%m-%d %H:%M:%S") . "<br>操作页面:" . $_SERVER["PHP_SELF"] . "<br>提交方式: " . $_SERVER["REQUEST_METHOD"] . "<br>提交参数: " . $StrFiltKey . "<br>提交数据: " . $StrFiltValue);
        print "<div style=\"position:fixed;top:0px;text-align:center;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"><br>您的提交带有不合法参数,不要酱紫嘛!</div>";
        exit;
    }
    if (preg_match("/" . $ArrFiltReq . "/is", $StrFiltKey) == 1) {
        slog("<br><br>操作IP: " . $_SERVER["REMOTE_ADDR"] . "<br>操作时间: " . strftime("%Y-%m-%d %H:%M:%S") . "<br>操作页面:" . $_SERVER["PHP_SELF"] . "<br>提交方式: " . $_SERVER["REQUEST_METHOD"] . "<br>提交参数: " . $StrFiltKey . "<br>提交数据: " . $StrFiltValue);
        print "<div style=\"position:fixed;top:0px;text-align:center;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"></div>";
        exit;
    }
}
Exemple #10
0
 public function processXML($bdii)
 {
     $resources = array();
     $model = new Resource();
     $oim_resources = $model->getgroupby("fqdn");
     foreach ($bdii->Resources->Resource as $resource) {
         $fqdn = (string) $resource->FQDN;
         if (isset($oim_resources[$fqdn])) {
             $oim_resource_info = $oim_resources[$fqdn][0];
             $resources[$oim_resource_info->id] = array("info" => $oim_resource_info, "bdii" => $resource);
         } else {
             slog("BDII FQDN: [{$fqdn}] doesn't exist in OIM");
         }
     }
     return $resources;
 }
Exemple #11
0
function get_answer_link_list($content)
{
    $dom = HTML5::loadHTML($content);
    $dom = $dom->getElementById('zh-profile-answer-list');
    $ret = array();
    if (empty($dom)) {
        echo "empty #zh-profile-answer-list\n";
        slog('empty #zh-profile-answer-list');
        return $ret;
    }
    foreach ($dom->getElementsByTagName('a') as $key => $node) {
        if ($attr = $node->getAttribute('class') == 'question_link') {
            $ret[] = $node->getAttribute('href');
        }
    }
    return $ret;
}
Exemple #12
0
function StopAttack($StrFiltKey, $StrFiltValue, $ArrFiltReq)
{
    $StrFiltValue = arr_foreach($StrFiltValue);
    if (preg_match("/" . $ArrFiltReq . "/is", $StrFiltValue) == 1) {
        slog("<br><br>操作IP: " . $_SERVER["REMOTE_ADDR"] . "<br>操作时间: " . strftime("%Y-%m-%d %H:%M:%S") . "<br>操作页面:" . $_SERVER["PHP_SELF"] . "<br>提交方式: " . $_SERVER["REQUEST_METHOD"] . "<br>来源: " . $_SERVER['HTTP_REFERER'] . "<br>提交参数: " . $StrFiltKey . "<br>提交数据: " . $StrFiltValue);
        header('HTTP/1.1 400 Bad Request');
        header('status: 400 Bad Request');
        print "<div style=\"position:fixed;top:0px;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"><br>您的提交带有不合法参数,谢谢合作!<br><br>了解更多请点击:<a href=\"http://www.16888.com\">http://www.16888.com</a></div>";
        exit;
    }
    if (preg_match("/" . $ArrFiltReq . "/is", $StrFiltKey) == 1) {
        slog("<br><br>操作IP: " . $_SERVER["REMOTE_ADDR"] . "<br>操作时间: " . strftime("%Y-%m-%d %H:%M:%S") . "<br>操作页面:" . $_SERVER["PHP_SELF"] . "<br>提交方式: " . $_SERVER["REQUEST_METHOD"] . "<br>来源: " . $_SERVER['HTTP_REFERER'] . "<br>提交参数: " . $StrFiltKey . "<br>提交数据: " . $StrFiltValue);
        header('HTTP/1.1 400 Bad Request');
        header('status: 400 Bad Request');
        print "<div style=\"position:fixed;top:0px;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"><br>您的提交带有不合法参数,谢谢合作!<br><br>了解更多请点击:<a href=\"http://www.16888.com\">http://www.16888.com</a></div>";
        exit;
    }
}
Exemple #13
0
 public function getBdii()
 {
     //try only for N seconds to pull this data
     $ctx = stream_context_create(array('http' => array('timeout' => 8)));
     //cache these xml for little bit
     $seconds = 60;
     $c = new Cache("/tmp/myosg.bdii");
     if ($c->isFresh($seconds)) {
         $cemonbdii_content = $c->get();
     } else {
         //cemon raw file listing for production
         slog("loading " . config()->cemonbdii_url);
         $cemonbdii_content = file_get_contents(config()->cemonbdii_url, 0, $ctx);
         if ($cemonbdii_content !== false) {
             $c->set($cemonbdii_content);
         } else {
             error_log("failed to download xml from " . config()->cemonbdii_url . " -- using previous cache");
             error_log(print_r($ctx, true));
             //use previous cache
             $cemonbdii_content = $c->get();
         }
     }
     $cemonbdii = new SimpleXMLElement($cemonbdii_content);
     /*
             $c = new Cache("/tmp/myosg.bdii-itb");
             if($c->isFresh($seconds)) { 
                 $cemonbdii_itb_content = $c->get();
             } else {
                 //cemon raw file listing for itb
                 slog("loading ".config()->cemonbdii_itb_url);
                 $cemonbdii_itb_content = file_get_contents(config()->cemonbdii_itb_url, 0, $ctx);
                 $c->set($cemonbdii_itb_content);
             }
     
             //merge itb content to prod content
             try {
                 $itb = new SimpleXMLElement($cemonbdii_itb_content);
                 $this->merge($cemonbdii, $itb);
             } catch(exception $e) {
                 elog("failed to parse for some reason... maybe itb is not available?");
             }
     */
     return $cemonbdii;
 }
Exemple #14
0
 public static function saveAnswer($base_url, $username, $answer_link_list)
 {
     foreach ($answer_link_list as $url) {
         if (preg_match('%^/question/(\\d+)/answer/(\\d+)%', $url, $matches)) {
             $qid = $matches[1];
             $aid = $matches[2];
         } else {
             echo "{$url} not good\n";
             exit(1);
         }
         $url = $base_url . $url;
         echo "\t{$url}";
         $t = microtime(true);
         list($code, $content) = odie_get($url);
         echo "\t[{$code}]";
         if ($code != 200) {
             // fail fast
             echo "\tfail\n";
             slog("{$url} [{$code}] error");
             $success_ratio = get_average(0, 'success_ratio');
             continue;
         } else {
             $success_ratio = get_average(1, 'success_ratio');
         }
         $t = intval((microtime(true) - $t) * 1000);
         $avg = intval(get_average($t));
         echo "\t{$t} ms\n";
         if (empty($content)) {
             echo "content is empty\n";
             slog("{$url} [{$code}] empty");
             return false;
         }
         list($question, $descript, $content, $vote) = parse_answer_pure($content);
         slog("{$url} [{$code}] ^{$vote}\t{$question}");
         Question::saveQuestion($qid, $question, $descript);
         Answer::_saveAnswer($aid, $qid, $username, $content, $vote);
     }
     if (isset($success_ratio) && isset($avg)) {
         $success_ratio = intval($success_ratio * 100) . '%';
         echo "\tAvg: {$avg} ms\tsuccess_ratio: {$success_ratio}\n";
     }
 }
 /**
  * 列表
  */
 public function tickeListAct()
 {
     slog("test");
     $areainfo = R('Api/areainfo');
     foreach ($areainfo['data'] as $k => $v) {
         //如果是成都地区,过滤佛山的场馆
         if (DISTRICT_SERVER == 'CHENGDU' && $v['id'] == 3) {
             continue;
         }
         $venuesinfo = R('Api/venuesinfo', array($v['id']));
         foreach ($venuesinfo['data'] as $k1 => $v1) {
             $areaName[$v1['id']]['id'] = $v1['id'];
             $areaName[$v1['id']]['name'] = $v['name'] . $v1['name'];
         }
     }
     $this->assign('activity_text', getSysConfig('activity-text'));
     $this->assign('isHasCoupon', \Wechat\Logic\CouponLogic::isHasCoupon(getOpenid()));
     $this->assign('venuesinfo', $areaName);
     $this->display();
 }
Exemple #16
0
 public function get()
 {
     //shiould take less than 5 seconds to pull this data
     $ctx = stream_context_create(array('http' => array('timeout' => 5)));
     //load OpenTickets XML
     $c = new Cache(config()->gocticket_open_cache);
     if (!$c->isFresh(60)) {
         try {
             slog("loading " . config()->gocticket_open_url);
             $xml = file_get_contents(config()->gocticket_open_url, 0, $ctx);
             //try parsing it..
             $obj = new SimpleXMLElement($xml);
             //store good xml
             $c->set($xml);
             return $obj;
         } catch (exception $e) {
             elog($e->getMessage() . " -- using cache.");
         }
     }
     slog("Using cache");
     return new SimpleXMLElement($c->get());
 }
Exemple #17
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //启动SocketLog
     slog(['error_handler' => true], 'config');
     $api = new API($this->user->account->toArray(), $this->user->account->getKey());
     $message = WechatMessage::create(['waid' => $api->waid, 'wuid' => $this->user->getKey(), 'type' => 'text', 'transport_type' => 'send', 'message_id' => '']);
     $data = ['touser' => $this->user->openid];
     $type = 'text';
     if ($this->media instanceof Attachment) {
         $attachment = $this->media;
         $type = $attachment->file_type();
         $type == 'audio' && ($type = 'voice');
         $media = $this->uploadToWechat($api, $this->media, $type);
         if (empty($media)) {
             return;
         }
         $type = $media['type'];
         //多余的步骤
         $data += ['msgtype' => $type, $type => ['media_id' => $media['media_id']]];
         if ($type == 'video') {
             $data[$type] += ['thumb_media_id' => '', 'title' => $attachment->filename, 'description' => $attachment->description];
         }
         slog('发送微信消息(来自附件)');
         slog($this->media->toArray());
         //入库
         WechatMessageMedia::create(['id' => $message->getKey(), 'media_id' => $media['media_id'], 'aid' => $this->media->getKey(), 'format' => $this->media->ext]);
     } elseif ($this->media instanceof WechatDepot) {
         //素材
         $depot = $this->media;
         $type = $depot->type;
         $data += ['msgtype' => $type, $type => []];
         $url = new UrlTool($api);
         if ($type == 'news') {
             $data[$type] = ['articles' => array_map(function ($v) use($url) {
                 return ['title' => $v['title'], 'description' => $v['description'], 'url' => $url->getURL('wechat/news?id=' . $v['id'], $this->user), 'picurl' => url('attachment?id=' . $v['cover_aid'])];
             }, $depot->news->toArray())];
         } else {
             if ($type == 'text') {
                 $data[$type] = ['content' => $depot->text->content];
             } else {
                 if ($type == 'callback') {
                     //
                 } else {
                     if ($type == 'music') {
                         $url = Attachment::findOrFail($depot->{$type}->thumb_aid)->url(NULL, true);
                         $data[$type] = ['title' => $depot->{$type}->title, 'description' => $depot->{$type}->description, 'musicurl' => $url, 'hqmusicurl' => $url];
                         !empty($depot->{$type}->thumb_aid) && ($media = $this->uploadToWechat($api, Attachment::find($depot->{$type}->thumb_aid), 'image'));
                         $data[$type] += ['thumb_media_id' => !empty($media) ? $media['thumb_media_id'] : ''];
                     } else {
                         $media = $this->uploadToWechat($api, Attachment::find($depot->{$type}->aid), $type);
                         $data[$type] = ['media_id' => $media['media_id']];
                         if ($type == 'video') {
                             !empty($depot->{$type}->thumb_aid) && ($media = $this->uploadToWechat($api, Attachment::find($depot->{$type}->thumb_aid), 'image'));
                             $data[$type] += ['title' => $depot->{$type}->title, 'description' => $depot->{$type}->description, 'thumb_media_id' => !empty($media) ? $media['thumb_media_id'] : ''];
                         }
                     }
                 }
             }
         }
         slog('发送微信消息(来自素材库)');
         slog($this->media->toArray());
         //入库
         $message->wdid = $this->media->getKey();
     } else {
         //String
         $data += ['msgtype' => 'text', 'text' => ['content' => $this->media]];
         //入库
         WechatMessageText::create(['id' => $message->getKey(), 'content' => $this->media]);
     }
     $message->type = $type;
     $message->save();
     return $api->sendCustomMessage($data);
 }
Exemple #18
0
 public function warnx($msg)
 {
     slog("{$msg}");
 }
require dirname(__DIR__) . "/odie.php";
require dirname(__DIR__) . "/logic.php";
require __DIR__ . "/lib_mongodb.php";
require __DIR__ . "/autoload.php";
use model\User;
use model\Question;
use model\Answer;
$base_url = 'http://www.zhihu.com';
$ids = Question::getIds();
echo "there are ", count($ids), " questions to fetch\n";
$sum = $existing_sum = 1;
foreach ($ids as $qid) {
    $url = "{$base_url}/question/{$qid}";
    timer();
    list($code, $content) = odie_get($url);
    slog($url . " [{$code}]");
    $t = timer();
    echo "Fetch question {$qid} [{$code}] {$t} ms\n";
    $username_list = get_username_list($content);
    timer();
    foreach ($username_list as $username => $nickname) {
        echo "\t{$username}";
        if (User::saveUser($username, $nickname)) {
            $existing_sum++;
        }
        $sum++;
    }
    Question::setFetched($qid);
    $rate = intval((1 - $existing_sum / $sum) * 100);
    $t = timer();
    echo "\tSave: {$t} ms\t Rate {$rate}%\n";
Exemple #20
0
slog(array('error_handler' => true, 'optimize' => true, 'show_included_files' => true), 'set_config');
slog('hello world');
//一般日志
slog('msg', 'log');
//一般日志
slog('msg', 'error');
//错误日志
slog('msg', 'info');
//信息日志
slog('msg', 'warn');
//警告日志
slog('msg', 'trace');
// 输入日志同时会打出调用栈
slog('msg', 'alert');
//将日志以alert方式弹出
slog('msg', 'log', 'color:red;font-size:20px;');
//自定义日志的样式,第三个参数为css样式
header("Content-type: text/html; charset=utf-8");
ini_set('display_errors', '1');
error_reporting(E_ALL ^ E_NOTICE);
if (!file_exists('PigData/install.lock')) {
    header('Location:install/index.php');
    exit;
}
if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value)
    {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
Exemple #21
0
<?php

include './php/SocketLog.class.php';
//配置
slog(array('host' => 'localhost', 'optimize' => false, 'show_included_files' => false, 'error_handler' => false, 'force_client_id' => '', 'allow_client_ids' => array()), 'set_config');
//输出日志
slog('hello world');
//一般日志
slog('msg', 'log');
//一般日志
slog('msg', 'error');
//错误日志
slog('msg', 'info');
//信息日志
slog('msg', 'warn');
//警告日志
slog('msg', 'trace');
// 输入日志同时会打出调用栈
slog('msg', 'alert');
//将日志以alert方式弹出
slog('msg', 'log', 'color:red;font-size:20px;');
//自定义日志的样式,第三个参数为css样式
//调试sql
$link = mysql_connect('localhost:3306', 'root', '', true);
mysql_select_db('kuaijianli', $link);
$sql = "DELETE * FROM `uxxxser`";
slog($sql, $link);
 public function config($name = 0)
 {
     $model = D('Config');
     $result = true;
     $data = array();
     $code = 404;
     $url = '';
     switch ($this->_method) {
         case 'head':
             break;
         case 'option':
             break;
         case 'get':
             // 列出资源
             if ('list' == $name) {
                 $data = $model->select();
             } else {
                 $id = $name;
                 $data = $model->find($id);
             }
             if ($model->getError() || $model->getDbError()) {
                 $result = false;
             } else {
                 $code = 200;
             }
             break;
         case 'put':
             if ('save' == $name) {
                 // 批量更新资源
                 $config = I('put.config');
                 if (empty($config)) {
                     $result = false;
                     $data = '表单为空';
                 } else {
                     if ($config && is_array($config)) {
                         foreach ($config as $name => $value) {
                             $map = array('name' => $name);
                             $model->where($map)->setField('value', $value);
                         }
                     }
                     $code = 200;
                 }
             } else {
                 $puts = $model->create(I('put.'));
                 if (false === $puts) {
                     $result = false;
                     $data = $model->getError();
                 } else {
                     $id = $puts['id'];
                     if ($find = $model->find($id)) {
                         $result = false !== $model->save($puts);
                         $code = $result ? 200 : 404;
                     } else {
                         $result = false;
                         $data = "record not found";
                         $code = 412;
                     }
                 }
             }
             S('DB_CONFIG_DATA', null);
             break;
         case 'post':
             // 新增资源
             $posts = $model->create();
             if (false == $posts) {
                 $data = $model->getError();
                 $result = false;
             } else {
                 $id = $model->add();
                 if (!$id) {
                     $result = false;
                 } else {
                     $code = 201;
                     $data = $id;
                     $url = '/admin.php/Config/index';
                 }
             }
             break;
         case 'delete':
             // 删除资源
             // parse_str(file_get_contents('php://input'), $_DELETE);
             // slog($_DELETE);
             $id = array_unique((array) I('get.id', 0));
             slog($id);
             if (empty($id)) {
                 $code = 404;
                 $data = '请选择要操作的数据';
             } else {
                 $code = 200;
                 $map = array('id' => array('in', $id));
                 if (M('Config')->where($map)->delete()) {
                     S('DB_CONFIG_DATA', null);
                     //记录行为
                     $url = '/admin.php/Config/index';
                     $data = '删除成功';
                 } else {
                     $code = 412;
                     $result = false;
                     $data = '删除失败!';
                 }
             }
             break;
     }
     if ($result) {
         $this->success($data, $code, $url);
     } else {
         $this->error($data, $code, $url);
     }
 }
Exemple #23
0
    $changes .= "\n";
}
echo $changes;
$summary = count($newdata) . " files scanned, " . count($changed) . " changed, " . count($added) . " added, " . count($deleted) . " deleted\n";
if (count($changed) + count($added) + count($deleted) > 0) {
    if ($emailAddressToAlert != "") {
        $headers = "Return-path: {$emailAddressToAlert}\r\n";
        $headers .= "Reply-to: {$emailAddressToAlert}\r\n";
        $headers .= "Content-Type: text/plain\r\n";
        $headers .= "Content-Transfer-Encoding: 7bit\r\n";
        $headers .= "From: {$emailAddressToAlert}\r\n";
        $headers .= "X-Priority: 3\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Organization: {$servername}\r\n";
        $headers .= "\n\n";
        //Add the new hash value to the email
        $emailBody = "Some files in the '{$scandir}' folder have changed since " . $oldsettings["date"] . ".\n" . $summary . "\n" . $changes . "\nScanned in " . (microtime(true) - $time_start) . " seconds.\n";
        mail($emailAddressToAlert, $emailSubject, $emailBody, $headers);
        //Simple mail function for alert.
    }
}
slog($summary);
// Write new data to a file
$datafile = fopen($scandir . $datafilename, "w");
fwrite($datafile, "---\t---\t" . date("Y-m-d H:i:s") . "\t---\t" . $scandir . "\t" . $mode . "\n");
foreach ($newdata as $filedata) {
    fwrite($datafile, $filedata["namehash"] . "\t" . $filedata["checkhash"] . "\t" . $filedata["date"] . "\t" . $filedata["size"] . "\t" . $filedata["name"] . "\t" . $filedata["ext"] . "\n");
}
fclose($datafile);
slog(date("Y-m-d H:i:s") . "  Done in " . (microtime(true) - $time_start) . " seconds!\n\n");
echo "\nDone in " . (microtime(true) - $time_start) . " seconds!</pre></html>";
            if (($attr = $node->getAttribute('class')) == 'zm-profile-header-img zg-avatar-big zm-avatar-editor-preview') {
                $src = $node->getAttribute('src');
            }
        }
        User::updateByUserName($username, array('avatar' => $src));
        $link_list = get_answer_link_list($content);
        $rs = Answer::saveAnswer($base_url, $username, $link_list);
        $num = get_page_num($content);
        if ($num > 1) {
            foreach (range(2, $num) as $i) {
                echo "\nNo. {$n} fetch page {$i}\t";
                $url_page = "{$url}?page={$i}";
                timer();
                list($code, $content) = uget($url_page);
                $t = timer();
                $avg = intval(get_average($t, 'user page'));
                slog("{$url_page} [{$code}]");
                echo "[{$code}]\t{$t} ms\tAvg: {$avg} ms\n";
                if ($code != 200) {
                    echo "奇奇怪怪的返回码 {$code}\n";
                    continue;
                }
                $link_list = get_answer_link_list($content);
                Answer::saveAnswer($base_url, $username, $link_list);
            }
        }
        User::updateByUserName($username, array('has_fetch' => true));
    } catch (Exception $e) {
        slog('warning: resume with ' . $e->getCode() . ' ' . $e->getMessage());
    }
}
Exemple #25
0
<?php

define('APP_PATH', './App/');
define('APP_DEBUG', 1);
define('BIND_MODULE', 'Api');
if (!function_exists('slog')) {
    require './SocketLog.class.php';
    $slog_config = array('host' => 'i.kuaijianli.com', 'port' => 1229, 'error_handler' => true, 'optimize' => true, 'allow_client_ids' => array('yangweijie_jay'), 'show_included_files' => false);
    if (isset($_GET['slog_force_client_id'])) {
        $slog_config['force_client_id'] = $_GET['slog_force_client_id'];
    }
    slog($slog_config, 'set_config');
}
require './ThinkPHP/ThinkPHP.php';
 function _setguest()
 {
     $guest = new User(null);
     Zend_Registry::set("user", $guest);
     slog("guest access from " . $_SERVER["REMOTE_ADDR"]);
 }
 /**
  * 执行语句
  * @access public
  * @param string $str  sql指令
  * @param boolean $fetchSql  不执行只是获取SQL
  * @return mixed
  */
 public function execute($str, $fetchSql = false)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     if (!empty($this->bind)) {
         $that = $this;
         $this->queryStr = strtr($this->queryStr, array_map(function ($val) use($that) {
             return '\'' . $that->escapeString($val) . '\'';
         }, $this->bind));
     }
     if ($fetchSql) {
         return $this->queryStr;
     }
     //释放前次的查询结果
     if (!empty($this->PDOStatement)) {
         $this->free();
     }
     $this->executeTimes++;
     N('db_write', 1);
     // 兼容代码
     // 记录开始执行时间
     $this->debug(true);
     $this->PDOStatement = $this->_linkID->prepare($str);
     if (false === $this->PDOStatement) {
         $this->error();
         return false;
     }
     foreach ($this->bind as $key => $val) {
         if (is_array($val)) {
             $this->PDOStatement->bindValue($key, $val[0], $val[1]);
         } else {
             $this->PDOStatement->bindValue($key, $val);
         }
     }
     $this->bind = array();
     slog($this->queryStr, $this->_linkID);
     $result = $this->PDOStatement->execute();
     $this->debug(false);
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = $this->PDOStatement->rowCount();
         if (preg_match("/^\\s*(INSERT\\s+INTO|REPLACE\\s+INTO)\\s+/i", $str)) {
             $this->lastInsID = $this->_linkID->lastInsertId();
         }
         return $this->numRows;
     }
 }
Exemple #28
0
 public function getHost($id)
 {
     $c = new Cache("/tmp/myosg.personar.hosts.{$id}");
     if ($c->isFresh(60 * 10)) {
         //seconds
         return $c->get();
         //use cache
     } else {
         //try only for N seconds to pull this data
         $ctx = stream_context_create(array('http' => array('timeout' => 8)));
         $url = config()->perfsonar_host_url . "/{$id}";
         slog("refreshing cache for {$url}");
         $json = file_get_contents($url, 0, $ctx);
         slog("done");
         if ($json !== false) {
             $hosts = json_decode($json);
             $c->set($hosts);
             return $hosts;
         } else {
             //failed to load then, use stale cache
             error_log("failed to download xml from {$url} -- using previous cache");
             error_log(print_r($ctx, true));
             return $c->get();
         }
     }
 }
 public function testlogAct()
 {
     print_r(date('Y-m-d', 1454300937));
     slog("45646546456");
 }
 public function tmpUploadVideo()
 {
     $appid = C('WEIXIN.APPID');
     $appsecret = C('WEIXIN.SECRET');
     $token = session("token");
     if ($token) {
         $auth = new WechatAuth($appid, $appsecret, $token);
     } else {
         $auth = new WechatAuth($appid, $appsecret);
         $token = $auth->getAccessToken();
         session(array('expire' => $token['expires_in']));
         session("token", $token['access_token']);
     }
     if (session('?weixin_video_id')) {
         return session('weixin_video_id');
     } else {
         $filename = './Public/video.mp4';
         $type = 'video';
         $discription = array('title' => '视频标题', 'introduction' => '视频描述');
         $media = $auth->materialAddMaterial($filename, $type, $discription);
         session('weixin_video_id', $media);
         slog($media);
         return session('weixin_video_id');
     }
 }