Example #1
0
 /**
  * Clear0
  *
  * 毎月最初にNTT の携帯電話通話料金およびパケットの料金カウンタをクリア
  *
  * @access	public
  * @return	void
  */
 public function clear0Action()
 {
     // $clears = Clear::find();
     // echo "There are ", count($clears), "<br>";
     $ym = date('Ym');
     // $ym="201512";
     $rec = Clear::query()->where("clearym= :ym:")->bind(array("ym" => $ym))->execute();
     if (count($rec) < 1) {
         $today = date('YmdHis');
         $mobiles = Mobil::query()->distinct("mobil_no")->execute();
         foreach ($mobiles as $m) {
             $mobil_no = $m->mobil_no;
             echo $mobil_no;
             $tel_rate = new TelRate();
             $tel_rate->mobil_no = $mobil_no;
             $tel_rate->normal_rate = 0;
             $tel_rate->op_time = $today;
             $tel_rate->save();
             $packet = new PacketAmount();
             $packet->mobil_no = $mobil_no;
             $packet->packet_amount = 0;
             $packet->op_time = $today;
             $packet->save();
         }
         $clear = new Clear();
         $clear->clearym = $ym;
         $clear->operationtm = $today;
         $clear->save();
     }
     $response = new \Phalcon\Http\Response();
     $response->redirect("/");
     return $response;
 }
Example #2
0
<?php

/**
 * 产品关键词清理
 */
$clear = new Clear();
$clear->clearSplitRepeat();
class Clear
{
    public function __construct()
    {
    }
    /**
     * 脚本清理分词重复
     *
     * @Author   tianyunzi
     * @DateTime 2015-10-30T19:10:50+0800
     * @return   [type]                   [description]
     */
    public function clearSplitRepeat()
    {
        $id = 0;
        while (1) {
            $this->local189 = new Table("local189");
            $this->local = new Table("local");
            $mysqlRs = $this->local189->findAll("select id, redword from gckeyword.key_proword where id > '{$id}' order by id asc limit 100");
            if (empty($mysqlRs)) {
                exit("所有关键词排查完毕");
            }
            foreach ($mysqlRs as $value) {
                $id = $value['id'];
Example #3
0
 /**
  * Delete files in a folder matching a pattern
  *
  * @param mixed $path null
  * @param string $pattern '.*\.(css|js)'
  * @return void
  * @access public
  */
 public static function direct($path = null, $pattern = '.*\\.(css|js)')
 {
     if (!$path) {
         return false;
     }
     if (!is_dir($path)) {
         Clear::$_messages[] = 'Path doesn\'t exist: ' . $path;
         return false;
     }
     if (!is_writable($path)) {
         Clear::$_messages[] = 'Path isn\'t writable: ' . $path;
         return false;
     }
     if (Clear::$settings['useExec']) {
         preg_match('#(.*)\\((.*)\\)#', $pattern, $matches);
         list($_, $prefix, $extensions) = $matches;
         $prefix = str_replace(array('.*', '\\'), array('*', ''), $prefix);
         $parterns = array();
         foreach (explode('|', $extensions) as $ext) {
             $parterns[] = $prefix . $ext;
         }
         $return = null;
         foreach ($parterns as $partern) {
             $cmd = "ls -f1 {$path}{$partern} | xargs rm";
             if (!Clear::exec($cmd)) {
                 Clear::$_messages[] = 'Successfully deleted all files in ' . $path;
                 $return = false;
                 continue;
             }
             Clear::$_messages[] = 'Command succeeded ' . $cmd;
             if ($return === null) {
                 $return = true;
             }
         }
         if ($return) {
             return true;
         }
     }
     uses('Folder', 'File');
     $Folder = new Folder($path);
     $files = $Folder->find($pattern);
     return Clear::deleteFiles($files);
 }
Example #4
0
 public function testExecute()
 {
     $instance = new Clear('');
     $session = new \Pry\Session('');
     $this->assertTrue($instance->execute($session));
 }
Example #5
0
 public function __construct()
 {
     if (isset($_COOKIE['loged']) && $_COOKIE['loged'] == true) {
         if (file_exists("../controls/view/admin_panel.php")) {
             include_once "../controls/view/admin_panel.php";
         } else {
             Logger::write("adminform_controller; #110 отсутсвует ../controls/view/admin_panel.php");
         }
     } else {
         if (self::blocked() == 0) {
             if (isset($_POST["adm_frm_sb"])) {
                 $user = Db::select_login("admin_users", Clear::data($_POST["adm_frm_lg"]));
                 if (trim($user['hash']) == trim(md5(Clear::data($_POST["adm_frm_lg"]) . Clear::data($_POST["adm_frm_ps"])))) {
                     self::setcookies($user);
                     if (file_exists("../logs/" . $_SERVER['REMOTE_ADDR'] . ".ini")) {
                         unlink("../logs/" . $_SERVER['REMOTE_ADDR'] . ".ini");
                     }
                     header("Location: http://" . $_SERVER['HTTP_HOST'] . "/controls/");
                     if (isset($_COOKIE['loged']) && !empty($_COOKIE['loged'])) {
                         if (file_exists("../controls/view/admin_panel.php")) {
                             include_once "../controls/view/admin_panel.php";
                         } else {
                             Logger::write("adminform_controller; отсутсвует ../controls/view/admin_panel.php");
                         }
                     }
                 } else {
                     $try = self::tryLogin() + 1;
                     self::try_write("try={$try};lasttime=" . date("H:i"), $_SERVER['REMOTE_ADDR']);
                     Logger::write("Неудачная попытка {$try} авторизации в админпанеле c IP {$_SERVER['REMOTE_ADDR']}");
                     if (file_exists("../controls/view/login_panel.php")) {
                         include_once "../controls/view/login_panel.php";
                     } else {
                         Logger::write("adminform_controller; #120 отсутсвует ../controls/view/login_panel.php");
                     }
                 }
             } else {
                 if (file_exists("../controls/view/login_panel.php")) {
                     include_once "../controls/view/login_panel.php";
                 } else {
                     Logger::write("adminform_controller; #133 отсутсвует ../controls/view/login_panel.php");
                 }
             }
         } else {
             if (file_exists("../controls/view/admin_error.php")) {
                 include_once "../controls/view/admin_error.php";
             } else {
                 Logger::write("adminform_controller; #139 отсутсвует ../controls/view/admin_error.php");
             }
         }
     }
 }