@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $banner_to_print = str_replace("{Name}", $name, $banner_to_print); |
| 37 | 37 | $description = self::$color_c."Know the dangers of email credentials reuse attacks.".self::$color_g; |
| 38 | 38 | $banner_to_print = str_replace("{Description}", $description, $banner_to_print); |
| 39 | - $loaded = self::$color_b."Loaded ".self::$color_y."14".self::$color_b." website.".self::$color_g; |
|
| 39 | + $loaded = self::$color_b."Loaded ".self::$color_y."14".self::$color_b." website.".self::$color_g; |
|
| 40 | 40 | $banner_to_print = str_replace("{Loaded}", $loaded, $banner_to_print); |
| 41 | 41 | echo $banner_to_print; |
| 42 | 42 | } |
@@ -376,20 +376,20 @@ discard block |
||
| 376 | 376 | |
| 377 | 377 | $ids = array(); |
| 378 | 378 | foreach ($set as $val) |
| 379 | - { |
|
| 379 | + { |
|
| 380 | 380 | ksort($val); |
| 381 | 381 | // 去重,其实不去也可以,因为相同的when只会执行第一个,后面的就直接跳过不执行了 |
| 382 | 382 | $key = md5($val[$index]); |
| 383 | - $ids[$key] = $val[$index]; |
|
| 384 | - |
|
| 385 | - foreach (array_keys($val) as $field) |
|
| 386 | - { |
|
| 387 | - if ($field != $index) |
|
| 388 | - { |
|
| 389 | - $final[$field][$key] = 'When `'.$index.'` = "'.$val[$index].'" Then "'.$val[$field].'"'; |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - } |
|
| 383 | + $ids[$key] = $val[$index]; |
|
| 384 | + |
|
| 385 | + foreach (array_keys($val) as $field) |
|
| 386 | + { |
|
| 387 | + if ($field != $index) |
|
| 388 | + { |
|
| 389 | + $final[$field][$key] = 'When `'.$index.'` = "'.$val[$index].'" Then "'.$val[$field].'"'; |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | 393 | //$ids = array_values($ids); |
| 394 | 394 | |
| 395 | 395 | // 如果不是数组而且不为空,就转数组 |
@@ -400,29 +400,29 @@ discard block |
||
| 400 | 400 | $where[] = $index.' In ("'.implode('","', $ids).'")'; |
| 401 | 401 | $where = empty($where) ? "" : " Where ".implode(" And ", $where); |
| 402 | 402 | |
| 403 | - $sql = "Update `".$table."` Set "; |
|
| 404 | - $cases = ''; |
|
| 403 | + $sql = "Update `".$table."` Set "; |
|
| 404 | + $cases = ''; |
|
| 405 | 405 | |
| 406 | - foreach ($final as $k => $v) |
|
| 407 | - { |
|
| 406 | + foreach ($final as $k => $v) |
|
| 407 | + { |
|
| 408 | 408 | // 过滤掉数据库没有的字段 |
| 409 | 409 | if (!in_array($k, $fields)) |
| 410 | 410 | { |
| 411 | 411 | continue; |
| 412 | 412 | } |
| 413 | - $cases .= '`'.$k.'` = Case '."\n"; |
|
| 414 | - foreach ($v as $row) |
|
| 415 | - { |
|
| 416 | - $cases .= $row."\n"; |
|
| 417 | - } |
|
| 413 | + $cases .= '`'.$k.'` = Case '."\n"; |
|
| 414 | + foreach ($v as $row) |
|
| 415 | + { |
|
| 416 | + $cases .= $row."\n"; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - $cases .= 'Else `'.$k.'` End, '; |
|
| 420 | - } |
|
| 419 | + $cases .= 'Else `'.$k.'` End, '; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - $sql .= substr($cases, 0, -2); |
|
| 422 | + $sql .= substr($cases, 0, -2); |
|
| 423 | 423 | |
| 424 | 424 | // 其实不带 Where In ($index) 的条件也可以的 |
| 425 | - $sql .= $where; |
|
| 425 | + $sql .= $where; |
|
| 426 | 426 | |
| 427 | 427 | if ($return_sql) return $sql; |
| 428 | 428 | |
@@ -139,8 +139,8 @@ |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * 获取默认配置 |
|
| 143 | - */ |
|
| 142 | + * 获取默认配置 |
|
| 143 | + */ |
|
| 144 | 144 | protected static function _get_default_config() |
| 145 | 145 | { |
| 146 | 146 | if (empty(self::$configs['default'])) |
@@ -758,35 +758,35 @@ |
||
| 758 | 758 | switch($command) |
| 759 | 759 | { |
| 760 | 760 | // 启动 phpspider |
| 761 | - case 'start': |
|
| 762 | - if ($command2 === '-d') |
|
| 763 | - { |
|
| 764 | - self::$daemonize = true; |
|
| 765 | - } |
|
| 766 | - break; |
|
| 767 | - case 'stop': |
|
| 768 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
| 769 | - if (count($info) <= 1) |
|
| 770 | - { |
|
| 771 | - echo "PHPSpider[$start_file] not run\n"; |
|
| 772 | - } |
|
| 773 | - else |
|
| 774 | - { |
|
| 775 | - //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
| 776 | - echo "PHPSpider[$start_file] stop success"; |
|
| 777 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
| 778 | - } |
|
| 779 | - exit; |
|
| 780 | - break; |
|
| 781 | - case 'kill': |
|
| 782 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
| 783 | - break; |
|
| 784 | - // 显示 phpspider 运行状态 |
|
| 785 | - case 'status': |
|
| 786 | - exit(0); |
|
| 787 | - // 未知命令 |
|
| 788 | - default : |
|
| 789 | - exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
| 761 | + case 'start': |
|
| 762 | + if ($command2 === '-d') |
|
| 763 | + { |
|
| 764 | + self::$daemonize = true; |
|
| 765 | + } |
|
| 766 | + break; |
|
| 767 | + case 'stop': |
|
| 768 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
| 769 | + if (count($info) <= 1) |
|
| 770 | + { |
|
| 771 | + echo "PHPSpider[$start_file] not run\n"; |
|
| 772 | + } |
|
| 773 | + else |
|
| 774 | + { |
|
| 775 | + //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
| 776 | + echo "PHPSpider[$start_file] stop success"; |
|
| 777 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
| 778 | + } |
|
| 779 | + exit; |
|
| 780 | + break; |
|
| 781 | + case 'kill': |
|
| 782 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
| 783 | + break; |
|
| 784 | + // 显示 phpspider 运行状态 |
|
| 785 | + case 'status': |
|
| 786 | + exit(0); |
|
| 787 | + // 未知命令 |
|
| 788 | + default : |
|
| 789 | + exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | |
@@ -385,36 +385,36 @@ |
||
| 385 | 385 | { |
| 386 | 386 | switch($type) |
| 387 | 387 | { |
| 388 | - case E_ERROR: // 1 // |
|
| 389 | - return 'E_ERROR'; |
|
| 390 | - case E_WARNING: // 2 // |
|
| 391 | - return 'E_WARNING'; |
|
| 392 | - case E_PARSE: // 4 // |
|
| 393 | - return 'E_PARSE'; |
|
| 394 | - case E_NOTICE: // 8 // |
|
| 395 | - return 'E_NOTICE'; |
|
| 396 | - case E_CORE_ERROR: // 16 // |
|
| 397 | - return 'E_CORE_ERROR'; |
|
| 398 | - case E_CORE_WARNING: // 32 // |
|
| 399 | - return 'E_CORE_WARNING'; |
|
| 400 | - case E_COMPILE_ERROR: // 64 // |
|
| 401 | - return 'E_COMPILE_ERROR'; |
|
| 402 | - case E_COMPILE_WARNING: // 128 // |
|
| 403 | - return 'E_COMPILE_WARNING'; |
|
| 404 | - case E_USER_ERROR: // 256 // |
|
| 405 | - return 'E_USER_ERROR'; |
|
| 406 | - case E_USER_WARNING: // 512 // |
|
| 407 | - return 'E_USER_WARNING'; |
|
| 408 | - case E_USER_NOTICE: // 1024 // |
|
| 409 | - return 'E_USER_NOTICE'; |
|
| 410 | - case E_STRICT: // 2048 // |
|
| 411 | - return 'E_STRICT'; |
|
| 412 | - case E_RECOVERABLE_ERROR: // 4096 // |
|
| 413 | - return 'E_RECOVERABLE_ERROR'; |
|
| 414 | - case E_DEPRECATED: // 8192 // |
|
| 415 | - return 'E_DEPRECATED'; |
|
| 416 | - case E_USER_DEPRECATED: // 16384 // |
|
| 417 | - return 'E_USER_DEPRECATED'; |
|
| 388 | + case E_ERROR: // 1 // |
|
| 389 | + return 'E_ERROR'; |
|
| 390 | + case E_WARNING: // 2 // |
|
| 391 | + return 'E_WARNING'; |
|
| 392 | + case E_PARSE: // 4 // |
|
| 393 | + return 'E_PARSE'; |
|
| 394 | + case E_NOTICE: // 8 // |
|
| 395 | + return 'E_NOTICE'; |
|
| 396 | + case E_CORE_ERROR: // 16 // |
|
| 397 | + return 'E_CORE_ERROR'; |
|
| 398 | + case E_CORE_WARNING: // 32 // |
|
| 399 | + return 'E_CORE_WARNING'; |
|
| 400 | + case E_COMPILE_ERROR: // 64 // |
|
| 401 | + return 'E_COMPILE_ERROR'; |
|
| 402 | + case E_COMPILE_WARNING: // 128 // |
|
| 403 | + return 'E_COMPILE_WARNING'; |
|
| 404 | + case E_USER_ERROR: // 256 // |
|
| 405 | + return 'E_USER_ERROR'; |
|
| 406 | + case E_USER_WARNING: // 512 // |
|
| 407 | + return 'E_USER_WARNING'; |
|
| 408 | + case E_USER_NOTICE: // 1024 // |
|
| 409 | + return 'E_USER_NOTICE'; |
|
| 410 | + case E_STRICT: // 2048 // |
|
| 411 | + return 'E_STRICT'; |
|
| 412 | + case E_RECOVERABLE_ERROR: // 4096 // |
|
| 413 | + return 'E_RECOVERABLE_ERROR'; |
|
| 414 | + case E_DEPRECATED: // 8192 // |
|
| 415 | + return 'E_DEPRECATED'; |
|
| 416 | + case E_USER_DEPRECATED: // 16384 // |
|
| 417 | + return 'E_USER_DEPRECATED'; |
|
| 418 | 418 | } |
| 419 | 419 | return ""; |
| 420 | 420 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | public static function css_to_xpath($selectors) |
| 259 | 259 | { |
| 260 | - $queries = self::parse_selector($selectors); |
|
| 260 | + $queries = self::parse_selector($selectors); |
|
| 261 | 261 | $delimiter_before = false; |
| 262 | 262 | $xquery = ''; |
| 263 | 263 | foreach($queries as $s) |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | return $xquery; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * @access private |
|
| 359 | - */ |
|
| 357 | + /** |
|
| 358 | + * @access private |
|
| 359 | + */ |
|
| 360 | 360 | public static function parse_selector($query) |
| 361 | 361 | { |
| 362 | 362 | $query = trim( preg_replace( '@\s+@', ' ', preg_replace('@\s*(>|\\+|~)\s*@', '\\1', $query) ) ); |
@@ -576,13 +576,13 @@ discard block |
||
| 576 | 576 | * ^ 前缀字符串 |
| 577 | 577 | * * 包含字符串 |
| 578 | 578 | * $ 后缀字符串 |
| 579 | - * @access private |
|
| 580 | - */ |
|
| 579 | + * @access private |
|
| 580 | + */ |
|
| 581 | 581 | protected static function is_regexp($pattern) |
| 582 | 582 | { |
| 583 | - return in_array( |
|
| 584 | - $pattern[ mb_strlen($pattern)-1 ], |
|
| 585 | - array('^','*','$') |
|
| 586 | - ); |
|
| 587 | - } |
|
| 583 | + return in_array( |
|
| 584 | + $pattern[ mb_strlen($pattern)-1 ], |
|
| 585 | + array('^','*','$') |
|
| 586 | + ); |
|
| 587 | + } |
|
| 588 | 588 | } |
@@ -607,35 +607,35 @@ discard block |
||
| 607 | 607 | switch($command) |
| 608 | 608 | { |
| 609 | 609 | // 启动 phpspider |
| 610 | - case 'start': |
|
| 611 | - if ($command2 === '-d') |
|
| 612 | - { |
|
| 613 | - self::$daemonize = true; |
|
| 614 | - } |
|
| 615 | - break; |
|
| 616 | - case 'stop': |
|
| 617 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
| 618 | - if (count($info) <= 1) |
|
| 619 | - { |
|
| 620 | - echo "PHPSpider[$start_file] not run\n"; |
|
| 621 | - } |
|
| 622 | - else |
|
| 623 | - { |
|
| 624 | - //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
| 625 | - echo "PHPSpider[$start_file] stop success"; |
|
| 626 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
| 627 | - } |
|
| 628 | - exit; |
|
| 629 | - break; |
|
| 630 | - case 'kill': |
|
| 631 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
| 632 | - break; |
|
| 633 | - // 显示 phpspider 运行状态 |
|
| 634 | - case 'status': |
|
| 635 | - exit(0); |
|
| 636 | - // 未知命令 |
|
| 637 | - default : |
|
| 638 | - exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
| 610 | + case 'start': |
|
| 611 | + if ($command2 === '-d') |
|
| 612 | + { |
|
| 613 | + self::$daemonize = true; |
|
| 614 | + } |
|
| 615 | + break; |
|
| 616 | + case 'stop': |
|
| 617 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
| 618 | + if (count($info) <= 1) |
|
| 619 | + { |
|
| 620 | + echo "PHPSpider[$start_file] not run\n"; |
|
| 621 | + } |
|
| 622 | + else |
|
| 623 | + { |
|
| 624 | + //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
| 625 | + echo "PHPSpider[$start_file] stop success"; |
|
| 626 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
| 627 | + } |
|
| 628 | + exit; |
|
| 629 | + break; |
|
| 630 | + case 'kill': |
|
| 631 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
| 632 | + break; |
|
| 633 | + // 显示 phpspider 运行状态 |
|
| 634 | + case 'status': |
|
| 635 | + exit(0); |
|
| 636 | + // 未知命令 |
|
| 637 | + default : |
|
| 638 | + exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | |
@@ -648,14 +648,14 @@ discard block |
||
| 648 | 648 | { |
| 649 | 649 | switch ($signal) { |
| 650 | 650 | // Stop. |
| 651 | - case SIGINT: |
|
| 652 | - log::warn("Program stopping..."); |
|
| 653 | - self::$terminate = true; |
|
| 654 | - break; |
|
| 655 | - // Show status. |
|
| 656 | - case SIGUSR2: |
|
| 657 | - echo "show status\n"; |
|
| 658 | - break; |
|
| 651 | + case SIGINT: |
|
| 652 | + log::warn("Program stopping..."); |
|
| 653 | + self::$terminate = true; |
|
| 654 | + break; |
|
| 655 | + // Show status. |
|
| 656 | + case SIGUSR2: |
|
| 657 | + echo "show status\n"; |
|
| 658 | + break; |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | |