--- /dev/null
+<?php
+/**
+ * bookmark management
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program. If not, see http://www.sun.com/cddl/cddl.html
+ */
+
+/**
+ * this script calls via exec() the httrack command.
+ * to use this you need http://www.httrack.com/ installed
+*/
+
+ini_set('error_reporting',-1); // E_ALL & E_STRICT
+ini_set('display_errors',false);
+ini_set('log_errors',true);
+ini_set('log_errors_max_len',"10M");
+ini_set('error_log','./error.file');
+
+$link = false;
+$to = false;
+$command = false;
+
+$path = dirname(__FILE__).'/';
+
+if(isset($_POST['link'])) $link = trim($_POST['link']);
+if(isset($_POST['saveTo'])) $to = trim($_POST['saveTo']);
+
+if(!empty($link) && !empty($to)) {
+ $command = "nohup /usr/bin/httrack -T3 -F'Mozilla/5.0' -r2 -* +*.gif +*.jpg +*.png +*.css +*.js '".$link."' -O ".$path.$to.'/ 1>&2 > /dev/null &';
+ $run = exec($command);
+}
+?>
\ No newline at end of file
$title = trim($_POST['new']['title']);
$cat = trim($_POST['new']['category']);
if(!empty($link) && !empty($title) && !empty($cat)) {
- $query = mysql_query("INSERT INTO `bookmarks`
- SET `category` = '".mysql_escape_string($cat)."',
- `title` = '".mysql_escape_string($title)."',
- `link` = '".mysql_escape_string($link)."',
- `date_added` = '".time()."'");
+ $mir = '0';
+ if(isset($_POST['new']['mirror']) && $_POST['new']['mirror'] == "yes") {
+ $mir = '1';
+ }
+ $query = mysql_query("INSERT INTO `bookmarks`
+ SET `category` = '".mysql_real_escape_string($cat)."',
+ `title` = '".mysql_real_escape_string($title)."',
+ `link` = '".mysql_real_escape_string($link)."',
+ `date_added` = '".time()."',
+ `mirror` = '".mysql_real_escape_string($mir)."'");
if($query !== false) {
+ if($mir === "1") {
+ // we want a mirror
+ $insertID = mysql_insert_id();
+ if(!empty($insertID)) {
+ $postfields['link'] = $link;
+ $postfields['saveTo'] = $insertID;
+ // do the curl call to trigger the mirror creation
+ # this way "avaoid" any wayting time
+ $ch = curl_init("http://www.tld.de/createMirror.php");
+ curl_setopt($ch, CURLOPT_POST, 1); // we use POST
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ # use this if you protect the script with htaccess
+ curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
+ $cResult = curl_exec($ch);
+ curl_close($ch);
+ }
+ }
+
header("Location: index.php");
}
else {
<input type="text" name="new[title]" value="" size="60" /><br />
Kategorie:<br />
<input type="text" name="new[category]" value="" size="60" /><br />
+ <br />
+ <input type="checkbox" name="new[mirror]" value="yes" /> Httrack Mirror anlegen.<br />
<button type="submit" title="Speichern" name="sub[submitNew]">Speichern</button>
</form>
<?php
echo '<ul>';
$cat = $entry['category'];
}
- echo '<li><a href="'.$entry['link'].'">'.$entry['title'].'</a> | <a href="index.php?edit='.$entry['id'].'" title="edit"><img src="edit.png" width="16" alt="edit" /></a></li>';
+ echo '<li><a href="'.$entry['link'].'">'.$entry['title'].'</a>';
+ if($entry['mirror'] == "1") {
+ echo ' | <a href="http://www.bananas-development-server.de/bookmarkMirror/'.$entry['id'].'/">mirror</a>';
+ }
+ echo ' | <a href="index.php?edit='.$entry['id'].'" title="edit"><img src="edit.png" width="16" alt="edit" /></a></li>';
}
echo '</ul>';
}