function weaverii_uploadit() { // upload theme from users computer // they've supplied and uploaded a file $ok = true; // no errors so far if (isset($_FILES['uploaded']['name'])) { $filename = $_FILES['uploaded']['name']; } else { $filename = ""; } if (isset($_FILES['uploaded']['tmp_name'])) { $openname = $_FILES['uploaded']['tmp_name']; } else { $openname = ""; } //Check the file extension $check_file = strtolower($filename); $pat = '.'; // PHP version strict checking bug... $end = explode($pat, $check_file); $ext_check = end($end); if ($filename == "") { $errors[] = "You didn't select a file to upload.<br />"; $ok = false; } if ($ok && $ext_check != 'w2t' && $ext_check != 'w2b') { $errors[] = "Theme files must have <em>.w2t</em> or <em>.w2b</em> extension.<br />"; $ok = false; } if ($ok) { if (!weaverii_f_exists($openname)) { $errors[] = '<strong><em style="color:red;">' . weaverii_t_('Sorry, there was a problem uploading your file. You may need to check your folder permissions or other server settings.') . '</em></strong>' . "<br />(Trying to use file '{$openname}')"; $ok = false; } } if (!$ok) { echo '<div id="message" class="updated fade"><p><strong><em style="color:red;">ERROR</em></strong></p><p>'; foreach ($errors as $error) { echo $error . '<br />'; } echo '</p></div>'; } else { // OK - read file and save to My Saved Theme // $handle has file handle to temp file. $contents = weaverii_f_get_contents($openname); if (!weaverii_set_current_to_serialized_values($contents, 'weaverii_uploadit:' . $openname)) { echo '<div id="message" class="updated fade"><p><strong><em style="color:red;">' . weaverii_t_('Sorry, there was a problem uploading your file. The file you picked was not a valid Weaver II theme file.') . '</em></strong></p></div>'; } else { weaverii_save_msg(weaverii_t_("Weaver II theme options reset to uploaded theme.")); } } }
function weaverii_upload_theme($filename) { if (!weaverii_f_exists($filename)) { return weaverii_f_fail("Can't open {$filename}"); } /* can't open */ $contents = weaverii_f_get_contents($filename); if (!$contents) { return weaverii_f_fail("Can't open {$filename}"); } return weaverii_set_current_to_serialized_values($contents); }