Fix https http urls
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Jul 2017 20:41:13 +0000 (16:41 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Jul 2017 20:41:13 +0000 (16:41 -0400)
Fix for site that may have url's with https

controllers/ToolboxImport.php

index 26b57da..dee1fa9 100644 (file)
             echo '<p>Fetching Pages</p>';
             $this->_post = get_option(GLM_WP_IMPORT_POST_OPTION, array());
             // grab all pages and build the post array
-            $start = filter_var($_REQUEST['start'], FILTER_VALIDATE_INT);
+            $start = isset( $_REQUEST['start'] ) ?  filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT ) : 0;
             $pages = $this->_fetchAllPages();
             $numPagesImported = count($pages);
 
                 if ($page['parent']) {
 
                 }
-                if ( $page['title'] ) {
+                if ( isset( $page['title'] ) && $page['title'] ) {
                     $pageName = $page['title'];
-                } else if ( $page['navigation_name'] ) {
+                } else if ( isset( $page['navigation_name'] ) && $page['navigation_name'] ) {
                     $pageName = $page['navigation_name'];
                 } else {
-                    $pageName = $page['category'];
+                    $pageName = isset( $page['category'] ) ? $page['category'] : '';
                 }
                 // if you don't find the parent page id then use the default given or 0
                 $parent = isset($this->_post[$page['parent']])
             global $wpdb;
             $this->_connect();
             echo '<p>Replace IS0 url\'s</p>';
-            $searchUrl = 'http://is0.gaslightmedia.com';
             // find all pages with links to site pages
             $sql = "
             SELECT *
               FROM {$wpdb->prefix}posts
-             WHERE post_content LIKE '%{$searchUrl}%'
+             WHERE post_content LIKE '%http://is0.gaslightmedia.com%' OR post_content LIKE '%https://is0.gaslightmedia.com%'
                AND post_type = 'page'";
             echo '<pre>'.$sql.'</pre>';
             $results = $wpdb->get_results($sql, OBJECT);
             if (count($results) > 0) {
                 //echo '<pre>' . print_r($results, true) . '</pre>';
-                $pattern = ';(http://is0.gaslightmedia.com/[^"]+);si';
+                $pattern = ';(https?://is0.gaslightmedia.com/[^"]+);si';
                 foreach ($results as $post) {
                     $content = $post->post_content;
                     preg_match_all($pattern, $post->post_content, $matches);