Exemple #1
0
            $oBrick->removeVersion('lat', $iTime);
            $oBrick->removeVersion('lng', $iTime);
            break;
        case 'form':
            if (sizeof($oBrick->getAllVersions('email', true)) == 1) {
                die('Not enough versions !');
            }
            // TODO
            $oBrick->removeVersion('email', $iTime);
            break;
        case 'short':
        case 'rich':
            if (sizeof($oBrick->getAllVersions('value', true)) == 1) {
                die('Not enough versions !');
            }
            // TODO
            $oBrick->removeVersion('value', $iTime);
            break;
    }
    if (!$oBrick->save()) {
        die("Can't save !");
    }
    DomParser::destroyCache();
    $app->redirect(str_replace('http://' . $utils->globals->server('server_name') . '/', '/', $utils->globals->server('http_referer')));
});
$app->get('/admin/exit/', function () use($app) {
    session_destroy();
    unset($_SESSION);
    $_SESSION = array();
    $app->redirect('/');
});
Exemple #2
0
 /**
  * 发送红包
  */
 private function sendRedPacket($openid, $act_id)
 {
     $data['mch_id'] = "1233967602";
     //香江商户号
     $data['mch_billno'] = $data['mch_id'] . date('YmdHis' . mt_rand(1000, 9999));
     list($money, $hongbaoinfo) = $this->getMoneyPerPacket($openid, $act_id, $data['mch_billno']);
     if ($money > 0) {
         $data['nonce_str'] = $this->genNonceStr();
         //随机数
         $data['wxappid'] = $this->config['appid'];
         //公众账号appid
         $data['nick_name'] = "香江全球家居CBD";
         //提供方名称
         $data['send_name'] = "香江全球家居CBD";
         //商户名称
         $data['re_openid'] = $openid;
         //用户openid
         $data['total_num'] = 1;
         //红包发放总人数
         $data['wishing'] = "真是好运!恭喜你获得现金红包,再接再励哟!";
         //红包祝福语
         $hostname = "";
         if (isset($_ENV['COMPUTERNAME'])) {
             $hostname = $_ENV['COMPUTERNAME'];
         }
         $ip = gethostbyname($hostname);
         $data['client_ip'] = empty($ip) ? "192.168.1.1" : $ip;
         //本机ip地址
         $data['act_name'] = "88万现金红包任性发";
         //活动名称
         $data['remark'] = "手慢无!快来抢!";
         //备注
         $data['total_amount'] = $money;
         //单位分,此处为1元
         $data['min_value'] = $money;
         //最小红包金额,单位分
         $data['max_value'] = $money;
         //最大红包金额,单位分
         $sign = $this->genSign($data);
         $data['sign'] = $sign;
         $param2 = "<xml>";
         foreach ($data as $key => $value) {
             $param2 .= '<' . $key . ">" . $value . "</" . $key . ">";
         }
         $param2 .= "</xml>";
         $result = $this->post($this->sendredpack_url, $param2);
         require_once "DomParser.php";
         $dom = new DomParser();
         if (!$dom->loadXML($result)) {
             //发送红包不成功,删除已抢记录
             error_log("openid:" . $data['re_openid'] . "...." . $result . "||||", 3, "shake2_hongbao.txt");
             $this->restoreRecord($hongbaoinfo['id']);
             return 0;
         }
         $result_data = $dom->toArray();
         $result_data = $result_data['xml'];
         if ($result_data['result_code'] !== 'SUCCESS') {
             //发送红包不成功,删除已抢记录
             $this->restoreRecord($hongbaoinfo['id']);
             return 0;
             //服务器返回错误,具体错误信息,请参看文档
         }
         return $money;
     } else {
         return 0;
     }
 }
Exemple #3
0
<?php

include "SendMessage.class.php";
include "DomParser.class.php";
/*const LOGIN         =   "******";
const PASSWORD      =   "******";
*/
const URL = "http://kinoprosmotr.net/8016-pervyy-mstitel-protivostoyanie-10-05-2016.html";
const NODE_XPATH = "/html/body/div[3]/div/div[2]/div[3]/div/div/div[2]/div[1]/div[2]/ul/li[2]/dt";
const POST_COMMENT_STR_PREFIX = "post_id=8016&comments=";
const POST_COMMENT_STR_SUFFIX = "&name=revconps31&mail=&editor_mode=&skin=kino2\n&sec_code=&question_answer=&recaptcha_response_field=&recaptcha_challenge_field=&allow_subscribe=0";
const COMMENTS_URL = "http://kinoprosmotr.net/engine/ajax/addcomments.php";
$login = $_GET['login_name'];
$password = $_GET['login_password'];
$send = new SendMessage($login, $password, URL, COMMENTS_URL);
$send->login();
$parser = new DomParser();
$filmName = $parser->getNodeValueByXpath(URL, NODE_XPATH);
$mes = POST_COMMENT_STR_PREFIX . $filmName . ". I liked the movie, but not more than 10/10. Expected more." . POST_COMMENT_STR_SUFFIX;
$send->sendMessage($mes);
echo "<br>THE WORK DONE!<br>";
 private function parseFlipkartSearch($search_term)
 {
     $url = 'http://www.flipkart.com/search.php?query=' . urlencode($search_term);
     $parser = new DomParser();
     $parser->load($url);
     $divs = $parser->elements($parser->getDom(), 'div');
     foreach ($divs as $div) {
         if ($parser->matchAttribute($div, 'class', 'search_result_item')) {
             $result = array();
             $idivs = $parser->elements($div, 'div');
             foreach ($idivs as $idiv) {
                 if ($parser->matchAttribute($idiv, 'class', 'search_result_image')) {
                     $images = $parser->elements($idiv, 'img');
                     foreach ($images as $image) {
                         //display('Image Link : ' . $parser->src($image));
                         $result['image'] = $parser->src($image);
                         // Do something about images which don't exist
                     }
                 } else {
                     if ($parser->matchAttribute($idiv, 'class', 'search_result_title')) {
                         $count = 0;
                         $links = $parser->elements($idiv, 'a');
                         foreach ($links as $link) {
                             if ($count == 0) {
                                 //display('Book link : http://flipkart.com' . $parser->href($link));
                                 $result['link'] = 'http://flipkart.com' . $parser->href($link);
                                 //display('Book Title : ' . $parser->text($link));
                                 $result['title'] = $parser->text($link);
                             } else {
                                 //display('Author Link : http://flipkart.com' . $parser->href($link));
                                 $result['authorlink'] = 'http://flipkart.com' . $parser->href($link);
                                 //display('Author Name : ' . $parser->text($link));
                                 $result['author'] = $parser->text($link);
                             }
                             $count++;
                         }
                     } else {
                         if ($parser->matchAttribute($idiv, 'class', 'search_result_item_info')) {
                             $spans = $parser->elements($idiv, 'span');
                             foreach ($spans as $span) {
                                 if ($parser->matchAttribute($span, 'class', 'search_results_price')) {
                                     $fonts = $parser->elements($span, 'font');
                                     foreach ($fonts as $font) {
                                         //display('Book price is ' . $parser->text($font));
                                         $result['price'] = $parser->text($font);
                                     }
                                 }
                             }
                             $tables = $parser->elements($idiv, 'table');
                             foreach ($tables as $table) {
                                 if ($parser->matchAttribute($table, 'class', 'search_result_item_shipping')) {
                                     $bolds = $parser->elements($table, 'b');
                                     foreach ($bolds as $bold) {
                                         $data = trim(strtolower($parser->text($bold)));
                                         if ($data == 'shipping free.') {
                                             //display('Shipping : Shipping free');
                                             $result['freeshipping'] = true;
                                         } else {
                                             if (strpos($data, 'days') !== false) {
                                                 $data = trim(str_replace('business days', '', $data));
                                                 //display('Delivery in : ' . $data);
                                                 $result['delivery'] = $data;
                                             } else {
                                                 if ($data == 'out of stock') {
                                                     //display('Out of stock : YES');
                                                     $result['available'] = false;
                                                 } else {
                                                     if ($data == 'email address:') {
                                                     } else {
                                                         display_error('Found ' . $data);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     $italics = $parser->elements($table, 'i');
                                     foreach ($italics as $italic) {
                                         $data = trim(strtolower($parser->text($italic)));
                                         if ($data == 'available.') {
                                             //display('Available (Available): YES');
                                             $result['available'] = true;
                                         } else {
                                             if ($data == 'in stock.') {
                                                 //display('Available (In stock) : YES');
                                                 $result['available'] = true;
                                             } else {
                                                 if ($data == 'imported edition.') {
                                                     $result['available'] = true;
                                                     $result['imported'] = true;
                                                 } else {
                                                     display_error('Found ' . $data);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             display($result);
         }
     }
 }