使用ncftp工具同步整个文件夹备份到FTP服务器ncftpput -R -z -u user -p pass remotehost /remote_directory /local_directory 同步整个目录
-R 递归同步
-z 是否断点续传
/remote_directory FTP上面的路径
/local_directory 要备份的路径
配合上次发的Dreamhost空间单用户多网站备份脚本,可以完美的达到备份的目的。
爱名网http://www.22.cn域名转移苦难记爱名网http://www.22.cn域名转移苦难记 07-12从朋友那在爱名网转购买了一个比较好的域名,然后想想转移到国外比较好,就尝试了转移,但是爱名网的系统需要身份验证,我提交了身份证验证,等了一天还是没有通过 从网上找到爱名网的一些信息,真是恶名连连,请看连接。 1.网上域名购买服务如何投诉?关于爱名网(22.cn)的 ! 2.22.cn网站中文域名非法违规不存在续费期,要求1000高价赎回! 建议各位朋友不要去爱名网http://www.22.cn进行交易。 2010-07-14最新情况 Dreamhost空间单用户多网站备份脚本代码如下,未测试 有任何建议请和我联系 部份程序参考 http://www.icnote.com/DreamHost-Auto-back-up/ Bash语言: Codee#11847
#工具信息
TAR=`which tar` MYSQLDUMP=`which mysqldump` #网站信息 #路径 numvalues=${#SITE[@]} ###数据库信息### echo “——————————————-” >> $LogFile if [ -f $SiteBackUpName ] echo “Web files back up finished!” >> $LogFile if [ -f $DBDumpFileName ] echo “Now database dump finished!” >> $LogFile 支持右键添加目录到Windows环境变量path变量中并立即生效的小工具使用说明: 1.不需要安装, 将下载后解压缩,将解压缩后的目录拷贝到你喜欢的路径下即可。 @使用备注: 环境变量分为用户环境变量和系统环境变量,用户环境变量只对当前用户有效,系统环境变量对于系统中的所有用户有效。 本程序修改的是用户环境变量中的path变量。同一个目录不会重复加入,程序会自动处理。 @关于程序修改Windows环境变量后使环境变量立即生效的问题: 本程序是使用SendMessageTimeout函数向系统发送设置改变的消息来实现的。具体代码如下: DWORD dwMsgResult = 0L; SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,LPARAM(“Environment”), SMTO_ABORTIFHUNG, 5000, &dwMsgResult); 5000是延时等待的时间长度,单位为毫秒。整个等待的长度为: Therefore, the total wait time can be up to the value of uTimeout multiplied by the number of top-level windows. 在本示例中整个程序等待的长度 = 5000 * 顶层窗口的个数; 实现原理 查询注册表path的值,如果路径已存在提示已存在,如果不存在的话添加到path,然后SendMessageTimeout让环境变量起作用。 DWORD dwMsgResult = 0L; Tags : indows环境变量小工具 ubuntu9.10安装go编译器备忘参考go语言官网教程并作相应的修改等 参考地址http://golang.org/doc/install.html 1.在~目录的.bash_profile设置相关的环境变量
$GOARCH 操作系统的架构,有以下可选 amd64 (64-bit x86, the most mature port), 386(32-bit x86), and arm(32-bit ARM, an incomplete port。 $GOBIN bin目录,官网上提示是可选的,但是在我的编译过程会提示缺少GOBIN目录。 以下是我的.bash_profile文件内容 export GOROOT=$HOME/go export GOARCH=386 export GOOS=linux export GOBIN=$HOME/bin 保存为用以下命令检查是否生效。 $ env | grep ‘^GO’ 2.从GO源码库下载源文件,进行编译 GO源码库使用的是Mercurial管理系统,需要安装相应的程序hg。 如果在您的机器上没有hg命令的话,请按照以下步骤进行安装 $ sudo easy_install mercurial 如果您的系统提示没有easy_install命令,请先运行apt-get install python-setuptools python-dev安装。 接下来我们将源码导出到$GOROOT目录(请确保$GOROOT目录存在) $ hg clone -r release https://go.googlecode.com/hg/ $GOROOT 3.开始编译 编译源码需要gcc等,如果您的系统没有gcc相关,请运行 $ sudo apt-get install bison gcc libc6-dev ed make 接着输入 $ cd $GOROOT/src $ make all 正式进行编译工作,接着可以看会电视休息会了 XD …N分钟后 如果提示 — cd ../test 0 known bugs; 0 unexpected bugs 就是编译成功了 4.使用编译器编译go语言 请到go官网查看编译器和连接器怎么使用 5.保持编译器最新 如果编译器有更新的话,可以使用以下命令进行更新编译 $ cd $GOROOT/src $ hg pull $ hg update release $ make all Tags : go compiler 恶心的strtok的实现留此为鉴 C语言: Codee#6730
01 #include <stdio.h>
02 #include <stdlib.h> 03 #include <string.h> 04 05 char *mystrtok(char *str, const char *delim); 06 07 int main(void) { 08 09 char str[] = “root:x::0:root:/root:/bin/bash:”; 10 char *token; 11 12 token = mystrtok(str, “:”); 13 printf(“%s\n“, token); 14 while ( (token = mystrtok(NULL, “:”)) != NULL) 15 printf(“%s\n“, token); 16 17 free(token); 18 return 0; 19 } 20 char *mystrtok(char *str, const char *delim) { 21 22 static char *last; 23 char *t; 24 int i = 0; 25 26 if ((NULL == str) && ((str=last) == NULL )) 27 return (NULL); 28 29 last = strstr(str, delim); 30 31 if (NULL == last) { 32 return NULL; 33 } else { 34 t = malloc(strlen(str) + 1); 35 memset(t, 0, strlen(t)); 36 for(i=0; i < (strlen(str) - strlen(last)); ++i) { 37 38 t[i] = str[i]; 39 } 40 41 while(last == strstr(last, delim)) 42 *last++; 43 return t; 44 } 45 } 使用colinux安装ubuntu使用colinux安装ubuntu 1.colinux和ubuntu简介 Ubuntu 发”oo-BOON-too”音,是一款免费、开源、易于使用的linux发行版。官网在这http://www.ubuntu.com/ 2.colinux和其它虚拟机相比有什么优势 3.安装和配置colinux 将colinux安装在一个简单的路径如d:\colinux。把下载的ubuntu Image文件一起放到D:\colinux,我们接下来要配置配置文件。 配置文件内容 ________________________________________________________________________________ 接着就可以运行以下命令启动了 1.直接从命令行启动 2.作为系统服务 于是就可以以服务的方式管理这个虚拟机了。例如启动它: c:\> net start ubuntu 若以服务方式启动,则需要手工打开 Console,才能看到其启动的样子,否则它在后台运行。这个Console在coLinux下,分别为colinux-console-fltk.exe和colinux-console-nt.exe。 coLinux有三种网络工作模式,即NAT、BRIDGE、TUNTAP。下面只介绍NAT和TUNTAP两种方式,BRIDGE由于我没有试成功,不便说明。 1. NAT(Network Address Translation,网络地址转换) 配置文件中关于NAT的配置为 ethX=slirp,<MAC>,<redirections> 刚才的配置文件中写道, eth0=slirp,,tcp:5901:5900/tcp:6699:22/udp:6699:22 2.TUNTAP ethX=tuntap,<network connection name>,<MAC> 如果有多个tuntap的网卡,则需要指定一个名称。在此没有那么多复杂的情况,我们就直接使用 eth0=tuntap 即可。到了Linux下之后,再利用 ifconfig 来配置网卡,便可通主机通讯了。若要在此方式下让Guest OS上网,则需要启动Windows的Internet连接共享,只要将Internet连接设置为共享,然后指定为TUNTAP共享即可,在此不再赘述。
1.X的配置 http://colinux.wikia.com/wiki/XCoLinux 5.参考 神田川歌手:南こうせつとかぐや姫 歌词: いつも私が待たされた 若かったあの頃 何も恐くなかった 貴方はもう捨てたのかしら いつもちっとも 似てないの 若かったあの頃 何も恐くなかった PHP smtp邮件群发程序啥也不说了 上代码 PHP语言: Codee#6096
001 <?php
002 /** 003 *通过phpmailer发送qq邮件 004 *@author ray 005 *@since 2009-08-07 006 */ 007 define(‘__DEBUG__’, false); 008 define(‘__PSW_FILE__’, dirname(__FILE__) . ‘/smtp.dat’); 009 define(‘SLEEPING_EMAIL’, dirname(__FILE__) . “/sleepMail.dat”);//休眠的email 010 define(‘SLEEPING_TIME’, 1800);//休眠多长时间,以秒为单位 011 define(‘FILE_APPEND’, 1); 012 if (!function_exists(‘file_put_contents’)) { 013 function file_put_contents($n, $d, $flag = false) { 014 $mode = ($flag == FILE_APPEND || strtoupper($flag) == ‘FILE_APPEND’) ? ‘a’ : ‘w’; 015 $f = @fopen($n, $mode); 016 if ($f === false) { 017 return 0; 018 } else { 019 if (is_array($d)) $d = implode($d); 020 $bytesWritten = fwrite($f, $d); 021 fclose($f); 022 return $bytesWritten; 023 } 024 } 025 } 026 $errorNo = 0; 027 $errorMsg = ”; 028 $currTime = time(); 029 $unuseMails = array(); 030 //收件人和邮件标题和邮件内容 031 $to = isset($argv[1]) ? $argv[1] : “” ; 032 $subject = isset($argv[2]) ? $argv[2] : “”; 033 $mailFile = isset($argv[3]) ? $argv[3] : “” ; 034 if (__DEBUG__) { 035 echo ” 036 file:$mailFile to:$to subject:$subject\r\n“; 037 } 038 if (empty($mailFile) || empty($to) || empty($subject)) { 039 $errorNo = 1; 040 $errorMsg = “参数不全”; 041 } 042 //加载不可用的email列表 043 if (!$errorNo) { 044 if (file_exists(SLEEPING_EMAIL)) { 045 $sleepMails = file(SLEEPING_EMAIL); 046 if (!empty($sleepMails)) { 047 048 foreach($sleepMails as $sleepMail) { 049 //解析 050 if (false !== strpos($sleepMail, ‘|’)) { 051 $tmp = explode(‘|’, $sleepMail); 052 if (isset($tmp[0]) && isset($tmp[1])) { 053 $mail = trim($tmp[0]); 054 $time = trim($tmp[1]); 055 056 //是否可用 057 if ( ($currTime - $time )< SLEEPING_TIME) { 058 $unuseMails[] = $mail; 059 } 060 } 061 } 062 } 063 } 064 } 065 } 066 if (!$errorNo) { 067 //随机加载smtp服务器和smtp用户名和密码 068 $info = file(__PSW_FILE__); 069 $len = count($info); 070 071 do { 072 $rnd = mt_rand(0, $len - 1); 073 $line = isset($info[$rnd]) ? $info[$rnd] : “”; 074 075 if (false !== strpos($line, ‘|’)) { 076 077 $tmp = explode(‘|’, $line); 078 if (isset($tmp[0]) && isset($tmp[1]) && isset($tmp[2])) { 079 080 $smtpServer = trim($tmp[0]); 081 $fromMail = trim($tmp[1]); 082 $psw = trim($tmp[2]); 083 $smtpUserName = substr($fromMail, 0, strrpos($fromMail, ‘@’)); 084 } 085 } 086 }while (in_array($fromMail, $unuseMails));//如果在不可用的列表中,在次加载 087 088 if (!isset($smtpServer) || !isset($fromMail) || !isset($psw)) { 089 $errorNo = 2; 090 $errorMsg = “没找到发件人QQ信箱和密码”; 091 } 092 } 093 if (!$errorNo && __DEBUG__) { 094 echo “smtp:$smtpServer from:$fromMail psw:$psw user:$smtpUserName\r\n“; 095 } 096 if (!$errorNo) { 097 //通过phpmailer连接smtp服务器发信 098 require(dirname(__FILE__) . “/phpmailer/class.phpmailer.php”); 099 require(dirname(__FILE__) . “/phpmailer/class.smtp.php”); 100 $mail = new PHPMailer(); 101 102 $body = $mail->getFile($mailFile); 103 $body = eregi_replace(“[\]“,”,$body); 104 105 //charset 106 $mail->CharSet = “GB2312″; 107 108 //$mail->SMTPDebug = 2;//用于显示具体的smtp错误 109 110 $mail->IsSMTP(); 111 $mail->SMTPAuth = true; 112 if (“smtp.qq.com” == trim($smtpServer)) { 113 $mail->Username = $fromMail; 114 } else { 115 $mail->Username = $smtpUserName; 116 } 117 $mail->Password = $psw; 118 $mail->Host = $smtpServer; 119 120 $mail->From = $fromMail; 121 $mail->FromName = “”; 122 123 $mail->IsHTML(true); 124 125 $mail->AddAddress($to); 126 $mail->Subject = $subject; 127 $mail->Body = $body; 128 129 if (!$mail->Send()) { 130 131 // echo “Message could not be sent. “; 132 $errorNo = 3; 133 $errorMsg = $mail->ErrorInfo; 134 } else { 135 echo ” 136 Send to $to success use $fromMail\r\n“; 137 exit; 138 } 139 } 140 if (3 == $errorNo) { 141 //记录信息,该信息地址休眠N分钟 142 $content = “$fromMail|” . time() . “\r\n“;//email|当前时间戳 143 file_put_contents(SLEEPING_EMAIL, $content, FILE_APPEND); 144 } 145 echo ” 146 Error No($errorNo) “ . $errorMsg . “\r\n“; 147 exit; 148 ?> 今天试着用该程序给qq信箱发了700多个推广邮件,得出了以下几个结论: smtp.dat文件格式为 |
|