PageRenderTime 209ms CodeModel.GetById 101ms app.highlight 60ms RepoModel.GetById 40ms app.codeStats 1ms

/audl.php

https://github.com/gartz/RapidLeetch
PHP | 435 lines | 404 code | 21 blank | 10 comment | 72 complexity | 7d2366325e6c858a4c71a5a9d061618c MD5 | raw file
  1<?php
  2define('RAPIDLEECH', 'yes');
  3error_reporting(0);
  4//ini_set('display_errors', 1);
  5set_time_limit(0);
  6ini_alter("memory_limit", "1024M");
  7ob_end_clean();
  8ob_implicit_flush(TRUE);
  9ignore_user_abort(1);
 10clearstatcache();
 11$PHP_SELF = !$PHP_SELF ? $_SERVER["PHP_SELF"] : $PHP_SELF;
 12define('HOST_DIR', 'hosts/');
 13define('IMAGE_DIR', 'images/');
 14define('CLASS_DIR', 'classes/');
 15define('CONFIG_DIR', 'configs/');
 16define('RAPIDLEECH', 'yes');
 17define('ROOT_DIR', realpath("./"));
 18define('PATH_SPLITTER', (strstr(ROOT_DIR, "\\") ? "\\" : "/"));
 19require_once(CONFIG_DIR.'setup.php');
 20if (substr($options['download_dir'],-1) != '/') $options['download_dir'] .= '/';
 21define('DOWNLOAD_DIR', (substr($options['download_dir'], 0, 6) == "ftp://" ? '' : $options['download_dir']));
 22$nn = "\r\n";
 23require_once("classes/other.php");
 24define ( 'TEMPLATE_DIR', 'templates/'.$options['template_used'].'/' );
 25
 26login_check();
 27
 28require(TEMPLATE_DIR.'/header.php');
 29?>
 30<br />
 31<center>
 32<?php
 33if ($_REQUEST["GO"] == "GO") {
 34  $getlinks=explode("\r\n",trim($_REQUEST['links']));
 35  if (!count($getlinks) || (trim($_REQUEST['links']) == "")) {
 36    html_error("No link submited");
 37  }
 38  if ($_REQUEST['server_side'] == 'on') {
 39    // Get supported download plugins
 40    require_once(HOST_DIR."download/hosts.php");
 41    require_once(CLASS_DIR."ftp.php");
 42    require_once(CLASS_DIR."http.php");
 43    if (isset($_POST["useproxy"]) && $_POST["useproxy"] == true && (!$_POST["proxy"] || !strstr($_POST["proxy"], ":"))) {
 44      html_error(lang(20), 0);
 45    }
 46?>
 47<table class="container" cellspacing="1">
 48  <tr>
 49    <td width="80%" align="center"><b><?php echo lang(21); ?></b></td>
 50    <td width="70" align="center"><b><?php echo lang(22); ?></b></td>
 51  </tr>
 52<?php
 53    for ($i = 0; $i < count($getlinks); $i++) {
 54      echo '  <tr><td width="80%" nowrap="nowrap">'.$getlinks[$i].'</td><td width="70" id="status'.$i.'">'.lang(23)."</td></tr>".$nn;
 55    }
 56?>
 57</table>
 58<script type="text/javascript">
 59/* <![CDATA[ */
 60function updateStatus(id, status)
 61{
 62  document.getElementById("status"+id).innerHTML = status;
 63}
 64function resetProgress()
 65{
 66  document.getElementById("received").innerHTML = '0 KB';
 67  document.getElementById("percent").innerHTML = '0%';
 68  document.getElementById("progress").style.width = '0%';
 69  document.getElementById("speed").innerHTML = '0 KB/s';
 70  document.title = 'RAPIDLEECH PLUGMOD - Auto Download';
 71}
 72/* ]]> */
 73</script>
 74<?php
 75    for ($i = 0; $i < count($getlinks); $i++) {
 76      $isHost = false;
 77      $hideDiv = false;
 78      unset($FileName);
 79      unset($force_name);
 80      //$bytesReceived = 0; // fix for GLOBAL in geturl()
 81      unset($bytesReceived);
 82      $LINK = $getlinks[$i];
 83      $Referer = $LINK;
 84      $Url = parse_url($LINK);
 85      $_GET = Array();
 86      $_GET["GO"] = "GO"; // for insert_location()
 87      $_GET["path"] = ((substr($options['download_dir'], 0, 6) != "ftp://") ? realpath(DOWNLOAD_DIR) : $options['download_dir']);
 88
 89      if (isset($_POST["useproxy"]) && $_POST["useproxy"] == true) {
 90        $_GET["useproxy"] = "on";
 91        $_GET["proxy"] = $_POST["proxy"];
 92        $pauth = ($_POST["proxyuser"] && $_POST["proxypass"]) ? base64_encode($_POST["proxyuser"].":".$_POST["proxypass"]) : "";
 93      }
 94
 95      if (isset($_POST['premium_acc'])) {
 96        $_GET["premium_acc"] = "on";
 97        $_GET["premium_user"] = $_POST["premium_user"];
 98        $_GET["premium_pass"] = $_POST["premium_pass"];
 99      }
100
101      if ($Url['scheme'] != 'http' && $Url['scheme'] != 'https' && $Url['scheme'] != 'ftp') {
102        echo '<script type="text/javascript">updateStatus('.$i.", '".lang(24)."');</script>".$nn;
103      } else {
104        echo '<div id="progress'.$i.'" style="display:block;">'.$nn;
105        foreach ($host as $site => $file) {
106          if (preg_match("/^(.+\.)?".$site."$/i", $Url["host"])) {
107            require_once (HOST_DIR . "DownloadClass.php");
108            require_once (HOST_DIR . 'download/' . $file);
109            $class = substr($file,0,-4);
110            $firstchar = substr($file,0,1);
111            if ($firstchar > 0) {
112              $class = "d".$class;
113            }
114            if (class_exists($class)) {
115              $hostClass = new $class();
116              $hostClass->Download($LINK);
117            }
118            $isHost = true;
119          }
120        }
121        if (!$isHost) {
122          $FileName = basename($Url["path"]);
123          insert_location("$PHP_SELF?filename=".urlencode($FileName)."&host=".$Url["host"]."&port=".$Url["port"]."&path=".urlencode($Url["path"].($Url["query"] ? "?".$Url["query"] : ""))."&referer=".urlencode($Referer)."&email=&partSize=&method=&proxy=".($_GET["useproxy"] ? $_GET["proxy"] : "")."&saveto=".$_GET["path"]."&link=".urlencode($LINK));
124        }
125        echo '<script type="text/javascript">updateStatus('.$i.", '".lang(25)."');</script>".$nn;
126        $redir = "";
127        $lastError = "";
128        do {
129          list($_GET["filename"],$tmp) = explode('?',urldecode(trim($_GET["filename"])));
130          $_GET["saveto"] = urldecode(trim($_GET["saveto"]));
131          $_GET["host"] = urldecode(trim($_GET["host"]));
132          $_GET["path"] = urldecode(trim($_GET["path"]));
133          $_GET["port"] = $_GET["port"] ? urldecode(trim($_GET["port"])) : 80;
134          $_GET["referer"] = $_GET["referer"] ? urldecode(trim($_GET["referer"])) : 0;
135          $_GET["link"] = urldecode(trim($_GET["link"]));
136          $_GET["post"] = $_GET["post"] ? unserialize(stripslashes(urldecode(trim($_GET["post"])))) : 0;
137          $_GET["cookie"] = $_GET["cookie"] ? urldecode(trim($_GET["cookie"])) : 0;
138
139          $redirectto = "";
140
141          $pauth = urldecode(trim($_GET["pauth"]));
142          $auth = urldecode(trim($_GET["auth"]));
143
144          if($_GET["auth"]) {
145            $AUTH["use"] = TRUE;
146            $AUTH["str"] = $_GET["auth"];
147          } else {
148            unset($AUTH);
149          }
150
151          $ftp = parse_url($_GET["link"]);
152          $IS_FTP = $ftp["scheme"] == "ftp" ? TRUE : FALSE;
153          $AUTH["ftp"] = array("login" => ($ftp["user"] ? $ftp["user"] : "anonymous"), "password" => ($ftp["pass"] ? $ftp["pass"] : "anonymous@leechget.com"));
154
155          $pathWithName = $_GET["saveto"].PATH_SPLITTER.$_GET["filename"];
156          while (stristr($pathWithName, "\\\\")) {
157            $pathWithName = str_replace("\\\\", "\\", $pathWithName);
158          }
159          list($pathWithName,$tmp) = explode('?',$pathWithName);
160
161          echo '<script type="text/javascript">updateStatus('.$i.", '".lang(26)."');</script>".$nn;
162          if ($ftp["scheme"] == "ftp" && !$_GET["proxy"]) {
163            $file = getftpurl($_GET["host"], $ftp["port"] ? $ftp["port"] : 21, $_GET["path"], $pathWithName);
164          } else {
165            $_GET["force_name"] ? $force_name = urldecode($_GET["force_name"]) : '';
166            $file = geturl($_GET["host"], $_GET["port"], $_GET["path"], $_GET["referer"], $_GET["cookie"], $_GET["post"], $pathWithName, $_GET["proxy"], $pauth, $auth, $ftp["scheme"]);
167          }
168          if ($redir && $lastError && stristr($lastError,"Error! it is redirected to [")) {
169            $redirectto = trim(cut_str($lastError,"Error! it is redirected to [","]"));
170            $_GET["link"] = $redirectto;
171            $purl = parse_url($redirectto);
172            list($_GET["filename"],$tmp) = explode('?',basename($redirectto));
173            $_GET["host"] = $purl["host"];
174            $_GET["path"] = $purl["path"].($purl["query"] ? "?".$purl["query"] : "");
175            $lastError = "";
176          }
177          if ($lastError) {
178            echo '<script type="text/javascript">updateStatus('.$i.", '".$lastError."');</script>".$nn;
179          } elseif ($file["bytesReceived"] == $file["bytesTotal"] || $file["size"] == "Unknown") {
180            echo '<script type="text/javascript">updateStatus('.$i.", '100%');resetProgress();</script>".$nn;
181            write_file(CONFIG_DIR."files.lst", serialize(array("name" => $file["file"], "size" => $file["size"], "date" => time(), "link" => $_GET["link"], "comment" => str_replace("\n", "\\n", str_replace("\r", "\\r", $_GET["comment"]))))."\r\n", 0);
182            $hideDiv = true;
183          } else {
184            echo '<script type="text/javascript">updateStatus('.$i.", '".lang(27)."');</script>".$nn;
185          }
186        }
187        while ($redirectto && !$lastError);
188        echo "</div>".$nn;
189        if ($hideDiv) {
190          echo '<script type="text/javascript">document.getElementById("progress'.$i.'").style.display="none";</script>'.$nn;
191        }
192      }
193      if ($_POST['server_dodelay'] == 'on') {
194        sleep((int) $_POST['serversidedelay']);
195      }
196    }
197    exit;
198  } else {
199    $start_link='index.php?audl=doum';
200
201    if(isset($_REQUEST['useproxy']) && $_REQUEST['useproxy'] && (!$_REQUEST['proxy'] || !strstr($_REQUEST['proxy'], ":"))) {
202           html_error(lang(20));
203       } else {
204         if ($_REQUEST['useproxy'] == "on") {
205        $start_link.='&proxy='.$_REQUEST['proxy'];
206        $start_link.='&proxyuser='.$_REQUEST['proxyuser'];
207        $start_link.='&proxypass='.$_REQUEST['proxypass'];
208      }
209       }
210
211    $start_link.='&imageshack_tor='.$_REQUEST['imageshack_acc'].'&premium_acc='.$_REQUEST['premium_acc'];
212    if (isset($_POST['premium_user'])) {
213      $start_link.='&premium_acc=on&premium_user='.urlencode($_POST['premium_user']).'&premium_pass='.urlencode($_POST['premium_pass']);
214    } elseif (isset($_POST['premium_acc'])) {
215      $start_link .= '&premium_acc=on';
216    }
217
218?>
219<script type="text/javascript">
220/* <![CDATA[ */
221  var current_dlink=-1;
222  var links = new Array();
223  var start_link='<?php echo $start_link; ?>';
224
225  function startauto() {
226    current_dlink=-1;
227    document.getElementById('auto').style.display='none';
228    nextlink();
229  }
230
231  function nextlink() {
232    if (document.getElementById('status'+current_dlink))
233      document.getElementById('status'+current_dlink).innerHTML='<?php echo lang(28); ?>';
234    current_dlink++;
235
236    if (current_dlink < links.length) {
237      document.getElementById('status'+current_dlink).innerHTML='<?php echo lang(26); ?>';
238      opennewwindow(current_dlink);
239    }
240  }
241
242  function opennewwindow(id) {
243    window.frames["idownload"].location = start_link+'&link='+links[id];
244  }
245  function addLinks() {
246    var tbody = document.getElementById("links").getElementsByTagName("tbody")[0];
247    var stringLinks = document.getElementById("addlinks").value;
248    var regexRN = new RegExp('\r\n',"g");
249    var regexN = new RegExp('\n',"g");
250    var stringLinksN = stringLinks.replace(regexRN, "\n");
251    var arrayLinks = stringLinksN.split(regexN);
252    for (var i = 0; i < arrayLinks.length; i++)
253    {
254      var row = document.createElement("tr");
255      var td1 = document.createElement("td");
256      td1.appendChild(document.createTextNode(arrayLinks[i]));
257      var td2 = document.createElement("td");
258      td2.appendChild(document.createTextNode("Waiting"));
259      td2.setAttribute("id", "status"+links.length);
260      row.appendChild(td1);
261      row.appendChild(td2);
262      tbody.appendChild(row);
263
264      links[links.length] = arrayLinks[i];
265    }
266    document.getElementById("addlinks").value = "";
267  }
268<?php
269
270    for ($i=0; $i<count($getlinks); $i++)
271      {
272        echo "\tlinks[".$i."]='".urlencode($getlinks[$i])."';\n";
273      }
274?>
275/* ]]> */
276</script>
277
278<table id="links" class="container" cellspacing="1">
279  <thead>
280    <tr><td width="80%" align="left"><b><?php echo lang(21); ?></b></td><td width="70" align="left"><b><?php echo lang(22); ?></b></td></tr>
281  </thead><tfoot>
282    <tr id="auto"><td colspan="2" align="center"><input type="button" value="<?php echo lang(29); ?>" onclick="javascript:startauto();" /></td></tr>
283  </tfoot><tbody>
284<?php
285    for ($i=0; $i<count($getlinks); $i++)
286      {
287        echo '    <tr><td nowrap="nowrap">'.$getlinks[$i].'</td><td id="status'.$i.'">'.lang(307)."</td></tr>\r\n";
288      }
289?>
290  </tbody>
291</table>
292<br />
293<iframe width="90%" height="300" src="" name="idownload"><?php echo lang(30); ?></iframe>
294<br />
295<table class="container" cellspacing="1">
296  <tr>
297    <td><textarea name="addlinks" id="addlinks" cols="100" rows="5"></textarea></td>
298    <td><input type="button" value="<?php echo lang(31); ?>" onclick="javascript:addLinks();" /></td>
299  </tr>
300</table>
301</center>
302<?php
303    include(TEMPLATE_DIR.'footer.php');
304    exit;
305  }
306}
307?>
308<script type="text/javascript">
309/* <![CDATA[ */
310  function ViewPage(page)
311    {
312      document.getElementById('listing').style.display='none';
313      document.getElementById('options').style.display='none';
314      document.getElementById(page).style.display='block';
315    }
316  function HideAll()
317    {
318      document.getElementById('entered').style.display='none';
319      /*document.getElementById('worked_frame').style.display='block';*/
320    }
321/* ]]> */
322</script>
323<table class="container" cellspacing="0" cellpadding="1" id="entered">
324  <tr><td>
325    <form action="?GO=GO" method="post" >
326    <table align="center" width="700" border="0">
327      <tr id="menu">
328        <td width="700" align="center">
329          <a href="javascript:ViewPage('listing');"><?php echo lang(32); ?></a>&nbsp;|&nbsp;<a href="javascript:ViewPage('options');"><?php echo lang(33); ?></a>
330        </td>
331      </tr>
332      <tr>
333        <td width="100%" valign="top">
334          <div id="listing" style="display:block;">
335            <table border="0" style="width:710px;">
336              <tr><td align="center"><textarea id="links" name="links" rows="15" cols="60" class="adlinks"></textarea></td></tr>
337              <tr><td align="center" valign="top"><input type="submit" value="<?php echo lang(34); ?>" onclick="javascript:HideAll();" style="width:100px;" /></td></tr>
338            </table>
339          </div>
340          <div id="options" style="display:none;">
341            <table cellspacing="5" style="width:710px;">
342              <tbody>
343                <tr>
344                  <td align="center">
345                    <table align="center">
346                      <tr>
347                        <td>
348                          <input type="checkbox" id="useproxy" name="useproxy" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('proxy').style.display=displ;"<?php echo $_COOKIE["useproxy"] ? ' checked="checked"' : ''; ?> />&nbsp;<?php echo lang(35); ?>
349                        </td>
350                        <td>&nbsp;</td>
351                        <td id="proxy"<?php echo $_COOKIE["useproxy"] ? '' : ' style="display: none;"'; ?>>
352                          <table border="0">
353                            <tr><td><?php echo lang(36); ?>:</td><td><input name="proxy" size="25"<?php echo $_COOKIE["proxy"] ? ' value="'.$_COOKIE["proxy"].'"' : ''; ?> /></td></tr>
354                            <tr><td><?php echo lang(37); ?>:</td><td><input name="proxyuser" size="25"<?php echo $_COOKIE["proxyuser"] ? ' value="'.$_COOKIE["proxyuser"].'"' : ''; ?> /></td></tr>
355                            <tr><td><?php echo lang(38); ?>:</td><td><input name="proxypass" size="25"<?php echo $_COOKIE["proxypass"] ? ' value="'.$_COOKIE["proxypass"].'"' : ''; ?> /></td></tr>
356                          </table>
357                        </td>
358                      </tr>
359                      <tr>
360                        <td>
361                        </td>
362                      </tr>
363                      <tr>
364                        <td>
365                          <input type="checkbox" value="on" name="imageshack_acc" id="imageshack_acc"<?php if (is_array($imageshack_acc)) { echo ' checked="checked"'; } ?> />&nbsp;<?php echo lang(39); ?>
366                        </td>
367                      </tr>
368<?php if ($maysaveto === true) { ?>
369                      <tr>
370                        <td>
371                          <input type="checkbox" name="saveto" id="saveto" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('path').style.display=displ;"<?php echo $_COOKIE["saveto"] ? ' checked="checked"' : ''; ?> />&nbsp;<?php echo lang(40); ?>
372                        </td>
373                        <td>&nbsp;</td>
374                        <td id="path" <?php echo $_COOKIE["saveto"] ? '' : ' style="display: none;"'; ?>>
375                          <?php echo lang(41); ?>:&nbsp;<input name="savedir" size="30" value="<?php echo realpath(($_COOKIE["savedir"] ? $_COOKIE["savedir"] : (strstr(realpath('./'), ':') ? addslashes($workpath) : $workpath))) ?>" />
376                        </td>
377                      </tr>
378<?php } ?>
379                      <tr>
380                        <td><input type="checkbox" name="premium_acc" id="premium_acc" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('premiumblock').style.display=displ;"<?php if (count($premium_acc) > 0) { echo ' checked="checked"'; } ?> />&nbsp;<?php echo lang(42); ?></td>
381                        <td>&nbsp;</td>
382                        <td id="premiumblock" style="display: none;">
383                          <table width="150" border="0">
384                            <tr><td><?php echo lang(37); ?>:&nbsp;</td><td><input type="text" name="premium_user" id="premium_user" size="15" value="" /></td></tr>
385                            <tr><td><?php echo lang(38); ?>:&nbsp;</td><td><input type="password" name="premium_pass" id="premium_pass" size="15" value="" /></td></tr>
386                          </table>
387                        </td>
388                      </tr>
389                      <tr>
390                        <td>
391                          <label><input type="checkbox" name="ytube_mp4" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('ytubeopt').style.display=displ;"<?php echo isset($_POST['yt_fmt']) ? ' checked="checked"' : ''; ?> />&nbsp;<?php echo lang(206); ?></label>
392                          <table width="150" border="0" id="ytubeopt" style="display: none;">
393                            <tr>
394                              <td colspan="2" style="white-space: nowrap;"><input type="checkbox" name="ytdirect" /><small> <?php echo lang(217); ?></small></td>
395                            </tr>
396                            <tr>
397                              <td><small><?php echo lang(218); ?></small></td>
398                              <td>
399                                <select name="yt_fmt" id="yt_fmt">
400                                  <option value="highest" selected="selected"><?php echo lang(219); ?></option>
401                                  <option value="0"><?php echo lang(220); ?></option>
402                                  <option value="5"><?php echo lang(221); ?></option>
403                                  <option value="6"><?php echo lang(222); ?></option>
404                                  <option value="13"><?php echo lang(223); ?></option>
405                                  <option value="17"><?php echo lang(224); ?></option>
406                                  <option value="18"><?php echo lang(225); ?></option>
407                                  <option value="22"><?php echo lang(226); ?></option>
408                                  <option value="34"><?php echo lang(227); ?></option>
409                                  <option value="35"><?php echo lang(228); ?></option>
410                                </select>
411                              </td>
412                            </tr>
413                          </table>
414                        </td>
415                      </tr>
416                      <tr><td><label><input type="checkbox" name="server_side" value="on" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('serverside').style.display=displ;" />&nbsp;<?php echo lang(43); ?></label></td></tr>
417                      <tr id="serverside" style="display: none;">
418                        <td><input type="checkbox" name="server_dodelay" value="on" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('serverdelay').style.display=displ;" /><?php echo lang(44); ?></td>
419                        <td>&nbsp;</td>
420                        <td id="serverdelay" style="display: none;"><?php echo lang(45); ?>: <input type="text" name="serversidedelay" /></td>
421                      </tr>
422                    </table>
423                  </td>
424                </tr>
425              </tbody>
426            </table>
427          </div>
428        </td>
429      </tr>
430    </table>
431    </form>
432  </td></tr>
433</table>
434</center>
435<?php include(TEMPLATE_DIR.'footer.php'); ?>