/** * Returns upload info * * @return array */ function w3_upload_info() { static $upload_info = null; if ($upload_info === null) { $upload_info = @nxt_upload_dir(); if (empty($upload_info['error'])) { $parse_url = @parse_url($upload_info['baseurl']); if ($parse_url) { $baseurlpath = !empty($parse_url['path']) ? trim($parse_url['path'], '/') : ''; } else { $baseurlpath = 'nxt-content/uploads'; } $upload_info['baseurlpath'] = '/' . $baseurlpath . '/'; } else { $upload_info = false; } } return $upload_info; }
/** * bp_core_avatar_url() * * Returns the raw base URL for root site upload location * * @uses nxt_upload_dir To get upload directory info * @return string Full URL to current upload location */ function bp_core_avatar_url() { global $bp; // See if the value has already been calculated and stashed in the $bp global if (isset($bp->avatar->url)) { $baseurl = $bp->avatar->url; } else { // If this value has been set in a constant, just use that if (defined('BP_AVATAR_URL')) { $baseurl = BP_AVATAR_URL; } else { // Get upload directory information from current site $upload_dir = nxt_upload_dir(); // Directory does not exist and cannot be created if (!empty($upload_dir['error'])) { $baseurl = ''; } else { $baseurl = $upload_dir['baseurl']; // If multisite, and current blog does not match root blog, make adjustments if (is_multisite() && bp_get_root_blog_id() != get_current_blog_id()) { $baseurl = trailingslashit(get_blog_option(bp_get_root_blog_id(), 'home')) . get_blog_option(bp_get_root_blog_id(), 'upload_path'); } } } // Stash in $bp for later use $bp->avatar->url = $baseurl; } return apply_filters('bp_core_avatar_url', $baseurl); }
function jfb_bp_avatar($avatar, $params = '') { //First, get the userid global $comment; if (is_object($comment)) { $user_id = $comment->user_id; } if (is_object($params)) { $user_id = $params->user_id; } if (is_array($params) && $params['object'] == 'user') { $user_id = $params['item_id']; } if (!$user_id) { return $avatar; } //Now that we have a userID, let's see if we have their facebook profile pic stored in usermeta. If not, fallback on the default. if ($params['type'] == 'full') { $fb_img = get_user_meta($user_id, 'facebook_avatar_full', true); } if (!$fb_img) { $fb_img = get_user_meta($user_id, 'facebook_avatar_thumb', true); } if (!$fb_img) { return $avatar; } //If the usermeta doesn't contain an absolute path, prefix it with the path to the uploads dir if (strpos($fb_img, "http") === FALSE) { $uploads_url = nxt_upload_dir(); $uploads_url = $uploads_url['baseurl']; $fb_img = trailingslashit($uploads_url) . $fb_img; } //And return the Facebook avatar (rather than the default nxt one) return '<img alt="' . esc_attr($params['alt']) . '" src="' . $fb_img . '" class="avatar" />'; }
/** * Retrieve the URL for an attachment. * * @since 2.1.0 * * @param int $post_id Attachment ID. * @return string */ function nxt_get_attachment_url($post_id = 0) { $post_id = (int) $post_id; if (!($post =& get_post($post_id))) { return false; } if ('attachment' != $post->post_type) { return false; } $url = ''; if ($file = get_post_meta($post->ID, '_nxt_attached_file', true)) { //Get attached file if (($uploads = nxt_upload_dir()) && false === $uploads['error']) { //Get upload directory if (0 === strpos($file, $uploads['basedir'])) { //Check that the upload base exists in the file location $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); } elseif (false !== strpos($file, 'nxt-content/uploads')) { $url = $uploads['baseurl'] . substr($file, strpos($file, 'nxt-content/uploads') + 18); } else { $url = $uploads['baseurl'] . "/{$file}"; } //Its a newly uploaded file, therefor $file is relative to the basedir. } } if (empty($url)) { //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recommended to rely upon this. $url = get_the_guid($post->ID); } $url = apply_filters('nxt_get_attachment_url', $url, $post->ID); if (empty($url)) { return false; } return $url; }
/** * Handle sideloads, which is the process of retrieving a media item from another server instead of * a traditional media upload. This process involves sanitizing the filename, checking extensions * for mime type, and moving the file to the appropriate directory within the uploads directory. * * @since 2.6.0 * * @uses nxt_handle_upload_error * @uses apply_filters * @uses nxt_check_filetype_and_ext * @uses current_user_can * @uses nxt_upload_dir * @uses nxt_unique_filename * @param array $file an array similar to that of a PHP $_FILES POST array * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). */ function nxt_handle_sideload(&$file, $overrides = false) { // The default error handler. if (!function_exists('nxt_handle_upload_error')) { function nxt_handle_upload_error(&$file, $message) { return array('error' => $message); } } // You may define your own function and pass the name in $overrides['upload_error_handler'] $upload_error_handler = 'nxt_handle_upload_error'; // You may define your own function and pass the name in $overrides['unique_filename_callback'] $unique_filename_callback = null; // $_POST['action'] must be set and its value must equal $overrides['action'] or this: $action = 'nxt_handle_sideload'; // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. $upload_error_strings = array(false, __("The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>."), __("The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form."), __("The uploaded file was only partially uploaded."), __("No file was uploaded."), '', __("Missing a temporary folder."), __("Failed to write file to disk."), __("File upload stopped by extension.")); // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false; $test_form = true; $test_size = true; // If you override this, you must provide $ext and $type!!!! $test_type = true; $mimes = false; // Install user overrides. Did we mention that this voids your warranty? if (is_array($overrides)) { extract($overrides, EXTR_OVERWRITE); } // A correct form post will pass this test. if ($test_form && (!isset($_POST['action']) || $_POST['action'] != $action)) { return $upload_error_handler($file, __('Invalid form submission.')); } // A successful upload will pass this test. It makes no sense to override this one. if (!empty($file['error'])) { return $upload_error_handler($file, $upload_error_strings[$file['error']]); } // A non-empty file will pass this test. if ($test_size && !(filesize($file['tmp_name']) > 0)) { return $upload_error_handler($file, __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.')); } // A properly uploaded file will pass this test. There should be no reason to override this one. if (!@is_file($file['tmp_name'])) { return $upload_error_handler($file, __('Specified file does not exist.')); } // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. if ($test_type) { $nxt_filetype = nxt_check_filetype_and_ext($file['tmp_name'], $file['name'], $mimes); extract($nxt_filetype); // Check to see if nxt_check_filetype_and_ext() determined the filename was incorrect if ($proper_filename) { $file['name'] = $proper_filename; } if ((!$type || !$ext) && !current_user_can('unfiltered_upload')) { return $upload_error_handler($file, __('Sorry, this file type is not permitted for security reasons.')); } if (!$ext) { $ext = ltrim(strrchr($file['name'], '.'), '.'); } if (!$type) { $type = $file['type']; } } // A writable uploads dir will pass this test. Again, there's no point overriding this one. if (!(($uploads = nxt_upload_dir()) && false === $uploads['error'])) { return $upload_error_handler($file, $uploads['error']); } $filename = nxt_unique_filename($uploads['path'], $file['name'], $unique_filename_callback); // Strip the query strings. $filename = str_replace('?', '-', $filename); $filename = str_replace('&', '-', $filename); // Move the file to the uploads dir $new_file = $uploads['path'] . "/{$filename}"; if (false === @rename($file['tmp_name'], $new_file)) { return $upload_error_handler($file, sprintf(__('The uploaded file could not be moved to %s.'), $uploads['path'])); } // Set correct file permissions $stat = stat(dirname($new_file)); $perms = $stat['mode'] & 0666; @chmod($new_file, $perms); // Compute the URL $url = $uploads['url'] . "/{$filename}"; $return = apply_filters('nxt_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type), 'sideload'); return $return; }
/** * Create a file in the upload folder with given content. * * If there is an error, then the key 'error' will exist with the error message. * If success, then the key 'file' will have the unique file path, the 'url' key * will have the link to the new file. and the 'error' key will be set to false. * * This function will not move an uploaded file to the upload folder. It will * create a new file with the content in $bits parameter. If you move the upload * file, read the content of the uploaded file, and then you can give the * filename and content to this function, which will add it to the upload * folder. * * The permissions will be set on the new file automatically by this function. * * @since 2.0.0 * * @param string $name * @param null $deprecated Never used. Set to null. * @param mixed $bits File content * @param string $time Optional. Time formatted in 'yyyy/mm'. * @return array */ function nxt_upload_bits($name, $deprecated, $bits, $time = null) { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.0'); } if (empty($name)) { return array('error' => __('Empty filename')); } $nxt_filetype = nxt_check_filetype($name); if (!$nxt_filetype['ext']) { return array('error' => __('Invalid file type')); } $upload = nxt_upload_dir($time); if ($upload['error'] !== false) { return $upload; } $upload_bits_error = apply_filters('nxt_upload_bits', array('name' => $name, 'bits' => $bits, 'time' => $time)); if (!is_array($upload_bits_error)) { $upload['error'] = $upload_bits_error; return $upload; } $filename = nxt_unique_filename($upload['path'], $name); $new_file = $upload['path'] . "/{$filename}"; if (!nxt_mkdir_p(dirname($new_file))) { $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); return array('error' => $message); } $ifp = @fopen($new_file, 'wb'); if (!$ifp) { return array('error' => sprintf(__('Could not write file %s'), $new_file)); } @fwrite($ifp, $bits); fclose($ifp); clearstatcache(); // Set correct file permissions $stat = @stat(dirname($new_file)); $perms = $stat['mode'] & 07777; $perms = $perms & 0666; @chmod($new_file, $perms); clearstatcache(); // Compute the URL $url = $upload['url'] . "/{$filename}"; return array('file' => $new_file, 'url' => $url, 'error' => false); }
<?php if (w3_is_writable_dir(nxt_CONTENT_DIR)) { ?> <code>OK</code> <?php } else { ?> <code>Not write-able</code> <?php } ?> </li> <li> <?php $uploads_dir = @nxt_upload_dir(); ?> <?php echo htmlspecialchars($uploads_dir['path']); ?> : <?php if (!empty($uploads_dir['error'])) { ?> <code>Error: <?php echo htmlspecialchars($uploads_dir['error']); ?> </code> <?php } elseif (!w3_is_writable_dir($uploads_dir['path'])) { ?>
/** * Set static upload directory properties * * @internal * @return boolean */ private function populate_dir_props() { // only populate dir info once if (!self::$populated) { // get upload directory details $upload_dir = nxt_upload_dir(); // make sure we didn't get an error if ($upload_dir['error'] == false) { // set upload dir path and url self::$upload_dir = realpath($upload_dir['basedir']); self::$upload_url = $upload_dir['baseurl']; // determine export path and url self::$export_dir = sprintf('%s/%s/%s', self::$upload_dir, ICE_EXPORTS_SUBDIR, ICE_ACTIVE_THEME); self::$export_url = sprintf('%s/%s/%s', self::$upload_url, ICE_EXPORTS_SUBDIR, ICE_ACTIVE_THEME); // don't try to set these twice self::$populated = true; // yay return true; } throw new ICE_Export_Exception($upload_dir['error']); } return true; }
function __construct($form, $urlholder) { if (empty($_FILES[$form]['name']) && empty($_GET[$urlholder])) { nxt_die(__('Please select a file')); } //Handle a newly uploaded file, Else assume its already been uploaded if (!empty($_FILES)) { $overrides = array('test_form' => false, 'test_type' => false); $file = nxt_handle_upload($_FILES[$form], $overrides); if (isset($file['error'])) { nxt_die($file['error']); } $this->filename = $_FILES[$form]['name']; $this->package = $file['file']; // Construct the object array $object = array('post_title' => $this->filename, 'post_content' => $file['url'], 'post_mime_type' => $file['type'], 'guid' => $file['url'], 'context' => 'upgrader', 'post_status' => 'private'); // Save the data $this->id = nxt_insert_attachment($object, $file['file']); // schedule a cleanup for 2 hours from now in case of failed install nxt_schedule_single_event(time() + 7200, 'upgrader_scheduled_cleanup', array($this->id)); } elseif (is_numeric($_GET[$urlholder])) { // Numeric Package = previously uploaded file, see above. $this->id = (int) $_GET[$urlholder]; $attachment = get_post($this->id); if (empty($attachment)) { nxt_die(__('Please select a file')); } $this->filename = $attachment->post_title; $this->package = get_attached_file($attachment->ID); } else { // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler. if (!(($uploads = nxt_upload_dir()) && false === $uploads['error'])) { nxt_die($uploads['error']); } $this->filename = $_GET[$urlholder]; $this->package = $uploads['basedir'] . '/' . $this->filename; } }
function woo_tumblog_file_upload() { global $nxtdb; //Upload overrides $filename = $_FILES['userfile']; // [name] [tmp_name] $override['test_form'] = false; $override['action'] = 'nxt_handle_upload'; //Handle Uploaded File $uploaded_file = nxt_handle_upload($filename, $override); // [file] [url] [type] //Create Attachment Object $attachment['post_title'] = $filename['name']; //post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type $attachment['post_content'] = ''; $attachment['post_status'] = 'inherit'; $attachment['post_mime_type'] = $uploaded_file['type']; $attachment['guid'] = $uploaded_file['url']; //Prepare file attachment $wud = nxt_upload_dir(); // [path] [url] [subdir] [basedir] [baseurl] [error] $filename_attach = $wud['basedir'] . $uploaded_file['file']; //Insert Attachment $attach_id = nxt_insert_attachment($attachment, $filename_attach, 0); $attach_data = nxt_generate_attachment_metadata($attach_id, $filename_attach); nxt_update_attachment_metadata($attach_id, $attach_data); //Handle Errors and Response if (!empty($uploaded_file['error'])) { echo 'Upload Error: ' . $uploaded_file['error']; } else { echo $uploaded_file['url'] . '|' . $attach_id . '|'; } // Is the Response }
/** * Outputs the form used by the importers to accept the data to be imported * * @since 2.0.0 * * @param string $action The action attribute for the form. */ function nxt_import_upload_form($action) { $bytes = apply_filters('import_upload_size_limit', nxt_max_upload_size()); $size = nxt_convert_bytes_to_hr($bytes); $upload_dir = nxt_upload_dir(); if (!empty($upload_dir['error'])) { ?> <div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?> </p> <p><strong><?php echo $upload_dir['error']; ?> </strong></p></div><?php } else { ?> <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(nxt_nonce_url($action, 'import-upload')); ?> "> <p> <label for="upload"><?php _e('Choose a file from your computer:'); ?> </label> (<?php printf(__('Maximum size: %s'), $size); ?> ) <input type="file" id="upload" name="import" size="25" /> <input type="hidden" name="action" value="save" /> <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?> " /> </p> <?php submit_button(__('Upload file and import'), 'button'); ?> </form> <?php } }
function et_create_images_temp_folder() { #clean et_temp folder once per week if (false !== ($last_time = get_option('et_schedule_clean_images_last_time'))) { $timeout = 86400 * 7; if ($timeout < time() - $last_time && '' != get_option('et_images_temp_folder')) { et_clean_temp_images(get_option('et_images_temp_folder')); } } if (false !== get_option('et_images_temp_folder')) { return; } $uploads_dir = nxt_upload_dir(); $destination_dir = false === $uploads_dir['error'] ? path_join($uploads_dir['basedir'], 'et_temp') : null; if (!nxt_mkdir_p($destination_dir)) { update_option('et_images_temp_folder', ''); } else { update_option('et_images_temp_folder', $destination_dir); update_option('et_schedule_clean_images_last_time', time()); } }
function jfb_output_premium_panel_tease() { global $jfb_homepage; global $opt_jfbp_notifyusers, $opt_jfbp_notifyusers_subject, $opt_jfbp_notifyusers_content, $opt_jfbp_commentfrmlogin, $opt_jfbp_nxtloginfrmlogin, $opt_jfbp_registrationfrmlogin, $opt_jfbp_cache_avatars, $opt_jfbp_cache_avatars_fullsize, $opt_jfbp_cache_avatar_dir; global $opt_jfbp_buttonsize, $opt_jfbp_buttontext, $opt_jfbp_requirerealmail; global $opt_jfbp_redirect_new, $opt_jfbp_redirect_new_custom, $opt_jfbp_redirect_existing, $opt_jfbp_redirect_existing_custom, $opt_jfbp_redirect_logout, $opt_jfbp_redirect_logout_custom; global $opt_jfbp_restrict_reg, $opt_jfbp_restrict_reg_url, $opt_jfbp_restrict_reg_uid, $opt_jfbp_restrict_reg_pid, $opt_jfbp_restrict_reg_gid; global $opt_jfbp_show_spinner, $jfb_data_url; global $opt_jfbp_wordbooker_integrate, $opt_jfbp_signupfrmlogin, $opt_jfbp_localize_facebook; global $opt_jfbp_xprofile_map, $opt_jfbp_xprofile_mappings, $jfb_xprofile_field_prefix; global $opt_jfbp_bpstream_login, $opt_jfbp_bpstream_logincontent, $opt_jfbp_bpstream_register, $opt_jfbp_bpstream_registercontent; function disableatt() { echo defined('JFB_PREMIUM') ? "" : "disabled='disabled'"; } ?> <h3>Premium Options <?php echo defined('JFB_PREMIUM_VER') ? "<small>(Version " . JFB_PREMIUM_VER . ")</small>" : ""; ?> </h3> <?php if (!defined('JFB_PREMIUM')) { echo "<div class=\"jfb-admin_warning\"><i><b>The following options are available to Premium users only.</b><br />For information about the nxt-FB-AutoConnect Premium Add-On, including purchasing instructions, please visit the plugin homepage <b><a href=\"{$jfb_homepage}#premium\">here</a></b></i>.</div>"; } ?> <form name="formPremOptions" method="post" action=""> <b>MultiSite Support:</b><br/> <input disabled='disabled' type="checkbox" name="musupport" value="1" <?php echo defined('JFB_PREMIUM') && function_exists('is_multisite') && is_multisite() ? "checked='checked'" : ""; ?> > Automatically enabled when a MultiSite install is detected <dfn title="The free plugin is not aware of users registered on other sites in your nxtMU installation, which can result in problems i.e. if someone tries to register on more than one site. The Premium version will actively detect and handle existing users across all your sites.">(Mouseover for more info)</dfn><br /><br /> <b>Double Logins:</b><br /> <input disabled='disabled' type="checkbox" name="doublelogin" value="1" <?php echo defined('JFB_PREMIUM') ? "checked='checked'" : ""; ?> /> Automatically handle double logins <dfn title="If a visitor opens two browser windows, logs into one, then logs into the other, the security nonce check will fail. This is because in the second window, the current user no longer matches the user for which the nonce was generated. The free version of the plugin reports this to the visitor, giving them a link to their desired redirect page. The premium version will transparently handle such double-logins: to visitors, it'll look like the page has just been refreshed and they're now logged in. For more information on nonces, please visit http://codex.nxtclass.org/NXTClass_Nonces.">(Mouseover for more info)</dfn><br /><br /> <!-- Facebook's OAuth 2.0 migration BROKE my ability to localize the XFBML-generated dialog. I've reported a bug, and will do my best to fix it as soon as possible. <b>Facebook Localization:</b><br /> <?php add_option($opt_jfbp_localize_facebook, 1); ?> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_localize_facebook; ?> " value="1" <?php echo get_option($opt_jfbp_localize_facebook) ? "checked='checked'" : ""; ?> > Translate Facebook prompts to the same locale as your nxtclass blog (Detected locale: <i><?php echo defined('nxtLANG') && nxtLANG != "" ? nxtLANG : "en_US"; ?> </i>) <dfn title="The nxtclass locale is specified in nxt-config.php, where valid language codes are of the form 'en_US', 'ja_JP', 'es_LA', etc. Please see http://codex.nxtclass.org/Installing_NXTClass_in_Your_Language for more information on localizing nxtclass, and http://developers.facebook.com/docs/internationalization/ for a list of locales supported by Facebook.">(Mouseover for more info)</dfn><br /><br /> --> <b>E-Mail Permissions:</b><br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_requirerealmail; ?> " value="1" <?php echo get_option($opt_jfbp_requirerealmail) ? 'checked="checked"' : ''; ?> /> Enforce access to user's real (unproxied) email <dfn title="The basic option to request user emails will prompt your visitors, but they can still hide their true addresses by using a Facebook proxy (click 'change' in the permissions dialog, and select '*****@*****.**'). This option performs a secondary check to enforce that they allow access to their REAL e-mail. Note that the check requires several extra queries to Facebook's servers, so it could result in a slightly longer delay before the login initiates.">(Mouseover for more info)</dfn><br /><br /> <b>Avatar Caching:</b><br /> <?php add_option($opt_jfbp_cache_avatars_fullsize, get_option($opt_jfbp_cache_avatars)); ?> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_cache_avatars; ?> " value="1" <?php echo get_option($opt_jfbp_cache_avatars) ? 'checked="checked"' : ''; ?> /> Cache Facebook avatars locally (thumbnail) <dfn title="This will make a local copy of Facebook avatars, so they'll always load reliably, even if Facebook's servers go offline or if a user deletes their photo from Facebook. They will be fetched and updated whenever a user logs in.">(Mouseover for more info)</dfn><br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_cache_avatars_fullsize; ?> " value="1" <?php echo get_option($opt_jfbp_cache_avatars_fullsize) ? 'checked="checked"' : ''; ?> /> Cache Facebook avatars locally (fullsize) <dfn title="Because most themes only utilize thumbnail-sized avatars, caching full-sized images is often unnecessary. If you're not actually using full-sized avatars I recommend disabling this option, as doing so will speed up logins and save space on your server (there's a small per-login performance cost to copying the files locally).">(Mouseover for more info)</dfn><br /> Cache directory: <span style="background-color:#FFFFFF; color:#aaaaaa; padding:2px 0;"><?php add_option($opt_jfbp_cache_avatar_dir, 'facebook-avatars'); $ud = nxt_upload_dir(); echo "<i>" . $ud['basedir'] . "/</i>"; ?> </span> <input <?php disableatt(); ?> type="text" size="20" name="<?php echo $opt_jfbp_cache_avatar_dir; ?> " value="<?php echo get_option($opt_jfbp_cache_avatar_dir); ?> " /> <dfn title="Changing the cache directory will not move existing avatars or update existing users; it only applies to subsequent logins. It's therefore recommended that you choose a cache directory once, then leave it be.">(Mouseover for more info)</dfn><br /><br /> <b>Wordbooker Avatar Integration:</b><br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_wordbooker_integrate; ?> " value="1" <?php echo get_option($opt_jfbp_wordbooker_integrate) ? 'checked="checked"' : ''; ?> /> Use Facebook avatars for <a href="http://nxtclass.org/extend/plugins/wordbooker/">Wordbooker</a>-imported comments <dfn title="The Wordbooker plugin allows you to push blog posts to your Facebook wall, and also to import comments on these posts back to your blog. This option will display real Facebook avatars for imported comments, provided the commentor logs into your site at least once.">(Mouseover for more info)</dfn><br /><br /> <b>Widget Appearance:</b><br /> Please use the <a href="<?php echo admin_url('widgets.php'); ?> " target="widgets">nxt-FB AutoConnect <b><i>Premium</i></b> Widget</a> if you'd like to:<br /> • Customize the Widget's text <dfn title="You can customize the text of: User, Pass, Login, Remember, Forgot, Logout, Edit Profile, Welcome.">(Mouseover for more info)</dfn><br /> • Hide the User/Pass fields (leaving Facebook as the only way to login)<br /> • Show the user's avatar (when logged in)<br /> • Show a "Remember" tickbox<br /> • Allow the user to simultaneously logout of your site <i>and</i> Facebook<br /><br /> <b>Button Appearance:</b><br /> <?php add_option($opt_jfbp_buttontext, "Login with Facebook"); ?> <?php add_option($opt_jfbp_buttonsize, "2"); ?> Text: <input <?php disableatt(); ?> type="text" size="30" name="<?php echo $opt_jfbp_buttontext; ?> " value="<?php echo get_option($opt_jfbp_buttontext); ?> " /> <dfn title="This setting applies to ALL of your Facebook buttons (in the widget, nxt-login.php, comment forms, etc).">(Mouseover for more info)</dfn><br /> Style: <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_buttonsize; ?> " value="2" <?php echo get_option($opt_jfbp_buttonsize) == 2 ? "checked='checked'" : ""; ?> >Small <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_buttonsize; ?> " value="3" <?php echo get_option($opt_jfbp_buttonsize) == 3 ? "checked='checked'" : ""; ?> >Medium <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_buttonsize; ?> " value="4" <?php echo get_option($opt_jfbp_buttonsize) == 4 ? "checked='checked'" : ""; ?> >Large <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_buttonsize; ?> " value="5" <?php echo get_option($opt_jfbp_buttonsize) == 5 ? "checked='checked'" : ""; ?> >X-Large<br /><br /> <b>Additional Buttons:</b><br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_commentfrmlogin; ?> " value="1" <?php echo get_option($opt_jfbp_commentfrmlogin) ? 'checked="checked"' : ''; ?> /> Add a Facebook Login button below the comment form<br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_nxtloginfrmlogin; ?> " value="1" <?php echo get_option($opt_jfbp_nxtloginfrmlogin) ? 'checked="checked"' : ''; ?> /> Add a Facebook Login button to the standard Login page (nxt-login.php)<br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_registrationfrmlogin; ?> " value="1" <?php echo get_option($opt_jfbp_registrationfrmlogin) ? 'checked="checked"' : ''; ?> /> Add a Facebook Login button to the Registration page (nxt-login.php)<br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_signupfrmlogin; ?> " value="1" <?php echo get_option($opt_jfbp_signupfrmlogin) ? 'checked="checked"' : ''; ?> /> Add a Facebook Login button to the Signup page (nxt-signup.php) (nxtMU Only)<br /><br /> <b>AJAX Spinner:</b><br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_show_spinner; ?> " value="0" <?php echo get_option($opt_jfbp_show_spinner) == 0 ? "checked='checked'" : ""; ?> >Don't show an AJAX spinner<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_show_spinner; ?> " value="1" <?php echo get_option($opt_jfbp_show_spinner) == 1 ? "checked='checked'" : ""; ?> >Show a white AJAX spinner to indicate the login process has started (<img src=" <?php echo $jfb_data_url; ?> /spinner/spinner_white.gif" alt="spinner" />)<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_show_spinner; ?> " value="2" <?php echo get_option($opt_jfbp_show_spinner) == 2 ? "checked='checked'" : ""; ?> >Show a black AJAX spinner to indicate the login process has started (<img src=" <?php echo $jfb_data_url; ?> /spinner/spinner_black.gif" alt="spinner" />)<br /><br /> <b>AutoRegistration Restrictions:</b><br /> <?php add_option($opt_jfbp_restrict_reg_url, '/'); ?> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_restrict_reg; ?> " value="0" <?php echo get_option($opt_jfbp_restrict_reg) == 0 ? "checked='checked'" : ""; ?> >Open: Anyone can login (Default)<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_restrict_reg; ?> " value="1" <?php echo get_option($opt_jfbp_restrict_reg) == 1 ? "checked='checked'" : ""; ?> >Closed: Only login existing blog users<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_restrict_reg; ?> " value="2" <?php echo get_option($opt_jfbp_restrict_reg) == 2 ? "checked='checked'" : ""; ?> >Invitational: Only login users who've been invited via the <a href="http://nxtclass.org/extend/plugins/nxtclass-mu-secure-invites/">Secure Invites</a> plugin <dfn title="For invites to work, the connecting user's Facebook email must be accessible, and it must match the email to which the invitation was sent.">(Mouseover for more info)</dfn><br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_restrict_reg; ?> " value="3" <?php echo get_option($opt_jfbp_restrict_reg) == 3 ? "checked='checked'" : ""; ?> >Friendship: Only login users who are friends with uid <input <?php disableatt(); ?> type="text" size="15" name="<?php echo $opt_jfbp_restrict_reg_uid; ?> " value="<?php echo get_option($opt_jfbp_restrict_reg_uid); ?> " /> on Facebook <dfn title="To find your Facebook uid, login and view your Profile Pictures album. The URL will be something like 'http://www.facebook.com/media/set/?set=a.123.456.789'. In this example, your uid would be 789 (the numbers after the last decimal point).">(Mouseover for more info)</dfn><br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_restrict_reg; ?> " value="4" <?php echo get_option($opt_jfbp_restrict_reg) == 4 ? "checked='checked'" : ""; ?> >Membership: Only login users who are members of group id <input <?php disableatt(); ?> type="text" size="15" name="<?php echo $opt_jfbp_restrict_reg_gid; ?> " value="<?php echo get_option($opt_jfbp_restrict_reg_gid); ?> " /> on Facebook <dfn title="To find a groups's id, view its URL. It will be something like 'http://www.facebook.com/group.php?gid=12345678'. In this example, the group id would be 12345678.">(Mouseover for more info)</dfn><br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_restrict_reg; ?> " value="5" <?php echo get_option($opt_jfbp_restrict_reg) == 5 ? "checked='checked'" : ""; ?> >Fanpage: Only login users who are fans of page id <input <?php disableatt(); ?> type="text" size="15" name="<?php echo $opt_jfbp_restrict_reg_pid; ?> " value="<?php echo get_option($opt_jfbp_restrict_reg_pid); ?> " /> on Facebook <dfn title="To find a page's id, view one of its photo albums. The URL will be something like 'http://www.facebook.com/media/set/?set=a.123.456.789'. In this example, the id would be 789 (the numbers after the last decimal point).">(Mouseover for more info)</dfn><br /> Redirect URL for denied logins: <input <?php disableatt(); ?> type="text" size="30" name="<?php echo $opt_jfbp_restrict_reg_url; ?> " value="<?php echo get_option($opt_jfbp_restrict_reg_url); ?> " /><br /><br /> <b>Custom Redirects:</b><br /> <?php add_option($opt_jfbp_redirect_new, "1"); ?> <?php add_option($opt_jfbp_redirect_existing, "1"); ?> <?php add_option($opt_jfbp_redirect_logout, "1"); ?> When a new user is autoregistered on your site, redirect them to:<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_redirect_new; ?> " value="1" <?php echo get_option($opt_jfbp_redirect_new) == 1 ? "checked='checked'" : ""; ?> >Default (refresh current page)<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_redirect_new; ?> " value="2" <?php echo get_option($opt_jfbp_redirect_new) == 2 ? "checked='checked'" : ""; ?> >Custom URL: <input <?php disableatt(); ?> type="text" size="47" name="<?php echo $opt_jfbp_redirect_new_custom; ?> " value="<?php echo get_option($opt_jfbp_redirect_new_custom); ?> " /> <small>(Supports %username% variables)</small><br /><br /> When an existing user returns to your site, redirect them to:<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_redirect_existing; ?> " value="1" <?php echo get_option($opt_jfbp_redirect_existing) == 1 ? "checked='checked'" : ""; ?> >Default (refresh current page)<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_redirect_existing; ?> " value="2" <?php echo get_option($opt_jfbp_redirect_existing) == 2 ? "checked='checked'" : ""; ?> >Custom URL: <input <?php disableatt(); ?> type="text" size="47" name="<?php echo $opt_jfbp_redirect_existing_custom; ?> " value="<?php echo get_option($opt_jfbp_redirect_existing_custom); ?> " /> <small>(Supports %username% variables)</small><br /><br /> When a user logs out of your site, redirect them to:<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_redirect_logout; ?> " value="1" <?php echo get_option($opt_jfbp_redirect_logout) == 1 ? "checked='checked'" : ""; ?> >Default (refresh current page)<br /> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_redirect_logout; ?> " value="2" <?php echo get_option($opt_jfbp_redirect_logout) == 2 ? "checked='checked'" : ""; ?> >Custom URL: <input <?php disableatt(); ?> type="text" size="47" name="<?php echo $opt_jfbp_redirect_logout_custom; ?> " value="<?php echo get_option($opt_jfbp_redirect_logout_custom); ?> " /><br /><br /> <b>Welcome Message:</b><br /> <?php add_option($opt_jfbp_notifyusers_content, "Thank you for logging into " . get_option('blogname') . " with Facebook.\nIf you would like to login manually, you may do so with the following credentials.\n\nUsername: %username%\nPassword: %password%"); ?> <?php add_option($opt_jfbp_notifyusers_subject, "Welcome to " . get_option('blogname')); ?> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_notifyusers; ?> " value="1" <?php echo get_option($opt_jfbp_notifyusers) ? 'checked="checked"' : ''; ?> /> Send a custom welcome e-mail to users who register via Facebook <small>(*If we know their address)</small><br /> <input <?php disableatt(); ?> type="text" size="102" name="<?php echo $opt_jfbp_notifyusers_subject; ?> " value="<?php echo get_option($opt_jfbp_notifyusers_subject); ?> " /><br /> <textarea <?php disableatt(); ?> cols="85" rows="5" name="<?php echo $opt_jfbp_notifyusers_content; ?> "><?php echo get_option($opt_jfbp_notifyusers_content); ?> </textarea><br /><br /> <b>BuddyPress Activity Stream:</b><br /> <?php add_option($opt_jfbp_bpstream_logincontent, "%user% logged in with Facebook"); ?> <?php add_option($opt_jfbp_bpstream_registercontent, "%user% registered with Facebook"); ?> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_bpstream_register; ?> " value="1" <?php echo get_option($opt_jfbp_bpstream_register) ? 'checked="checked"' : ''; ?> /> When a new user autoconnects to your site, post to the BP Activity Stream: <input <?php disableatt(); ?> type="text" size="50" name="<?php echo $opt_jfbp_bpstream_registercontent; ?> " value="<?php echo get_option($opt_jfbp_bpstream_registercontent); ?> " /><br /> <input <?php disableatt(); ?> type="checkbox" name="<?php echo $opt_jfbp_bpstream_login; ?> " value="1" <?php echo get_option($opt_jfbp_bpstream_login) ? 'checked="checked"' : ''; ?> /> When an existing user returns to your site, post to the BP Activity Stream: <input <?php disableatt(); ?> type="text" size="50" name="<?php echo $opt_jfbp_bpstream_logincontent; ?> " value="<?php echo get_option($opt_jfbp_bpstream_logincontent); ?> " /><br /><br /> <b>BuddyPress X-Profile Mappings</b><br /> This section will let you automatically fill in your Buddypress users' X-Profile data from their Facebook profiles.<br /> <small>• Facebook fields marked with an asterisk (i.e. Birthday*) require the user to approve extra permissions during login.</small><br /> <small>• Some limitations exist regarding which X-Profile fields can be populated <dfn title="Only 'Text Box,' 'Multi-Line Text Box,' and 'Date Selector'-type profile fields can be mapped at this time. Due to unpredictability in matching freeform values from Facebook to pre-defined values on BuddyPress, support for dropdowns, radiobuttons, and checkboxes MAY be added in the future.">(Mouseover for more info)</dfn></small><br /> <small>• Some limitations exist regarding which Facebook fields can be imported <dfn title="Because some Facebook fields are formatted differently, each one needs to be explicitly implemented. I've included an initial selection of fields (i.e. Name, Gender, Birthday, Bio, etc), but if you need another field to be available, please request it on the support page and I'll do my best to add it to the next update.">(Mouseover for more info)</dfn></small><br /><br /> <?php //If people report problems with Buddypress detection, use this more robust method: http://codex.buddypress.org/plugin-development/checking-buddypress-is-active/ if (!function_exists('bp_has_profile')) { echo "<i>BuddyPress Not Found. This section is only available on BuddyPress-enabled sites.</i>"; } else { if (!bp_has_profile()) { echo "Error: BuddyPress Profile Not Found. This should never happen - if you see this message, please report it on the plugin support page."; } else { //Present the 3 mapping options: disable mapping, map new users, or map new and returning users ?> <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_xprofile_map; ?> " value="0" <?php echo get_option($opt_jfbp_xprofile_map) == 0 ? "checked='checked'" : ""; ?> >Disable Mapping <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_xprofile_map; ?> " value="1" <?php echo get_option($opt_jfbp_xprofile_map) == 1 ? "checked='checked'" : ""; ?> >Map New Users Only <input <?php disableatt(); ?> type="radio" name="<?php echo $opt_jfbp_xprofile_map; ?> " value="2" <?php echo get_option($opt_jfbp_xprofile_map) == 2 ? "checked='checked'" : ""; ?> >Map New And Returning Users<br /><?php //Make a list of which Facebook fields may be mapped to each type of xProfile field. Omitted types (i.e. checkbox) are treated as "unmappable." //The format is "xprofile_field_type"->"(fbfieldname1, fbfieldDisplayname1), (fbfieldname2, fbfieldDisplayname2), ..." //(Available FB fields are documented at: https://developers.facebook.com/docs/reference/api/user/) $allowed_mappings = array('textbox' => array('id' => "ID", 'name' => "Name", 'first_name' => "First Name", 'middle_name' => "Middle Name", 'last_name' => "Last Name", 'username' => "Username", 'gender' => "Gender", 'link' => "Profile URL", "website" => "Website*", 'bio' => "Bio*", 'political' => "Political*", "religion" => "Religion*", 'relationship_status' => "Relationship*", "location" => "City*", "hometown" => "Hometown*", 'languages' => "Languages*"), 'textarea' => array('id' => "ID", 'name' => "Name", 'first_name' => "First Name", 'middle_name' => "Middle Name", 'last_name' => "Last Name", 'username' => "Username", 'gender' => "Gender", 'link' => "Profile URL", "website" => "Website*", 'bio' => "Bio*", 'political' => "Political*", "religion" => "Religion*", 'relationship_status' => "Relationship*", "location" => "City*", "hometown" => "Hometown*", 'languages' => "Languages*"), 'datebox' => array('birthday' => 'Birthday*')); $allowed_mappings = apply_filters('nxtfb_xprofile_allowed_mappings', $allowed_mappings); //Go through all of the XProfile fields and offer possible Facebook mappings for each (in a dropdown). //(current_mappings is used to set the initial state of the panel, i.e. based on what mappings are already in the db) $current_mappings = get_option($opt_jfbp_xprofile_mappings); while (bp_profile_groups()) { //Create a "box" for each XProfile Group global $group; bp_the_profile_group(); ?> <div style="width:420px; padding:5px; margin:2px 0; background-color:#EEEDDA; border:1px solid #CCC;"><?php echo "Group \"{$group->name}\":<br />"; //And populate the group box with Textarea(xprofile field)->Dropdown(possible facebook mappings) while (bp_profile_fields()) { //Output the X-Profile field textarea global $field; bp_the_profile_field(); ?> <input disabled='disabled' type="text" size="20" name="<?php echo $field->name; ?> " value="<?php echo $field->name; ?> " /> -> <?php //If there aren't any available Facebook mappings, just put a disabled textbox and "hidden" field that sets this option as '0' if (!$allowed_mappings[$field->type]) { echo "<input disabled='disabled' type='text' size='30' name='{$field->name}" . "_unavail" . "' value='(No Mappings Available)' />"; echo "<input type='hidden' name='{$field->id}' value='0' />"; continue; } //Otherwise, list all of the available mappings in a dropdown. ?> <select name="<?php echo $jfb_xprofile_field_prefix . $field->id; ?> "> <option value="0">(No Mapping)</option><?php foreach ($allowed_mappings[$field->type] as $fbname => $userfriendlyname) { echo "<option " . ($current_mappings[$field->id] == $fbname ? "selected" : "") . " value=\"{$fbname}\">{$userfriendlyname}</option>"; } ?> </select><br /><?php } ?> </div><?php } } } ?> <input type="hidden" name="prem_opts_updated" value="1" /> <div class="submit"><input <?php disableatt(); ?> type="submit" name="Submit" value="Save Premium" /></div> </form> <?php }
/** * Finds a pingback server URI based on the given URL. * * Checks the HTML for the rel="pingback" link and x-pingback headers. It does * a check for the x-pingback headers first and returns that, if available. The * check for the rel="pingback" has more overhead than just the header. * * @since 1.5.0 * * @param string $url URL to ping. * @param int $deprecated Not Used. * @return bool|string False on failure, string containing URI on success. */ function discover_pingback_server_uri($url, $deprecated = '') { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.7'); } $pingback_str_dquote = 'rel="pingback"'; $pingback_str_squote = 'rel=\'pingback\''; /** @todo Should use Filter Extension or custom preg_match instead. */ $parsed_url = parse_url($url); if (!isset($parsed_url['host'])) { // Not an URL. This should never happen. return false; } //Do not search for a pingback server on our own uploads $uploads_dir = nxt_upload_dir(); if (0 === strpos($url, $uploads_dir['baseurl'])) { return false; } $response = nxt_remote_head($url, array('timeout' => 2, 'httpversion' => '1.0')); if (is_nxt_error($response)) { return false; } if (nxt_remote_retrieve_header($response, 'x-pingback')) { return nxt_remote_retrieve_header($response, 'x-pingback'); } // Not an (x)html, sgml, or xml page, no use going further. if (preg_match('#(image|audio|video|model)/#is', nxt_remote_retrieve_header($response, 'content-type'))) { return false; } // Now do a GET since we're going to look in the html headers (and we're sure its not a binary file) $response = nxt_remote_get($url, array('timeout' => 2, 'httpversion' => '1.0')); if (is_nxt_error($response)) { return false; } $contents = nxt_remote_retrieve_body($response); $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote); $pingback_link_offset_squote = strpos($contents, $pingback_str_squote); if ($pingback_link_offset_dquote || $pingback_link_offset_squote) { $quote = $pingback_link_offset_dquote ? '"' : '\''; $pingback_link_offset = $quote == '"' ? $pingback_link_offset_dquote : $pingback_link_offset_squote; $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset); $pingback_href_start = $pingback_href_pos + 6; $pingback_href_end = @strpos($contents, $quote, $pingback_href_start); $pingback_server_url_len = $pingback_href_end - $pingback_href_start; $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len); // We may find rel="pingback" but an incomplete pingback URL if ($pingback_server_url_len > 0) { // We got it! return $pingback_server_url; } } return false; }