forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.3 KiB
74 lines
2.3 KiB
<?php |
|
|
|
use app\Interfaces\IApiMedia; |
|
use app\Providers\ApiTelegram; |
|
use app\Providers\Logger; |
|
use app\Providers\Positus; |
|
use app\Providers\Whatsapp; |
|
|
|
function logger($name = null, $active = true) |
|
{ |
|
return new Logger(($name ? $name . "_" . date('Ymd') : 'logger_' . date('Ymd')), $active, CONF_LOG_PATH); |
|
} |
|
|
|
function whereIn($array) |
|
{ |
|
if (is_array($array)) { |
|
return "'" . implode("','", $array) . "'"; |
|
} |
|
return "'$array'"; |
|
} |
|
/** |
|
* undocumented function summary |
|
* |
|
* Undocumented function long description |
|
* |
|
* @param Type $var Description |
|
* @return IApiMedia |
|
* @throws conditon |
|
**/ |
|
function returnChannel($channel) |
|
{ |
|
switch ($channel) { |
|
case CONF_WHATSAPP_CHANNEL: |
|
return new Positus(); |
|
case CONF_TELEGRAM_CHANNEL: |
|
return new ApiTelegram(); |
|
} |
|
} |
|
|
|
function ConvertWavToMp3($fileOrig) |
|
{ |
|
try { |
|
// ffmpeg -i 61f1a021ca8908.72216404_1643308267776 61f1a021ca8908.72216404_1643308267776 |
|
$cmd = "ffmpeg -y -i $fileOrig $fileOrig.mp3"; |
|
exec($cmd); |
|
copy($fileOrig . ".mp3", $fileOrig); |
|
} catch (\Exception $th) { |
|
throw $th; |
|
} |
|
} |
|
//retorna uma string sem acentos |
|
function removeAcentos($str, $upper = False) |
|
{ |
|
$text = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý'); |
|
$subs = array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'P', 'B', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y'); |
|
for ($i = 0; $i < strlen($str); $i++) { |
|
$j = array_search($str[$i], $text); |
|
if ($j) |
|
$str[$i] = $subs[$j]; |
|
} |
|
|
|
if ($upper) |
|
$str = strtoupper($str); |
|
return ($str); |
|
} |
|
|
|
//retorna uma string sem acentos |
|
function removeAcentosArray(array $str) |
|
{ |
|
foreach ($str as $key => $value) { |
|
$str[$key] = removeAcentos($value); |
|
} |
|
return ($str); |
|
} |