Changeset 2376893
- Timestamp:
- 09/08/2020 04:56:54 AM (5 years ago)
- Location:
- nomore404-404-redirection-and-firewall
- Files:
-
- 2397 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
nomore404-404-redirection-and-firewall/trunk/includes/nomore404-activation.php
r2368272 r2376893 38 38 39 39 $obj_settings = new NoMore404_Settings(); 40 NoMore404_Model_Static_Class::good_error_log('settings:', $obj_settings);40 //NoMore404_Model_Static_Class::good_error_log('settings:', $obj_settings); 41 41 42 42 $table_name1 = $prefix . "nomore404_uri"; … … 70 70 ADD whitelist TINYINT(1) NOT NULL DEFAULT '0'"; 71 71 $result = $wpdb->query($update_query1); 72 NoMore404_Model_Static_Class::good_error_log('Table 1 update 1 result:', $result);72 //NoMore404_Model_Static_Class::good_error_log('Table 1 update 1 result:', $result); 73 73 74 74 } … … 77 77 ADD comment VARCHAR(50) NULL"; 78 78 $result = $wpdb->query($update_query1); 79 NoMore404_Model_Static_Class::good_error_log('Table 1 update 2 result:', $result);79 //NoMore404_Model_Static_Class::good_error_log('Table 1 update 2 result:', $result); 80 80 } 81 81 if($obj_settings->options['dbversion'] < '1.13'){ // alter table here if before v 1.13 … … 83 83 ADD uploaded TINYINT(1) NOT NULL DEFAULT '0'"; 84 84 $result = $wpdb->query($update_query1); 85 NoMore404_Model_Static_Class::good_error_log('Table 1 update 3 result:', $result);85 //NoMore404_Model_Static_Class::good_error_log('Table 1 update 3 result:', $result); 86 86 } 87 87 88 88 $table1updated = True; 89 NoMore404_Model_Static_Class::var_error_log('Table 1 updated:', $table1updated);89 //NoMore404_Model_Static_Class::var_error_log('Table 1 updated:', $table1updated); 90 90 } 91 91 … … 175 175 $obj_settings->SetLatestVersions(); 176 176 } 177 NoMore404_Model_Static_Class::good_error_log('settings:', $obj_settings);177 //NoMore404_Model_Static_Class::good_error_log('settings:', $obj_settings); 178 178 } 179 179 -
nomore404-404-redirection-and-firewall/trunk/includes/nomore404-list-table-class.php
r2368272 r2376893 866 866 $data = NoMore404_Model_Static_Class::getCallers($orderby, $order, $search, $uriid, $current_page, $per_page); 867 867 868 //NoMore404_Model_Static_Class::good_error_log('Callers in list class:', $data); 869 868 870 $total_items = NoMore404_Model_Static_Class::countCallers($search, $uriid); 869 871 -
nomore404-404-redirection-and-firewall/trunk/includes/nomore404-model.php
r2368272 r2376893 48 48 49 49 $query = 'SELECT * FROM ' . self::$uri_caller_table_name; 50 $query .= ' WHERE uploaded <> 1 AND '; 51 $query .= '('; 52 $query .= 'caller_id IN '; 53 $query .= '(SELECT uc.caller_id FROM ' . self::$caller_table_name . ' uc '; 54 $query .= 'WHERE uc.uploaded <> 1 AND (uc.whitelist = 1 OR uc.malicious = 1 OR uc.suspicious = 1)'; 55 $query .= ') OR '; 56 $query .= 'uri_id IN '; 57 $query .= '(SELECT uu.uri_id FROM ' . self::$uri_table_name . ' uu '; 58 $query .= 'WHERE uu.uploaded <> 1 AND (uu.whitelist = 1 OR uu.malicious = 1 OR uu.suspicious = 1) '; 59 $query .= ') '; 60 $query .= ') '; 50 $query .= ' WHERE uploaded <> 1'; 61 51 $query .= ' ORDER BY uri_id'; 62 52 … … 64 54 65 55 if($markuploaded){ 66 $query = 'UPDATE ' . self::$uri_caller_table_name . ' SET uploaded = 1'; 67 $query .= ' WHERE uploaded <> 1 AND '; 68 $query .= '('; 69 $query .= 'caller_id IN '; 70 $query .= '(SELECT uc.caller_id FROM ' . self::$caller_table_name . ' uc '; 71 $query .= 'WHERE uc.uploaded <> 1 AND (uc.whitelist = 1 OR uc.malicious = 1 OR uc.suspicious = 1)'; 72 $query .= ') OR '; 73 $query .= 'uri_id IN '; 74 $query .= '(SELECT uu.uri_id FROM ' . self::$uri_table_name . ' uu '; 75 $query .= 'WHERE uu.uploaded <> 1 AND (uu.whitelist = 1 OR uu.malicious = 1 OR uu.suspicious = 1) '; 76 $query .= ') '; 77 $query .= ') '; 56 $query = 'UPDATE ' . self::$uri_caller_table_name . ' SET uploaded = 1, date_uploaded = UTC_TIMESTAMP()'; 57 $query .= ' WHERE uploaded <> 1'; 78 58 $query .= ' ORDER BY uri_id'; 79 59 $wpdb->query($query); … … 95 75 96 76 if($markuploaded){ 97 $query = 'UPDATE ' . self::$uri_table_name . ' SET uploaded = 1 ';77 $query = 'UPDATE ' . self::$uri_table_name . ' SET uploaded = 1, date_uploaded = UTC_TIMESTAMP()'; 98 78 $query .= ' WHERE uploaded <> 1 AND (whitelist = 1 OR malicious = 1 OR suspicious = 1)'; 99 79 $wpdb->query($query); … … 116 96 117 97 if($markuploaded){ 118 $query = 'UPDATE ' . self::$caller_table_name . ' SET uploaded = 1 ';98 $query = 'UPDATE ' . self::$caller_table_name . ' SET uploaded = 1, date_uploaded = UTC_TIMESTAMP()'; 119 99 $query .= ' WHERE uploaded <> 1 AND (whitelist = 1 OR malicious = 1 OR suspicious = 1)'; 120 100 $wpdb->query($query); … … 175 155 $output = $wpdb->insert_id; 176 156 } catch (Exception $ex) { 177 self::good_error_log('Caught URICaller insert error:',$ex->getMessage());157 //self::good_error_log('Caught URICaller insert error:',$ex->getMessage()); 178 158 return False; // if insert did not work - return false 179 159 } … … 188 168 array('uri_id' => $uri_id, 'caller_id' => $caller_id)); 189 169 } catch (Exception $ex) { 190 self::good_error_log('Caught URICaller update error:',$ex->getMessage());170 //self::good_error_log('Caught URICaller update error:',$ex->getMessage()); 191 171 return False; // if insert did not work - return false 192 172 } … … 219 199 $output = $wpdb->insert_id; 220 200 } catch (Exception $ex) { 221 self::good_error_log('Caught Caller insert error:',$ex->getMessage());201 //self::good_error_log('Caught Caller insert error:',$ex->getMessage()); 222 202 return False; // if insert did not work - return false 223 203 } … … 232 212 $output = $wpdb->update(self::$caller_table_name, $caller_data, array('caller_id' => $caller_id)); 233 213 } catch (Exception $ex) { 234 self::good_error_log('Caught Caller update error:',$ex->getMessage());214 //self::good_error_log('Caught Caller update error:',$ex->getMessage()); 235 215 return False; // if update did not work - return false 236 216 } … … 256 236 ); 257 237 } catch (Exception $ex) { 258 self::good_error_log('Caught Caller delete error:',$ex->getMessage());238 //self::good_error_log('Caught Caller delete error:',$ex->getMessage()); 259 239 return False; // if update did not work - return false 260 240 } … … 266 246 global $wpdb; 267 247 268 self::good_error_log('Counting callers by URIid:', $filteruriid);248 //self::good_error_log('Counting callers by URIid:', $filteruriid); 269 249 270 250 if('' == $filteruriid ){ // if not filtered then normal sort and search applies … … 299 279 300 280 } 301 self::good_error_log('Running query:', $cleanedsql);281 //self::good_error_log('Running query:', $cleanedsql); 302 282 $num = (int) $wpdb->get_var($cleanedsql); 303 self::good_error_log('Number of records:', $num);283 //self::good_error_log('Number of records:', $num); 304 284 return $num; 305 285 } … … 329 309 } 330 310 }else{ 331 $query = 'SELECT * FROM ' . self::$caller_table_name . ' c '; 311 // prepare list of fields 312 $listOfFieldsToGet = 'c.caller_id, c.caller_ip, c.comment, c.hostname, c.date_created, c.date_last_used, 313 c.counter, c.suspicious, c.malicious, c.whitelist, c.uploaded'; 314 315 // form query 316 $query = 'SELECT ' . $listOfFieldsToGet . ' FROM ' . self::$caller_table_name . ' c '; 332 317 $query .= 'INNER JOIN ' . self::$uri_caller_table_name . ' uc '; 333 318 $query .= 'ON c.caller_id = uc.caller_id and uc.uri_id = %d'; … … 349 334 } 350 335 $output = $wpdb->get_results($cleanedsql, ARRAY_A); 336 //NoMore404_Model_Static_Class::good_error_log('SQL in model class:', $cleanedsql); 337 //NoMore404_Model_Static_Class::good_error_log('Callers in model class:', $output); 351 338 return $output; 352 339 } … … 370 357 ); 371 358 } catch (Exception $ex) { 372 self::good_error_log('Caught URI delete error:',$ex->getMessage());359 //self::good_error_log('Caught URI delete error:',$ex->getMessage()); 373 360 return False; // if update did not work - return false 374 361 } … … 481 468 return $uri_data; 482 469 } 470 483 471 public static function InsertURI($uri_data) { 484 472 global $wpdb; … … 488 476 $output = $wpdb->insert_id; 489 477 } catch (Exception $ex) { 490 self::good_error_log('Caught insert error:',$ex->getMessage());478 //self::good_error_log('Caught insert error:',$ex->getMessage()); 491 479 return False; // if insert did not work - return false 492 480 } … … 501 489 $output = $wpdb->update(self::$uri_table_name, $uri_data, array('uri_id' => $uri_id)); 502 490 } catch (Exception $ex) { 503 self::good_error_log('Caught update error:',$ex->getMessage());491 //self::good_error_log('Caught update error:',$ex->getMessage()); 504 492 return $output; // if insert did not work - return false 505 493 } -
nomore404-404-redirection-and-firewall/trunk/includes/nomore404-upload-download.php
r2368272 r2376893 27 27 // if not uploaded then all changes to uploaded flag will be rolled back 28 28 public static function UploadAllNewData($dofullupload = false) { 29 global $wpdb; 30 29 31 // Start Transaction 30 32 $wpdb->query( "START TRANSACTION" ); … … 33 35 $strJSON = Self::CreateJSON4Upload(FALSE); // what was not uploaded yet 34 36 37 //NoMore404_Model_Static_Class::good_error_log('Uploading info:', $strJSON); 38 35 39 if(FALSE !== $strJSON){ // there is something to upload 36 40 $uploaded = self::UploadStringAsFile2S3($strJSON); 37 41 38 if($uploaded) $wpdb->query( " ROLLBACK" );42 if($uploaded) $wpdb->query( "COMMIT" ); 39 43 else $wpdb->query( "ROLLBACK" ); 40 44 }else{ … … 78 82 'ACL' => 'bucket-owner-full-control', 79 83 ]); 80 NoMore404_Model_Static_Class::good_error_log('S3UploadResult:', $result); 84 //NoMore404_Model_Static_Class::good_error_log('S3UploadResult:', $result); 85 //NoMore404_Model_Static_Class::good_error_log('File uploaded:', $file2upload); 81 86 82 87 // returns true if uploaded … … 113 118 $strJSONText .= '"wp_version": "' . get_bloginfo('version') . '",' . PHP_EOL; // wordpress verson 114 119 $strJSONText .= '"version": "' . NOMORE404VERSION . '",' . PHP_EOL; // plug in versions 115 $strJSONText .= '"dbversion": "' . NOMORE404DBVERSION . '" ,' . PHP_EOL; //116 $strJSONText .= '"Callers": '; // start of caller records120 $strJSONText .= '"dbversion": "' . NOMORE404DBVERSION . '"'; // 121 117 122 118 123 // lets get callers data 119 // first get data what was not uploaded yet 124 // first get data what was not uploaded yet and mark them uploaded as well in transaction 120 125 $callers2upload = NoMore404_Model_Static_Class::getCallersForUpload(TRUE); 121 126 //NoMore404_Model_Static_Class::good_error_log('Callers:', $callers2upload); 122 if(NULL !== $callers2upload){ // there is something to take in 127 //NoMore404_Model_Static_Class::var_error_log('Callers to upload:',$callers2upload); 128 if((NULL !== $callers2upload) && (is_array($callers2upload) && sizeof($callers2upload) > 0)){ 129 // there is something to take in, it is array with at least one element 123 130 //NoMore404_Model_Static_Class::good_error_log('Callers:', $callers2upload); 124 131 //NoMore404_Model_Static_Class::good_error_log('CallersJSON:', json_encode($callers2upload, JSON_FORCE_OBJECT)); 125 $strJSONText .= json_encode($callers2upload, JSON_PRETTY_PRINT) . ',' . PHP_EOL; 132 $strJSONText .= ',' . PHP_EOL . '",Callers": '; // start of caller records 133 $strJSONText .= json_encode($callers2upload, JSON_PRETTY_PRINT); 126 134 $thereIsSomethingToUpload = TRUE; 127 135 //NoMore404_Model_Static_Class::good_error_log('JSON error:',json_last_error_msg()); … … 129 137 130 138 131 $strJSONText .= '"URIs": '; // start of URIs records 139 132 140 $URIs2upload = NoMore404_Model_Static_Class::getURIsForUpload(TRUE); // get data what was not uploaded yet 133 if(NULL !== $URIs2upload){ // there is something to take in 134 $strJSONText .= json_encode($URIs2upload, JSON_PRETTY_PRINT) . ',' . PHP_EOL; 141 if(NULL !== $URIs2upload && (is_array($URIs2upload) && sizeof($URIs2upload) > 0)){ 142 $strJSONText .= ',' . PHP_EOL . '"URIs": '; // start of URIs records 143 // there is something to take in, it is array with at least one element 144 $strJSONText .= json_encode($URIs2upload, JSON_PRETTY_PRINT); 135 145 $thereIsSomethingToUpload = TRUE; 136 146 } 137 147 138 $strJSONText .= '"URICaller": '; // start of URIs records148 139 149 $URICaller2upload = NoMore404_Model_Static_Class::getURICallerForUpload(TRUE); // get data what was not uploaded yet 140 150 //NoMore404_Model_Static_Class::good_error_log('$URICaller2upload:', $URICaller2upload); 141 if(NULL !== $URICaller2upload){ // there is something to take in 151 if(NULL !== $URICaller2upload && (is_array($URICaller2upload) && sizeof($URICaller2upload) > 0)){ 152 $strJSONText .= ',' . PHP_EOL . '"URICaller": '; // start of URIs records 153 // there is something to take in, it is array with at least one element 142 154 $strJSONText .= json_encode($URICaller2upload, JSON_PRETTY_PRINT) . PHP_EOL; 143 155 $thereIsSomethingToUpload = TRUE; -
nomore404-404-redirection-and-firewall/trunk/includes/nomore404-view.php
r2368272 r2376893 216 216 $output .= '</tr>' . PHP_EOL; 217 217 218 $output .= '<td>Date Uploaded</td>' . PHP_EOL; 219 $output .= '<td>' . esc_attr($uri_data['date_uploaded']) . '</td>' . PHP_EOL; 220 $output .= '</tr>' . PHP_EOL; 221 $output .= '<tr>' . PHP_EOL; 222 223 $output .= '<td>Date Downloaded</td>' . PHP_EOL; 224 $output .= '<td>' . esc_attr($uri_data['date_downloaded']) . '</td>' . PHP_EOL; 225 $output .= '</tr>' . PHP_EOL; 226 $output .= '<tr>' . PHP_EOL; 227 228 $output .= '<tr>' . PHP_EOL; 229 $output .= '<td>Uploaded</td>' . PHP_EOL; 230 $output .= '<td><input type="checkbox" name="uploaded" value="Enabled" ' 231 . checked($uri_data['uploaded'], true, false) . '>' . PHP_EOL; 232 $output .= '</td>' . PHP_EOL; 233 $output .= '</tr>' . PHP_EOL; 234 218 235 $output .= '</table>' . PHP_EOL; 219 236 echo $output; … … 255 272 $output .= '</tr>' . PHP_EOL; 256 273 $output .= '<tr>' . PHP_EOL; 274 257 275 $output .= '<td>Date Last Used</td>' . PHP_EOL; 258 276 $output .= '<td>' . esc_attr($caller_data['date_last_used']) . '</td>' . PHP_EOL; 259 277 $output .= '</tr>' . PHP_EOL; 260 278 $output .= '<tr>' . PHP_EOL; 279 261 280 $output .= '<td>Counter</td>' . PHP_EOL; 262 281 $output .= '<td>' . esc_attr($caller_data['counter']) . '</td>' . PHP_EOL; 263 282 $output .= '</tr>' . PHP_EOL; 264 283 $output .= '<tr>' . PHP_EOL; 284 265 285 $output .= '<td>Suspicious</td>' . PHP_EOL; 266 286 $output .= '<td><input type="checkbox" name="suspicious" value="Enabled" ' … … 282 302 $output .= '</td>' . PHP_EOL; 283 303 $output .= '</tr>' . PHP_EOL; 304 305 $output .= '<td>Date Uploaded</td>' . PHP_EOL; 306 $output .= '<td>' . esc_attr($caller_data['date_uploaded']) . '</td>' . PHP_EOL; 307 $output .= '</tr>' . PHP_EOL; 308 $output .= '<tr>' . PHP_EOL; 309 310 $output .= '<td>Date Downloaded</td>' . PHP_EOL; 311 $output .= '<td>' . esc_attr($caller_data['date_downloaded']) . '</td>' . PHP_EOL; 312 $output .= '</tr>' . PHP_EOL; 313 $output .= '<tr>' . PHP_EOL; 314 315 $output .= '<tr>' . PHP_EOL; 316 $output .= '<td>Uploaded</td>' . PHP_EOL; 317 $output .= '<td><input type="checkbox" name="uploaded" value="Enabled" ' 318 . checked($caller_data['uploaded'], true, false) . '>' . PHP_EOL; 319 $output .= '</td>' . PHP_EOL; 320 $output .= '</tr>' . PHP_EOL; 284 321 285 322 $output .= '</table>' . PHP_EOL; -
nomore404-404-redirection-and-firewall/trunk/nomore404.php
r2368272 r2376893 4 4 * Plugin URI: https://devoutpro.com/nomore404 5 5 * Description: NoMore404 is a free WordPress plugin for redirection of 404 pages (301 type of redirection) and simple firewall to block malicious hosts and URLs. 6 * Version: 1.1 36 * Version: 1.14 7 7 * Requires at least: 4.0 8 8 * Requires PHP: 5.3 … … 32 32 defined('ABSPATH') or exit; 33 33 34 define("NOMORE404VERSION", "1.1 3");35 define("NOMORE404DBVERSION", "1.1 3");34 define("NOMORE404VERSION", "1.14"); 35 define("NOMORE404DBVERSION", "1.14"); 36 36 37 37 // plugin activation and uninstallation … … 343 343 if (isset($_SESSION['uri_data'])) 344 344 $uri_data = array_merge($uri_data,$_SESSION['uri_data']); 345 //NoMore404_Model_Static_Class::var_error_log('URI data after merge: ', $uri_data);346 345 }elseif ('edit' === $_GET['mode']) { // edit existing uri 347 346 $uri_id = (int) $_GET['id']; … … 430 429 431 430 if (isset($_POST['btnUpload'])) { // button upload clicked 432 //NoMore404_Model_Static_Class::good_error_log('Uploading...', $_POST);433 431 $uploaded = NoMore404_UD_Static_Class::UploadAllNewData(); 434 432 if($uploaded) … … 504 502 $caller_data['malicious'] = ( isset($_POST['malicious']) ? True : False ); 505 503 $caller_data['whitelist'] = ( isset($_POST['whitelist']) ? True : False ); 504 $caller_data['uploaded'] = ( isset($_POST['uploaded']) ? True : False ); 506 505 507 506 if($caller_data['malicious']) $caller_data['suspicious'] = True; // malicious is stronger … … 584 583 $uri_data['malicious'] = ( isset($_POST['malicious']) ? True : False ); 585 584 $uri_data['whitelist'] = ( isset($_POST['whitelist']) ? True : False ); 585 $uri_data['uploaded'] = ( isset($_POST['uploaded']) ? True : False ); 586 586 587 587 $_SESSION['uri_data'] = $uri_data; // save uri data in session … … 799 799 ?> 800 800 <div class="notice notice-error is-dismissible"> 801 <p><?php _e('Upload did not work, contact support.'); ?></p>801 <p><?php _e('Upload did not work, possibly nothing to upload.'); ?></p> 802 802 </div> 803 803 <?php -
nomore404-404-redirection-and-firewall/trunk/readme.txt
r2368272 r2376893 6 6 Tested up to: 5.5 7 7 Requires PHP: 5.3 8 Stable tag: 1.1 38 Stable tag: 1.14 9 9 License: GPLv2 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 30 30 31 31 == Changelog == 32 1.14 Manual upload of data to the backend system for analysis is done 32 33 1.13 Fixed activation and db upgrade errors. 33 34 Uploading whitelists, suspects and blacklists to the backend
Note: See TracChangeset
for help on using the changeset viewer.