| <?php |
| if ($_GET['hangup'] == "yes"){exit();} |
| $what1 = $_GET['transitio']; |
| $several = $_GET['several']; |
| $password = $_GET['password']; |
| |
| IF ($_GET['transi']!=null) |
| $kkk = $_GET['transi']; |
| |
| IF ($_GET['transi']!=null) |
| $yyyy = 'move'; |
| |
| IF ($_GET['transi']==null) |
| $yyyy = 'delete'; |
| |
| IF ($_GET['transition']!=null) |
| $transition = 'go_to_folder='.$_GET['transition']; |
| |
| |
| |
| $Answer = $transition.'&;'; |
| |
| |
| $con = new connecting_to_yemot_api($several,$password); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/ExaminationAmericanLogOK.ymgr', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')OK.ymgr', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/ExaminationAmericanMiddle.ini', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')Middle.ini', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/ExaminationAmericanLogOK.html', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')OK.html', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| IF ($_GET['messages']===yes){ |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/000', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')000', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/001', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')001', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/002', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')002', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/003', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')003', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/004', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')004', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/005', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')005', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/006', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')006', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/007', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')007', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/008', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')008', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/009', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')009', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/010', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')010', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/011', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')011', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/012', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')012', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/013', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')013', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/014', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')014', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/015', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')015', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/016', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')016', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/017', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')017', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/018', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')018', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/019', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')019', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| |
| |
| |
| |
| $body = array |
| ( |
| |
| 'action' => $yyyy, |
| 'what' => 'ivr2:'.$what1.'/020', |
| 'target' => 'ivr2:'.$kkk.'/('.date ('d-m-Y h-i').')020', |
| ); |
| |
| $a = $con -> connecting('FileAction', $body); |
| } |
| |
| |
| |
| IF ($_GET['Text']!=null) |
| $bbb = 'id_list_message=' ; |
| IF ($_GET['Audio']!=null) |
| $bbb = 'id_list_message=' ; |
| IF ($_GET['Text']!=null) |
| $Text = 't-'.$_GET['Text'].'.'; |
| IF ($_GET['Audio']!=null) |
| $Audio = 'f-'.$_GET['Audio'].'.'; |
| IF ($_GET['Text']!=null) |
| $bb = '&' ; |
| IF ($_GET['Audio']!=null) |
| $bb = '&' ; |
| IF ($_GET['transition']!=null) |
| $transition = 'go_to_folder='.$_GET['transition']; |
| |
| $Answer = $bbb.$Text.$Audio.$bb.$transition.'&;'; |
| print_r ($Answer); |
| |
| |
| |
| class BodyPost |
| { |
| |
| public static function PartPost($name, $val) |
| { |
| $body = 'Content-Disposition: form-data; name="' . $name . '"'; |
| |
| if($val instanceof oFile) |
| { |
| $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; |
| |
| 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); |
| |
| if(!empty($info['basename']) && is_readable($name)) |
| { |
| $this->name = $info['basename']; |
| |
| $this->mime = mime_content_type($name); |
| |
| $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; |
| } |
| else |
| { |
| 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; |
| } |
| } |
| ?> |