diff --git a/bin/noblogs.in b/bin/noblogs.in index a01b43f7556e8bfce00b4df536a383ba6221c78f..c2abb3b408a5e5f5a51d72fb27a8f0fe648a780a 100755 --- a/bin/noblogs.in +++ b/bin/noblogs.in @@ -58,7 +58,7 @@ Known commands: -mail sends email to ai-changes@investici.org -json print JSON output - https-siteurl BLOG + fix-https BLOG Adds https (instead of http) to siteurl and home options. fix-cdn BLOG @@ -386,39 +386,32 @@ function do_check_updates($args) { } -// replaces http with https, and removes ending slash -function add_https_to_uri($uri){ - $re = "#^http[s]?://([^.]+\.noblogs\.org)[/]?$#i"; - $subst = "https://$1"; - return preg_replace($re,$subst,$uri); -} - // adds https to siteurl and home options (and also flattrs custom image) -function do_https_siteurl($args){ - $field_to_update = array('home', 'siteurl', 'flattrss_custom_image_url'); - foreach ($args as $arg) { - $blog = noblogs_get_blog($arg); - if (!$blog) { - echo "Blog {$arg} not found.\n"; - continue; - } - switch_to_blog($blog->blog_id); - - foreach ($field_to_update as $field){ - $old = get_option($field); - if ( $old === false ){ - continue; - } - $new = add_https_to_uri($old); - if ($old === $new){ - continue; - } - update_option($field,$new); - } +function do_fix_https($args){ + $fields_to_update = array('home', 'siteurl', 'flattrss_custom_image_url'); + foreach ($args as $arg) { + $blog = noblogs_get_blog($arg); + if (!$blog) { + echo "Blog {$arg} not found.\n"; + continue; + } + switch_to_blog($blog->blog_id); - echo "{$arg}\n"; - restore_current_blog(); + foreach ($fields_to_update as $field) { + $old_value = get_option($field); + if ($old_value === false) { + continue; + } + $new_value = str_replace("http://", "https://", $old_value); + if ($old_value === $new_value){ + continue; + } + update_option($field, $new_value); } + + echo "{$arg}\n"; + restore_current_blog(); + } } // rewrites the correct settings for the CDN