zoukankan      html  css  js  c++  java
  • MD5做为文件名。机器唯一码有电脑的CPU信息和MAC地址,这两个信息需要在linux或unix系统下才能获取吧。

    可以采用机器(电脑)唯一码 + 上传IP + 当前时间戳 + GUID ( + 随机数),然后MD5做为文件名。机器唯一码有电脑的CPU信息和MAC地址,这两个信息需要在linux或unix系统下才能获取吧。

    //获取电脑的CPU信息
    function OnlyU(){
            $a = '';
            $b = array();
            if(function_exists('exec')){
                    if(mailto:!@exec( /all",$b)){
                            return false;
                    }
            }elseif(function_exists('system')){
                    ob_start();
                    if(mailto:!@system( /all")){
                            return false;
                    }else{
                    }
                    $b = ob_get_contents();
                    ob_end_clean();
                    $b = explode(" ",$b);//print_r($b);
                    array_pop($b);
            }else{
                    return false;
            }

            $all = sizeof($b);
            for($i = 0; $i < $all; $i++){
                    if(strpos($b[$i],"Description") !== false){
                            if(strpos($b[$i+1],"Physical Address") !== false){
                                    $c = explode(":",$b[$i+1]);
                                    $a = trim($c[1]);
                                    break;
                            }
                    }
            } // End for
            return empty($a)?false:$a;
    } // End function OnlyU


    //获取网卡的MAC的地址

    function getMAC() {
     @exec("ipconfig /all",$array);
     for($Tmpa;$Tmpa<count($array);$Tmpa++){
      if(eregi("Physical",$array[$Tmpa])){
       $mac=explode(":",$array[$Tmpa]);
       return $mac[1];
      }
     }
    }

    // 生成guid字符串
    function guid($separated = true) {
        if (function_exists ( 'com_create_guid' )) {
            $charid = substr ( strtolower ( com_create_guid () ), 1, - 1 );
            if (! $separated)
                return str_replace ( '-', '', $charid );
            else
                return $charid;
        } else {
            // 生成一个随机的md5串, 然后通过分割来 获得guid
            mt_srand ( ( double ) microtime () * 10000 );
            $charid = md5 ( uniqid ( rand (), true ) );
        }
       
        if (! $separated) {
            return $charid;
        }
        $hyphen = chr ( 45 );
        $uuid = substr ( $charid, 0, 8 ) . $hyphen . substr ( $charid, 8, 4 ) . $hyphen . substr ( $charid, 12, 4 ) . $hyphen . substr ( $charid, 16, 4 ) . $hyphen . substr ( $charid, 20, 12 );
        return $uuid;
    }

  • 相关阅读:
    js数组去重
    js和jq实现全选反选
    js的作用域深入理解
    js对数组的常用操作
    如何写出让java虚拟机发生内存溢出异常OutOfMemoryError的代码
    JAVA编程思想(第四版)学习笔记----4.8 switch(知识点已更新)
    通过拦截器Interceptor实现Spring MVC中Controller接口访问信息的记录
    JAVA编程思想(第四版)学习笔记----11.10 Map
    JAVA中的for-each循环与迭代
    JAVA编程思想(第四版)学习笔记----11.5 List,11.6迭代器
  • 原文地址:https://www.cnblogs.com/wangluochong/p/4337176.html
Copyright © 2011-2022 走看看