הקלדת מקשים ע"ג הטלפון והפיכתו לקובץ tts
נשלח: 22:32 09/09/2019
איך עושים שמאזין יוכל להקיש על גבי מקשי הטלפון מספרים וזה ישמר כקובץ בשלוחה שאני הגדיר???
חיפשתי ולא מצאתי
חיפשתי ולא מצאתי
ימות המשיח
https://freeivr.co.il/oldforum/
זה עובד ע"י API והוא פרסם פעם את הקודזה שייך לקול הירושלמי והוא פרסם כאן בעבר את המייל שלו.
קוד: בחירת הכל
<?php
if(!isset($_GET['maarechet']) || !isset($_GET['path']) || !isset($_GET['pas'])){
print "id_list_message=t-";
print "שולחה זו לא עדיין לא הוגדרה";
print ".&go_to_folder=/&";
exit;
}
$maarechet = $_GET['maarechet'];
$pas = $_GET['pas'];
$path = $_GET['path'];
if(!isset($_GET['text']) || $_GET['text'] == null){
print "read=t-הקש את הטקסט וסולמית לסיום.=text,No,100,1,7,No,,,";
exit;
}
$text = $_GET['text'];
$instance = new trans();
$text = $instance->hamara($text);
if(!isset($_GET['text_ok']) || $_GET['text_ok'] == null){
print "read=t-$text, לאישור הַקֵש אחת, לביטול הַקֵש שתיים.=text_ok,No,1,1,7,No,,,,1.2,";
exit;
}
$text_ok = $_GET['text_ok'];
if($text_ok != 1){
exit("go_to_folder=/&");
}
$number = file_number();
$upload = myUpload($number,$text,$maarechet,$pas,$path);
if($upload != "ok"){
print "id_list_message=t-";
print "העלאה נכשלה";
print ".&go_to_folder=/&";
exit;
}
else{
print "id_list_message=t-";
print "הפעולה הצליחה";
print ".&go_to_folder=/&";
exit;
}
//===============================================================================
function myUpload($file_number,$text,$maarechet,$pas,$path){
$con = new connecting_to_yemot_api("$maarechet", "$pas");
$File = new oFile('ext.ini', 'text/plain', "$text");
$body = array
(
'path' => "ivr/$path/$file_number.tts",
'convertAudio' => 0,
'fileUpload' => $File
);
$a = $con -> connecting('UploadFile', $body);
//print_r($a);
//$a = $a;
$responseStatus = $a->responseStatus;
if($responseStatus == "OK"){
return "ok";
}
else{
return "none";
}
}
function file_number(){
$file = "number.txt";
if(!file_exists($file)){
$my_file = fopen($file, 'w');
$my_file = fopen($file, 'r+');
fwrite($my_file, "100");
fclose($my_file );
}
$number = (int) file_get_contents($file);
$number++;
$my_file = fopen($file, 'r+');
fwrite($my_file, $number);
fclose($my_file );
return "$number";
}
class BodyPost
{
// part "multipart/form-data"
public static function PartPost($name, $val)
{
$body = 'Content-Disposition: form-data; name="' . $name . '"';
// check instance of oFile
if($val instanceof oFile)
{
//global $file;
$file = $val->Name();
$mime = $val->Mime();
$cont = $val->Content();
$body .= '; filename="' . $file . '"' . "\r\n";
$body .= 'Content-Type: ' . $mime ."\r\n\r\n";
$body .= $cont."\r\n";
} else $body .= "\r\n\r\n".$val."\r\n";
return $body;
}
public static function Get(array $post, $delimiter = '-------------0123456789')
{
if(is_array($post) && !empty($post))
{
$bool = true;
//foreach($post as $val) if($val instanceof oFile) {$bool = true; break; };
if($bool)
{
$ret = '';
foreach($post as $name=>$val)
$ret .= '--' . $delimiter. "\r\n". self::PartPost($name, $val);
$ret .= "--" . $delimiter . "--\r\n";
} else $ret = http_build_query($post);
} else throw new \Exception('Error input param!');
return $ret;
}
}
class oFile
{
private $name;
private $mime;
private $content;
public function __construct($name, $mime=null, $content=null)
{
if(is_null($content))
{
$info = pathinfo($name);
// check is exist and readable file
if(!empty($info['basename']) && is_readable($name))
{
$this->name = $info['basename'];
// get MIME
$this->mime = mime_content_type($name);
// load file
$content = file_get_contents($name);
if($content!==false)
{
$this->content = $content;
}
else
{
throw new Exception('Don`t get content - "'.$name.'"');
}
}
else
{
throw new Exception('Error param');
}
}
else
{
$this->name = $name;
if(is_null($mime)) $mime = mime_content_type($name);
$this->mime = $mime;
$this->content = $content;
};
}
public function Name() { return $this->name; }
public function Mime() { return $this->mime; }
public function Content() { return $this->content; }
}
class connecting_to_yemot_api
{
public $token;
const URL = 'https://www.call2all.co.il/ym/api/';
public function __construct($user_name, $password)
{
$body = array('username' => $user_name, 'password' => $password);
$body = http_build_query($body);
$opts = array('http' => array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded",
'content' => $body,
'follow_location' => false) );
$context = stream_context_create($opts);
$url = self::URL.'Login';
$result = file_get_contents($url, FALSE, $context);
$result = json_decode($result);
if($result -> responseStatus == 'OK')
{
$this -> token = $result -> token;
return TRUE;
$drdr = "ok";
}
else
{
//print "id_list_message=f-901.&go_to_folder=/10&";
$drdr = "no";
//throw new Exception('שם המשתמש או הסיסמא של המערכת שגויים');
//throw new Exception();
// להדפיס כאן באם אחד מהנתונים שגוי
//print "id_list_message=t-";
//echo 'שם המשתמש או הסיסמא של המערכת שגויים';
//throw new Exception('שם המשתמש או הסיסמא של המערכת שגויים');
}
}
public function __destruct()
{
$this -> connecting('Logout');
}
public function connecting($action, $body = array())
{
$delimiter = '----'.uniqid();
$body['token'] = $this -> token;
$body = BodyPost::Get($body, $delimiter);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: multipart/form-data; boundary='.$delimiter,
'content' => $body,
'follow_location' => false
)
);
$context = stream_context_create($opts);
$url = self::URL.$action;
$result = file_get_contents($url, FALSE, $context);
$headers = $this -> parseHeaders($http_response_header);
if($headers['Content-Type'][0] == 'application/json')
{
return json_decode($result);
}
else
{
return $result;
}
}
private function parseHeaders($headers)
{
// פונקציה שמקבלת מערך של שורות הכותרות
// הפונקציה מפרקת את קבצי הקוקי לתת-מערך נפרד
// מערך הכותרות
$head = array();
foreach( $headers as $k=>$v )
{
$t = explode( ':', $v, 2 );
if( isset( $t[1] ) )
{
if($t[0] == 'Set-Cookie')
{
$CookiesArr = array();
$cookies = explode( ';', $t[1]);
foreach($cookies as $cookie)
{
$c = explode( '=', $cookie);
if( isset( $c[1] ) )
{
$CookiesArr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$CookiesArr[] = trim( $c[0] );
}
}
$head[ trim($t[0]) ] = $CookiesArr;
}
elseif($t[0] == 'Content-Type')
{
$arr = array();
$children = explode( ';', $t[1]);
foreach($children as $child)
{
$c = explode( '=', $child);
if( isset( $c[1] ) )
{
$arr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$arr[] = trim( $c[0] );
}
}
$head[ trim($t[0]) ] = $arr;
}
else
{
$head[ trim($t[0]) ] = trim( $t[1] );
}
}
else
{
$head[] = $v;
if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) )
{
$head['reponse_code'] = intval($out[1]);
}
}
}
return $head;
}
}
class trans{
public function hamara($kelet){
$arraj = array();
if (strpos($kelet, '*') !== false) {
$kelet = str_replace("*", "1",$kelet);}
$aaaa = substr($kelet, 0, 4);
$aaa = substr($kelet, 0, 3);
$aa = substr($kelet, 0, 2);
$a = substr($kelet, 0, 1);
while ($kelet != null){
if($aaaa%1111 == 0){
// print "ארבע";
$arraj[] = $aaaa;
$kelet = substr($kelet, 4);
$aaaa = substr($kelet, 0, 4);
$aaa = substr($kelet, 0, 3);
$aa = substr($kelet, 0, 2);
$a = substr($kelet, 0, 1);
}
else{
if($aaa%111 == 0){
// print "שלוש";
$arraj[] = $aaa;
$kelet = substr($kelet, 3);
$aaaa = substr($kelet, 0, 4);
$aaa = substr($kelet, 0, 3);
$aa = substr($kelet, 0, 2);
$a = substr($kelet, 0, 1);
}
else{if($aa%11 == 0) {
// print "שתים";
$arraj[] = $aa;
$kelet = substr($kelet, 2);
$aaaa = substr($kelet, 0, 4);
$aaa = substr($kelet, 0, 3);
$aa = substr($kelet, 0, 2);
$a = substr($kelet, 0, 1);
}
else{
// print "אחד";
$arraj[] = $a;
$kelet = substr($kelet, 1);
$aaaa = substr($kelet, 0, 4);
$aaa = substr($kelet, 0, 3);
$aa = substr($kelet, 0, 2);
$a = substr($kelet, 0, 1);
}}}}
$count = count ($arraj);
for($i = 0; $i < $count; $i++){
$my_var = $arraj[$i];
switch($my_var) {
case 3:
$arraj[$i] = 'א';
break;
case 33:
$arraj[$i] = 'ב';
break;
case 333:
$arraj[$i] = 'ג';
break;
case 2:
$arraj[$i] = 'ד';
break;
case 22:
$arraj[$i] = 'ה';
break;
case 222:
$arraj[$i] = 'ו';
break;
case 6:
$arraj[$i] = 'ז';
break;
case 66:
$arraj[$i] = 'ח';
break;
case 666:
$arraj[$i] = 'ט';
break;
case 5555:
$arraj[$i] = 'ל';
break;
case 555:
$arraj[$i] = 'ך';
break;
case 55:
$arraj[$i] = 'כ';
break;
case 5:
$arraj[$i] = 'י';
break;
case 4444:
$arraj[$i] = 'ן';
break;
case 444:
$arraj[$i] = 'נ';
break;
case 44:
$arraj[$i] = 'ם';
break;
case 4:
$arraj[$i] = 'מ';
break;
case 9999:
$arraj[$i] = 'ף';
break;
case 999:
$arraj[$i] = 'פ';
break;
case 99:
$arraj[$i] = 'ע';
break;
case 9:
$arraj[$i] = 'ס';
break;
case 888:
$arraj[$i] = 'ק';
break;
case 88:
$arraj[$i] = 'ץ';
break;
case 8:
$arraj[$i] = 'צ';
break;
case 777:
$arraj[$i] = 'ת';
break;
case 77:
$arraj[$i] = 'ש';
break;
case 7:
$arraj[$i] = 'ר';
break;
case 0:
$arraj[$i] = ' ';
break;
default:
$arraj[$i] = "";
break;
}}
$pelet = implode("", $arraj);
$pelet = trim($pelet);
return $pelet;
}
}
קוד: בחירת הכל
type=api
api_link=https://example.com/index.php(להחליף בכתובת שלכם)
api_add_0=maarechet=מספר המערכת שלכם
api_add_1=pas=סיסמת הניהול
api_add_2=path=השלוחה להעלאת הקבצים
title=העלאת טקסט ע"י מאזינים
api_call_id_send=no