Skip to content

Instantly share code, notes, and snippets.

@itolosa
Created August 5, 2014 10:25
Show Gist options
  • Save itolosa/f9f69d81a48003b35263 to your computer and use it in GitHub Desktop.
Save itolosa/f9f69d81a48003b35263 to your computer and use it in GitHub Desktop.
jdownloader crawljob enqueuer
<!DOCTYPE html>
<html>
<head>
<title>job enqueue</title>
</head>
<body>
<p>Sistemator 3000</p>
<form action="app.php" method="POST">
<label>Nombre del archivo</label><br>
<input type="text" name="name" value=""><br>
<label>url</label><br>
<input type="text" name="url" value=""><br>
<input type="submit" value="Submit">
</form>
<?php
$txt = <<<EOT
->NEW ENTRY<-
chunks=0
extractPasswords=[]
enabled=null
packageName=MyPackageName
autoStart=TRUE
extractAfterDownload=UNSET
downloadFolder=null
priority=DEFAULT
forcedStart=UNSET
downloadPassword=null
#use only if text contains one single link
filename=null
overwritePackagizerEnabled=false
comment=null
autoConfirm=UNSET
deepAnalyseEnabled=false
addOfflineLink=true
EOT;
if (preg_match("/[a-zA-Z0-9]+/", $_POST["name"], $matches)) {
echo 'creating file...';
//echo "Match was found <br />";
$url = $_POST["url"];
$fname = $matches[0];
$fp = fopen($fname.".crawljob", "w");
fwrite($fp, $txt);
fwrite($fp, "text=".$url);
fclose($fp);
//exec("echo '".$url."' > ".getcwd()."/".$fname.".crawljob");
echo '<p>file created successfully!<p><br>';
} else {
if ($_POST["name"]) {
echo '<p>failed parsing name</p><br>';
} else {
if (0 < strlen($_POST["url"])) {
$len = count(scandir(getcwd()));
$url = $_POST["url"];
$fp = fopen("{$len}.crawljob", "w");
fwrite($fp, $txt);
fwrite($fp, "text=".$url);
fclose($fp);
echo '<p>file created successfully!<p><br>';
} else {
if ($_GET["clear"] == "true") {
exec("rm -rf ".getcwd()."/*.crawljob");
}
}
}
}
?>
<p>
<?php
$dirs = scandir(getcwd());
foreach ($dirs as $d) {
if (substr($d, -9) == ".crawljob") {
echo $d."<br>";
}
}
?>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment