刷公司日志 php 脚本


#!/usr/bin/env php
/**
* 自动刷日志工具
* Useage : diarly.php diarly.php [start_date] [end_date]
* 日期格式: 2009-01-20 默认刷当日日志
*
* @Author rikugun <mailto:v5.rikugun@gmail.com>
*/
<?php
class Diarly{
//需要设置
//登录提交url
var $sLoginUrl = "http://yourdomain/logincheck.php";
//提交日志url
var $sSubmitUrl = "http://yourdomain/general/diary/new/submit.php";
//登录用户名
var $username = "用户名";
//登录密码
var $psw = "密码";
//日志内容
var $content = "日志内容";
//结束设置

var $ch;
var $postField;
var $cfp;
function Diarly(){
}
function init($start_date,$end_date){
$this->ch = curl_init();
$this->cfp = tempnam('/tmp','leznet');
$this->username = iconv('UTF-8','GB2312',$this->username);
$this->psw = iconv('UTF-8','GB2312',$this->psw);
$this->filename = $filename;
$this->content =urlencode(iconv('UTF-8','GB2312',$this->content));
$this->postField = "DIA_TYPE=1&CONTENT=".$this->content;
curl_setopt($this->ch,CURLOPT_POST,1);
$this->curr_date = new DateTime($start_date);
$this->end_date = $end_date;
}

//登录
function login(){
echo "Now Loginng ...\n";
$logstr = "USERNAME=".urlencode($this->username)."&PASSWORD=".urlencode($this->psw);
// echo "Login with ".$logstr."\n";
curl_setopt($this->ch,CURLOPT_URL,$this->sLoginUrl);
// curl_setopt($this->ch,CURLOPT_NOBODY,1);
curl_setopt($this->ch,CURLOPT_POSTFIELDS,$logstr);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cfp);
curl_setopt($this->ch,CURLOPT_COOKIEFILE,$this->cfp);
curl_exec($this->ch);
echo "Success Login\n";
}
//添加日志
function submit(){
echo "Now Sending Diarly(ies) to Sever\n";
curl_setopt($this->ch,CURLOPT_URL,$this->sSubmitUrl);
while ($this->curr_date->format('Y-m-d')!==$this->end_date) {
echo "Add Diarly of ".$this->curr_date->format('Y-m-d')." end with less than ".$this->end_date."\n";
$postfield = $this->postField."&DIA_DATE=".$this->curr_date->format('Y-m-d');
curl_setopt($this->ch,CURLOPT_POSTFIELDS,$postfield);
curl_exec($this->ch);
echo curl_error($this->ch);
$this->curr_date->modify("+1 day");
}
echo "Success Add Diarly(ies)!\n";
}

function close(){
curl_close($this->ch);
unlink($this->cfp);
}
}

//var_dump($argv);
$d = new Diarly();
//处理输入参数
switch(count($argv)){
case 3:
$d->init($argv[1],$argv[2]);
break;
case 2:
$d->init(date('Y-m-d'),$argv[2]);
break;
case 1:
$d->init(date('Y-m-d'),date('Y-m-d',time()+24*60*60));
break;
default:
useage();
}
$d->login();
$d->submit();
$d->close();
echo "Total Success!\n";

function useage(){
echo "Useage: diarly.php [start_date] [end_date]\n";
exit (1);
}
?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值