1 <?php
2 3 4 5 6 7 8 9
10
11 12 13 14 15 16 17
18 class P3StringHelper {
19
20 public static function cleanName($name, $maxLength = 0) {
21 $name = preg_replace("/[^.A-Za-z0-9_-]/", "", $name);
22 if ($maxLength > 0 && strlen($name) > $maxLength) {
23 $name = substr($name, 0, $maxLength / 2 - 2) . ".." . substr($name, strlen($name) - $maxLength / 2 + 1);
24 }
25 return $name;
26 }
27
28 public static function generateUniqueFilename($path) {
29 $pathinfo = pathinfo($path);
30 return $pathinfo['filename'] . uniqid('-') . '.' . $pathinfo['extension'];
31 }
32
33 }
34
35 ?>
36