]> 91.132.146.200 Git - dolphin.git/commitdiff
updated the bookmark script
authorBanana <banana@starscream.de>
Fri, 10 Jun 2011 14:36:21 +0000 (16:36 +0200)
committerBanana <banana@starscream.de>
Fri, 10 Jun 2011 14:36:21 +0000 (16:36 +0200)
bookmarks/createMirror.php [new file with mode: 0644]
bookmarks/index.php

diff --git a/bookmarks/createMirror.php b/bookmarks/createMirror.php
new file mode 100644 (file)
index 0000000..a294d51
--- /dev/null
@@ -0,0 +1,37 @@
+<?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
index 4348c634c86f4c53cdf0dcbd2234ea5d44f15caa..5580afb350a2ed12f9f799c7eecd7ee9dbadf6f9 100644 (file)
@@ -28,12 +28,37 @@ if(isset($_POST['sub']['submitNew'])) {
        $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 {
@@ -100,6 +125,8 @@ if(mysql_num_rows($query) > 0) {
                <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
@@ -114,7 +141,11 @@ if(mysql_num_rows($query) > 0) {
                                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>';
        }