码迷,mamicode.com
首页 > 其他好文 > 详细

pureftpd.passwd解析

时间:2014-05-09 10:21:38      阅读:350      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   color   

将pureftpd.passwd文件的内容转换成sql语句,导入到mysql

pureftp.passwd格式:

<account>:<password>:<uid>:<gid>:<gecos>:<home directory>:<upload bandwidth>:
<download bandwidth>:<upload ratio>:<download ratio>:<max number of connections>:
<files quota>:<size quota>:<authorized local IPs>:<refused local IPs>:
<authorized client IPs>:<refused client IPs>:<time restrictions>

bubuko.com,布布扣
<?php

// 将pureftpd.passwd转换成sql语句
pureftp();
function pureftp() {
    $filename = "pureftpd.passwd";
    $fd = fopen($filename, "r");
    while (!feof($fd)) {
        $line = fgets($fd);
        // echo $line ;
        if (trim($line) != "")
            handle_lines($line);
    }
}

function handle_lines($line) {
    $user_info = explode(":", $line);
    $username = $user_info[0];
    $password = $user_info[1];
    $uid = $user_info[2];
    $gid = $user_info[3];
    $gecos = $user_info[4];
    $home = $user_info[5];

    $sql = "INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`) " . " VALUES (‘{$username}‘, ‘1‘, ‘{$password}‘, " . "‘{$uid}‘, ‘{$gid}‘," . "‘{$home}‘);";

    echo "$sql\n";
}
?>
bubuko.com,布布扣

 

pureftpd.passwd解析,布布扣,bubuko.com

pureftpd.passwd解析

标签:style   blog   class   code   java   color   

原文地址:http://www.cnblogs.com/trying/p/3716811.html

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