public static function sendTorrent($fname, $isStart, $isAddPath, $directory, $label, $saveTorrent, $isFast, $addition = null)
 {
     $hash = false;
     $torrent = is_object($fname) ? $fname : new Torrent($fname);
     if (!$torrent->errors()) {
         if ($isFast && ($resume = self::fastResume($torrent, $directory, $isAddPath))) {
             $torrent = $resume;
         }
         $cmd = new rXMLRPCCommand($isStart ? 'load_raw_start' : 'load_raw');
         $cmd->addParameter(base64_encode($torrent->__toString()), "base64");
         if (!$saveTorrent && is_string($fname)) {
             @unlink($fname);
         }
         $comment = $torrent->comment();
         if ($comment) {
             if (isInvalidUTF8($comment)) {
                 $comment = win2utf($comment);
             }
             if (strlen($comment) > 0) {
                 $comment = "VRS24mrker" . rawurlencode($comment);
                 if (strlen($comment) <= 4096) {
                     $cmd->addParameter("d.set_custom2=" . $comment);
                 }
             }
         }
         if ($label && strlen($label) > 0) {
             $label = rawurlencode($label);
             if (strlen($label) <= 4096) {
                 $cmd->addParameter("d.set_custom1=" . $label);
             }
         }
         if ($directory && strlen($directory) > 0) {
             $cmd->addParameter(($isAddPath ? "d.set_directory=\"" : "d.set_directory_base=\"") . $directory . "\"");
         }
         if (is_array($addition)) {
             foreach ($addition as $key => $prm) {
                 $cmd->addParameter($prm, 'string');
             }
         }
         $req = new rXMLRPCRequest($cmd);
         if ($req->run() && !$req->fault) {
             $hash = $torrent->hash_info();
         }
     }
     return $hash;
 }
/**
* 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;


}
示例#3
0
include_once "./load_settings.php";
if ($argv[1] != '') {
    //echo date('Y-m-d H:i:s')." command line call: ".$argv[1]."\n";
    //DebMes("command line call: ".$argv[1]);
    $commandLine = 1;
    if (preg_match('/^(.+?)\\.(.+?)$/is', $argv[1], $matches)) {
        $op = "m";
        $object = $matches[1];
        $m = $matches[2];
    }
    $total = count($argv);
    for ($i = 1; $i < $total; $i++) {
        //echo "\n".'|'.$argv[$i].'|'."\n";
        if (preg_match('/^(.+?)[:=](.*?)$/is', $argv[$i], $matches)) {
            $_GET[$matches[1]] = trim(win2utf($matches[2]));
            ${$matches[1]} = trim(win2utf($matches[2]));
        } else {
            //echo "Arg: ".$argv[$i]."\n";
            $_GET['other_params'][] = $argv[$i];
            $other_params[] = $argv[$i];
        }
    }
}
foreach ($_GET as $k => $v) {
    $request .= '&' . $k . '=' . $v;
}
if (!$request && $commandLine) {
    $request = implode(' ', $argv);
}
//echo "object: $object op: $op m: $m status: $status ";exit;
if (!$commandLine) {
示例#4
0
/**
* 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;

 }
示例#5
0
 public static function toUTF($out, $encoding)
 {
     if (function_exists('iconv')) {
         $out = iconv($encoding, 'UTF-8//TRANSLIT', $out);
     } else {
         if (function_exists('mb_convert_encoding')) {
             $out = mb_convert_encoding($out, 'UTF-8', $encoding);
         } else {
             if (function_exists('utf8_encode')) {
                 $out = utf8_encode($out);
             } else {
                 $out = win2utf($out);
             }
         }
     }
     return $out;
 }
示例#6
0
function rtAddTorrent($fname, $isStart, $directory, $label, $dbg = false)
{
    if ($isStart) {
        $method = 'load_start_verbose';
    } else {
        $method = 'load_verbose';
    }
    if ($dbg) {
        rtDbg(__FUNCTION__, "1" . $fname);
    }
    $torrent = new Torrent($fname);
    if ($dbg) {
        rtDbg(__FUNCTION__, "2");
    }
    if ($torrent->errors()) {
        if ($dbg) {
            rtDbg(__FUNCTION__, "fail to create Torrent() object");
        }
        return false;
    }
    if ($directory && strlen($directory) > 0) {
        $directory = rtMakeStrParam("d.set_directory=\"" . $directory . "\"");
    } else {
        $directory = "";
    }
    $comment = $torrent->comment();
    if ($comment && strlen($comment) > 0) {
        if (isInvalidUTF8($comment)) {
            $comment = win2utf($comment);
        }
        if (strlen($comment) > 0) {
            $comment = rtMakeStrParam("d.set_custom2=VRS24mrker" . rawurlencode($comment));
            if (strlen($comment) > 4096) {
                $comment = '';
            }
        }
    } else {
        $comment = "";
    }
    if ($label && strlen($label) > 0) {
        $label = rtMakeStrParam("d.set_custom1=\"" . rawurlencode($label) . "\"");
    } else {
        $label = "";
    }
    $addition = "";
    global $saveUploadedTorrents;
    $delete_tied = $saveUploadedTorrents ? "" : rtMakeStrParam("d.delete_tied=");
    $content = '<?xml version="1.0" encoding="UTF-8"?>' . '<methodCall>' . '<methodName>' . $method . '</methodName>' . '<params>' . '<param><value><string>' . $fname . '</string></value></param>' . $directory . $comment . $label . $addition . $delete_tied . '</params></methodCall>';
    //if( $dbg ) rtDbg( __FUNCTION__, $content );
    $res = rXMLRPCRequest::send($content);
    if ($dbg && !empty($res)) {
        rtDbg(__FUNCTION__, $res);
    }
    if (!$res || ($res = '')) {
        return false;
    } else {
        return $torrent->hash_info();
    }
}
示例#7
0
 protected function convert($out, $needTranslate = false)
 {
     if ($needTranslate) {
         $out = self::removeTegs($out);
     }
     if (function_exists('iconv')) {
         $out = iconv($this->encoding, 'UTF-8//TRANSLIT', $out);
     } else {
         if (function_exists('mb_convert_encoding')) {
             $out = mb_convert_encoding($out, 'UTF-8', $this->encoding);
         } else {
             $out = win2utf($out);
         }
     }
     return $out;
 }
示例#8
0
// start calculation of execution time
include_once DIR_MODULES . "application.class.php";
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
// connecting to database
include_once "./load_settings.php";
if ($argv[1] != '') {
    $commandLine = 1;
    if (preg_match('/^(.+?)\\.(.+?)$/is', $argv[1], $matches)) {
        $op = "m";
        $object = $matches[1];
        $m = $matches[2];
    }
    $total = count($argv);
    for ($i = 1; $i < $total; $i++) {
        if (preg_match('/^(.+?)[:=](.*?)$/is', $argv[$i], $matches)) {
            $matchesParsed = trim(win2utf($matches[2]));
            $_GET[$matches[1]] = $matchesParsed;
            ${$matches[1]} = $matchesParsed;
        } else {
            $_GET['other_params'][] = $argv[$i];
            $other_params[] = $argv[$i];
        }
    }
}
if (preg_match('/\\/\\?(\\w+)\\.(\\w+)/', $_SERVER['REQUEST_URI'], $matches)) {
    $_GET['op'] = 'm';
    $_GET['object'] = $matches[1];
    $_GET['m'] = $matches[2];
}
foreach ($_GET as $k => $v) {
    $request .= '&' . $k . '=' . $v;
示例#9
0
 public static function sendTorrent($fname, $isStart, $isAddPath, $directory, $label, $saveTorrent, $isFast, $isNew = true, $addition = null)
 {
     $hash = false;
     $torrent = is_object($fname) ? $fname : new Torrent($fname);
     if (!$torrent->errors()) {
         if ($isFast && ($resume = self::fastResume($torrent, $directory, $isAddPath))) {
             $torrent = $resume;
         } else {
             if ($isNew) {
                 if (isset($torrent->{'libtorrent_resume'})) {
                     unset($torrent->{'libtorrent_resume'});
                 }
             }
         }
         if ($isNew) {
             if (isset($torrent->{'rtorrent'})) {
                 unset($torrent->{'rtorrent'});
             }
         }
         $raw_value = base64_encode($torrent->__toString());
         $filename = is_object($fname) ? $torrent->getFileName() : $fname;
         if (strlen($raw_value) < self::RTORRENT_PACKET_LIMIT || is_null($filename) || !isLocalMode()) {
             $cmd = new rXMLRPCCommand($isStart ? 'load_raw_start' : 'load_raw');
             $cmd->addParameter($raw_value, "base64");
             if (!is_null($filename) && !$saveTorrent) {
                 @unlink($filename);
             }
         } else {
             $cmd = new rXMLRPCCommand($isStart ? 'load_start' : 'load');
             $cmd->addParameter($filename);
         }
         if (!is_null($filename) && rTorrentSettings::get()->iVersion >= 0x805) {
             $cmd->addParameter(getCmd("d.set_custom") . "=x-filename," . rawurlencode(getFileName($filename)));
         }
         $req = new rXMLRPCRequest();
         if ($directory && strlen($directory) > 0) {
             if (!rTorrentSettings::get()->correctDirectory($directory)) {
                 return false;
             }
             $req->addCommand(new rXMLRPCCommand('execute', array('mkdir', '-p', $directory)));
             $cmd->addParameter(($isAddPath ? getCmd("d.set_directory=") . "\"" : getCmd("d.set_directory_base=") . "\"") . $directory . "\"");
         }
         $comment = $torrent->comment();
         if ($comment) {
             if (isInvalidUTF8($comment)) {
                 $comment = win2utf($comment);
             }
             if (strlen($comment) > 0) {
                 $comment = "VRS24mrker" . rawurlencode($comment);
                 if (strlen($comment) <= 4096) {
                     $cmd->addParameter(getCmd("d.set_custom2=") . $comment);
                 }
             }
         }
         if ($label && strlen($label) > 0) {
             $label = rawurlencode($label);
             if (strlen($label) <= 4096) {
                 $cmd->addParameter(getCmd("d.set_custom1=") . $label);
             }
         }
         if (is_array($addition)) {
             foreach ($addition as $key => $prm) {
                 $cmd->addParameter($prm, 'string');
             }
         }
         $req->addCommand($cmd);
         if ($req->run() && !$req->fault) {
             $hash = $torrent->hash_info();
         }
     }
     return $hash;
 }
示例#10
0
 function show_log()
 {
     $result = GetLogBuy(true);
     echo win2utf($result);
 }
示例#11
0
<response>
<osmp_txn_id><?php 
echo htmlspecialchars($_GET['txn_id']);
?>
</osmp_txn_id>
<?php 
if ($op_id) {
    ?>
<prv_txn><?php 
    echo $op_id;
    ?>
</prv_txn><?php 
}
if ($sum) {
    ?>
<sum><?php 
    echo $sum;
    ?>
</sum><?php 
}
?>
<result><?php 
echo $result;
?>
</result>
<comment><?php 
echo win2utf($comment);
?>
</comment>
</response>