Changeset 1089508
- Timestamp:
- 02/13/2015 11:45:02 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gearside-developer-dashboard/trunk/gearside_developer_dashboard.php
r1044543 r1089508 89 89 $todo_file_counter = 0; 90 90 $todo_instance_counter = 0; 91 foreach ( g lob_r($todo_dirpath . '/*') as $todo_file ) {91 foreach ( gearside_glob_r($todo_dirpath . '/*') as $todo_file ) { 92 92 $todo_counted = 0; 93 93 $todo_hidden = 0; … … 102 102 $todo_skipFilenames = array('README.md', 'nebula_admin_functions.php', 'error_log', 'Mobile_Detect.php', 'class-tgm-plugin-activation.php'); 103 103 104 if ( ! contains(basename($todo_file), $todo_skipExtensions) && !contains(basename($todo_file), $todo_skipFilenames) ) {104 if ( !gearside_contains(basename($todo_file), $todo_skipExtensions) && !gearside_contains(basename($todo_file), $todo_skipFilenames) ) { 105 105 foreach ( file($todo_file) as $todo_lineNumber => $todo_line ) { 106 106 $todo_hidden = 0; … … 210 210 echo '<style>.todo_results {height: auto !important; resize: none;}</style>'; 211 211 } 212 echo '</div><!--/todo_results--> ';212 echo '</div><!--/todo_results--></div>'; 213 213 } 214 214 … … 228 228 function dashboard_developer_info() { 229 229 230 $whois = getwhois( nebula_url_components('sld'), ltrim(nebula_url_components('tld'), '.'));230 $whois = getwhois(gearside_url_components('sld'), ltrim(gearside_url_components('tld'), '.')); 231 231 232 232 //Get Expiration Date 233 if ( contains($whois, array('Registrar Registration Expiration Date: ')) ) {233 if ( gearside_contains($whois, array('Registrar Registration Expiration Date: ')) ) { 234 234 $domain_exp_detected = substr($whois, strpos($whois, "Registrar Registration Expiration Date: ")+40, 10); 235 } elseif ( contains($whois, array('Registry Expiry Date: ')) ) {235 } elseif ( gearside_contains($whois, array('Registry Expiry Date: ')) ) { 236 236 $domain_exp_detected = substr($whois, strpos($whois, "Registry Expiry Date: ")+22, 10); 237 237 } else { … … 246 246 247 247 //Get Registrar URL 248 if ( contains($whois, array('Registrar URL: ')) &&contains($whois, array('Updated Date: ')) ) {248 if ( gearside_contains($whois, array('Registrar URL: ')) && gearside_contains($whois, array('Updated Date: ')) ) { 249 249 $domain_registrar_url_start = strpos($whois, "Registrar URL: ")+15; 250 250 $domain_registrar_url_stop = strpos($whois, "Updated Date: ")-$domain_registrar_url_start; 251 251 $domain_registrar_url = substr($whois, $domain_registrar_url_start, $domain_registrar_url_stop); 252 } elseif ( contains($whois, array('Registrar URL: ')) &&contains($whois, array('Update Date: ')) ) {252 } elseif ( gearside_contains($whois, array('Registrar URL: ')) && gearside_contains($whois, array('Update Date: ')) ) { 253 253 $domain_registrar_url_start = strpos($whois, "Registrar URL: ")+15; 254 254 $domain_registrar_url_stop = strpos($whois, "Update Date: ")-$domain_registrar_url_start; 255 255 $domain_registrar_url = substr($whois, $domain_registrar_url_start, $domain_registrar_url_stop); 256 } elseif ( contains($whois, array('URL: ')) &&contains($whois, array('Relevant dates:')) ) { //co.uk256 } elseif ( gearside_contains($whois, array('URL: ')) && gearside_contains($whois, array('Relevant dates:')) ) { //co.uk 257 257 $domain_registrar_url_start = strpos($whois, "URL: ")+5; 258 258 $domain_registrar_url_stop = strpos($whois, "Relevant dates: ")-$domain_registrar_url_start; … … 264 264 $domain_registrar_start = ''; 265 265 $domain_registrar_stop = ''; 266 if ( contains($whois, array('Registrar: ')) &&contains($whois, array('Sponsoring Registrar IANA ID:')) ) {266 if ( gearside_contains($whois, array('Registrar: ')) && gearside_contains($whois, array('Sponsoring Registrar IANA ID:')) ) { 267 267 $domain_registrar_start = strpos($whois, "Registrar: ")+11; 268 268 $domain_registrar_stop = strpos($whois, "Sponsoring Registrar IANA ID:")-$domain_registrar_start; 269 269 $domain_registrar = substr($whois, $domain_registrar_start, $domain_registrar_stop); 270 } elseif ( contains($whois, array('Registrar: ')) &&contains($whois, array('Registrar IANA ID: ')) ) {270 } elseif ( gearside_contains($whois, array('Registrar: ')) && gearside_contains($whois, array('Registrar IANA ID: ')) ) { 271 271 $domain_registrar_start = strpos($whois, "Registrar: ")+11; 272 272 $domain_registrar_stop = strpos($whois, "Registrar IANA ID: ")-$domain_registrar_start; 273 273 $domain_registrar = substr($whois, $domain_registrar_start, $domain_registrar_stop); 274 } elseif ( contains($whois, array('Registrar: ')) &&contains($whois, array('Registrar IANA ID: ')) ) {274 } elseif ( gearside_contains($whois, array('Registrar: ')) && gearside_contains($whois, array('Registrar IANA ID: ')) ) { 275 275 $domain_registrar_start = strpos($whois, "Registrar: ")+11; 276 276 $domain_registrar_stop = strpos($whois, "Registrar IANA ID: ")-$domain_registrar_start; 277 277 $domain_registrar = substr($whois, $domain_registrar_start, $domain_registrar_stop); 278 } elseif ( contains($whois, array('Sponsoring Registrar:')) &&contains($whois, array('Sponsoring Registrar IANA ID:')) ) {278 } elseif ( gearside_contains($whois, array('Sponsoring Registrar:')) && gearside_contains($whois, array('Sponsoring Registrar IANA ID:')) ) { 279 279 $domain_registrar_start = strpos($whois, "Sponsoring Registrar:")+21; 280 280 $domain_registrar_stop = strpos($whois, "Sponsoring Registrar IANA ID:")-$domain_registrar_start; 281 281 $domain_registrar = substr($whois, $domain_registrar_start, $domain_registrar_stop); 282 } elseif ( contains($whois, array('Registrar:')) &&contains($whois, array('Number: ')) ) {282 } elseif ( gearside_contains($whois, array('Registrar:')) && gearside_contains($whois, array('Number: ')) ) { 283 283 $domain_registrar_start = strpos($whois, "Registrar:")+17; 284 284 $domain_registrar_stop = strpos($whois, "Number: ")-$domain_registrar_start; 285 285 $domain_registrar = substr($whois, $domain_registrar_start, $domain_registrar_stop); 286 } elseif ( contains($whois, array('Registrar:')) &&contains($whois, array('URL:')) ) { //co.uk286 } elseif ( gearside_contains($whois, array('Registrar:')) && gearside_contains($whois, array('URL:')) ) { //co.uk 287 287 $domain_registrar_start = strpos($whois, "Registrar: ")+11; 288 288 $domain_registrar_stop = strpos($whois, "URL: ")-$domain_registrar_start; … … 293 293 //Get Reseller Name 294 294 $domain_reseller = ''; 295 if ( contains($whois, array('Reseller: ')) &&contains($whois, array('Domain Status: ')) ) {295 if ( gearside_contains($whois, array('Reseller: ')) && gearside_contains($whois, array('Domain Status: ')) ) { 296 296 $reseller1 = strpos($whois, 'Reseller: '); 297 297 $reseller2 = strpos($whois, 'Reseller: ', $reseller1 + strlen('Reseller: ')); … … 323 323 324 324 //Get last modified filename and date 325 $dir = g lob_r( get_template_directory() . '/*');325 $dir = gearside_glob_r( get_template_directory() . '/*'); 326 326 $last_date = 0; 327 327 $skip_files = array(); … … 330 330 if( is_file($file) ) { 331 331 $mod_date = filemtime($file); 332 if ( $mod_date > $last_date && ! contains(basename($file), $skip_files) ) {332 if ( $mod_date > $last_date && !gearside_contains(basename($file), $skip_files) ) { 333 333 $last_date = $mod_date; 334 334 $last_filename = basename($file); … … 337 337 } 338 338 } 339 $nebula_size = foldersize(get_template_directory());339 $nebula_size = gearside_foldersize(get_template_directory()); 340 340 $upload_dir = wp_upload_dir(); 341 $uploads_size = foldersize($upload_dir['basedir']);341 $uploads_size = gearside_foldersize($upload_dir['basedir']); 342 342 343 343 $secureServer = ''; … … 435 435 436 436 //Search theme or plugin files via Gearside Developer Metabox 437 add_action('wp_ajax_ search_theme_files', 'search_theme_files');438 add_action('wp_ajax_nopriv_ search_theme_files', 'search_theme_files');439 function search_theme_files() {437 add_action('wp_ajax_gearside_search_theme_files', 'gearside_search_theme_files'); 438 add_action('wp_ajax_nopriv_gearside_search_theme_files', 'gearside_search_theme_files'); 439 function gearside_search_theme_files() { 440 440 if ( strlen($_POST['data'][0]['searchData']) < 3 ) { 441 441 echo '<p><strong>Error:</strong> Minimum 3 characters needed to search!</p>'; … … 459 459 $file_counter = 0; 460 460 $instance_counter = 0; 461 foreach ( g lob_r($dirpath . '/*') as $file ) {461 foreach ( gearside_glob_r($dirpath . '/*') as $file ) { 462 462 $counted = 0; 463 463 if ( is_file($file) ) { … … 470 470 $skipExtensions = array('.jpg', '.jpeg', '.png', '.gif', '.ico', '.tiff', '.psd', '.ai', '.apng', '.bmp', '.otf', '.ttf', '.ogv', '.flv', '.fla', '.mpg', '.mpeg', '.avi', '.mov', '.woff', '.eot', '.mp3', '.mp4', '.wmv', '.wma', '.aiff', '.zip', '.zipx', '.rar', '.exe', '.dmg', '.swf', '.pdf', '.pdfx', '.pem'); 471 471 $skipFilenames = array('error_log'); 472 if ( ! contains(basename($file), $skipExtensions) && !contains(basename($file), $skipFilenames) ) {472 if ( !gearside_contains(basename($file), $skipExtensions) && !gearside_contains(basename($file), $skipFilenames) ) { 473 473 foreach ( file($file) as $lineNumber => $line ) { 474 474 if ( stripos($line, $_POST['data'][0]['searchData']) !== false ) { … … 510 510 511 511 //Get the full URL. Not intended for secure use ($_SERVER var can be manipulated by client/server). 512 function nebula_requested_url($host="HTTP_HOST") { //Can use "SERVER_NAME" as an alternative to "HTTP_HOST".512 function gearside_requested_url($host="HTTP_HOST") { //Can use "SERVER_NAME" as an alternative to "HTTP_HOST". 513 513 $protocol = ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ) ? 'https' : 'http'; 514 514 $full_url = $protocol . '://' . $_SERVER["$host"] . $_SERVER["REQUEST_URI"]; … … 518 518 519 519 //Separate a URL into it's components. 520 function nebula_url_components($segment="all", $url=null) {520 function gearside_url_components($segment="all", $url=null) { 521 521 if ( !$url ) { 522 $url = nebula_requested_url();522 $url = gearside_requested_url(); 523 523 } 524 524 … … 598 598 case ('file') : //Filename will be just the filename/extension. 599 599 case ('filename') : 600 if ( contains(basename($url_compontents['path']), array('.')) ) {600 if ( gearside_contains(basename($url_compontents['path']), array('.')) ) { 601 601 return basename($url_compontents['path']); 602 602 } else { … … 606 606 607 607 case ('path') : //Path should be just the path without the filename/extension. 608 if ( contains(basename($url_compontents['path']), array('.')) ) { //@TODO "Nebula" 0: This will possibly give bad data if the directory name has a "." in it608 if ( gearside_contains(basename($url_compontents['path']), array('.')) ) { //@TODO "Nebula" 0: This will possibly give bad data if the directory name has a "." in it 609 609 return str_replace(basename($url_compontents['path']), '', $url_compontents['path']); 610 610 } else { … … 626 626 627 627 //Traverse multidimensional arrays 628 function in_array_r($needle, $haystack, $strict = true) {628 function gearside_in_array_r($needle, $haystack, $strict = true) { 629 629 foreach ($haystack as $item) { 630 if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {630 if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && gearside_in_array_r($needle, $item, $strict))) { 631 631 return true; 632 632 } … … 636 636 637 637 //Recursive Glob 638 function g lob_r($pattern, $flags = 0) {638 function gearside_glob_r($pattern, $flags = 0) { 639 639 $files = glob($pattern, $flags); 640 640 foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { 641 $files = array_merge($files, g lob_r($dir . '/' . basename($pattern), $flags));641 $files = array_merge($files, gearside_glob_r($dir . '/' . basename($pattern), $flags)); 642 642 } 643 643 return $files; … … 645 645 646 646 //Add up the filesizes of files in a directory (and it's sub-directories) 647 function foldersize($path) {647 function gearside_foldersize($path) { 648 648 $total_size = 0; 649 649 $files = scandir($path); … … 653 653 $currentFile = $cleanPath . $t; 654 654 if (is_dir($currentFile)) { 655 $size = foldersize($currentFile);655 $size = gearside_foldersize($currentFile); 656 656 $total_size += $size; 657 657 } else { … … 665 665 666 666 //Checks to see if an array contains a string. 667 function contains($str, array $arr) {667 function gearside_contains($str, array $arr) { 668 668 foreach( $arr as $a ) { 669 669 if ( stripos($str, $a) !== false ) {
Note: See TracChangeset
for help on using the changeset viewer.