Browse Source

Add files via upload

wibyweb 2 years ago
parent
commit
179f5da88b
2 changed files with 53 additions and 40 deletions
  1. 5 0
      html/insert/form.html.php
  2. 48 40
      html/insert/insert.php

+ 5 - 0
html/insert/form.html.php

@@ -81,6 +81,11 @@
         <label for="updatable">updatable (0 for no, or integer value 1-6, 1 is default):</label>   
         <label for="updatable">updatable (0 for no, or integer value 1-6, 1 is default):</label>   
 
 
         <textarea id="updatable" name="updatable"></textarea> 
         <textarea id="updatable" name="updatable"></textarea> 
+      </div> 
+      <div>
+        <label for="shard">shard (leave blank if not using shards, otherwise indicate a shard number):</label>   
+
+        <textarea id="shard" name="shard"></textarea> 
       </div>   
       </div>   
       <div><input type="submit" value="Submit"/></div>    
       <div><input type="submit" value="Submit"/></div>    
 
 

+ 48 - 40
html/insert/insert.php

@@ -8,16 +8,10 @@
 	}
 	}
 
 
 	if (!isset($_POST['url']))    
 	if (!isset($_POST['url']))    
-
 	{    
 	{    
-
 	  include 'form.html.php';    
 	  include 'form.html.php';    
-
-	}    
-
-	else    
-
-	{    
+	}else{    
+		
 		$link = mysqli_connect('localhost', 'crawler', 'seekout');
 		$link = mysqli_connect('localhost', 'crawler', 'seekout');
 
 
 		if (!$link)
 		if (!$link)
@@ -43,49 +37,62 @@
  
  
 	    $url = mysqli_real_escape_string($link, $_POST['url']);
 	    $url = mysqli_real_escape_string($link, $_POST['url']);
 	    $url = str_replace("''", "%27", $url); 
 	    $url = str_replace("''", "%27", $url); 
-//		$url = str_replace("\'", "\'\'", $_POST['url']);
-//		$url = str_replace("\"", "\"\"", $url);
 		$title = mysqli_real_escape_string($link, $_POST['title']);
 		$title = mysqli_real_escape_string($link, $_POST['title']);
-//		$title = str_replace("\'", "\'\'", $_POST['title']);
-//		$title = str_replace("\"", "\"\"", $title);
 		$tags = mysqli_real_escape_string($link, $_POST['tags']);
 		$tags = mysqli_real_escape_string($link, $_POST['tags']);
-//		$tags = str_replace("\'", "\'\'", $_POST['tags']);
-//		$tags = str_replace("\"", "\"\"", $tags);
 		$description = mysqli_real_escape_string($link, $_POST['description']);
 		$description = mysqli_real_escape_string($link, $_POST['description']);
-//		$description = str_replace("\'", "\'\'", $_POST['description']);
-//		$description = str_replace("\"", "\"\"", $description);
 		$body = mysqli_real_escape_string($link, $_POST['body']);
 		$body = mysqli_real_escape_string($link, $_POST['body']);
-//		$body = str_replace("\'", "\'\'", $_POST['body']);
-//		$body = str_replace("\"", "\"\"", $body);
 		$http = mysqli_real_escape_string($link, $_POST['http']);
 		$http = mysqli_real_escape_string($link, $_POST['http']);
-//		$http = str_replace("\'", "\'\'", $_POST['http']);
-//		$http = str_replace("\"", "\"\"", $http);
 		$surprise = mysqli_real_escape_string($link, $_POST['surprise']);
 		$surprise = mysqli_real_escape_string($link, $_POST['surprise']);
-//		$surprise = str_replace("\'", "\'\'", $_POST['surprise']);
-//		$surprise = str_replace("\"", "\"\"", $surprise);
 		$worksafe = mysqli_real_escape_string($link, $_POST['worksafe']);
 		$worksafe = mysqli_real_escape_string($link, $_POST['worksafe']);
-//		$worksafe = str_replace("\'", "\'\'", $_POST['worksafe']);
-//		$worksafe = str_replace("\"", "\"\"", $worksafe);
     	$enable = mysqli_real_escape_string($link, $_POST['enable']);
     	$enable = mysqli_real_escape_string($link, $_POST['enable']);
-//		$enable = str_replace("\'", "\'\'", $_POST['enable']);
-//		$enable = str_replace("\"", "\"\"", $enable);
 		$updatable = mysqli_real_escape_string($link, $_POST['updatable']);
 		$updatable = mysqli_real_escape_string($link, $_POST['updatable']);
-//		$updatable = str_replace("\'", "\'\'", $_POST['updatable']);
-//		$updatable = str_replace("\"", "\"\"", $updatable);
+		$shard = mysqli_real_escape_string($link, $_POST['shard']);
 
 
-		$sql = "INSERT INTO windex (url,title,tags,description,body,http,surprise,worksafe,enable,updatable,approver) 
+		if($shard == ""){
+			$sql = "INSERT INTO windex (url,title,tags,description,body,http,surprise,worksafe,enable,updatable,approver) 
 	VALUES ('".$url."','".$title."','".$tags."','".$description."','".$body."','".$http."','".$surprise."','".$worksafe."','".$enable."','".$updatable."','".$_SESSION["user"]."')";
 	VALUES ('".$url."','".$title."','".$tags."','".$description."','".$body."','".$http."','".$surprise."','".$worksafe."','".$enable."','".$updatable."','".$_SESSION["user"]."')";
-
-
-		if (!mysqli_query($link, $sql))   
-		{
-		  $error = 'Error fetching index: ' . mysqli_error($link);  
-		  include 'error.html.php';  
-		  exit(); 
+			if (!mysqli_query($link, $sql))   
+			{
+			  $error = 'Error fetching index: ' . mysqli_error($link);  
+			  include 'error.html.php';  
+			  exit(); 
+			}	
+		}else{
+			$sql = "INSERT INTO windex (url,title,tags,description,body,http,surprise,worksafe,enable,updatable,shard,approver) 
+	VALUES ('".$url."','".$title."','".$tags."','".$description."','".$body."','".$http."','".$surprise."','".$worksafe."','".$enable."','".$updatable."','".$shard."','".$_SESSION["user"]."')";
+			if (!mysqli_query($link, $sql))   
+			{
+			  $error = 'Error fetching index: ' . mysqli_error($link);  
+			  include 'error.html.php';  
+			  exit(); 
+			}
+			
+			$result = mysqli_query($link,"SELECT id FROM windex WHERE url = '".$url."'");
+			if ($result === false)  
+			{
+			  $error = 'Error: ' . mysqli_error($link);  
+			  include 'error.html.php';  
+			  exit(); 
+			}	
+			while($row = mysqli_fetch_array($result))
+			{
+				$idArray[] = $row['id'];
+			}	
+			$id = $idArray[0];
+						
+			$sql = "INSERT INTO ws$shard (id,url,title,tags,description,body,http,surprise,worksafe,enable,updatable,shard,approver) 
+	VALUES ('".$id."','".$url."','".$title."','".$tags."','".$description."','".$body."','".$http."','".$surprise."','".$worksafe."','".$enable."','".$updatable."','".$shard."','".$_SESSION["user"]."')";
+			if (!mysqli_query($link, $sql))   
+			{
+			  $error = 'Error fetching index: ' . mysqli_error($link);  
+			  include 'error.html.php';  
+			  exit(); 
+			}			
+					
 		}
 		}
 
 
-	    	$output = 'No errors '.      
-	    	$url . ' ' .    
+	    $output = 'No errors '.      
+	    $url . ' ' .    
 		$title . ' ' . 
 		$title . ' ' . 
 		$tags . ' ' . 
 		$tags . ' ' . 
 		$description . ' ' . 
 		$description . ' ' . 
@@ -93,8 +100,9 @@
 		$http . ' ' . 
 		$http . ' ' . 
 		$surprise . ' ' . 
 		$surprise . ' ' . 
 		$worksafe . ' ' . 
 		$worksafe . ' ' . 
-	    	$enable . ' ' .
-		$updatable;  
+	    $enable . ' ' .
+		$updatable . ' ' .
+		$shard;  
 
 
 		include 'insert.html.php';       
 		include 'insert.html.php';       
 	}
 	}