zoukankan      html  css  js  c++  java
  • pureftpd.passwd解析

    将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>

    <?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
    ";
    }
    ?>
  • 相关阅读:
    setTimeout详解
    【康娜的线段树】
    【[CQOI2016]手机号码】
    【[IOI2014]Wall 砖墙】
    【[1007]梦美与线段树】
    【[POI2010]ANT-Antisymmetry】
    【[HEOI2016/TJOI2016]排序】
    【[SCOI2016]背单词】
    【[HNOI2008]GT考试】
    【[JSOI2007]建筑抢修】
  • 原文地址:https://www.cnblogs.com/trying/p/3716811.html
Copyright © 2011-2022 走看看