Browse Source

* Two Form factor auth (telegram)
* Multiple IP by user
* User identification by certificate
* Image cache compression
* CSS optimization
* RSS Clean-up
* Add themes
* Add footer
* Add Films ***WORK IN PROGRESS***

Admin:
* Add "Add Shows" feature
* Add "Add Torrent" feature
* Add "User" feature
* Add "Missing" feature
* Add "Config" feature
* Add "Add Sources" feature


Signed-off-by: Benjamin <benjamin@ewft.org>

Benjamin 5 years ago
parent
commit
0d9e9a92e3
100 changed files with 2457 additions and 351 deletions
  1. 1 0
      .gitignore
  2. 0 16
      about.php
  3. 75 6
      admin/action.php
  4. 71 3
      admin/admin.js
  5. 44 39
      admin/admin.php
  6. 860 0
      admin/utils/Torrent.php
  7. 23 0
      admin/utils/tortomagnet.php
  8. 31 0
      admin/utils/utils.php
  9. 55 0
      admin/view/Shows.php
  10. 12 16
      admin/view/admin_menu.php
  11. 27 13
      admin/view/home.php
  12. 174 9
      admin/view/manually_add.php
  13. 31 0
      admin/view/missing.php
  14. 60 1
      admin/view/sources.php
  15. 42 6
      admin/view/tor_in_progress.php
  16. 2 1
      admin/view/user.php
  17. 0 72
      bdd.php
  18. BIN
      cache/-g.jpg
  19. BIN
      cache/108611-1.jpg
  20. BIN
      cache/108611-g.jpg
  21. BIN
      cache/121361-13.jpg
  22. BIN
      cache/121361-g19.jpg
  23. BIN
      cache/153021-1.jpg
  24. BIN
      cache/153021-g.jpg
  25. BIN
      cache/164301-1.jpg
  26. BIN
      cache/164301-g10.jpg
  27. BIN
      cache/164541-1.jpg
  28. BIN
      cache/164541-g5.jpg
  29. BIN
      cache/176941-1.jpg
  30. BIN
      cache/176941-g.jpg
  31. 0 0
      cache/248742-.jpg
  32. BIN
      cache/248742-1.jpg
  33. BIN
      cache/248742-g10.jpg
  34. BIN
      cache/248835-10.jpg
  35. BIN
      cache/248835-g8.jpg
  36. BIN
      cache/248841-1.jpg
  37. BIN
      cache/248841-g.jpg
  38. BIN
      cache/255316-1.jpg
  39. BIN
      cache/255316-g.jpg
  40. BIN
      cache/257655-1.jpg
  41. BIN
      cache/257655-g.jpg
  42. BIN
      cache/258171-g9.jpg
  43. BIN
      cache/258823-1.jpg
  44. BIN
      cache/258823-g8.jpg
  45. BIN
      cache/259569-1.jpg
  46. BIN
      cache/259569-g.jpg
  47. 0 0
      cache/261557-1.jpg
  48. BIN
      cache/261557-g.jpg
  49. BIN
      cache/263365-1.jpg
  50. BIN
      cache/263365-g.jpg
  51. BIN
      cache/265912-1.jpg
  52. BIN
      cache/265912-g6.jpg
  53. BIN
      cache/267260-1.jpg
  54. BIN
      cache/267260-g.jpg
  55. BIN
      cache/269591-1.jpg
  56. BIN
      cache/269591-g.jpg
  57. BIN
      cache/269604-4.jpg
  58. BIN
      cache/269604-g.jpg
  59. BIN
      cache/278125-g2.jpg
  60. BIN
      cache/278155-1.jpg
  61. BIN
      cache/278155-g.jpg
  62. BIN
      cache/73762-g21.jpg
  63. 0 0
      cache/75682-.jpg
  64. BIN
      cache/75682-1.jpg
  65. BIN
      cache/75682-10.jpg
  66. BIN
      cache/75682-g10.jpg
  67. BIN
      cache/75760-1.jpg
  68. BIN
      cache/75760-g.jpg
  69. BIN
      cache/78804-1.jpg
  70. BIN
      cache/78804-50.jpg
  71. BIN
      cache/78804-g.jpg
  72. BIN
      cache/78804-g50.jpg
  73. BIN
      cache/80379-1.jpg
  74. BIN
      cache/80379-g12.jpg
  75. BIN
      cache/84676-g7.jpg
  76. BIN
      cache/95441-1.jpg
  77. BIN
      cache/95441-g.jpg
  78. BIN
      cache/Thumbs.db
  79. 89 51
      index.php
  80. 3 0
      js/jquery.min.js
  81. 0 0
      js/menu_jquery.js
  82. 9 8
      nbproject/project.properties
  83. 8 21
      rss.php
  84. 52 2
      themes/blue_std/css/button.css
  85. 43 0
      themes/blue_std/css/dragndrop.css
  86. 39 1
      themes/blue_std/css/menu_admin.css
  87. 47 0
      themes/blue_std/css/message.css
  88. 26 0
      themes/blue_std/css/style.css
  89. 63 0
      themes/blue_std/css/table.css
  90. 53 0
      themes/blue_std/css/toggle.css
  91. BIN
      themes/blue_std/img/hover.gif
  92. 110 0
      themes/new_theme/style.css
  93. 5 3
      themes/theme.php
  94. 0 83
      utils.php
  95. 106 0
      utils/bdd.php
  96. 25 0
      utils/const.php
  97. 37 0
      utils/telegram.php
  98. 182 0
      utils/utils.php
  99. 52 0
      utils/valid_action.php
  100. 0 0
      view/following.php

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/nbproject/private/

+ 0 - 16
about.php

@@ -1,16 +0,0 @@
-<?php
-
-/* 
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-?>
-<section>
-    <h2>About GIWYT</h2>
-    
-    GIWYT = Giwyt Is Watching Your Tvshows
-    
-    
-    
-</section>

+ 75 - 6
admin/action.php

@@ -5,13 +5,13 @@
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
  */
-include_once '../bdd.php';
+include_once '../utils/bdd.php';
 
 
 
 
 header("Content-Type: text/xml");
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
 echo "<list>";
 $action = (isset($_POST["action"])) ? $_POST["action"] : NULL;
 $variable2 = (isset($_POST["param0"])) ? $_POST["param0"] : NULL;
@@ -27,18 +27,67 @@ if ($action && $variable2) {
                 $seluser = $bdd->query('INSERT INTO users WHERE `id`='.$variable2.' ');
                 echo "<result>OK</result>";
             break;
+        
+        case "add_show":
+        
+         $name = $_POST["param0"];
+    $tvdbidb = $_POST["param1"];
+    $followed = $_POST["param2"];
+    $hddname = $_POST["param3"];
+    $posterid = $_POST["param4"];
+    $bannerid = $_POST["param5"];
+    $displayname = $_POST["param6"];
+     $bdd->exec("INSERT INTO `tv_shows`.`TVS_shows` (`ID`, `Name`, `tvdbid`, `followed`, `HDD_Name`, `TVDB_banner_id`, `TVDB_poster_id`, `display_name`) VALUES (NULL, '".$name."', '".$tvdbidb."', '".$followed."', '".$hddname."', '".$posterid."', '".$bannerid."', '".$displayname."');");
+    echo "<result>OK</result>";
+            break;
+        
         case "add_tor":
                 //echo $variable2;
+                $type = $_POST["param1"];
                 $startpos=stripos($variable2,'btih:') + 5;
                 $hash=substr($variable2,$startpos,40);
-                $bdd->exec("INSERT INTO torrent_data VALUES('','".$variable2."','2','0','NA',UPPER('".$hash."'),'','0','0','0',CURRENT_TIMESTAMP,'')");
-               // echo "INSERT INTO torrent_data VALUES('','".$variable2."','2','0','NA',UPPER('".$hash."'),'','0','0','0',CURRENT_TIMESTAMP,'')";
+                switch ($type){
+                    case "1": //tvshows
+                        $show = $_POST["param2"];
+                        $season = $_POST["param3"];
+                        $episode = $_POST["param4"];
+                        $quality = $_POST["param5"];
+                        $bdd->exec("INSERT IGNORE INTO `tv_shows`.`TVS_episode` (`id`, `season_num`, `episode_num`, `plop`, `shows_id`) VALUES (NULL, '".$season."', '".$episode."', '1', '".$show."');");
+                        $episo_ids = $bdd->query("SELECT * FROM  `TVS_episode` WHERE  `season_num` =".$season." AND  `episode_num` =".$episode." AND  `shows_id` =".$show);
+                        $episo_id = $episo_ids->fetch();
+                        $epi_id = $episo_id["id"];
+                    break;
+                
+                    case "2": //std
+                        $quality = "NA";
+                        $epi_id =0;
+                        break;
+                    
+                    case "3": //music
+                        $quality = "NA";
+                        $epi_id =0;
+                        break;
+                    default :
+                        break;
+                        
+                }
+                
+                
+                
+                $bdd->exec("INSERT INTO torrent_data VALUES('','".$variable2."','".$type."','".$epi_id."','".$quality."',UPPER('".$hash."'),'','0','0','0',CURRENT_TIMESTAMP,'')");
+                echo "<result>OK</result>";
+            break;
+        case "add_src":
+                $show = $_POST["param0"];
+                $suplier = $_POST["param1"];
+                $regexp = $_POST["param2"];
+                $bdd->exec("INSERT INTO  `tv_shows`.`sources` (`id` ,`tvshows_id` ,`supplier_id` ,`regexp`)VALUES (NULL ,  '".$show."',  '".$suplier."',  '".$regexp."');");
                 echo "<result>OK</result>";
             break;
         case "mod_state":
                 
-                $state = (isset($_POST["param1"])) ? $_POST["param1"] : NULL;
-                if($state){
+                if((isset($_POST["param1"]))){
+                $state = $_POST["param1"];
                 //echo $variable2;
                 $bdd->exec("UPDATE  `tv_shows`.`torrent_data` SET  `state` =  '".$state."' WHERE  `torrent_data`.`id` =".$variable2.";");
                 //echo "UPDATE  `tv_shows`.`torrent_data` SET  `state` =  '".$state."' WHERE  `torrent_data`.`id` =".$variable2.";";
@@ -98,9 +147,29 @@ if ($action && $variable2) {
             while($userdata = $seluser->fetch()){
                 echo "<item id=\"". $userdata["id"]."\" name=\"". $userdata["name"]."\" username=\"".$userdata["username"]."\"  ip=\"".$userdata["ip"]."\"/> "; 
             }
+            break;
             
+        case "tortomagnet":
+        
             
+            $torrent = new Torrent( $_FILES["file"]["tmp_name"] );
+ /*           echo '<table>';
+            echo '<tr>';
+            echo '<tr><td>private</td><td>', $torrent->is_private() ? 'yes' : 'no','</td></tr>'; 
+            echo '<tr><td>annonce</td><td> ', $torrent->announce(),'</td></tr>';
+            echo '<tr><td>name</td><td> ', $torrent->name(), '</td></tr>';
+            echo '<tr><td>comment</td><td> ', $torrent->comment(), '</td></tr>';
+            echo '<tr><td>piece_length</td><td> ', $torrent->piece_length(), '</td></tr>';
+            echo '<tr><td>size</td><td> ', $torrent->size( 2 ),'</td></tr>';
+            echo '<tr><td>hash info</td><td> ', $torrent->hash_info(),'</td></tr>';*/
+// get magnet link
+/*echo '<tr><td>magnet</td><td id="tormagnet"> ', $torrent->magnet(),'</td></tr>';
+echo '</table>';
+            */
             break;
+        
+        
+        
         default:
             break;
     }

+ 71 - 3
admin/admin.js

@@ -166,13 +166,81 @@ function add_user_req(user, ip, name, admin) {
     request_action(delete_user_cb, "add", [user]);
 }
 
+/******************************************************************************/
+/*                              SHOWS                                         */
+/******************************************************************************/
+
+function add_show() {
+
+    var name = document.getElementById("name_tb").value;
+    var tvdbidb = document.getElementById("tvdbid_tb").value;
+    var followed = document.getElementById("followed_tb").value;
+    var hddname = document.getElementById("hddname_tb").value;
+    var posterid = document.getElementById("posterid_tb").value;
+    var bannerid = document.getElementById("bannerid_tb").value;
+    var displayname = document.getElementById("displayname_tb").value;
+    
+    request_action(add_show_cb, "add_show", [name,tvdbidb,followed,hddname,posterid,bannerid,displayname]);
+}
+
+function add_show_cb(Data) {
+     var nodes = Data.getElementsByTagName("result");
+    if (nodes[0].innerHTML  === 'OK') {
+        message("Success : Show Added", 0);
+    } else {
+        message("Error", 1);
+    }
+}
+
+
+/******************************************************************************/
+/*                            SOURCES                                         */
+/******************************************************************************/
+
+function add_source() {
+    var e =  document.getElementById("show_sel");
+    var show = e.options[e.selectedIndex].value;
+    var supplier = document.getElementById("supplier_sel").value;
+    var regexp = document.getElementById("regexp_tb").value;
+    request_action(add_source_cb, "add_src", [show,supplier,regexp]);
+}
+
+function add_source_cb(Data) {
+     var nodes = Data.getElementsByTagName("result");
+    if (nodes[0].innerHTML  === 'OK') {
+        message("Success : Source Added", 0);
+    } else {
+        message("Error", 1);
+    }
+}
+
+
 /******************************************************************************/
 /*                           TORRENTS                                         */
 /******************************************************************************/
 
-function add_torrent() {
-    var magnet = document.getElementById("tamagnet").value;
-    request_action(add_torrent_cb, "add_tor", [magnet]);
+function add_torrent(id) {
+    var magnet = document.getElementById(id).value;
+    var type = $('input[name="toggle"]:checked').val();
+     var e =  document.getElementById("show_sel");
+    var show = e.options[e.selectedIndex].value;
+    var season = document.getElementById("season").value;
+    var episode = document.getElementById("episode").value;
+    var e =  document.getElementById("quality_sel");
+    var quality = e.options[e.selectedIndex].value;
+    request_action(add_torrent_cb, "add_tor", [magnet,type,show,season,episode,quality]);
+}
+
+function add_torrentt(id) {
+    var magnet = document.getElementById(id).textContent;
+    var type = $('input[name="toggle"]:checked').val();
+    var e =  document.getElementById("show_sel");
+    var show = e.options[e.selectedIndex].value;
+    var season = document.getElementById("season").value;
+    var episode = document.getElementById("episode").value;
+    var e =  document.getElementById("quality_sel");
+    var quality = e.options[e.selectedIndex].value;
+    request_action(add_torrent_cb, "add_tor", [magnet,type,show,season,episode,quality]);
 }
 
 function add_torrent_cb(Data) {

+ 44 - 39
admin/admin.php

@@ -1,5 +1,5 @@
 <?php
-include_once 'utils.php';
+include_once 'admin/utils/utils.php';
 include_once 'bdd.php';
 
 
@@ -8,12 +8,15 @@ include_once 'bdd.php';
 
 if(!isAdmin()){
 
-include_once 'admin/view/not_admin.php';    
+    include_once 'admin/view/not_admin.php';    
 
 }elseif (false) {
- include_once 'view/maintenance.php';
+    include_once 'view/maintenance.php';
 
 }else {
+    ?>
+    <script type='text/javascript' src='admin/admin.js'></script>
+    <?php
     include_once 'admin/view/admin_menu.php';
     if (isset($_GET['psub_id'])) {
         switch ($_GET['psub_id']) {
@@ -21,7 +24,11 @@ include_once 'admin/view/not_admin.php';
                 include_once 'admin/view/home.php';
                 break;
             case 1:
-                include_once 'admin/view/user.php';
+                if($GLOBALS["isSAdmin"]){
+                    include_once 'admin/view/user.php';
+                }else{
+                    include_once 'admin/view/home.php';
+                }
                 break;
             case 2:
             include_once 'admin/view/history.php';
@@ -30,7 +37,11 @@ include_once 'admin/view/not_admin.php';
                 include_once 'admin/view/manually_add.php';
                 break;
             case 4:
-                include_once 'admin/view/config.php';
+                if($GLOBALS["isSAdmin"]){
+                    include_once 'admin/view/config.php';
+                }else{
+                    include_once 'admin/view/home.php';
+                }
                 break;
             case 5:
                  include_once 'admin/view/tor_in_progress.php';
@@ -38,7 +49,27 @@ include_once 'admin/view/not_admin.php';
                // include_once 'project1/header.php';
                // include_once 'project1/TVS_showslist.php';
                // break;
-             
+            case 6:
+                if($GLOBALS["isSAdmin"]){
+                    include_once 'admin/view/missing.php';
+                }else{
+                    include_once 'admin/view/home.php';
+                }
+                break;
+             case 7:
+                if($GLOBALS["isSAdmin"]){
+                    include_once 'admin/view/sources.php';
+                }else{
+                    include_once 'admin/view/home.php';
+                }
+                break;
+             case 8:
+                if($GLOBALS["isSAdmin"]){
+                    include_once 'admin/view/Shows.php';
+                }else{
+                    include_once 'admin/view/home.php';
+                }
+                break;
             default:
                 include_once 'admin/view/home.php';
                 break;
@@ -47,41 +78,15 @@ include_once 'admin/view/not_admin.php';
     include_once 'admin/view/home.php';
     }
     ?>
-<style>
-    .message_ok {
-        background-color: #83c41a;
-        width: 100%;
-        height: 30px;
-        text-align: center;
-        visibility: visible;
-     }
-    .message_info {
-        background-color: #99ccff;
-        width: 100%;
-        height: 30px;
-        text-align: center;
-        visibility: visible;
-     }
-         .message_nok {
-        background-color: #f5978e;
-        width: 100%;
-        height: 30px;
-        text-align: center;
-        visibility: visible;
-     }
-
-     
-         .message_hidden {
-        background-color: #f5978e;
-        width: 100%;
-        height: 0px;
-        text-align: center;
-        visibility: hidden;
-     }
-</style>
+
 
 <div id="message" class="message_hidden"></div>
-    <script onload="request(showUsertable)" type='text/javascript' src='admin/admin.js'></script>
+
+
+
+
+
+
     <?php
     }
 

+ 860 - 0
admin/utils/Torrent.php

@@ -0,0 +1,860 @@
+<?php
+/**
+ * Torrent
+ *
+ * PHP version 5.2+ (with cURL extention enabled)
+ *
+ * LICENSE: This source file is subject to version 3 of the GNU GPL
+ * that is available through the world-wide-web at the following URI:
+ * http://www.gnu.org/licenses/gpl.html. If you did not receive a copy of
+ * the GNU GPL License and are unable to obtain it through the web, please
+ * send a note to adrien.gibrat@gmail.com so I can mail you a copy.
+ *
+ * 1) Features:
+ * - Decode torrent file or data from local file and distant url
+ * - Build torrent from source folder/file(s) or distant url
+ * - Super easy usage & syntax
+ * - Silent Exception error system
+ *
+ * 2) Usage example
+ * <code>
+require_once 'Torrent.php';
+
+// get torrent infos
+$torrent = new Torrent( './test.torrent' );
+echo '<br>private: ', $torrent->is_private() ? 'yes' : 'no', 
+	 '<br>annonce: ', $torrent->announce(), 
+	 '<br>name: ', $torrent->name(), 
+	 '<br>comment: ', $torrent->comment(), 
+	 '<br>piece_length: ', $torrent->piece_length(), 
+	 '<br>size: ', $torrent->size( 2 ),
+	 '<br>hash info: ', $torrent->hash_info(),
+	 '<br>stats: ';
+var_dump( $torrent->scrape() );
+echo '<br>content: ';
+var_dump( $torrent->content() );
+echo '<br>source: ',
+	 $torrent;
+
+// get magnet link
+$torrent->magnet(); // use $torrent->magnet( false ); to get non html encoded ampersand
+
+// create torrent
+$torrent = new Torrent( array( 'test.mp3', 'test.jpg' ), 'http://torrent.tracker/annonce' );
+$torrent->save('test.torrent'); // save to disk
+
+// modify torrent
+$torrent->announce('http://alternate-torrent.tracker/annonce'); // add a tracker
+$torrent->announce(false); // reset announce trackers
+$torrent->announce(array('http://torrent.tracker/annonce', 'http://alternate-torrent.tracker/annonce')); // set tracker(s), it also works with a 'one tracker' array...
+$torrent->announce(array(array('http://torrent.tracker/annonce', 'http://alternate-torrent.tracker/annonce'), 'http://another-torrent.tracker/annonce')); // set tiered trackers
+$torrent->comment('hello world');
+$torrent->name('test torrent');
+$torrent->is_private(true);
+$torrent->httpseeds('http://file-hosting.domain/path/'); // Bittornado implementation
+$torrent->url_list(array('http://file-hosting.domain/path/','http://another-file-hosting.domain/path/')); // 
+GetRight implementation
+
+// print errors
+if ( $errors = $torrent->errors() )
+	var_dump( $errors );
+
+// send to user
+$torrent->send();
+ * </code>
+ *
+ * @author   Adrien Gibrat <adrien.gibrat@gmail.com>
+ * @tester   Jeong, Anton, dokcharlie, official testers ;) Thanks for your precious feedback
+ * @copyleft 2010 - Just use it!
+ * @license  http://www.gnu.org/licenses/gpl.html GNU General Public License version 3
+ * @version  Release: 1.2 (6 july 2010)
+ */
+
+class Torrent {
+	
+	/**
+	* @const float Default http timeout
+	*/
+	const timeout = 30;
+
+	/**
+	* @var array List of error occured
+	*/
+	static protected $_errors = array();
+
+	/** Read and decode torrent file/data OR build a torrent from source folder/file(s)
+	 * Supported signatures:
+	 * - Torrent(); // get an instance (usefull to scrape and check errors)
+	 * - Torrent( string $torrent ); // analyse a torrent file
+	 * - Torrent( string $torrent, string $announce );
+	 * - Torrent( string $torrent, array $meta );
+	 * - Torrent( string $file_or_folder ); // create a torrent file
+	 * - Torrent( string $file_or_folder, string $announce_url, [int $piece_length] );
+	 * - Torrent( string $file_or_folder, array $meta, [int $piece_length] );
+	 * - Torrent( array $files_list );
+	 * - Torrent( array $files_list, string $announce_url, [int $piece_length] );
+	 * - Torrent( array $files_list, array $meta, [int $piece_length] );
+	 * @param string|array torrent to read or source folder/file(s) (optional, to get an instance)
+	 * @param string|array announce url or meta informations (optional)
+	 * @param int piece length (optional)
+	 */
+	public function __construct ( $data = null, $meta = array(), $piece_length = 256 ) {
+		if ( is_null( $data ) )
+			return false;
+		if ( $piece_length < 32 || $piece_length > 4096 )
+			return self::set_error( new Exception( 'Invalid piece lenth, must be between 32 and 4096' ) );
+		if ( is_string( $meta ) )
+			$meta = array( 'announce' => $meta );
+		if ( $this->build( $data, $piece_length * 1024 ) )
+			$this->touch();
+		else
+			$meta = array_merge( $meta, $this->decode( $data ) );
+		foreach( $meta as $key => $value )
+			$this->{$key} = $value;
+	}
+
+	/** Convert the current Torrent instance in torrent format
+	 * @return string encoded torrent data
+	 */
+	public function __toString() {
+		return $this->encode( $this );
+	}
+
+	/** Return last error message
+	 * @return string|boolean last error message or false if none
+	 */
+	public function error() {
+		return empty( self::$_errors ) ?
+			false :
+			self::$_errors[0]->getMessage();
+	}
+
+	/** Return Errors
+	 * @return array|boolean error list or false if none
+	 */
+	public function errors() {
+		return empty( self::$_errors ) ?
+			false :
+			self::$_errors;
+	}
+
+	/**** Getters and setters ****/
+
+	/** Getter and setter of torrent announce url / list
+	 * If the argument is a string, announce url is added to announce list (or set as announce if announce is not set)
+	 * If the argument is an array/object, set announce url (with first url) and list (if array has more than one url), tiered list supported
+	 * If the argument is false announce url & list are unset
+	 * @param null|false|string|array announce url / list, reset all if false (optional, if omitted it's a getter)
+	 * @return string|array|null announce url / list or null if not set
+	 */
+	public function announce ( $announce = null ) {
+		if ( is_null( $announce ) )
+			return ! isset( $this->{'announce-list'} ) ?
+				isset( $this->announce ) ? $this->announce : null :
+				$this->{'announce-list'};
+		$this->touch();
+		if ( is_string( $announce ) && isset( $this->announce ) )
+			return $this->{'announce-list'} = self::announce_list( isset( $this->{'announce-list'} ) ? $this->{'announce-list'} : $this->announce, $announce );
+		unset( $this->{'announce-list'} );
+		if ( is_array( $announce ) || is_object( $announce ) )
+			if ( ( $this->announce = self::first_announce( $announce ) ) && count( $announce ) > 1 )
+				return $this->{'announce-list'} = self::announce_list( $announce );
+			else
+				return $this->announce;
+		if ( ! isset( $this->announce ) && $announce )
+			return $this->announce = (string) $announce;
+		unset( $this->announce );
+	}
+
+	/** Getter and setter of torrent comment
+	 * @param null|string comment (optional, if omitted it's a getter)
+	 * @return string|null comment or null if not set
+	 */
+	public function comment ( $comment = null ) {
+		return is_null( $comment ) ?
+			isset( $this->comment ) ? $this->comment : null :
+			$this->touch( $this->comment = (string) $comment );
+	}
+
+	/** Getter and setter of torrent name
+	 * @param null|string name (optional, if omitted it's a getter)
+	 * @return string|null name or null if not set
+	 */
+	public function name ( $name = null ) {
+		return is_null( $name ) ?
+			isset( $this->info['name'] ) ? $this->info['name'] : null :
+			$this->touch( $this->info['name'] = (string) $name );
+	}
+
+	/** Getter and setter of private flag
+	 * @param null|boolean is private or not (optional, if omitted it's a getter)
+	 * @return boolean private flag
+	 */
+	public function is_private ( $private = null ) {
+		return is_null( $private ) ?
+			! empty( $this->info['private'] ) :
+			$this->touch( $this->info['private'] = $private ? 1 : 0 );
+	}
+
+	/** Getter and setter of webseed(s) url list ( GetRight implementation )
+	 * @param null|string|array webseed or webseeds mirror list (optional, if omitted it's a getter)
+	 * @return string|array|null webseed(s) or null if not set
+	 */
+	public function url_list ( $urls = null ) {
+		return is_null( $urls ) ?
+			isset( $this->{'url-list'} ) ? $this->{'url-list'} : null :
+			$this->touch( $this->{'url-list'} = is_string( $urls) ? $urls : (array) $urls );
+	}
+
+	/** Getter and setter of httpseed(s) url list ( Bittornado implementation )
+	 * @param null|string|array httpseed or httpseeds mirror list (optional, if omitted it's a getter)
+	 * @return array|null httpseed(s) or null if not set
+	 */
+	public function httpseeds ( $urls = null ) {
+		return is_null( $urls ) ?
+			isset( $this->httpseeds ) ? $this->httpseeds : null :
+			$this->touch( $this->httpseeds = (array) $urls );
+	}
+
+	/**** Analyze BitTorrent ****/
+
+	/** Get piece length
+	 * @return integer piece length or null if not set
+	 */
+	public function piece_length () {
+		return isset( $this->info['piece length'] ) ?
+			$this->info['piece length'] :
+			null;
+	}
+
+	/** Compute hash info
+	 * @return string hash info or null if info not set
+	 */
+	public function hash_info () {
+		return isset( $this->info ) ?
+			sha1( self::encode( $this->info ) ) :
+			null;
+	}
+
+	/** List torrent content
+	 * @param integer|null size precision (optional, if omitted returns sizes in bytes)
+	 * @return array file(s) and size(s) list, files as keys and sizes as values
+	 */
+	public function content ( $precision = null ) {
+		$files = array();
+		if ( isset( $this->info['files'] ) && is_array( $this->info['files'] ) )
+			foreach ( $this->info['files'] as $file )
+				$files[self::path( $file['path'], $this->info['name'] )] = $precision ?
+					self::format( $file['length'], $precision ) :
+					$file['length'];
+		elseif ( isset( $this->info['name'] ) )
+				$files[$this->info['name']] = $precision ?
+					self::format( $this->info['length'], $precision ) :
+					$this->info['length'];
+		return $files;
+	}
+
+	/** List torrent content pieces and offset(s)
+	 * @return array file(s) and pieces/offset(s) list, file(s) as keys and pieces/offset(s) as values
+	 */
+	public function offset () {
+		$files = array();
+		$size = 0;
+		if ( isset( $this->info['files'] ) && is_array( $this->info['files'] ) )
+			foreach ( $this->info['files'] as $file )
+				$files[self::path( $file['path'], $this->info['name'] )] = array(
+					'startpiece'	=> floor( $size / $this->info['piece length'] ),
+					'offset'	=> fmod( $size, $this->info['piece length'] ),
+					'size'		=> $size += $file['length'],
+					'endpiece'	=> floor( $size / $this->info['piece length'] )
+				);
+		elseif ( isset( $this->info['name'] ) )
+				$files[$this->info['name']] = array(
+					'startpiece'	=> 0,
+					'offset'	=> 0,
+					'size'		=> $this->info['length'],
+					'endpiece'	=> floor( $this->info['length'] / $this->info['piece length'] )
+				);
+		return $files;
+	}
+
+	/** Sum torrent content size
+	 * @param integer|null size precision (optional, if omitted returns size in bytes)
+	 * @return integer|string file(s) size
+	 */
+	public function size ( $precision = null ) {
+		$size = 0;
+		if ( isset( $this->info['files'] ) && is_array( $this->info['files'] ) )
+			foreach ( $this->info['files'] as $file )
+				$size += $file['length'];
+		elseif ( isset( $this->info['name'] ) )
+				$size = $this->info['length'];
+		return is_null( $precision ) ?
+			$size :
+			self::format( $size, $precision );
+	}
+
+	/** Request torrent statistics from scrape page USING CURL!!
+	 * @param string|array announce or scrape page url (optional, to request an alternative tracker BUT requirered for static call)
+	 * @param string torrent hash info (optional, requirered ONLY for static call)
+	 * @param float read timeout in seconds (optional, default to self::timeout 30s)
+	 * @return array tracker torrent statistics
+	 */
+	/* static */ public function scrape ( $announce = null, $hash_info = null, $timeout = self::timeout ) {
+		$packed_hash = urlencode( pack('H*', $hash_info ? $hash_info : $this->hash_info() ) );
+		$handles = $scrape = array();
+		if ( ! function_exists( 'curl_multi_init' ) )
+			return self::set_error( new Exception( 'Install CURL with "curl_multi_init" enabled' ) );
+		$curl = curl_multi_init();
+		foreach ( (array) ($announce ? $announce : $this->announce()) as $tier )
+			foreach ( (array) $tier as $tracker ) {
+				$tracker = str_ireplace( array( 'udp://', '/announce', ':80/' ), array( 'http://', '/scrape', '/' ), $tracker );
+				if ( isset( $handles[$tracker] ) )
+					continue;
+				$handles[$tracker] = curl_init( $tracker . '?info_hash=' . $packed_hash );
+				curl_setopt( $handles[$tracker], CURLOPT_RETURNTRANSFER, true );
+				curl_setopt( $handles[$tracker], CURLOPT_TIMEOUT, $timeout );
+				curl_multi_add_handle( $curl, $handles[$tracker] );
+			}
+		do {
+			while ( ( $state = curl_multi_exec( $curl, $running ) ) == CURLM_CALL_MULTI_PERFORM );
+				if( $state != CURLM_OK )
+					continue;
+			while ( $done = curl_multi_info_read( $curl ) ) {
+				$info = curl_getinfo( $done['handle'] );
+				$tracker = explode( '?', $info['url'], 2 );
+				$tracker = array_shift( $tracker );
+				if ( empty( $info['http_code'] ) ) {
+					$scrape[$tracker] = self::set_error( new Exception( 'Tracker request timeout (' . $timeout . 's)' ), true );
+					continue;
+				} elseif ( $info['http_code'] != 200 ) {
+					$scrape[$tracker] = self::set_error( new Exception( 'Tracker request failed (' . $info['http_code'] . ' code)' ), true );
+					continue;
+				}
+				$data = curl_multi_getcontent( $done['handle'] );
+				$stats = self::decode_data( $data );
+				curl_multi_remove_handle( $curl, $done['handle'] );
+				$scrape[$tracker] = empty( $stats['files'] ) ?
+					self::set_error( new Exception( 'Empty scrape data' ), true ) :
+					array_shift( $stats['files'] ) + ( empty( $stats['flags'] ) ? array() : $stats['flags'] );
+			}
+		} while ( $running );
+		curl_multi_close( $curl );
+		return $scrape;
+	}
+
+	/**** Save and Send ****/
+
+	/** Save torrent file to disk
+	 * @param null|string name of the file (optional)
+	 * @return boolean file has been saved or not
+	 */
+	public function save ( $filename = null ) {
+		return file_put_contents( is_null( $filename ) ? $this->info['name'] . '.torrent' : $filename, $this->encode( $this ) );
+	}
+
+	/** Send torrent file to client
+	 * @param null|string name of the file (optional)
+	 * @return void script exit
+	 */
+	public function send ( $filename = null ) {
+		$data = $this->encode( $this );
+		header( 'Content-type: application/x-bittorrent' );
+		header( 'Content-Length: ' . strlen( $data ) );
+		header( 'Content-Disposition: attachment; filename="' . ( is_null( $filename ) ? $this->info['name'] . '.torrent' : $filename ) . '"' );
+		exit( $data );
+	}
+
+	/** Get magnet link
+	 * @param boolean html encode ampersand, default true (optional)
+	 * @return string magnet link
+	 */
+	public function magnet ( $html = true ) {
+		$ampersand = $html ? '&amp;' : '&';
+		return sprintf( 'magnet:?xt=urn:btih:%2$s%1$sdn=%3$s%1$sxl=%4$d%1$str=%5$s', $ampersand, $this->hash_info(), urlencode( $this->name() ), $this->size(), implode( $ampersand .'tr=', self::untier( $this->announce() ) ) );
+	}	
+
+	/**** Encode BitTorrent ****/
+
+	/** Encode torrent data
+	 * @param mixed data to encode
+	 * @return string torrent encoded data
+	 */
+	static public function encode ( $mixed ) {
+		switch ( gettype( $mixed ) ) {
+			case 'integer':
+			case 'double':
+				return self::encode_integer( $mixed );
+			case 'object':
+				$mixed = get_object_vars( $mixed );
+			case 'array':
+				return self::encode_array( $mixed );
+			default:
+				return self::encode_string( (string) $mixed );
+		}
+	}
+
+	/** Encode torrent string
+	 * @param string string to encode
+	 * @return string encoded string
+	 */
+	static private function encode_string ( $string ) {
+		return strlen( $string ) . ':' . $string;
+	}
+
+	/** Encode torrent integer
+	 * @param integer integer to encode
+	 * @return string encoded integer
+	 */
+	static private function encode_integer ( $integer ) {
+		return 'i' . $integer . 'e';
+	}
+
+	/** Encode torrent dictionary or list
+	 * @param array array to encode
+	 * @return string encoded dictionary or list
+	 */
+	static private function encode_array ( $array ) {
+		if ( self::is_list( $array ) ) {
+			$return = 'l';
+			foreach ( $array as $value )
+				$return .= self::encode( $value );
+		} else {
+			ksort( $array, SORT_STRING );
+			$return = 'd';
+			foreach ( $array as $key => $value )
+				$return .= self::encode( strval( $key ) ) . self::encode( $value );
+		}
+		return $return . 'e';
+	}
+
+	/**** Decode BitTorrent ****/
+
+	/** Decode torrent data or file
+	 * @param string data or file path to decode
+	 * @return array decoded torrent data
+	 */
+	static protected function decode ( $string ) {
+		$data = is_file( $string ) || self::url_exists( $string ) ?
+			self::file_get_contents( $string ) :
+			$string;
+		return (array) self::decode_data( $data );
+	}
+
+	/** Decode torrent data
+	 * @param string data to decode
+	 * @return array decoded torrent data
+	 */
+	static private function decode_data ( & $data ) {
+		switch( self::char( $data ) ) {
+		case 'i':
+			$data = substr( $data, 1 );
+			return self::decode_integer( $data );
+		case 'l':
+			$data = substr( $data, 1 );
+			return self::decode_list( $data );
+		case 'd':
+			$data = substr( $data, 1 );
+			return self::decode_dictionary( $data );
+		default:
+			return self::decode_string( $data );
+		}
+	}
+
+	/** Decode torrent dictionary
+	 * @param string data to decode
+	 * @return array decoded dictionary
+	 */
+	static private function decode_dictionary ( & $data ) {
+		$dictionary = array();
+		$previous = null;
+		while ( ( $char = self::char( $data ) ) != 'e' ) {
+			if ( $char === false )
+				return self::set_error( new Exception( 'Unterminated dictionary' ) );
+			if ( ! ctype_digit( $char ) )
+				return self::set_error( new Exception( 'Invalid dictionary key' ) );
+			$key = self::decode_string( $data );
+			if ( isset( $dictionary[$key] ) )
+				return self::set_error( new Exception( 'Duplicate dictionary key' ) );
+			if ( $key < $previous )
+				return self::set_error( new Exception( 'Missorted dictionary key' ) );
+			$dictionary[$key] = self::decode_data( $data );
+			$previous = $key;
+		}
+		$data = substr( $data, 1 );
+		return $dictionary;
+	}
+
+	/** Decode torrent list
+	 * @param string data to decode
+	 * @return array decoded list
+	 */
+	static private function decode_list ( & $data ) {
+		$list = array();
+		while ( ( $char = self::char( $data ) ) != 'e' ) {
+			if ( $char === false )
+				return self::set_error( new Exception( 'Unterminated list' ) );
+			$list[] = self::decode_data( $data );
+		}
+		$data = substr( $data, 1 );
+		return $list;
+	}
+
+	/** Decode torrent string
+	 * @param string data to decode
+	 * @return string decoded string
+	 */
+	static private function decode_string ( & $data ) {
+		if ( self::char( $data ) === '0' && substr( $data, 1, 1 ) != ':' )
+			self::set_error( new Exception( 'Invalid string length, leading zero' ) );
+		if ( ! $colon = @strpos( $data, ':' ) )
+			return self::set_error( new Exception( 'Invalid string length, colon not found' ) );
+		$length = intval( substr( $data, 0, $colon ) );
+		if ( $length + $colon + 1 > strlen( $data ) )
+			return self::set_error( new Exception( 'Invalid string, input too short for string length' ) );
+		$string = substr( $data, $colon + 1, $length );
+		$data = substr( $data, $colon + $length + 1 );
+		return $string;
+	}
+
+	/** Decode torrent integer
+	 * @param string data to decode
+	 * @return integer decoded integer
+	 */
+	static private function decode_integer ( & $data ) {
+		$start = 0;
+		$end   = strpos( $data, 'e');
+		if ( $end === 0 )
+			self::set_error( new Exception( 'Empty integer' ) );
+		if ( self::char( $data ) == '-' )
+			$start++;
+		if ( substr( $data, $start, 1 ) == '0' && $end > $start + 1 )
+			self::set_error( new Exception( 'Leading zero in integer' ) );
+		if ( ! ctype_digit( substr( $data, $start, $start ? $end - 1 : $end ) ) )
+			self::set_error( new Exception( 'Non-digit characters in integer' ) );
+		$integer = substr( $data, 0, $end );
+		$data    = substr( $data, $end + 1 );
+		return 0 + $integer;
+	}
+
+	/**** Internal Helpers ****/
+
+	/** Build torrent info
+	 * @param string|array source folder/file(s) path
+	 * @param integer piece length
+	 * @return array|boolean torrent info or false if data isn't folder/file(s)
+	 */
+	protected function build ( $data, $piece_length ) {
+		if ( is_null( $data ) )
+			return false;
+		elseif ( is_array( $data ) && self::is_list( $data ) )
+			return $this->info = $this->files( $data, $piece_length );
+		elseif ( is_dir( $data ) )
+			return $this->info = $this->folder( $data, $piece_length );
+		elseif ( ( is_file( $data ) || self::url_exists( $data ) ) && ! self::is_torrent( $data ) )
+			return $this->info = $this->file( $data, $piece_length );
+		else
+			return false;
+	}
+
+	/** Set torrent creator and creation date
+	 * @param any param
+	 * @return any param
+	 */
+	protected function touch ( $void = null ) {
+		$this->{'created by'}		= 'Torrent RW PHP Class - http://github.com/adriengibrat/torrent-rw';
+		$this->{'creation date'}	= time();
+		return $void;
+	}
+
+	/** Add an error to errors stack
+	 * @param Exception error to add
+	 * @param boolean return error message or not (optional, default to false)
+	 * @return boolean|string return false or error message if requested
+	 */
+	static protected function set_error ( $exception, $message = false ) {
+		return ( array_unshift( self::$_errors, $exception ) && $message ) ? $exception->getMessage() : false;
+	}
+
+	/** Build announce list
+	 * @param string|array announce url / list
+	 * @param string|array announce url / list to add (optionnal)
+	 * @return array announce list (array of arrays)
+	 */
+	static protected function announce_list( $announce, $merge = array() ) {
+		return array_map( create_function( '$a', 'return (array) $a;' ), array_merge( (array) $announce, (array) $merge ) );
+	}
+
+	/** Get the first announce url in a list
+	 * @param array announce list (array of arrays if tiered trackers)
+	 * @return string first announce url
+	 */
+	static protected function first_announce( $announce ) {
+		while ( is_array( $announce ) )
+			$announce = reset( $announce );
+		return $announce;
+	}
+
+	/** Helper to pack data hash
+	 * @param string data
+	 * @return string packed data hash
+	 */
+	static protected function pack ( & $data ) {
+		return pack('H*', sha1( $data ) ) . ( $data = null );
+	}
+
+	/** Helper to build file path
+	 * @param array file path
+	 * @param string base folder
+	 * @return string real file path
+	 */
+	static protected function path ( $path, $folder ) {
+		array_unshift( $path, $folder );
+		return join( DIRECTORY_SEPARATOR, $path );
+	}
+
+	/** Helper to test if an array is a list
+	 * @param array array to test
+	 * @return boolean is the array a list or not
+	 */
+	static protected function is_list ( $array ) {
+		foreach ( array_keys( $array ) as $key )
+			if ( ! is_int( $key ) )
+				return false;
+		return true;
+	}
+
+	/** Build pieces depending on piece length from a file handler
+	 * @param ressource file handle
+	 * @param integer piece length
+	 * @param boolean is last piece
+	 * @return string pieces
+	 */
+	private function pieces ( $handle, $piece_length, $last = true ) {
+		static $piece, $length;
+		if ( empty( $length ) )
+			$length	= $piece_length;
+		$pieces = null;
+		while ( ! feof( $handle ) ) {
+			if ( ( $length = strlen( $piece .= fread( $handle, $length ) ) ) == $piece_length )
+				$pieces .= self::pack( $piece );
+			elseif ( ( $length = $piece_length - $length ) < 0 )
+				return self::set_error( new Exception( 'Invalid piece length!' ) );
+		}
+		fclose( $handle );
+		return $pieces . ( $last && $piece ? self::pack( $piece ) : null);
+	}
+
+	/** Build torrent info from single file
+	 * @param string file path
+	 * @param integer piece length
+	 * @return array torrent info
+	 */
+	private function file ( $file, $piece_length ) {
+		if ( ! $handle = self::fopen( $file, $size = self::filesize( $file ) ) )
+			return self::set_error( new Exception( 'Failed to open file: "' . $file . '"' ) );
+		if ( self::is_url( $file ) )
+			$this->url_list( $file );
+		$path = explode( DIRECTORY_SEPARATOR, $file );
+		return array(
+			'length'	=> $size,
+			'name'		=> end( $path ),
+			'piece length'	=> $piece_length,
+			'pieces'	=> $this->pieces( $handle, $piece_length )
+		);
+	}
+
+	/** Build torrent info from files
+	 * @param array file list
+	 * @param integer piece length
+	 * @return array torrent info
+	 */
+	private function files ( $files, $piece_length ) {
+		if ( ! self::is_url( current( $files ) ) )
+			$files = array_map( 'realpath', $files );
+		sort( $files );
+		usort( $files, create_function( '$a,$b', 'return strrpos($a,DIRECTORY_SEPARATOR)-strrpos($b,DIRECTORY_SEPARATOR);' ) );
+		$first	= current( $files );
+		$root	= dirname( $first );
+		if ( $url = self::is_url( $first ) )
+			$this->url_list( dirname( $root ) . DIRECTORY_SEPARATOR );
+		$path	= explode( DIRECTORY_SEPARATOR, dirname( $url ? $first : realpath( $first ) ) );
+		$pieces = null; $info_files = array(); $count = count( $files ) - 1;
+		foreach ( $files as $i => $file ) {
+			if ( $path != array_intersect_assoc( $file_path = explode( DIRECTORY_SEPARATOR, $file ), $path ) ) {
+				self::set_error( new Exception( 'Files must be in the same folder: "' . $file . '" discarded' ) );
+				continue;
+			}
+			if ( ! $handle = self::fopen( $file, $filesize = self::filesize( $file ) ) ) {
+				self::set_error( new Exception( 'Failed to open file: "' . $file . '" discarded' ) );
+				continue;
+			}
+			$pieces .= $this->pieces( $handle, $piece_length, $count == $i );
+			$info_files[] = array(
+				'length'	=> $filesize,
+				'path'		=> array_diff( $file_path, $path )
+			);
+		}
+		return array(
+			'files'		=> $info_files,
+			'name'		=> end( $path ),
+			'piece length'	=> $piece_length,
+			'pieces'	=> $pieces
+		);
+
+	}
+
+	/** Build torrent info from folder content
+	 * @param string folder path
+	 * @param integer piece length
+	 * @return array torrent info
+	 */
+	private function folder ( $dir, $piece_length ) {
+		return $this->files( self::scandir( $dir ), $piece_length );
+	}
+
+	/** Helper to return the first char of encoded data
+	 * @param string encoded data
+	 * @return string|boolean first char of encoded data or false if empty data
+	 */
+	static private function char ( $data ) {
+		return empty( $data ) ?
+			false :
+			substr( $data, 0, 1 );
+	}
+
+	/**** Public Helpers ****/
+
+	/** Helper to format size in bytes to human readable
+	 * @param integer size in bytes
+	 * @param integer precision after coma
+	 * @return string formated size in appropriate unit
+	 */
+	static public function format ( $size, $precision = 2 ) {
+		$units = array ('octets', 'Ko', 'Mo', 'Go', 'To');
+		while( ( $next = next( $units ) ) && $size > 1024 )
+			$size /= 1024;
+		return round( $size, $precision ) . ' ' . ( $next ? prev( $units ) : end( $units ) );
+	}
+
+	/** Helper to return filesize (even bigger than 2Gb -linux only- and distant files size)
+	 * @param string file path
+	 * @return double|boolean filesize or false if error
+	 */
+	static public function filesize ( $file ) {
+		if ( is_file( $file ) )
+			return (double) sprintf( '%u', @filesize( $file ) );
+		else if ( $content_length = preg_grep( $pattern = '#^Content-Length:\s+(\d+)$#i', (array) @get_headers( $file ) ) )
+			return (int) preg_replace( $pattern, '$1', reset( $content_length ) );
+	}
+
+	/** Helper to open file to read (even bigger than 2Gb, linux only)
+	 * @param string file path
+	 * @param integer|double file size (optional)
+	 * @return ressource|boolean file handle or false if error
+	 */
+	static public function fopen ( $file, $size = null ) {
+		if ( ( is_null( $size ) ? self::filesize( $file ) : $size ) <= 2 * pow( 1024, 3 ) )
+			return fopen( $file, 'r' );
+		elseif ( PHP_OS != 'Linux' )
+			return self::set_error( new Exception( 'File size is greater than 2GB. This is only supported under Linux' ) );
+		elseif ( ! is_readable( $file ) )
+			return false;
+		else
+			return popen( 'cat ' . escapeshellarg( realpath( $file ) ), 'r' );
+	}
+
+	/** Helper to scan directories files and sub directories recursivly
+	 * @param string directory path
+	 * @return array directory content list
+	 */
+	static public function scandir ( $dir ) {
+		$paths = array();
+		foreach ( scandir( $dir ) as $item )
+				if ( $item != '.' && $item != '..' )
+					if ( is_dir( $path = realpath( $dir . DIRECTORY_SEPARATOR . $item ) ) )
+						$paths = array_merge( self::scandir( $path ), $paths );
+					else
+						$paths[] = $path;
+		return $paths;
+	}
+
+	/** Helper to check if string is an url (http)
+	 * @param string url to check
+	 * @return boolean is string an url
+	 */
+	static public function is_url ( $url ) {
+		return preg_match( '#^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$#i', $url );
+	}
+
+	/** Helper to check if url exists
+	 * @param string url to check
+	 * @return boolean does the url exist or not
+	 */
+	static public function url_exists ( $url ) {
+		return self::is_url( $url ) ?
+			(bool) self::filesize ( $url ) :
+			false;
+	}
+	/** Helper to check if a file is a torrent
+	 * @param string file location
+	 * @param float http timeout (optional, default to self::timeout 30s)
+	 * @return boolean is the file a torrent or not
+	 */
+	static public function is_torrent ( $file, $timeout = self::timeout ) {
+		return ( $start = self::file_get_contents( $file, $timeout, 0, 11 ) )
+			 && $start === 'd8:announce'
+			 || $start === 'd10:created'
+			 || $start === 'd13:creatio'
+			 || substr($start, 0, 7) === 'd4:info'
+			 || substr($start, 0, 3) === 'd9:'; // @see https://github.com/adriengibrat/torrent-rw/pull/17
+	}
+
+	/** Helper to get (distant) file content
+	 * @param string file location
+	 * @param float http timeout (optional, default to self::timeout 30s)
+	 * @param integer starting offset (optional, default to null)
+	 * @param integer content length (optional, default to null)
+	 * @return string|boolean file content or false if error
+	 */
+	static public function file_get_contents ( $file, $timeout = self::timeout, $offset = null, $length = null ) {
+		if ( is_file( $file ) || ini_get( 'allow_url_fopen' ) ) {
+			$context = ! is_file( $file ) && $timeout ? 
+				stream_context_create( array( 'http' => array( 'timeout' => $timeout ) ) ) : 
+				null;
+			return ! is_null( $offset ) ? $length ?
+				@file_get_contents( $file, false, $context, $offset, $length ) : 
+				@file_get_contents( $file, false, $context, $offset ) : 
+				@file_get_contents( $file, false, $context );
+		} elseif ( ! function_exists( 'curl_init' ) )
+			return self::set_error( new Exception( 'Install CURL or enable "allow_url_fopen"' ) );
+		$handle = curl_init( $file );
+		if ( $timeout )
+			curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
+		if ( $offset || $length )
+			curl_setopt( $handle, CURLOPT_RANGE, $offset . '-' . ( $length ? $offset + $length -1 : null ) );
+		curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 );
+		$content = curl_exec( $handle );
+		$size = curl_getinfo( $handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD );
+		curl_close( $handle );
+		return ( $offset && $size == -1 ) || ( $length && $length != $size ) ? $length ?
+			substr( $content, $offset, $length) :
+			substr( $content, $offset) :
+			$content;
+	}
+
+	/** Flatten announces list
+	 * @param array announces list
+	 * @return array flattened annonces list
+	 */
+	static public function untier( $announces ) {
+		$list = array();
+		foreach ( (array) $announces as $tier ) {
+			is_array( $tier ) ? 
+				$list = array_merge( $list, self::untier( $tier ) ) :
+				array_push( $list, $tier );
+		}
+		return $list;
+	}
+
+}

+ 23 - 0
admin/utils/tortomagnet.php

@@ -0,0 +1,23 @@
+<?php
+
+/* 
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+require_once 'Torrent.php';
+
+//var_dump($_FILES["file"]["tmp_name"]);
+$torrent = new Torrent( $_FILES["file"]["tmp_name"] );
+/*echo '<table>';
+echo '<tr>';
+echo '<tr><td>private</td><td>', $torrent->is_private() ? 'yes' : 'no','</td></tr>'; 
+echo '<tr><td>annonce</td><td> ', $torrent->announce(),'</td></tr>';
+echo '<tr><td>name</td><td> ', $torrent->name(), '</td></tr>';
+echo '<tr><td>comment</td><td> ', $torrent->comment(), '</td></tr>';
+echo '<tr><td>piece_length</td><td> ', $torrent->piece_length(), '</td></tr>';
+echo '<tr><td>size</td><td> ', $torrent->size( 2 ),'</td></tr>';
+echo '<tr><td>hash info</td><td> ', $torrent->hash_info(),'</td></tr>';*/
+// get magnet link
+echo  $torrent->magnet();

+ 31 - 0
admin/utils/utils.php

@@ -0,0 +1,31 @@
+<?php
+
+/* 
+ * Copyright (C) 2015 bnj
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+function adm_ispage($param) {
+        if (isset($_GET['psub_id'])) {
+            if($param == $_GET['psub_id']){
+                echo "class='active'";
+            }
+        }else{
+            if($param==0){
+                echo "class='active'";
+            }
+        }       
+ }

+ 55 - 0
admin/view/Shows.php

@@ -5,4 +5,59 @@
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
  */
+?>
+<section class="admin">
+    <h2>Shows</h2>
+    <div>
+    <form>
+        
+        Name : <input id="name_tb" type="text" name="name">
+        TVDB id : <input id="tvdbid_tb" type="text" name="tvdbid"><br>
+        Followed : <input id="followed_tb" type="text" name="followed">
+        HDD Name : <input id="hddname_tb" type="text" name="hddname"><br>
+        Poster id : <input id="posterid_tb" type="text" name="posterid">
+        Banner id : <input id="bannerid_tb" type="text" name="bannerid"><br>
+        Display Name : <input id="displayname_tb" type="text" name="displayname">
+        <a href="#" class="addbut" onclick='add_show()'>Add</a>
+    </form>
+    </div>
+    
+    
+    
+    
+    
+    
+    
+      <table class="disk_status  right">
+        <thead>
+            <tr>  <td>ID </td><td>Name</td>  <td>TVDB ID</td><td>Display Name</td></tr>
+        </thead>
+           
+<tbody id="array_devices">
+<?php    
+    $booll=TRUE;
+        $tordata = $bdd->query('SELECT * FROM  `TVS_shows` ');
+                while ($tordatarow = $tordata->fetch()) {
+           
+                    if ($booll) {
+                        echo '<tr class="tr_row0"> ';
+                    }else{
+                        echo '<tr class="tr_row1"> ';
+                    }
+    $booll = !$booll;
+    
+    
+    echo '  <td>' . $tordatarow["ID"].'</td>';
+    echo '<td>' . $tordatarow["Name"].'</td>';
+    echo '<td>' . $tordatarow["tvdbid"].'</td>';
+    echo '<td>'. $tordatarow["display_name"].'</td>';
+   
+    
+        }
+    ?>
+</tbody>
+    </table>
+ 
+    
 
+</section>

+ 12 - 16
admin/view/admin_menu.php

@@ -5,30 +5,26 @@
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
  */
-
-function adm_ispage($param) {
-        if (isset($_GET['psub_id'])) {
-            if($param == $_GET['psub_id']){
-                echo "class='active'";
-            }
-        }else{
-            if($param==0){
-                echo "class='active'";
-            }
-        }
-        
-    }
-
 ?>
 <div id='admin_menu'>
     <div>
         <ul>
             <li <?php adm_ispage(0) ?>><a href='index.php?page_id=43&psub_id=0'><span>Home</span></a></li>
-            <li <?php adm_ispage(1) ?> ><a href='index.php?page_id=43&psub_id=1'><span>Users</span></a></li>
             <li <?php adm_ispage(2) ?> ><a href='index.php?page_id=43&psub_id=2'><span>History</span></a></li>
             <li <?php adm_ispage(3) ?> ><a href='index.php?page_id=43&psub_id=3'><span>Add Torrent</span></a></li>
+            <li <?php adm_ispage(5) ?>><a href='index.php?page_id=43&psub_id=5'><span>In Progress</span></a></li>
+            <?php
+                if($GLOBALS["isSAdmin"]){
+            ?>
+            <li <?php adm_ispage(8) ?> ><a href='index.php?page_id=43&psub_id=8'><span>Shows</span></a></li>
+            <li <?php adm_ispage(1) ?> ><a href='index.php?page_id=43&psub_id=1'><span>Users</span></a></li>
+            <li <?php adm_ispage(7) ?> ><a href='index.php?page_id=43&psub_id=7'><span>Sources</span></a></li>
             <li <?php adm_ispage(4) ?>><a href='index.php?page_id=43&psub_id=4'><span>Config</span></a></li>
-             <li <?php adm_ispage(5) ?>><a href='index.php?page_id=43&psub_id=5'><span>In Progress</span></a></li>
+            <li <?php adm_ispage(6) ?>><a href='index.php?page_id=43&psub_id=6'><span>Missing Episodes</span></a></li>
+             
+             <?php
+             }?>
+             
         </ul>
     </div>
 </div>

+ 27 - 13
admin/view/home.php

@@ -21,29 +21,43 @@ $rest = $status->fetch();
 
 <section class="admin">
     <h2>Home</h2>
+    <div class="admindiv">
 
-
-
-    <div> <?php echo $last1['time']; ?> min </div> 
-    <div> <?php echo $last2['time']; ?> min </div> 
-    <div> <?php echo $last3['time']; ?> min </div> 
+    <table style="width:100%">
+        <tr>
+            <td>Torrent Supplier</td>
+            <td> <?php echo $last1['time']; ?> min</td>
+        </tr>
+         <tr>
+            <td>Torrent Monitor</td>
+            <td> <?php echo $last2['time']; ?> min</td>
+        </tr>
+         <tr>
+            <td>Torrent Getter</td>
+            <td> <?php echo $last3['time']; ?> min</td>
+        </tr>
+    </table>
+  
 
     <table style="width:100%">
         <tr>
             <td>Server ext</td> 
-            <td><?php echo $rest['trans']; ?></td> <td><?php echo formatBytes($rest['free_1']); ?></td>
+            <td><?php echo $rest['trans']; ?></td>
+            <td><div id="progress" class="graph"><div id="bar" style="width:<?php echo $rest['free_1']/7000000000; ?>%"><p><?php echo  formatBytes($rest['free_1']); ?></p></div></div></td>
+            <td> </td>
         </tr>
         <tr>
             <td>Server vpn</td>
-            <td><?php echo $rest['trans2']; ?></td> <td><?php echo formatBytes($rest['free_2']); ?></td> 
+            <td><?php echo $rest['trans2']; ?></td>
+            <td><div id="progress" class="graph"><div id="bar" style="width:<?php echo $rest['free_2']/7000000000; ?>%"><p><?php echo  formatBytes($rest['free_2']); ?></p></div></div></td>
+           
+
         </tr>
         <tr>
             <td>Distant vpn</td>
-            <td><?php echo $rest['transdist']; ?></td><td><?php echo formatBytes($rest['free_d']); ?></td>
-        </tr>
-
-
-
+            <td><?php echo $rest['transdist']; ?></td>
+          <td><div id="progress" class="graph"><div id="bar" style="width:<?php echo $rest['free_d']/7000000000; ?>%"><p><?php echo  formatBytes($rest['free_d']); ?></p></div></div></td>
+                 </tr>
     </table>
 
 
@@ -73,7 +87,7 @@ $rest = $status->fetch();
                 <span class="onoffswitch-switch"></span>
             </label>
         </div>
-        
+    </div>    
 </section>
 
 

+ 174 - 9
admin/view/manually_add.php

@@ -1,6 +1,5 @@
 <?php
-
-/* 
+/*
  * To change this license header, choose License Headers in Project Properties.
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
@@ -8,11 +7,177 @@
 ?>
 
 
-<section class="new_item">
-    <h2>Add Torrent</h2>
-    <form>
-        <textarea id="tamagnet" rows="6" cols="80" ></textarea>
-         <a href="#" class="addbut" onclick="add_torrent()">Add</a>
+<section class="admin">
+    <h2>Type</h2>
+    <div class="admindiv">
+        <form>
+            <div class="toggle">
+                <label><input type="radio" name="toggle" value="2" checked="checked"><span class="input-checked" >Normal</span></label>    
+            </div>
+            <div class="toggle">
+                <label><input type="radio" name="toggle" value="3"><span>Music</span></label>
+            </div>
+            <div class="toggle">
+                <label><input type="radio" name="toggle" value="1"><span>TV Show</span></label>
+            </div>
+            <div id="show_form" style="display: none">
+            <select id="show_sel" name="show">
+        <?php    
+            $shows_list = $bdd->query('SELECT * FROM  `TVS_shows`');
+            while ($show = $shows_list->fetch()) {
+                echo '<option value="'.$show["ID"].'">'.$show["Name"].'</option>';
+            }
+        ?>
+        </select>
+                S<input id="season" type="number" name="Season" size="3">
+            E<input id="episode" type="number" name="Episode" size="3">
+            <select id="quality_sel" name="quality">
+                <option value="FHD">FHD</option>
+                <option value="HD">HD</option>
+                <option value="SD">SD</option>
+                <option value="NA">NA</option>
+            </select>
+            </div>
+        </form>
+    </div>
+    <script>
+        $('label').click(function(){
+    $(this).children('span').addClass('input-checked');
+    $(this).parent('.toggle').siblings('.toggle').children('label').children('span').removeClass('input-checked');
+    if($(this).children('input')[0].value === "1"){
+        document.getElementById('show_form').style.display = 'block';;
+    }else{
+        document.getElementById('show_form').style.display = 'none';
+    }
+});
+    </script>
+</section>
+
+<section class="admin">
+    <h2>Add Magnet</h2>
+    <div class="admindiv">
+        <form>
+            <textarea id="tamagnet" rows="6" placeholder="Magnet Link ( start with magnet:?xt= )" ></textarea>
+            <p>
+                <a href="#" class="addbut" onclick='add_torrent("tamagnet")'>Add</a>
+            </p>
         </form>
- </section> 
- 
+    </div>
+</section>
+
+<section class="admin">
+    <h2>Add Torrent</h2>
+    <div class="admindiv">
+        <article>
+            <div id="holder">
+                <span>
+                    Drag'n'Drop .torrent file here !
+                </span>
+            </div> 
+            <div id="tormagnet">
+            </div> 
+            <p id="upload" class="hidden">
+                <label>
+                    Drag & drop not supported, but you can still upload via this input field:<br>
+                    <input type="file">
+                </label>
+            </p>
+            <p id="filereader">
+                File API & FileReader API not supported
+            </p>
+            <p id="formdata">
+                XHR2's FormData is not supported
+            </p>
+            <p id="progress">
+                XHR2's upload progress isn't supported
+            </p>
+        </article>
+        <p> 
+            <a id="buttoradd" href="#" style="display:none" class="addbut" onclick="add_torrentt('tormagnet')">Add</a>
+        </p> 
+    </div> 
+    <script>
+        var holder = document.getElementById('holder'),
+                tests = {
+                    filereader: typeof FileReader != 'undefined',
+                    dnd: 'draggable' in document.createElement('span'),
+                    formdata: !!window.FormData,
+                    progress: "upload" in new XMLHttpRequest
+                },
+        support = {
+            filereader: document.getElementById('filereader'),
+            formdata: document.getElementById('formdata'),
+            progress: document.getElementById('progress')
+        },
+        acceptedTypes = {
+            'image/png': true,
+            'image/jpeg': true,
+            'image/gif': true
+        },
+        progress = document.getElementById('uploadprogress'),
+                fileupload = document.getElementById('upload');
+
+        "filereader formdata progress".split(' ').forEach(function (api) {
+            if (tests[api] === false) {
+                support[api].className = 'fail';
+            } else {
+                // FFS. I could have done el.hidden = true, but IE doesn't support
+                // hidden, so I tried to create a polyfill that would extend the
+                // Element.prototype, but then IE10 doesn't even give me access
+                // to the Element object. Brilliant.
+                support[api].className = 'hidden';
+            }
+        });
+
+        function readfiles(files) {
+            debugger;
+            var formData = tests.formdata ? new FormData() : null;
+            for (var i = 0; i < files.length; i++) {
+                if (tests.formdata)
+                    formData.append('file', files[i]);
+
+            }
+
+            // now post a new XHR request
+            if (tests.formdata) {
+                var xhr = new XMLHttpRequest();
+                xhr.open('POST', '/admin/utils/tortomagnet.php');
+
+                xhr.onreadystatechange = function () {
+                    if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
+                        document.getElementById('holder').style.display = 'none';
+                        document.getElementById('buttoradd').style.display = 'block';
+                        document.getElementById("tormagnet").innerHTML = xhr.responseText;
+                        // callback(xhr.responseXML);
+                    }
+                };
+
+                xhr.send(formData);
+            }
+        }
+
+        if (tests.dnd) {
+            holder.ondragover = function () {
+                this.className = 'hover';
+                return false;
+            };
+            holder.ondragend = function () {
+                this.className = '';
+                return false;
+            };
+            holder.ondrop = function (e) {
+                this.className = '';
+                e.preventDefault();
+                readfiles(e.dataTransfer.files);
+            }
+        } else {
+            fileupload.className = 'hidden';
+            fileupload.querySelector('input').onchange = function () {
+                readfiles(this.files);
+            };
+        }
+
+    </script>
+
+</section> 
+

File diff suppressed because it is too large
+ 31 - 0
admin/view/missing.php


+ 60 - 1
admin/view/sources.php

@@ -9,7 +9,66 @@
 ?>
 <section class="admin">
     <h2>Sources</h2>
-      
+    <div>
+    <form>
+        <select id="show_sel" name="show">
+        <?php    
+            $shows_list = $bdd->query('SELECT * FROM  `TVS_shows`');
+            while ($show = $shows_list->fetch()) {
+                echo '<option value="'.$show["ID"].'">'.$show["Name"].'</option>';
+            }
+        ?>
+        </select>
+        <select id="supplier_sel" name="supplier">
+        <?php    
+            $supplier_list = $bdd->query('SELECT * FROM  `supplier` ');
+            while ($supplier = $supplier_list->fetch()) {
+                echo '<option value="'.$supplier["id"].'">'.$supplier["name"].'</option>';
+            }
+        ?>
+        </select>
+        <input id="regexp_tb" type="text" name="RegExp">
+        <a href="#" class="addbut" onclick='add_source()'>Add</a>
+    </form>
+    </div>
+    
+    
+    
+    
+    
+    
+    
+      <table class="disk_status  right">
+        <thead>
+            <tr>  <td>ID </td><td>Name</td>  <td>Supplier</td><td>RegExp</td></tr>
+        </thead>
+           
+<tbody id="array_devices">
+<?php    
+    $booll=TRUE;
+        $tordata = $bdd->query('SELECT * FROM  `sources`,`TVS_shows`  WHERE `TVS_shows`.`id`= `sources`.`tvshows_id` ');
+                while ($tordatarow = $tordata->fetch()) {
+           
+                    if ($booll) {
+                        echo '<tr class="tr_row0"> ';
+                        
+                    }else{
+                        echo '<tr class="tr_row1"> ';
+                    }
+    $booll = !$booll;
+    
+    
+    echo '  <td>' . $tordatarow["id"].'</td>';
+    echo '<td>' . $tordatarow["Name"].'</td>';
+    echo '<td>' . $tordatarow["supplier_id"].'</td>';
+    echo '<td>'. $tordatarow["regexp"].'</td>';
+   
+    
+        }
+    ?>
+</tbody>
+    </table>
+ 
     
 
 </section>

+ 42 - 6
admin/view/tor_in_progress.php

@@ -7,21 +7,57 @@
 ?>
 <section class="admin">
     <h2>Torrent In Progress</h2>
-    <table>
-       <tr>  <th>ID </th><th>Name</th>  <th>State</th><th>EXT</th> <th>VPN</th><th>Added</th>   </tr>
-
+   <!-- <div class="admindiv"> -->
+    <table class="disk_status  right">
+        <thead>
+            <tr>  <td>ID </td><td>Name</td>  <td>State</td><td>EXT</td> <td>VPN</td></tr>
+        </thead>
+           
+<tbody id="array_devices">
 <?php    
-        $tordata = $bdd->query('SELECT * FROM  `torrent_data` WHERE  `state`<>7 ');
+    $booll=TRUE;
+        $tordata = $bdd->query('SELECT * FROM  `torrent_data` WHERE  `state`<7 ');
                 while ($tordatarow = $tordata->fetch()) {
            
+                    if ($booll) {
+                        echo '<tr class="tr_row0"> ';
+                        
+                    }else{
+                        echo '<tr class="tr_row1"> ';
+                    }
+    $booll = !$booll;
+    
+    
+    echo '  <td>' . $tordatarow["id"].'</td>';
+    echo '<td>' . $tordatarow["modif_hash"].'</td>';
+    echo '<td>' . $tordatarow["state"].'</td>';
+    echo '<td><div  class="usage-disk"><span style="margin:0; width:' . $tordatarow["percent"].'%"><span>' . $tordatarow["percent"].'%</span></div></span></td>';
+    echo '<td><div  class="usage-disk"><span style="margin:0;width:' . $tordatarow["percent_dist"].'%"><span>' . $tordatarow["percent_dist"].'%</span></span></div></td>';
+   // echo '<td>' . $tordatarow["timeadded"].'</td>';
+    
+  /*  echo '<td><select name="c" id="numstate'.$tordatarow["id"].'" >
+        <option value="0">Etat Initial - à mettre en DL</option>
+        <option value="1">DL en cours sur serveur</option>
+        <option value="2">Verification sur serveur</option>
+        <option value="3">DL en cours à la maison</option>
+        <option value="4">Verification Maison</option>
+        <option value="5">Audi</option>
+        <option value="7">Fini < 4 mois</option>
+        <option value="8">Fini > 4 mois</option>
+        <option value="9">Fini et supprimé</option>
+        <option value="21">A supprimer</option>
+        </select></td>';
+    */
     
-    echo '<tr>  <td>' . $tordatarow["id"].'</td><td>' . $tordatarow["modif_hash"].'</td>  <td>' . $tordatarow["state"].'</td><td>' . $tordatarow["percent"].'</td> <td>' . $tordatarow["percent_dist"].'</td>  <td>' . $tordatarow["timeadded"].'</td> <td><input type="number" id="numstate'.$tordatarow["id"].'" /></td><td><a href="#" class="addbut" onclick="modify_state('.$tordatarow["id"].')">Modify</a></td>'
-            . '  </tr>';
+    //echo '<td><a href="#" class="addbut" onclick="modify_state('.$tordatarow["id"].')">Modify</a></td>'
+      //      . '  </tr>';
 
     
         }
     ?>
+</tbody>
     </table>
+   <!-- </div> -->
 </section>
 
 

+ 2 - 1
admin/view/user.php

@@ -10,6 +10,7 @@
 
 <section class="admin">
     <h2>Users</h2>
+    <div class="admindiv">
     <div id="UserTable" onload="showUsertable();"></div>
 
 
@@ -22,7 +23,7 @@
 
 
     </form>
-
+    </div>
 </section>
 
 

+ 0 - 72
bdd.php

@@ -1,72 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-try {
-    // On se connecte à MySQL
-    $bdd = new PDO('mysql:host=10.5.0.21;dbname=tv_shows', 'tv_shows', 'YfAUKKGwv8dm8NXV');
-} catch (Exception $e) {
-    // En cas d'erreur, on affiche un message et on arrête tout
-    die('Erreur : ' . $e->getMessage());
-}
-
-function isUser() {
-    $seluser = $GLOBALS["bdd"]->query('SELECT * FROM users ');
-    while ($userdata = $seluser->fetch()) {
-        if ($userdata["ip"] ==  get_client_ip()) {
-            break;
-        }
-    }
-    $seluser->closeCursor(); // Termine le traitement de la requête
-    if ($userdata["ip"] !=  get_client_ip()) {
-
-       $seluser = $GLOBALS["bdd"]->query('INSERT INTO  `tv_shows`.`unauthorized` (`id` ,`ip` ,`time` ,`page`,`cert`) VALUES (NULL ,  \'' .  get_client_ip() . '\',CURRENT_TIMESTAMP ,  \'' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . '\', \'' . $_SERVER["HTTP_SSL_CLIENT_S_DN"] . '\' );');
-
-
-        return FALSE;
-    } else {
-         $GLOBALS["bdd"]->query('UPDATE `tv_shows`.`users` SET `last_login` =CURRENT_TIMESTAMP()  WHERE `users`.`id` = '.$userdata["id"].';');
-
-        
-        return TRUE;
-    }
-}
-
-
-function isAdmin() {
-    $seluser = $GLOBALS["bdd"]->query('SELECT * FROM users ');
-    while ($userdata = $seluser->fetch()) {
-        if ($userdata["ip"] ==  get_client_ip()) {
-            break;
-        }
-    }
-    $seluser->closeCursor(); // Termine le traitement de la requête
-    if ($userdata["admin"] != '1') {
-       $seluser = $GLOBALS["bdd"]->query('INSERT INTO  `tv_shows`.`unauthorized` (`id` ,`ip` ,`time` ,`page`,`cert`) VALUES (NULL ,  \'' . get_client_ip() . '\',CURRENT_TIMESTAMP ,  \'' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . '\', \'' . $_SERVER["HTTP_SSL_CLIENT_S_DN"] . '\' );');
-       $GLOBALS["isAdmin"]=FALSE;
-       return FALSE;
-    } else {
-        $GLOBALS["isAdmin"]=TRUE;
-        return TRUE;
-    }
-}
-
-function isMaintenance() {
-    $reqmaint = $GLOBALS["bdd"]->query('SELECT  `Value` FROM  `config` WHERE  `Section` =  "web" AND  `Setting` =  "maintenance"');
-    $maintval = $reqmaint->fetch();
-    $reqmaint->closeCursor(); // Termine le traitement de la requête
-  
-    return $maintval["Value"]==="1" && !$GLOBALS["isAdmin"] ;   
-}
-
-function getThemes() {
-    $reqmaint = $GLOBALS["bdd"]->query('SELECT  `Value` FROM  `config` WHERE  `Section` =  "web" AND  `Setting` =  "theme"');
-    $maintval = $reqmaint->fetch();
-    $reqmaint->closeCursor(); // Termine le traitement de la requête
-    
-    return $maintval["Value"];   
-}

BIN
cache/-g.jpg


BIN
cache/108611-1.jpg


BIN
cache/108611-g.jpg


BIN
cache/121361-13.jpg


BIN
cache/121361-g19.jpg


BIN
cache/153021-1.jpg


BIN
cache/153021-g.jpg


BIN
cache/164301-1.jpg


BIN
cache/164301-g10.jpg


BIN
cache/164541-1.jpg


BIN
cache/164541-g5.jpg


BIN
cache/176941-1.jpg


BIN
cache/176941-g.jpg


+ 0 - 0
cache/248742-.jpg


BIN
cache/248742-1.jpg


BIN
cache/248742-g10.jpg


BIN
cache/248835-10.jpg


BIN
cache/248835-g8.jpg


BIN
cache/248841-1.jpg


BIN
cache/248841-g.jpg


BIN
cache/255316-1.jpg


BIN
cache/255316-g.jpg


BIN
cache/257655-1.jpg


BIN
cache/257655-g.jpg


BIN
cache/258171-g9.jpg


BIN
cache/258823-1.jpg


BIN
cache/258823-g8.jpg


BIN
cache/259569-1.jpg


BIN
cache/259569-g.jpg


+ 0 - 0
cache/261557-1.jpg


BIN
cache/261557-g.jpg


BIN
cache/263365-1.jpg


BIN
cache/263365-g.jpg


BIN
cache/265912-1.jpg


BIN
cache/265912-g6.jpg


BIN
cache/267260-1.jpg


BIN
cache/267260-g.jpg


BIN
cache/269591-1.jpg


BIN
cache/269591-g.jpg


BIN
cache/269604-4.jpg


BIN
cache/269604-g.jpg


BIN
cache/278125-g2.jpg


BIN
cache/278155-1.jpg


BIN
cache/278155-g.jpg


BIN
cache/73762-g21.jpg


+ 0 - 0
cache/75682-.jpg


BIN
cache/75682-1.jpg


BIN
cache/75682-10.jpg


BIN
cache/75682-g10.jpg


BIN
cache/75760-1.jpg


BIN
cache/75760-g.jpg


BIN
cache/78804-1.jpg


BIN
cache/78804-50.jpg


BIN
cache/78804-g.jpg


BIN
cache/78804-g50.jpg


BIN
cache/80379-1.jpg


BIN
cache/80379-g12.jpg


BIN
cache/84676-g7.jpg


BIN
cache/95441-1.jpg


BIN
cache/95441-g.jpg


BIN
cache/Thumbs.db


+ 89 - 51
index.php

@@ -1,60 +1,98 @@
 <?php
+header("Content-type: text/html; charset=utf-8");
+// Script start
+$rustart = getrusage();
 
-include_once 'utils.php';
-include_once 'bdd.php';
-include_once 'theme.php';
-
-isAdmin();
-
-/* Verify IP */
-if (!isUser()) {
-    include_once 'view/unknown_ip.php';
-} else {
-    include_once 'view/head.php';
-    include_once 'view/header.php';
-
-    if (isMaintenance()) {
-        include_once 'view/maintenance.php';
-    } else {
-        if (isset($_GET['page_id'])) {
-            switch ($_GET['page_id']) {
-                case 0:
-                    include_once 'view/main.php';
-                    break;
-                case 1:
-                    include_once 'view/show_desc.php';
-                    break;
-                case 2:
-                    include_once 'view/episode_desc.php';
-                    break;
-                case 3:
-                    include_once 'view/user.php';
-                    break;
-                case 4:
-                    include_once 'view/manually_add.php';
-                    break;
-                case 5:
-                    include_once 'view/show_list.php';
-                    break;
-                case 6:
-                    include_once 'view/about.php';
-                    break;
-                case 43:
-                    if (isAdmin()) {
-                        include_once 'admin/admin.php';
-                    }
-                    break;
-                default:
-                    include_once 'view/main.php';
-                    break;
+include_once 'utils/utils.php';
+include_once 'utils/bdd.php';
+include_once 'themes/theme.php';
+
+
+
+switch (auth_user()) {
+    case AUTH_NOT_USER:
+        include_once 'view/unknown_ip.php';
+        break;
+
+    case AUTH_USER_INVALID_IP:
+        
+       
+        
+        if (isset($_POST['action'])) {
+            include_once './utils/valid_action.php';
+        }else{
+             include_once 'view/head.php';
+            include_once 'view/valid_ip.php';
+        }
+        break;
+
+    case AUTH_USER_VALID_IP:
+
+         if (!isset($_GET['script'])) {
+              include_once 'view/head.php';
+              include_once 'view/header.php';
+         ?>
+              <script>
+           function loadNowPlaying(){
+                $("#body").load("index.php?page_id=<?php echo $_GET['page_id']; ?>&psub_id=<?php echo $_GET['psub_id']; ?>&script=1");
             }
+            setInterval(function(){loadNowPlaying()}, 30000);
+        </script>
+        <?php
+         }
+        if (isMaintenance()) {
+            include_once 'view/maintenance.php';
         } else {
-            echo '<div class="modal" onClick="this.style.display = \'none\';"></div>';
-            include_once 'view/main.php';
+            if (isset($_GET['page_id'])) {
+                switch ($_GET['page_id']) {
+                    case 0:
+                        include_once 'view/main.php';
+                        break;
+                    case 1:
+                        include_once 'view/show_desc.php';
+                        break;
+                    case 2:
+                        include_once 'view/episode_desc.php';
+                        break;
+                    case 3:
+                        include_once 'view/user.php';
+                        break;
+                    case 4:
+                        include_once 'view/manually_add.php';
+                        break;
+                    case 5:
+                        include_once 'view/show_list.php';
+                        break;
+                    case 6:
+                        include_once 'view/about.php';
+                        break;
+                     case 7:
+                        if (isSAdmin()) {
+                            include_once 'view/movies.php';
+                        }
+                        break;
+                    case 43:
+                        if (isAdmin()) {
+                            include_once 'admin/admin.php';
+                        }
+                        break;
+                    default:
+                        include_once 'view/main.php';
+                        break;
+                }
+            } else {
+                echo '<div class="modal" onClick="this.style.display = \'none\';"></div>';
+                include_once 'view/main.php';
+            }
+            
+            if (!isset($_GET['script'])) {
+                include_once 'view/footer.php';
+            }
         }
-    }
+        break;
+    default:
+        break;
 }
 
-include_once 'view/footer.php';
 
 ?>

File diff suppressed because it is too large
+ 3 - 0
js/jquery.min.js


+ 0 - 0
menu_jquery.js → js/menu_jquery.js


+ 9 - 8
nbproject/project.properties

@@ -1,8 +1,9 @@
-browser.reload.on.save=true
-include.path=${php.global.include.path}
-php.version=PHP_53
-source.encoding=UTF-8
-src.dir=.
-tags.asp=false
-tags.short=false
-web.root=.
+browser.reload.on.save=true
+include.path=${php.global.include.path}
+php.version=PHP_53
+project.license=gpl30
+source.encoding=UTF-8
+src.dir=.
+tags.asp=false
+tags.short=false
+web.root=.

+ 8 - 21
rss.php

@@ -5,28 +5,15 @@
  * and open the template in the editor.
  */
 
-include_once 'utils.php';
+include_once 'utils/utils.php';
+include_once 'utils/bdd.php';
 
-try {
-    // On se connecte à MySQL
-    $bdd = new PDO('mysql:host=10.5.0.21;dbname=tv_shows', 'tv_shows', 'YfAUKKGwv8dm8NXV');
-} catch (Exception $e) {
-    // En cas d'erreur, on affiche un message et on arrête tout
-    die('Erreur : ' . $e->getMessage());
-}
-
-/* Verify IP */
-
-
-$seluser = $bdd->query('SELECT * FROM users ');
-while ($userdata = $seluser->fetch()) {
-    if ($userdata["ip"] == get_client_ip()) {
+switch (auth_user()) {
+    case AUTH_NOT_USER:
+        include_once 'view/unknown_ip.php';
         break;
-    }
-}
-if ($userdata["ip"] != get_client_ip()) {
-    
-}else{
+
+    default :
     
     header("Content-type: text/xml"); 
     ?>
@@ -40,7 +27,7 @@ if ($userdata["ip"] != get_client_ip()) {
         <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
         <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
         <docs>http://blogs.law.harvard.edu/tech/rss</docs>
-        <generator>GIWYT RSS 0.8</generator>
+        <generator>GIWYT RSS 0.9</generator>
         <webMaster>webmaster@ewft.org</webMaster>
 
     <?php

+ 52 - 2
themes/blue_std/css/button.css

@@ -58,6 +58,7 @@ and open the template in the editor.
 
 
 .addbut {
+        width: 100%;
 	-moz-box-shadow:inset 0px 1px 0px 0px #c1ed9c;
 	-webkit-box-shadow:inset 0px 1px 0px 0px #c1ed9c;
 	box-shadow:inset 0px 1px 0px 0px #c1ed9c;
@@ -87,7 +88,7 @@ and open the template in the editor.
 	font-style:normal;
 	height:30px;
 	line-height:30px;
-	width:131px;
+	//width:131px;
 	text-decoration:none;
 	text-align:center;
 	text-shadow:1px 1px 0px #689324;
@@ -199,4 +200,53 @@ and open the template in the editor.
 .reabut:active {
 	position:relative;
 	top:1px;
-}
+}
+
+
+
+
+
+.validbut {
+	-moz-box-shadow:inset 0px 1px 0px 0px #c1ed9c;
+	-webkit-box-shadow:inset 0px 1px 0px 0px #c1ed9c;
+	box-shadow:inset 0px 1px 0px 0px #c1ed9c;
+	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #9dce2c), color-stop(1, #8cb82b) );
+	background:-moz-linear-gradient( center top, #9dce2c 5%, #8cb82b 100% );
+	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#9dce2c', endColorstr='#8cb82b');
+	background-color:#9dce2c;
+	-webkit-border-top-left-radius:0px;
+	-moz-border-radius-topleft:0px;
+	border-top-left-radius:0px;
+	-webkit-border-top-right-radius:0px;
+	-moz-border-radius-topright:0px;
+	border-top-right-radius:0px;
+	-webkit-border-bottom-right-radius:0px;
+	-moz-border-radius-bottomright:0px;
+	border-bottom-right-radius:0px;
+	-webkit-border-bottom-left-radius:0px;
+	-moz-border-radius-bottomleft:0px;
+	border-bottom-left-radius:0px;
+	text-indent:0;
+	border:1px solid #83c41a;
+	display:inline-block;
+	color:#ffffff;
+        font-family:Arial;
+	font-size:12px;
+	font-weight:bold;
+	font-style:normal;
+	height:28px;
+	line-height:28px;
+	width:100px;
+	text-decoration:none;
+	text-align:center;
+	text-shadow:1px 1px 0px #689324;
+}
+.validbut:hover {
+	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #8cb82b), color-stop(1, #9dce2c) );
+	background:-moz-linear-gradient( center top, #8cb82b 5%, #9dce2c 100% );
+	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8cb82b', endColorstr='#9dce2c');
+	background-color:#8cb82b;
+}.validbut:active {
+	position:relative;
+	top:1px;
+}

+ 43 - 0
themes/blue_std/css/dragndrop.css

@@ -0,0 +1,43 @@
+/*
+Copyright (C) 2015 bnj
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/* 
+    Created on : 26 mars 2015, 20:09:53
+    Author     : bnj
+*/
+
+#holder {   border: 10px dashed #ccc;
+            min-height: 200px;
+            margin: 20px auto;
+            vertical-align: middle;
+            display: flex;
+            justify-content: center;
+            align-content: center;
+            flex-direction: column;
+            text-align: center;
+            font-style: bold;
+            color: #afafaf;
+}
+
+#holder.hover { border: 10px dashed #0c0; }
+#holder img { display: block; margin: 10px auto; }
+#holder p { margin: 10px; font-size: 14px; }
+#tormagnet { word-wrap: break-word;}
+#buttoradd { width: 100%;}
+progress { width: 100%; }
+progress:after { content: '%'; }
+.fail { background: #c00; padding: 2px; color: #fff; }
+.hidden { display: none !important;}

+ 39 - 1
themes/blue_std/css/menu_admin.css

@@ -60,4 +60,42 @@ display: inline-block;
   background: #2580a2 url('../img/hover.gif') left center no-repeat;
   color: #fff;
   padding-bottom: 8px;
-}
+}
+
+
+.graph {
+                padding: 0;
+                width: 70px; /* width and height are arbitrary, just make sure the #bar styles are changed accordingly */
+                height: 20px;
+                border: 1px solid #888; 
+                background: rgb(168,168,168);
+                background: -moz-linear-gradient(top, rgba(168,168,168,1) 0%, rgba(204,204,204,1) 23%);
+                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(168,168,168,1)), color-stop(23%,rgba(204,204,204,1)));
+                background: -webkit-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);
+                background: -o-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);
+                background: -ms-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);
+                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a8a8a8', endColorstr='#cccccc',GradientType=0 );
+                background: linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);
+                position: relative;
+            }
+            #bar {
+                
+                height: 19px; /* Not 30px because the 1px top-border brings it up to 30px to match #graph */
+                background: rgb(255,197,120); 
+                background: -moz-linear-gradient(top, rgba(255,197,120,1) 0%, rgba(244,128,38,1) 100%); 
+                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,197,120,1)), color-stop(100%,rgba(244,128,38,1))); 
+                background: -webkit-linear-gradient(top, rgba(255,197,120,1) 0%,rgba(244,128,38,1) 100%); 
+                background: -o-linear-gradient(top, rgba(255,197,120,1) 0%,rgba(244,128,38,1) 100%); 
+                background: -ms-linear-gradient(top, rgba(255,197,120,1) 0%,rgba(244,128,38,1) 100%); 
+                background: linear-gradient(top, rgba(255,197,120,1) 0%,rgba(244,128,38,1) 100%); 
+                border-top: 1px solid #fceabb;
+            }
+            #bar p { position: absolute; text-align: center; width: 100%; margin: 0; }
+            .error {
+                /* These styles are arbitrary */
+                background-color: #fceabb;
+                padding: 1em;
+                font-weight: bold;
+                color: red;
+                border: 1px solid red;
+            }

+ 47 - 0
themes/blue_std/css/message.css

@@ -0,0 +1,47 @@
+/*
+Copyright (C) 2015 bnj
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/* 
+    Created on : 26 mars 2015, 19:52:00
+    Author     : bnj
+*/
+
+.message_ok,.message_info,.message_nok{
+    display: block;
+    position: fixed;
+    top : 0;
+    left: 0;
+    width: 100%;
+    height: 30px;
+    text-align: center;
+    visibility: visible;
+}
+
+.message_ok {
+    background-color: #83c41a;
+}
+
+.message_info {
+    background-color: #99ccff;
+}
+
+.message_nok {
+    background-color: #f5978e;
+}
+
+.message_hidden {
+    visibility: hidden;
+}

+ 26 - 0
themes/blue_std/css/style.css

@@ -1,3 +1,15 @@
+@import "menu.css";
+@import "menu_admin.css";
+@import "button.css";
+@import "message.css";
+@import "dragndrop.css";
+@import "table.css";
+@import "toggle.css";
+
+
+
+
+
 
 @font-face {
     font-family: 'Capriola';
@@ -304,7 +316,13 @@ section div
     display: inline-block;
     vertical-align: top;
     width:80%;
+    float: right;
+
+}
 
+.admindiv
+{
+    margin: 1%;
 }
 
 .admin table
@@ -479,3 +497,11 @@ nav a:hover
 }
 
 
+#tamagnet
+{
+    width: 100%;
+    
+}
+
+
+

+ 63 - 0
themes/blue_std/css/table.css

@@ -0,0 +1,63 @@
+/*
+Copyright (C) 2015 bnj
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/* 
+    Created on : 11 avr. 2015, 19:40:59
+    Author     : bnj
+*/
+
+
+
+
+
+table{border-spacing:0;margin:0 0 0 0;width:100%;color:#404040;border-bottom-right-radius:5px;border-bottom-left-radius:5px;}
+table thead td{padding:5px 0;}
+table tbody td{padding:7px 0;}
+table.small tbody td{padding:3px 0;}
+table.wide tbody td{padding:10px 0;}
+table tbody tr.tr_row0{background:#F8F8F8;}
+table tbody tr.tr_row1{background:#FFFFFF;}
+table tbody tr.tr_last{background:#F0F0F0;border-top:1px solid #E8E8E8;border-bottom:1px solid #E8E8E8;}
+table td.td_col0{background:#FFFFFF;}
+table td.td_col1{background:#F8F8F8;}
+table td.cpu-info{border:1px solid #303030;}
+table.disk_status{border-collapse:collapse;white-space:nowrap;}
+table.disk_status td span{margin-left:10px;}
+table.disk_status thead tr:first-child td{font-size:13px;text-shadow:1px 1px 0 #FFFFFF;background:-webkit-radial-gradient(#E0E0E0,#C0C0C0);background:linear-gradient(#E0E0E0,#C0C0C0);}
+table.disk_status thead tr:last-child{border-bottom:1px solid #F0F0F0;}
+table.disk_status tr>td{width:8%;padding-left:12px;padding-right:0;white-space:nowrap;}
+//table.disk_status tr>td+td{width:auto;}
+table.disk_status tr>td+td+td{text-align:center;padding-left:4px;padding-right:8px;}
+table.disk_status.stats tr>td+td{text-align:left;padding-left:0;padding-right:12px;}
+table.disk_status.left tr>td+td+td+td{text-align:left;padding-left:16px;padding-right:0;}
+table.disk_status.right tr>td+td+td+td{text-align:right;padding-left:0;padding-right:16px;}
+table.disk_status.center tr>td+td+td+td{text-align:center;padding-left:8px;padding-right:8px;}
+table.disk_status select{background:none;}
+table.disk_status tbody tr:hover td{background:-webkit-radial-gradient(#F8F8F8,#D8D8D8);background:linear-gradient(#F8F8F8,#D8D8D8);}
+
+
+
+
+.usage-bar{float:left;height:16px;line-height:16px;width:130px;padding:1px 1px 1px 2px;margin:6px 12px;border-radius:3px;background-color:#585858;box-shadow:0 1px 0 #989898,inset 0 1px 0 #202020;}
+.usage-bar>span{display:block;height:100%;text-align:right;text-shadow:1px 1px 0 #000000;border-radius:2px;background-color:#808080;box-shadow:inset 0 1px 0 rgba(255,255,255,.5);}
+.usage-bar>span>span{padding:0 4px;font-size:10px;}
+.usage-disk{height:16px;line-height:16px;padding:0;margin:0;border-radius:3px;background-color:#585858;}
+.usage-disk>span{display:block;height:100%;border-radius:2px;background-color:#1aa0f6;box-shadow:inset 0 1px 0 rgba(255,255,255,.5);text-align:center;}
+.usage-disk>span>span{padding:0 6px;font-size:10px;color:#FFFFFF;}
+.usage-disk.sys{height:20px;line-height:20px;margin-right:8px;padding:1px 0 1px 1px;}
+.usage-disk.sys>span{text-align:right;color:#FFFFFF;text-shadow:1px 1px 0 #000000;}
+.usage-disk.all{margin-right:2px;}
+.usage-disk.all>span{text-align:right;color:#FFFFFF;font-size:10px;}

+ 53 - 0
themes/blue_std/css/toggle.css

@@ -0,0 +1,53 @@
+/*
+Copyright (C) 2015 bnj
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/* 
+    Created on : 10 avr. 2015, 17:53:17
+    Author     : bnj
+*/
+
+
+.toggle {
+    margin:4px;
+    background-color:#EFEFEF;
+    border-radius:4px;
+    border:1px solid #D0D0D0;
+    overflow: visible;
+    float:left;
+    padding: 0px;
+}
+
+.toggle label {
+    float:left;
+    width:10.0em;
+}
+
+.toggle label span {
+    text-align:center;
+    padding:3px 0px;
+    display:block;
+    cursor: pointer;
+}
+
+.toggle label input {
+    position:absolute;
+    top:-20px;
+}
+
+.toggle .input-checked /*, .bounds input:checked + span works for firefox and ie9 but breaks js for ie8(ONLY) */ {
+    background-color:#404040;
+    color:#F7F7F7;
+}

BIN
themes/blue_std/img/hover.gif


+ 110 - 0
themes/new_theme/style.css

@@ -0,0 +1,110 @@
+/*
+Copyright (C) 2015 bnj
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/* 
+    Created on : 25 juin 2015, 22:28:14
+    Author     : bnj
+*/
+
+
+/* ==================================================
+   Header
+================================================== */
+
+header {
+	width: 100%;
+	z-index: 99;
+}
+
+header .sticky-nav {
+	position: relative;
+	width: 100%;
+	height: 60px;
+	background: #26292E;
+	z-index: 1001;
+	
+	-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
+	-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
+	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
+}
+
+header .sticky-nav.stuck {
+	position: fixed;
+	top: 0;
+	left: 0;
+	z-index: 1001;
+}
+
+header #logo {
+	color: #FFFFFF;
+	float: left;
+	padding: 15px 0;
+	margin-left: 20px;
+}
+
+header #logo a {
+	background: url(../img/logo.png) no-repeat;
+	width: 96px;
+	height: 30px;
+	text-indent: -9999px;
+	display: block;
+	opacity: 1;
+	filter: alpha(opacity=100);
+	
+	-webkit-transition: opacity 0.25s ease-in-out 0s;	
+	   -moz-transition: opacity 0.25s ease-in-out 0s;
+		 -o-transition: opacity 0.25s ease-in-out 0s;
+		    transition: opacity 0.25s ease-in-out 0s;	
+}
+
+header #logo a:hover {
+	opacity: 0.65;
+	filter: alpha(opacity=65);	
+}
+
+nav#menu {
+	float: right;
+	margin-right: 20px;
+}
+
+nav#menu #menu-nav {
+	margin: 0;
+	padding: 0;	
+}
+
+nav#menu #menu-nav li {
+	list-style: none;
+	display: inline-block;
+	margin-left: 50px;	
+}
+
+nav#menu #menu-nav li:first-child {
+	margin-left: 0;	
+}
+
+nav#menu #menu-nav li a {
+	color: #FFFFFF;
+	font-size: 16px;
+	font-weight: 300;
+	line-height: 60px;
+	display: block;
+	text-transform: uppercase;
+}
+
+nav#menu #menu-nav li.current a,
+nav#menu #menu-nav li a:hover {
+	color: #DE5E60;
+}

+ 5 - 3
theme.php → themes/theme.php

@@ -6,9 +6,11 @@
  * and open the template in the editor.
  */
 
-
-$themesdir = './themes/'.getThemes().'/';
-
+if(isset($_GET['theme'])){
+    $themesdir = './themes/new_theme/';
+}else{
+    $themesdir = './themes/'.getThemes().'/';
+}
 if (!is_dir($themesdir)) {
     $themesdir = "./themes/blue_std/";
 }

+ 0 - 83
utils.php

@@ -1,83 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-function cache_image($image_url) {
-    //replace with your cache directory