/** * Title * * Description * * @access public */ function raiseEvent($name, $params = 0, $parent = 0) { $p = ''; $url = BASE_URL . '/objects/?object=' . urlencode($this->object_title) . '&op=m&m=' . urlencode($name); if (is_array($params)) { foreach ($params as $k => $v) { $p .= utf2win(' ' . $k . ':"' . $v . '"'); $url .= '&' . urlencode($k) . '=' . urlencode($v); } } //echo DOC_ROOT.'/obj.bat '.utf2win().'.'.$name.' '.$p."<br>"; //$cmd=(DOC_ROOT.'/obj.bat '.utf2win($this->object_title).'.'.$name.' '.$p); //echo $url; $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); /* curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 500); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_TIMEOUT_MS, 500); */ curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); //$mh = curl_multi_init(); //curl_multi_add_handle($mh,$ch); //curl_multi_exec($mh,$running); //popen("start /B ". $cmd, "r"); }
/** * FrontEnd * * Module frontend * * @access public */ function usual(&$out) { $terminals=SQLSelect("SELECT * FROM terminals WHERE CANPLAY=1 ORDER BY TITLE"); $total=count($terminals); for($i=0;$i<$total;$i++) { //if ($terminals[$i]['NAME']==$session->data['PLAY_TERMINAL']) { // $terminals[$i]['SELECTED']=1; // $out['TERMINAL_TITLE']=$terminals[$i]['TITLE']; //} } $out['TERMINALS']=$terminals; $out['TERMINALS_TOTAL']=count($terminals); if ($this->mode=='play') { //echo $this->owner->popup; global $showplayer; $this->showplayer=1; if ($this->showplayer) { $showplayer=1; } if ($showplayer) { $this->showplayer=1; $out['SHOWPLAYER']=1; } global $terminal_id; $out['TERMINAL_ID']=$terminal_id; } global $collection_id; if ($this->collection_id) { $collection_id=$this->collection_id; } $this->collection_id=$collection_id; $out['COLLECTIONS']=SQLSelect("SELECT * FROM collections ORDER BY TITLE"); if (count($out['COLLECTIONS'])==1) { $collection_id=$out['COLLECTIONS'][0]['ID']; $this->collection_id=$collection_id; $out['COLLECTIONS_TOTAL']=1; } if ($collection_id) { $collection=SQLSelectOne("SELECT * FROM collections WHERE ID='".(int)$collection_id."'"); $path=($collection['PATH']);//addslashes $out['COLLECTION_ID']=$collection['ID']; } else { return; } //$this->getConfig(); //$path=$this->config['PATH']; // echo $path; // global $folder; if ($this->folder) { $folder=base64_decode($this->folder); } else { $this->folder=base64_encode($folder); } $favorites=SQLSelect("SELECT * FROM media_favorites WHERE 1 ORDER BY ID DESC"); if ($favorites) { $total=count($favorites); for($i=0;$i<$total;$i++) { $favorites[$i]['PATH']=urlencode(utf2win($favorites[$i]['PATH'])); } $out['FAVORITES']=$favorites; } $folder=str_replace('././', './', $folder); $path=str_replace('././', './', $path); $act_dir=$path.$folder; $out['MEDIA_PATH']=win2utf($path); $out['CURRENT_DIR']=win2utf('./'.$folder); $out['CURRENT_DIR']=str_replace('././', './', $out['CURRENT_DIR']); $out['CURRENT_DIR_TITLE']=$folder; $tmp=explode('/', $out['CURRENT_DIR']); $total=count($tmp); if ($total>0) { $spath='.'; for($i=0;$i<$total;$i++) { $tmp_rec=array(); $tmp_rec['TITLE']=$tmp[$i]; $spath.='/'.$tmp_rec['TITLE']; $spath=str_replace('././', './', $spath); $tmp_rec['PATH']=urlencode(utf2win($spath).'/'); if ($tmp_rec['TITLE']=='.') { $tmp_rec['TITLE']='Home'; } $out['HISTORY'][]=$tmp_rec; //echo $tmp_rec['PATH']."<br>"; } $out['CURRENT_DIR_TITLE']=($out['HISTORY'][$total-3]['TITLE'].'/'.$out['HISTORY'][$total-2]['TITLE']); } $out['CURRENT_DIR_TITLE_HTML']=urlencode($out['CURRENT_DIR_TITLE']); $out['CURRENT_DIR_HTML']=urlencode('./'.($folder)); $tmp=SQLSelectOne("SELECT ID FROM media_favorites WHERE LIST_ID='".(int)$list_id."' AND COLLECTION_ID='".$collection['ID']."' AND PATH LIKE '".DBSafe($out['CURRENT_DIR'])."'"); if ($tmp['ID']) { $out['FAVORITE']=1; } global $file; if ($file) { $out['FILE']=win2utf($file); $out['BASEFILE']=win2utf(basename($file)); $file=str_replace('/', '\\\\', $file); $out['FULLFILE']=win2utf(addslashes($path).$file); $out['FULLFILE_S']=str_replace('\\\\', '\\', $out['FULLFILE']); } if (preg_match('/foto/is', $act_dir) || preg_match('/photo/is', $act_dir)) { $out['LIST_MODE']='foto'; } $descriptions=$this->getDescriptions($act_dir); global $media_ajax; if ($media_ajax) { global $op; global $list_id; global $title; global $dir; header ("HTTP/1.0: 200 OK\n"); header ('Content-Type: text/html; charset=utf-8'); $tmp_path=$dir; if ($op=='favorite_add') { $rec=array(); $rec['TITLE']=$title; $rec['PATH']=$tmp_path; $rec['LIST_ID']=(int)$list_id; $rec['COLLECTION_ID']=$collection_id; SQLInsert('media_favorites', $rec); echo "OK"; } if ($op=='favorite_remove') { SQLExec("DELETE FROM media_favorites WHERE LIST_ID='".(int)$list_id."' AND COLLECTION_ID='".$collection['ID']."' AND PATH LIKE '".DBSafe($tmp_path)."'"); echo "OK"; } exit; } function sort_files($a, $b) { return strcmp(strtoupper($a["TITLE"]), strtoupper($b["TITLE"])); } $dirs=array(); //$act_dir='\\\\home\\media\\'; //echo $act_dir; $d=openDir($act_dir); //exit; if ($d) { while ($file=readDir($d)) { if (($file==".") || ($file=="..")) { continue; } if (Is_Dir($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; $rec['TITLE_SHORT']=$rec['TITLE']; if (strlen($rec['TITLE_SHORT'])>50) { $rec['TITLE_SHORT']=substr($rec['TITLE_SHORT'], 0, 50).'...'; } $rec['TITLE']=win2utf($rec['TITLE']); $rec['TITLE_SHORT']=win2utf($rec['TITLE_SHORT']); if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } $rec['PATH']=urlencode(($folder.$file)).'/'; $rec['REAL_PATH']=$dir.$file; $rec['ID']=md5($rec['REAL_PATH']); $dirs[]=$rec; } } closeDir($d); } //$dirs=mysort_array($dirs, "TITLE"); usort($dirs, 'sort_files'); //print_r($dirs); if (count($dirs)>0) $out['DIRS']=$dirs; @$d=openDir($act_dir); if ($d) { $cover=$this->getCover($act_dir); if ($cover) { $out['COVER']=$cover; $out['COVER_PATH']=urlencode(str_replace('\\\\', '\\', $act_dir).$cover); } $files=array(); while ($file=readDir($d)) { if (($file==".") || ($file=="..") || ($file=="Descript.ion")) { continue; } if (Is_File($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } if (strlen($rec['TITLE'])>50) { $rec['TITLE_SHORT']=substr($rec['TITLE'], 0, 50)."..."; } else { $rec['TITLE_SHORT']=$rec['TITLE']; } $rec['TITLE']=win2utf($rec['TITLE']); $rec['TITLE_SHORT']=win2utf($rec['TITLE_SHORT']); $rec['REAL_PATH']=($folder.$file); $rec['PATH']=urlencode($folder.$file); $rec['FULL_PATH']=urlencode(str_replace('\\\\', '\\', $act_dir).$file); $size=filesize($act_dir.$file); $total_size+=$size; if ($size>1024) { if ($size>1024*1024) { $size=(((int)(($size/1024/1024)*10))/10)." Mb"; } else { $size=(int)($size/1024)." Kb"; } } else { $size.=" b"; } $rec['SIZE']=$size; $rec['ID']=md5($rec['PATH']); $files[]=$rec; } } closeDir($d); } //$files=mysort_array($files, "TITLE"); usort($files, 'sort_files'); if (count($files)>0) { $total=count($files); $out['TOTAL_FILES']=$total; for($i=0;$i<$total;$i++) { if (preg_match('/\.jpg$/is', $files[$i]['PATH'])) { $files[$i]['IS_FOTO']=1; } if (($i+1)%4==0) { $files[$i]['NEWROW']=1; } } $out['FILES']=$files; } $out['TOTAL_DIRS']=count($dirs); if ($total_size>1024) { if ($total_size>1024*1024) { $total_size=(((int)(($total_size/1024/1024)*10))/10)." Mb"; } else { $total_size=(int)($total_size/1024)." Kb"; } } else { $total_size.=" b"; } $out['TOTAL_SIZE']=$total_size; }
$sqlQuery = "DELETE\n FROM safe_execs\n WHERE ADDED < '" . date('Y-m-d H:i:s', time() - 180) . "'"; SQLExec($sqlQuery); $sqlQuery = "SELECT *\n FROM safe_execs\n WHERE EXCLUSIVE = 1\n ORDER BY PRIORITY DESC, ID LIMIT 5"; $safe_execs = SQLSelect($sqlQuery); $total = count($safe_execs); for ($i = 0; $i < $total; $i++) { $command = utf2win($safe_execs[$i]['COMMAND']); $sqlQuery = "DELETE\n FROM safe_execs\n WHERE ID = '" . $safe_execs[$i]['ID'] . "'"; SQLExec($sqlQuery); echo "Executing (exclusive): " . $command . "\n"; DebMes("Executing (exclusive): " . $command); exec($command); } $sqlQuery = "SELECT *\n FROM safe_execs\n WHERE EXCLUSIVE = 0\n ORDER BY PRIORITY DESC, ID"; $safe_execs = SQLSelect($sqlQuery); $total = count($safe_execs); for ($i = 0; $i < $total; $i++) { $command = utf2win($safe_execs[$i]['COMMAND']); $sqlQuery = "DELETE\n FROM safe_execs\n WHERE ID = '" . $safe_execs[$i]['ID'] . "'"; SQLExec($sqlQuery); echo "Executing: " . $command . "\n"; DebMes("Executing: " . $command); execInBackground($command); } if (file_exists('./reboot') || $_GET['onetime']) { $db->Disconnect(); exit; } sleep(1); } DebMes("Unexpected close of cycle: " . basename(__FILE__));
$playerAddr = 'http://' . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT']; $request = json_encode($json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $playerAddr . "/jsonrpc"); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); $responseRaw = curl_exec($ch); return json_decode($responseRaw); } $uid = rand(1, 9999999); $players = xbmc_request($ch, $terminal, 'Player.GetActivePlayers'); $player_type = $players->result[0]->type; $player_id = $players->result[0]->playerid; if ($command == 'refresh') { $out['PLAY'] = preg_replace('/\\\\$/is', '', $out['PLAY']); $path = str_replace('/', "\\", utf2win($out['PLAY'])); if (is_file($path)) { //play file $result = xbmc_request($ch, $terminal, 'Player.Open', array('item' => array('file' => $path))); } else { //play folder ///!!!!!! how to get it working??? $result = xbmc_request($ch, $terminal, 'Player.Open', array('item' => array('path' => $path))); } } if ($command == 'pause') { $result = xbmc_request($ch, $terminal, 'Player.PlayPause', array('playerid' => (int) $player_id)); } if ($command == 'fullscreen') { } if ($command == 'next') {
/** * Title * * Description * * @access public */ function recognizeTime($text, &$newText) { $result=0; $found=0; $new_time=time(); $text=utf2win($text); if (preg_match('/через (\d+) секунд.?/is', $text, $m)) { $new_time=time()+$m[1]; $newText=trim(str_replace($m[0], '', $text)); $found=1; } elseif (preg_match('/через (\d+) минут.?/is', $text, $m)) { $new_time=time()+$m[1]*60; $newText=trim(str_replace($m[0], '', $text)); $found=1; } elseif (preg_match('/через (\d+) час.?/is', $text, $m)) { $new_time=time()+$m[1]*60*60; $newText=trim(str_replace($m[0], '', $text)); $found=1; } elseif (preg_match('/в (\d+):(\d+)/is', $text, $m)) { $new_time=mktime($m[1], $m[2], 0, date('m'), date('d'), date('Y')); $newText=trim(str_replace($m[0], '', $text)); $found=1; } $newText=win2utf($newText); if ($found) { $result=$new_time; } return $result; }