Code Duplication    Length = 28-28 lines in 2 locations

class/oledrion_utils.php 1 location

@@ 650-677 (lines=28) @@
647
     * @param  boolean $trimName Do we need to create a "short" unique name ?
648
     * @return string  The unique filename to use (with its extension)
649
     */
650
    public static function createUploadName($folder, $fileName, $trimName = false)
651
    {
652
        $workingfolder = $folder;
653
        if (xoops_substr($workingfolder, strlen($workingfolder) - 1, 1) !== '/') {
654
            $workingfolder .= '/';
655
        }
656
        $ext  = basename($fileName);
657
        $ext  = explode('.', $ext);
658
        $ext  = '.' . $ext[count($ext) - 1];
659
        $true = true;
660
        while ($true) {
661
            $ipbits = explode('.', $_SERVER['REMOTE_ADDR']);
662
            list($usec, $sec) = explode(' ', microtime());
663
            $usec = (integer)($usec * 65536);
664
            $sec  = ((integer)$sec) & 0xFFFF;
665
666
            if ($trimName) {
667
                $uid = sprintf('%06x%04x%04x', ($ipbits[0] << 24) | ($ipbits[1] << 16) | ($ipbits[2] << 8) | $ipbits[3], $sec, $usec);
668
            } else {
669
                $uid = sprintf('%08x-%04x-%04x', ($ipbits[0] << 24) | ($ipbits[1] << 16) | ($ipbits[2] << 8) | $ipbits[3], $sec, $usec);
670
            }
671
            if (!file_exists($workingfolder . $uid . $ext)) {
672
                $true = false;
673
            }
674
        }
675
676
        return $uid . $ext;
677
    }
678
679
    /**
680
     * Replace html entities with their ASCII equivalent

class/utility.php 1 location

@@ 793-820 (lines=28) @@
790
     * @param  boolean $trimName Do we need to create a "short" unique name ?
791
     * @return string  The unique filename to use (with its extension)
792
     */
793
    public static function createUploadName($folder, $fileName, $trimName = false)
794
    {
795
        $workingfolder = $folder;
796
        if (xoops_substr($workingfolder, strlen($workingfolder) - 1, 1) != '/') {
797
            $workingfolder .= '/';
798
        }
799
        $ext  = basename($fileName);
800
        $ext  = explode('.', $ext);
801
        $ext  = '.' . $ext[count($ext) - 1];
802
        $true = true;
803
        while ($true) {
804
            $ipbits = explode('.', $_SERVER['REMOTE_ADDR']);
805
            list($usec, $sec) = explode(' ', microtime());
806
            $usec = (integer)($usec * 65536);
807
            $sec  = ((integer)$sec) & 0xFFFF;
808
809
            if ($trimName) {
810
                $uid = sprintf('%06x%04x%04x', ($ipbits[0] << 24) | ($ipbits[1] << 16) | ($ipbits[2] << 8) | $ipbits[3], $sec, $usec);
811
            } else {
812
                $uid = sprintf('%08x-%04x-%04x', ($ipbits[0] << 24) | ($ipbits[1] << 16) | ($ipbits[2] << 8) | $ipbits[3], $sec, $usec);
813
            }
814
            if (!file_exists($workingfolder . $uid . $ext)) {
815
                $true = false;
816
            }
817
        }
818
819
        return $uid . $ext;
820
    }
821
822
    /**
823
     * Replace html entities with their ASCII equivalent