コード例 #1
0
ファイル: class.sms.php プロジェクト: ragav-hari/Bharat
 private function login_way2sms($username, $password)
 {
     $html = $this->curl->post("http://www.way2sms.com", "1=1");
     if (!preg_match("/Location:(.*)\n/", $html, $matches)) {
         print "Error getting domain";
         cprint($html);
         return 0;
     }
     $domain = trim($matches[1]);
     $this->data['domain'] = $domain;
     cprint("Domain:{$domain}");
     $html = $this->curl->post("{$domain}Login1.action", "username={$username}&password={$password}&Submit=Sign+in");
     if (!preg_match('/<h3>Welcome to Way2SMS<.h3>/', $html)) {
         //print("Error Logging In");
         //print($html);
         return 0;
     }
     //print("Logged In Successfully");
     if (!preg_match("/Location:(.*)[?]id=(.*)\n/", $html, $matches)) {
         //print("Error getting location & token");
         cprint($html);
         return 0;
     }
     $referer = trim($matches[1]);
     $token = trim($matches[2]);
     $this->data['referer'] = $referer;
     $this->data['token'] = $token;
     cprint("Referer:{$referer}");
     cprint("Token:{$token}");
     return 1;
 }
コード例 #2
0
function cleanupRequests($location, $table)
{
    global $gSkipRuns, $gbActuallyDoit;
    $query = "select * from crawls where location = '{$location}' and finishedDateTime is not null order by crawlid desc limit " . ($gSkipRuns + 1) . ";";
    $results = doQuery($query);
    mysql_data_seek($results, $gSkipRuns);
    $row = mysql_fetch_assoc($results);
    if ($gbActuallyDoit) {
        $nUnfinished = doSimpleQuery("select count(*) from crawls where location = '{$location}' and finishedDateTime is null;");
        if (0 < $nUnfinished) {
            cprint("SORRY! There is an unfinished crawl for location '{$location}'. Skipping the cleanup while the crawl is running.");
            return;
        }
        // Actually delete rows and optimize the table.
        cprint("Delete requests from \"{$table}\" table starting with crawl \"{$row['label']}\" crawlid={$row['crawlid']} minPageid={$row['minPageid']} maxPageid={$row['maxPageid']} and earlier...");
        $cmd = "delete from {$table} where crawlid <= {$row['crawlid']};";
        cprint("{$cmd}");
        doSimpleCommand($cmd);
        cprint("DONE\nOptimize table \"{$table}\"...");
        doSimpleCommand("optimize table {$table};");
        cprint("DONE");
    } else {
        cprint("WOULD delete requests from \"{$table}\" table starting with crawl \"{$row['label']}\" crawlid={$row['crawlid']} minPageid={$row['minPageid']} maxPageid={$row['maxPageid']} and earlier...");
    }
}
コード例 #3
0
<?php

error_reporting(E_ALL);
ob_implicit_flush(true);
include_once "class.curl.php";
include_once "class.sms.php";
include_once "cprint.php";
$smsapp = new sms();
$smsapp->setGateway('way2sms');
$myno = $_POST['fromno'];
$p = $_POST['pass'];
$tonum = $_POST['tono'];
$mess = $_POST['message'];
cprint("Logging in ..\n");
$ret = $smsapp->login($myno, $p);
if (!$ret) {
    cprint("Error Logging In");
    exit(1);
}
print "Logged in Successfully\n";
print "Sending SMS ..\n";
$ret = $smsapp->send($tonum, $mess);
if (!$ret) {
    print "Error in sending message";
    exit(1);
}
print "Message sent";
コード例 #4
0
ファイル: CNode.php プロジェクト: johnlion/hlsc
 function delete()
 {
     if (isPost()) {
         extract($_POST);
     }
     if (isGet()) {
         extract($_GET);
     }
     /** 模拟数据 */
     $_POST['data'] = array(array('nidtype' => 'message_voicetesdfsd'), array('nidtype' => 'message_voicetest'));
     extract($_POST);
     cprint($this->cinode->node_type_delete($data));
 }
コード例 #5
0
ファイル: functions.php プロジェクト: kellenqian/axion
/**
 * 快速打印数据(命令行模式)
 *
 * @param mix $mix_target
 * @param bool $bool_isBreakPoint 开启则打印完成后停止程序执行
 * @return null
 */
function P_cli($mix_target, $bool_isBreakPoint = false, $return = false)
{
    static $_pcount;
    $lable = $return ? $_pcount : ++$_pcount;
    if (is_array($mix_target)) {
        foreach ($mix_target as $k => $v) {
            if (is_bool($v)) {
                $mix_target[$k] = $v == true ? '(bool)true' : '(bool)false';
            }
            if ($v === null) {
                $mix_target[$k] = '(null)';
            }
            if (is_array($v)) {
                $mix_target[$k] = p_cli($v, false, true);
            }
        }
    }
    $result = '';
    if (is_bool($mix_target)) {
        $result = $mix_target == true ? '(bool)true' : '(bool)false';
    }
    if ($mix_target === null) {
        $result = '(null)';
    }
    if ($return) {
        return $mix_target;
    }
    $output = print_r($mix_target, TRUE);
    $debug = debug_backtrace();
    $debug_mode = false;
    if (AXION_CONFIG::get('axion.debug.level') > 0) {
        $debug_mode = cprint('(Debug Mode ON)', COR_BLINK, true);
    }
    $str = '';
    if ($lable) {
        $str .= 'Debug Lable:' . $lable;
        $str = cprint($str, COR_HIGHLIGHT, true);
        echo $str . " " . $debug_mode . "\n";
    }
    $str = 'In ' . $debug[1]['file'] . ' @Line ' . $debug[1]['line'] . "\n";
    $str = cprint($str, COR_RED, true);
    $output = cprint($output, COR_BLUE, true);
    $str .= $output . $result . "\n";
    if ($bool_isBreakPoint) {
        exit($str);
    }
    echo $str;
    return;
}
コード例 #6
0
function parseParams()
{
    global $argv, $argc, $gSublabel, $gbImportUrls, $locations, $gUrlsFile, $gNumUrls, $gbUrlsFileSpecified;
    // if there are any options they MUST be in this order:
    //   # of URLs or URL file
    //   location
    //   1 or 0 for whether to import URLs
    //   sublabel
    for ($i = 1; $i < $argc; $i++) {
        $val = $argv[$i];
        if (1 === $i) {
            // # of URLs or URL file
            if (file_exists($val)) {
                $gUrlsFile = $val;
                $gbUrlsFileSpecified = 1;
                $gbImportUrls = false;
            } else {
                if (0 < intval($val) && $val === "" . intval($val)) {
                    $gNumUrls = $val;
                } else {
                    cprint("ERROR: Unexpected value for 'numurls|urlfile' parameter: {$val}");
                    exit;
                }
            }
        } else {
            if (2 === $i) {
                $locations = array($val);
            } else {
                if (3 === $i) {
                    if ("1" === $argv[3]) {
                        $gbImportUrls = $gbUrlsFileSpecified ? false : true;
                        // If the list of URLs is specified in a file, we DON'T want to import the Alexa list.
                    } else {
                        if ("0" === $argv[3]) {
                            $gbImportUrls = false;
                        } else {
                            cprint("ERROR: Unexpected value for importUrls: '" . $argv[3] . "'.");
                            exit;
                        }
                    }
                } else {
                    if (4 === $i) {
                        // sublabel
                        $gSublabel = $val;
                    }
                }
            }
        }
    }
}
コード例 #7
0
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
require_once "../utils.inc";
require_once "batch_lib.inc";
require_once "bootstrap.inc";
$bHtml = array_key_exists("REMOTE_ADDR", $_SERVER);
cprint(reportSummary());
echo $bHtml ? "<pre>" : "";
$labelFromRun = statusLabel();
$curPasses = crawlPasses($labelFromRun, $gArchive, $locations[0]);
echo "completed passes: {$curPasses}\n\n";
echo "running tasks:\n";
$device = curDevice();
foreach ($gaTasks as $task) {
    // lock file for this specific task.
    $lockfile = lockFilename($device, $task);
    $fp = fopen($lockfile, "w+");
    if (!flock($fp, LOCK_EX | LOCK_NB)) {
        // this task is still running
        echo "    {$task}\n";
    }
}
コード例 #8
0
ファイル: CUser.php プロジェクト: johnlion/hlsc
 public function select()
 {
     $data = $this->ciuser->select($param = array('records' => 20, 'offset' => 0));
     cprint($data);
 }
コード例 #9
0
ファイル: copy.php プロジェクト: GuoCheng111/httparchive
        lprint("Deleting orphans now...");
        doSimpleCommand($cmd);
    } else {
        lprint("You should delete them, recalculate the stats, and regenerate the mysql dump files.\n    {$cmd}");
    }
} else {
    lprint("No orphaned records.");
}
// Compute stats
require_once "../stats.inc";
require_once "../dbapi.inc";
$device = curDevice();
if (getStats($gLabel, "All", $device)) {
    lprint("Stats already computed.");
} else {
    lprint("Computing stats for {$gLabel} {$device}...");
    replaceStats($gLabel, null, $device, null, $crawl['crawlid']);
    if ($gbDev && $gStatsTableDesktop != $gStatsTableDev) {
        lprint("Copy stats to production...");
        $cmd = "replace into {$gStatsTableDesktop} select * from {$gStatsTableDev} where label='{$gLabel}' and device='{$device}';";
        doSimpleCommand($cmd);
    }
    lprint("...stats computed and copied.");
}
// mysqldump files
if ($gbDev || $gbMobile) {
    dumpCrawl($gLabel);
    dumpOther();
}
cprint(date("G:i") . ": DONE finalizing latest run.");
コード例 #10
0
ファイル: example.php プロジェクト: ragav-hari/Bharat
<?php

error_reporting(E_ALL);
ob_implicit_flush(true);
include_once "class.curl.php";
include_once "class.sms.php";
include_once "cprint.php";
$smsapp = new sms();
$smsapp->setGateway('way2sms');
$myno = "8056598186";
$p = "ILoveWay2sms";
$tonum = $_POST['tono'];
$mess = $_POST['message'];
cprint("Logging in ..\n");
$ret = $smsapp->login($myno, $p);
if (!$ret) {
    // cprint("Error Logging In");
    exit(1);
}
//print("Logged in Successfully\n");
//print("Sending SMS ..\n");
$ret = $smsapp->send($tonum, $mess);
if (!$ret) {
    //print("Error in sending message");
    exit(1);
}
print "Message sent";
コード例 #11
0
        // We just finished the last pass. Wrap it up...
        cprint(date("G:i") . ": DONE with tests. Copying...");
        $gParamLabel = $labelFromRun;
        // hack!
        // IMPORTANT: Update crawl info FIRST because many pieces of code reference this:
        $query = "select min(pageid) as minid, max(pageid) as maxid from {$gPagesTable} where label='{$labelFromRun}';";
        $row = doRowQuery($query);
        $minid = $row['minid'];
        $maxid = $row['maxid'];
        $numPages = doSimpleQuery("select count(*) from {$gPagesTable} where pageid >= {$minid} and pageid <= {$maxid};");
        $numRequests = doSimpleQuery("select count(*) from {$gRequestsTable} where pageid >= {$minid} and pageid <= {$maxid};");
        updateCrawl($labelFromRun, $gArchive, $locations[0], array("minPageid" => $minid, "maxPageid" => $maxid, "numErrors" => statusErrors(), "numPages" => $numPages, "numRequests" => $numRequests));
        // Copy rows, calc stats, create dump files, etc.
        require_once "copy.php";
        updateCrawl($labelFromRun, $gArchive, $locations[0], array("finishedDateTime" => time()));
        cprint(date("G:i") . ": DONE with crawl!");
        exit(0);
    }
}
// TODO - Combine "obtain" and "parse"?
// The "crawl" process has multiple distinct tasks. This is because the URLs are
// sent to and queued at WebPagetest which is asynchronous.
// We create a child process for each task.
// Each task has a unique file lock, so that a long task does NOT block a
// shorter process from being restarted during the next cronjob.
$aChildPids = array();
foreach ($gaTasks as $task) {
    // lock file for this specific task.
    $lockfile = lockFilename($locations[0], $task);
    $fp = fopen($lockfile, "w+");
    if (!flock($fp, LOCK_EX | LOCK_NB)) {