Example #1
0
 function uriGenerate($s, $sTable, $sField, $iMaxLen = 255)
 {
     if ($GLOBALS['oTemplConfig']->bAllowUnicodeInPreg) {
         $s = orca_mb_replace('/[^\\pL^\\pN]+/u', '-', $s);
     } else {
         $s = orca_mb_replace('/([^\\d^\\w]+)/u', '-', $s);
     }
     // latin characters
     $s = orca_mb_replace('/([-^]+)/', '-', $s);
     if (!$s) {
         $s = '-';
     }
     if ($this->uriCheckUniq($s, $sTable, $sField)) {
         return $s;
     }
     // try to add date
     if (orca_mb_len($s) > 240) {
         $s = orca_mb_substr($s, 0, 240);
     }
     $s .= '-' . date('Y-m-d');
     if ($this->uriCheckUniq($s, $sTable, $sField)) {
         return $s;
     }
     // try to add number
     for ($i = 0; $i < 999; ++$i) {
         if ($this->uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
             return $s . '-' . $i;
         }
     }
     return rand(0, 999999999);
 }
 function uriGenerate($s, $sTable, $sField, $iMaxLen = 255)
 {
     //$s = orca_mb_replace ('/([^\d^\w]+)/', '-', $s); // latin characters
     $s = orca_mb_replace('/[^\\pL^\\pN]+/u', '-', $s);
     // unicode characters
     $s = orca_mb_replace('/([-^]+)/', '-', $s);
     if ($this->uriCheckUniq($s, $sTable, $sField)) {
         return $s;
     }
     // try to add date
     if (orca_mb_len($s) > 240) {
         $s = orca_mb_substr($s, 0, 240);
     }
     $s .= '-' . date('Y-m-d');
     if ($this->uriCheckUniq($s, $sTable, $sField)) {
         return $s;
     }
     // try to add number
     for ($i = 0; $i < 999; ++$i) {
         if ($this->uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
             return $s . '-' . $i;
         }
     }
     return rand(0, 999999999);
 }