码迷,mamicode.com
首页 > Web开发 > 详细

linux端php

时间:2015-06-09 11:35:13      阅读:603      评论:0      收藏:0      [点我收藏+]

标签:

#!/usr/local/bin/php

-----------------------------------------------------------用到文件

/usr/local/apache/conf/httpd.conf

/etc/userdomains

//////////////////////////////////////////输入网址查帐号//////////////////////////////////////////////////////paymentcopy.php

echo ‘input URL(test.com/fr.test.com):‘;//aburcrombieinmad
$shelldb = "\cp -a /etc/userdomains /home/zlog/;";
exec($shelldb);
fscanf(STDIN, ‘%s‘, $webDir);
$geturl =file(‘userdomains‘);
$urls = array_map(‘trim‘,$geturl);
foreach($urls as $k=>$v){
if(strstr($v,$webDir)){
$domain_user=explode(‘:‘, $v);
$domain=trim($domain_user[0]);
$user=trim($domain_user[1]);
}
}

if(file_exists("/home/{$user}/www/includes/configure.php"))
{include("/home/{$user}/www/includes/configure.php");
echo DB_DATABASE."\n";}

/////////////////////////目录查询////////////////////////////////////////////////////////////////////////////////

function myscandir($pathname){

foreach( glob($pathname) as $filename ){

if(strpos($filename,"cpmove-"))
$filenames .= basename($filename)."\n";
}
file_put_contents(‘cpfileresults.txt‘,$filenames);
}
myscandir(‘/home/*‘);

///////////////////////////////////////////////数据库常用////////////////////////////////////////////////////////////////////////////////

$myupdatesql = "UPDATE `configuration` SET `configuration_value` = replace(`configuration_value` ,‘usachoutletservice@gmail.com‘,‘outletservices@hotmail.com‘);";

/***************************************复制通道开始***************************************/paymentcopy.php

#!/usr/local/bin/php
<?php
chdir(‘/home/zlog/‘);
echo ‘input URL(test.com/fr.test.com):‘;//aburcrombieinmad
$shelldb = "\cp -a /etc/userdomains /home/zlog/;";
exec($shelldb);
fscanf(STDIN, ‘%s‘, $webDir);
$webDir = strtolower(trim($webDir));
$geturl =file(‘userdomains‘);
$urls = array_map(‘trim‘,$geturl);
foreach($urls as $k=>$v){
if(strstr($v,$webDir)){
$domain_user=explode(‘:‘, $v);
$domain=trim($domain_user[0]);
$user=trim($domain_user[1]);
}
}
/////////////////////////数据库复制//////////////////////////////////////
$deletesql = ‘delete FROM `configuration` WHERE `configuration_key` like "%FRISTCCPAY%";‘;
$deletesql .= ‘delete FROM `configuration` WHERE `configuration_key` like "%FRISTONECC%";‘;
$insertsql = <<<EOT
INSERT INTO `configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES
(‘Enable FRISTONECC Module‘, ‘MODULE_PAYMENT_FRISTONECC_STATUS‘, ‘True‘, ‘Do you want to accept Fristpay payments?‘, 6, 0, NULL, ‘2014-05-27 04:15:58‘, NULL, ‘zen_cfg_select_option(array(‘‘True‘‘, ‘‘False‘‘), ‘),
(‘Fristpay ID‘, ‘MODULE_PAYMENT_FRISTONECC_SELLER‘, ‘107418‘, ‘Fristpay ID‘, 6, 2, NULL, ‘2014-05-27 04:15:58‘, NULL, NULL),
(‘Fristpay MD5 key‘, ‘MODULE_PAYMENT_FRISTONECC_MD5KEY‘, ‘qiSN0D‘, ‘Fristpay MD5 key‘, 6, 4, NULL, ‘2014-05-27 04:15:58‘, NULL, NULL),
(‘Payment Zone‘, ‘MODULE_PAYMENT_FRISTONECC_ZONE‘, ‘0‘, ‘If a zone is selected, only enable this payment method for that zone.‘, 6, 10, NULL, ‘2014-05-27 04:15:58‘, ‘zen_get_zone_class_title‘, ‘zen_cfg_pull_down_zone_classes(‘),
(‘Set Pending Notification Status‘, ‘MODULE_PAYMENT_FRISTONECC_ORDER_STATUS_ID‘, ‘1‘, ‘Set the status of orders made with this payment module to this value<br />(Processing recommended)‘, 6, 12, NULL, ‘2014-05-27 04:15:58‘, ‘zen_get_order_status_name‘, ‘zen_cfg_pull_down_order_statuses(‘),
(‘Sort order of display‘, ‘MODULE_PAYMENT_FRISTONECC_SORT_ORDER‘, ‘0‘, ‘Sort order of display. Lowest is displayed first.‘, 6, 12, NULL, ‘2014-05-27 04:15:58‘, NULL, NULL),
(‘Fristpay transaction URL<br />Default: <code>https://payment.fristpay.com/payment/payment/direct.xml</code><br />‘, ‘MODULE_PAYMENT_FRISTONECC_HANDLER‘, ‘https://payment.fristpay.com/payment/payment/direct.xml‘, ‘Fristpay transaction URL‘, 6, 14, NULL, ‘2014-05-27 04:15:58‘, NULL, ‘‘);
EOT;
/***
$mysqldirnames = array();
$dbDir = opendir(‘/var/lib/mysql‘);
while (false != ($filename=readdir($dbDir))) {
$mysqldirnames[] = $filename;
}
foreach($mysqldirnames as $sqldirname) {
if(preg_match(‘/^‘.$user.‘/‘, $sqldirname))
break;
}
***/
if(file_exists("/home/{$user}/public_html/includes/configure.php")) {
include("/home/{$user}/www/includes/configure.php");
$sqldirname =DB_DATABASE;
if($sqldirname){
$pdo = new Pdo ("mysql:dbname=" . $sqldirname, ‘root‘, ‘Lin7Cc3x#$%‘ );
$pdo->exec($deletesql);
$pdo->exec($insertsql);
}
else{echo ‘ Not found database!‘ . "\n";}
//////////////////////////////////////////////////////////////////////
/////////////////////////文件复制//////////////////////////////////////
$shell = "\cp -a /home/zlog/payment/* /home/{$user}/public_html/;";
$shell .= "\chown -R {$user}:{$user} /home/zlog/payment/";
exec($shell);
echo $domain.‘---‘.$user .‘ OK!‘ . "\n";
}
else{echo $webDir. " not found\n";}
//////////////////////////////////////////////////////////////////////

/***************************************复制通道结束*****************************************/paymentcopy.php

/***************************************检测网址是否可打开开始*****************************************/

#!/usr/local/bin/php
<?php
//...........
set_time_limit(0);
ignore_user_abort(true);
chdir(‘/home/zlog/‘);
$shelldb = "\cp -a /etc/userdomains /home/zlog/";
exec($shelldb);
<?php
$geturl =file(‘userdomains‘);
$urls = array_map(‘trim‘,$geturl);
$i=0;
foreach($urls as $k=>$v){
if(!strpos($v,‘: nobody‘)){
$domain_user=explode(‘:‘, $v);
$domain=‘http://‘.$domain_user[0];
$user=$domain_user[1];
//print_r($domain);
// echo "$i<hr/>";
$array = @get_headers($domain);
if(preg_match(‘/200/‘,$array[0])){
echo $domain." OK ----{$i}";
}else{
echo $domain." cannt open ----{$i}";
$faileurl .= $domain.‘ ‘." cannt open ".$array[0]."\n";
}
echo "\n";
}
$i++;
}
file_put_contents(‘check_faileopen_url.php‘, $faileurl);

/***************************************检测网址是否可打开结束*****************************************/

/***************************************多了www配置数据库替换开始*****************************************/

#!/usr/local/bin/php
<?php
$seletsql = "SELECT * FROM `configuration` WHERE `configuration_key` = ‘FOOTER_KEYWORDS‘;";
chdir(‘/home/zlog‘);
$dbDir = opendir(‘/var/lib/mysql‘);
//$filename =‘batencia_li12db‘;
while (false != ($filename=readdir($dbDir))) {
if(file_exists(‘/var/lib/mysql/‘ . $filename . ‘/configuration.frm‘) && $filename != ".")
{
$pdo = new Pdo ("mysql:dbname=" . $filename, ‘root‘, ‘Lin7Cc3x#$%‘ );
$datades = $pdo->query($seletsql);
$maxdes = $datades->fetchAll(PDO::FETCH_ASSOC);
$configuration_valuetemp=str_replace(‘www.www.‘,‘www.‘,$maxdes[0][‘configuration_value‘]);
$updatesql = "UPDATE `configuration` SET `configuration_value` = ‘$configuration_valuetemp‘ WHERE `configuration_key` = ‘FOOTER_KEYWORDS‘;";
if($pdo->exec($updatesql))
{echo $filename."OK" . "\n";}
else echo $filename."Fail" . "\n";
}
}

/***************************************多了www配置数据库替换结束*****************************************/

/***************************************网站模版备份开始*****************************************/

#!/usr/local/bin/php
<?php
//...........
set_time_limit(0);
ignore_user_abort(true);
chdir(‘/home/zlog/‘);
$shelldb = "\cp -a /etc/userdomains /home/zlog/;";
if(!is_dir("/home/zzzbackup"))
{$shelldb .= "mkdir /home/zzzbackup";}
exec($shelldb);
//$geturl =Array ( "elvert.eu: elvertw3fam");
$geturl =file(‘userdomains‘);
$urls = array_map(‘trim‘,$geturl);
$i=0;
foreach($urls as $k=>$v){
if(!strpos($v,‘: nobody‘)){
$domain_user=explode(‘:‘, $v);
$domain=trim($domain_user[0]);
$domainurl=‘http://‘.$domain;
$user=trim($domain_user[1]);
//print_r($domain);
// echo "$i<hr/>";
$datetime = date("y-m-d");
echo $domain." ING~ \n";
//echo "cd /home/$user/public_html\n";
//echo "tar zcvpf /home/zzzbackup/{$domain}-{$datetime}.tar.gz includes --exclude languages\n";
$bakorder = "cd /home/$user/public_html;";
$bakorder .= "tar zcvpf /home/zzzbackup/$domain-{$datetime}.tar.gz includes";
//$bakorder .= "tar zcvpf /home/zzzbackup/$domain-{$datetime}.tar.gz includes --exclude languages";
if(is_dir("/home/$user/public_html/includes"))
{
exec($bakorder);
$bakok.=$domainurl."\n";
}

//只要includes文件夹 不要整个绝对目录都压缩进去,排除language文件夹
}
$i++;
}
$datetime2 = date("y-m-d");
$bakordersql = "cd /var/lib;";
$bakordersql .= "tar zcvpf /home/zzzbackup/{$datetime2}-mysqlbackup.tar.gz mysql &";
exec($bakordersql);
file_put_contents(‘checkurlbackup_ok.php‘, $bakok);

/************************************网站模版备份结束**************************************************/

linux端php

标签:

原文地址:http://www.cnblogs.com/alex-13/p/4562682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!