mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 06:03:38 +09:00
Merge pull request #72 from jonfalcon/master
SSL Checker / auto login after registering
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<div class="">
|
||||
|
||||
|
||||
<p>
|
||||
<label class="um-admin-half"><?php _e('Registration Status','ultimatemember'); ?> <?php $this->tooltip( __('Select the status you would like this user role to have after they register on your site','ultimatemember') ); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
<select name="_um_status" id="_um_status" class="umaf-selectjs um-adm-conditional" style="width: 300px"
|
||||
data-cond1="approved" data-cond1-show="approved"
|
||||
|
||||
<select name="_um_status" id="_um_status" class="umaf-selectjs um-adm-conditional" style="width: 300px"
|
||||
data-cond1="approved" data-cond1-show="approved"
|
||||
data-cond2="checkmail" data-cond2-show="checkmail"
|
||||
data-cond3="pending" data-cond3-show="pending">
|
||||
<option value="approved" <?php selected('approved', $ultimatemember->query->get_meta_value('_um_status') ); ?>><?php _e('Auto Approve','ultimatemember'); ?></option>
|
||||
<option value="checkmail" <?php selected('checkmail', $ultimatemember->query->get_meta_value('_um_status') ); ?>><?php _e('Require Email Activation','ultimatemember'); ?></option>
|
||||
<option value="pending" <?php selected('pending', $ultimatemember->query->get_meta_value('_um_status') ); ?>><?php _e('Require Admin Review','ultimatemember'); ?></option>
|
||||
</select>
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
<!-- Automatic Approval Settings -->
|
||||
|
||||
|
||||
<div class="approved">
|
||||
<p>
|
||||
<label class="um-admin-half"><?php _e('Action to be taken after registration','ultimatemember'); ?> <?php $this->tooltip( __('Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message','ultimatemember') ); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<select name="_um_auto_approve_act" id="_um_auto_approve_act" class="umaf-selectjs um-adm-conditional" style="width: 300px" data-cond1="redirect_url" data-cond1-show="_um_auto_approve_act">
|
||||
<option value="redirect_profile" <?php selected('redirect_profile', $ultimatemember->query->get_meta_value('_um_auto_approve_act') ); ?>><?php _e('Redirect to profile','ultimatemember'); ?></option>
|
||||
<option value="redirect_url" <?php selected('redirect_url', $ultimatemember->query->get_meta_value('_um_auto_approve_act') ); ?>><?php _e('Redirect to URL','ultimatemember'); ?></option>
|
||||
@@ -32,28 +32,37 @@
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
<p class="_um_auto_approve_act">
|
||||
<label class="um-admin-half" for="_um_auto_approve_url"><?php _e('Set Custom Redirect URL','ultimatemember'); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<input type="text" value="<?php echo $ultimatemember->query->get_meta_value('_um_auto_approve_url', null, 'na'); ?>" name="_um_auto_approve_url" id="_um_auto_approve_url" />
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Automatic Approval Settings -->
|
||||
|
||||
|
||||
<!-- Email Approval Settings -->
|
||||
|
||||
|
||||
<div class="checkmail">
|
||||
|
||||
|
||||
<p>
|
||||
<label class="um-admin-half"><?php _e('Login user after validating the activation link?','ultimatemember'); ?> <?php $this->tooltip( __('Login the user after validating the activation link','ultimatemember') ); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
<?php $this->ui_on_off('_um_login_email_activate', 0); ?>
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
<p>
|
||||
<label class="um-admin-half"><?php _e('Action to be taken after registration','ultimatemember'); ?> <?php $this->tooltip( __('Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message','ultimatemember') ); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
<select name="_um_checkmail_action" id="_um_checkmail_action" class="umaf-selectjs um-adm-conditional" style="width: 300px"
|
||||
|
||||
<select name="_um_checkmail_action" id="_um_checkmail_action" class="umaf-selectjs um-adm-conditional" style="width: 300px"
|
||||
data-cond1="show_message" data-cond1-show="_um_checkmail_action-1"
|
||||
data-cond2="redirect_url" data-cond2-show="_um_checkmail_action-2">
|
||||
<option value="show_message" <?php selected('show_message', $ultimatemember->query->get_meta_value('_um_checkmail_action') ); ?>><?php _e('Show custom message','ultimatemember'); ?></option>
|
||||
@@ -62,46 +71,46 @@
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
<p class="_um_checkmail_action-1">
|
||||
<label class="um-admin-half"><?php _e('Personalize the custom message','ultimatemember'); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<textarea name="_um_checkmail_message" id="_um_checkmail_message"><?php echo $ultimatemember->query->get_meta_value('_um_checkmail_message', null, __('Thank you for registering. Before you can login we need you to activate your account by clicking the activation link in the email we just sent you.','ultimatemember') ); ?></textarea>
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
<p class="_um_checkmail_action-2">
|
||||
<label class="um-admin-half" for="_um_checkmail_url"><?php _e('Set Custom Redirect URL','ultimatemember'); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<input type="text" value="<?php echo $ultimatemember->query->get_meta_value('_um_checkmail_url', null, 'na'); ?>" name="_um_checkmail_url" id="_um_checkmail_url" />
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
<p>
|
||||
<label class="um-admin-half" for="_um_url_email_activate"><?php _e('URL redirect after e-mail activation','ultimatemember'); ?> <?php $this->tooltip( __('If you want users to go to a specific page other than login page after e-mail activation, enter the URL here.','ultimatemember') ); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<input type="text" value="<?php echo $ultimatemember->query->get_meta_value('_um_url_email_activate', null, 'na'); ?>" name="_um_url_email_activate" id="_um_url_email_activate" />
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Email Approval Settings -->
|
||||
|
||||
|
||||
<!-- Moderator Approval Settings -->
|
||||
|
||||
|
||||
<div class="pending">
|
||||
<p>
|
||||
<label class="um-admin-half"><?php _e('Action to be taken after registration','ultimatemember'); ?> <?php $this->tooltip( __('Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message','ultimatemember') ); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
<select name="_um_pending_action" id="_um_pending_action" class="umaf-selectjs um-adm-conditional" style="width: 300px"
|
||||
|
||||
<select name="_um_pending_action" id="_um_pending_action" class="umaf-selectjs um-adm-conditional" style="width: 300px"
|
||||
data-cond1="show_message" data-cond1-show="_um_pending_action-1"
|
||||
data-cond2="redirect_url" data-cond2-show="_um_pending_action-2">
|
||||
<option value="show_message" <?php selected('show_message', $ultimatemember->query->get_meta_value('_um_pending_action') ); ?>><?php _e('Show custom message','ultimatemember'); ?></option>
|
||||
@@ -110,30 +119,30 @@
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
<p class="_um_pending_action-1">
|
||||
<label class="um-admin-half"><?php _e('Personalize the custom message','ultimatemember'); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<textarea name="_um_pending_message" id="_um_pending_message"><?php echo $ultimatemember->query->get_meta_value('_um_pending_message', null, __('Thank you for applying for membership to our site. We will review your details and send you an email letting you know whether your application has been successful or not.','ultimatemember') ); ?></textarea>
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
|
||||
<p class="_um_pending_action-2">
|
||||
<label class="um-admin-half" for="_um_pending_url"><?php _e('Set Custom Redirect URL','ultimatemember'); ?></label>
|
||||
<span class="um-admin-half">
|
||||
|
||||
|
||||
<input type="text" value="<?php echo $ultimatemember->query->get_meta_value('_um_pending_url', null, 'na'); ?>" name="_um_pending_url" id="_um_pending_url" />
|
||||
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Moderator Approval Settings -->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="um-admin-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
+128
-122
@@ -5,7 +5,7 @@ class UM_Files {
|
||||
function __construct() {
|
||||
|
||||
add_action('init', array(&$this, 'setup_paths'), 1);
|
||||
|
||||
|
||||
$this->fonticon = array(
|
||||
'pdf' => array('icon' => 'um-faicon-file-pdf-o', 'color' => '#D24D4D' ),
|
||||
'txt' => array('icon' => 'um-faicon-file-text-o' ),
|
||||
@@ -20,30 +20,30 @@ class UM_Files {
|
||||
'rar' => array('icon' => 'um-faicon-file-zip-o' ),
|
||||
'mp3' => array('icon' => 'um-faicon-file-audio-o' ),
|
||||
);
|
||||
|
||||
|
||||
$this->default_file_fonticon = 'um-faicon-file-o';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @allowed image types
|
||||
***/
|
||||
function allowed_image_types() {
|
||||
|
||||
|
||||
$array['png'] = 'PNG';
|
||||
$array['jpeg'] = 'JPEG';
|
||||
$array['jpg'] = 'JPG';
|
||||
$array['gif'] = 'GIF';
|
||||
|
||||
|
||||
$array = apply_filters('um_allowed_image_types', $array);
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @allowed file types
|
||||
***/
|
||||
function allowed_file_types() {
|
||||
|
||||
|
||||
$array['pdf'] = 'PDF';
|
||||
$array['txt'] = 'Text';
|
||||
$array['csv'] = 'CSV';
|
||||
@@ -56,11 +56,11 @@ class UM_Files {
|
||||
$array['zip'] = 'ZIP';
|
||||
$array['rar'] = 'RAR';
|
||||
$array['mp3'] = 'MP3';
|
||||
|
||||
|
||||
$array = apply_filters('um_allowed_file_types', $array);
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Get extension icon
|
||||
***/
|
||||
@@ -71,7 +71,7 @@ class UM_Files {
|
||||
return $this->default_file_fonticon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Get extension icon background
|
||||
***/
|
||||
@@ -82,21 +82,27 @@ class UM_Files {
|
||||
return '#666';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Setup upload directory
|
||||
***/
|
||||
function setup_paths(){
|
||||
|
||||
|
||||
$this->upload_dir = wp_upload_dir();
|
||||
|
||||
|
||||
$this->upload_basedir = $this->upload_dir['basedir'] . '/ultimatemember/';
|
||||
$this->upload_baseurl = $this->upload_dir['baseurl'] . '/ultimatemember/';
|
||||
|
||||
|
||||
$this->upload_basedir = apply_filters('um_upload_basedir_filter', $this->upload_basedir );
|
||||
$this->upload_baseurl = apply_filters('um_upload_baseurl_filter', $this->upload_baseurl );
|
||||
|
||||
if( is_ssl() ){
|
||||
|
||||
// @note : is_ssl() doesn't work properly for some sites running with load balancers
|
||||
// Check the links for more info about this bug
|
||||
// https://codex.wordpress.org/Function_Reference/is_ssl
|
||||
// http://snippets.webaware.com.au/snippets/wordpress-is_ssl-doesnt-work-behind-some-load-balancers/
|
||||
if( is_ssl() || stripos( get_option( 'siteurl' ), 'https://' ) !== false
|
||||
|| ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
|
||||
&& $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ) {
|
||||
$this->upload_baseurl = str_replace("http://", "https://", $this->upload_baseurl);
|
||||
}
|
||||
|
||||
@@ -114,9 +120,9 @@ class UM_Files {
|
||||
@mkdir( $this->upload_temp , 0755, true);
|
||||
umask($old);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Generate unique temp directory
|
||||
***/
|
||||
@@ -127,14 +133,14 @@ class UM_Files {
|
||||
$array['url'] = $this->upload_temp_url . $unique_number . '/';
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @get path only without file name
|
||||
***/
|
||||
function path_only( $file ) {
|
||||
return trailingslashit( dirname( $file ) );
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @fix image orientation
|
||||
***/
|
||||
@@ -160,103 +166,103 @@ class UM_Files {
|
||||
}
|
||||
return $rotate;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Process an image
|
||||
***/
|
||||
function create_and_copy_image($source, $destination, $quality = 100) {
|
||||
|
||||
|
||||
$info = @getimagesize($source);
|
||||
|
||||
|
||||
if ($info['mime'] == 'image/jpeg'){
|
||||
|
||||
|
||||
$image = imagecreatefromjpeg($source);
|
||||
|
||||
|
||||
} else if ($info['mime'] == 'image/gif'){
|
||||
|
||||
|
||||
$image = imagecreatefromgif($source);
|
||||
|
||||
} else if ($info['mime'] == 'image/png'){
|
||||
|
||||
|
||||
$image = imagecreatefrompng($source);
|
||||
|
||||
}
|
||||
|
||||
list($w, $h) = @getimagesize( $source );
|
||||
if ( $w > um_get_option('image_max_width') ) {
|
||||
|
||||
|
||||
$ratio = round( $w / $h, 2 );
|
||||
$new_w = um_get_option('image_max_width');
|
||||
$new_h = round( $new_w / $ratio, 2 );
|
||||
|
||||
|
||||
$image_p = imagecreatetruecolor( $new_w, $new_h );
|
||||
imagecopyresampled( $image_p, $image, 0, 0, 0, 0, $new_w, $new_h, $w, $h );
|
||||
$image_p = $this->fix_image_orientation($image_p, $source);
|
||||
imagejpeg( $image_p, $destination, $quality);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$image = $this->fix_image_orientation($image, $source);
|
||||
imagejpeg( $image, $destination, $quality);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Process a file
|
||||
***/
|
||||
function upload_temp_file($source, $destination) {
|
||||
|
||||
|
||||
move_uploaded_file($source, $destination);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Process a temp upload
|
||||
***/
|
||||
function new_image_upload_temp($source, $destination, $quality = 100){
|
||||
|
||||
|
||||
$unique_dir = $this->unique_dir();
|
||||
|
||||
|
||||
$this->make_dir( $unique_dir['dir'] );
|
||||
|
||||
$this->create_and_copy_image($source, $unique_dir['dir'] . $destination, $quality);
|
||||
|
||||
|
||||
$url = $unique_dir['url'] . $destination;
|
||||
|
||||
return $url;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Process a temp upload for files
|
||||
***/
|
||||
function new_file_upload_temp($source, $destination ){
|
||||
|
||||
|
||||
$unique_dir = $this->unique_dir();
|
||||
|
||||
|
||||
$this->make_dir( $unique_dir['dir'] );
|
||||
|
||||
$this->upload_temp_file($source, $unique_dir['dir'] . $destination);
|
||||
|
||||
|
||||
$url = $unique_dir['url'] . $destination;
|
||||
|
||||
return $url;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Make a Folder
|
||||
***/
|
||||
function make_dir( $dir ){
|
||||
|
||||
|
||||
$old = umask(0);
|
||||
@mkdir( $dir, 0755, true);
|
||||
umask($old);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Get extension by mime type
|
||||
***/
|
||||
@@ -264,64 +270,64 @@ class UM_Files {
|
||||
$split = explode('/',$mime);
|
||||
return $split[1];
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Get file data
|
||||
***/
|
||||
function get_file_data($file){
|
||||
|
||||
|
||||
$array['size'] = filesize($file);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Get image data
|
||||
***/
|
||||
function get_image_data($file){
|
||||
|
||||
|
||||
$array['size'] = filesize($file);
|
||||
|
||||
|
||||
$array['image'] = @getimagesize($file);
|
||||
|
||||
|
||||
if ( $array['image'] > 0 ) {
|
||||
|
||||
|
||||
$array['invalid_image'] = false;
|
||||
|
||||
|
||||
list($width, $height, $type, $attr) = @getimagesize($file);
|
||||
|
||||
|
||||
$array['width'] = $width;
|
||||
$array['height'] = $height;
|
||||
$array['ratio'] = $width / $height;
|
||||
|
||||
|
||||
$array['extension'] = $this->get_extension_by_mime_type( $array['image']['mime'] );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$array['invalid_image'] = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Check image upload and handle errors
|
||||
***/
|
||||
function check_image_upload($file, $field) {
|
||||
global $ultimatemember;
|
||||
$error = null;
|
||||
|
||||
|
||||
$fileinfo = $this->get_image_data($file);
|
||||
$data = $ultimatemember->fields->get_field($field);
|
||||
|
||||
|
||||
if ( $data == null ) {
|
||||
$data = apply_filters("um_custom_image_handle_{$field}", '' );
|
||||
if ( !$data ) {
|
||||
$error = __('This media type is not recognized.','ultimatemember');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $fileinfo['invalid_image'] == true ) {
|
||||
$error = sprintf(__('Your image is invalid or too large!','ultimatemember') );
|
||||
} elseif ( isset( $data['allowed_types'] ) && !$this->in_array( $fileinfo['extension'], $data['allowed_types'] ) ) {
|
||||
@@ -333,10 +339,10 @@ class UM_Files {
|
||||
} elseif ( isset($data['min_height']) && ( $fileinfo['height'] < $data['min_height'] ) ) {
|
||||
$error = sprintf(__('Your photo is too small. It must be at least %spx wide.','ultimatemember'), $data['min_height']);
|
||||
}
|
||||
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Check file upload and handle errors
|
||||
***/
|
||||
@@ -346,16 +352,16 @@ class UM_Files {
|
||||
|
||||
$fileinfo = $this->get_file_data($file);
|
||||
$data = $ultimatemember->fields->get_field($field);
|
||||
|
||||
|
||||
if ( !$this->in_array( $extension, $data['allowed_types'] ) ) {
|
||||
$error = ( isset( $data['extension_error'] ) && !empty( $data['extension_error'] ) ) ? $data['extension_error'] : 'not allowed';
|
||||
} elseif ( isset($data['min_size']) && ( $fileinfo['size'] < $data['min_size'] ) ) {
|
||||
$error = $data['min_size_error'];
|
||||
}
|
||||
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @If a value exists in comma seperated list
|
||||
***/
|
||||
@@ -364,17 +370,17 @@ class UM_Files {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @This function will delete file upload from server
|
||||
***/
|
||||
function delete_file( $src ) {
|
||||
|
||||
|
||||
if ( strstr( $src, '?' ) ){
|
||||
$splitted = explode('?', $src );
|
||||
$src = $splitted[0];
|
||||
}
|
||||
|
||||
|
||||
$is_temp = um_is_temp_upload( $src );
|
||||
if ( $is_temp ) {
|
||||
unlink( $is_temp );
|
||||
@@ -383,38 +389,38 @@ class UM_Files {
|
||||
die('Not a valid temp file');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @delete a main user photo
|
||||
***/
|
||||
function delete_core_user_photo( $user_id, $type ) {
|
||||
|
||||
|
||||
delete_user_meta( $user_id, $type );
|
||||
|
||||
|
||||
do_action("um_after_remove_{$type}", $user_id);
|
||||
|
||||
|
||||
$dir = $this->upload_basedir . $user_id . '/';
|
||||
$prefix = $type;
|
||||
chdir($dir);
|
||||
$matches = glob($prefix.'*',GLOB_MARK);
|
||||
|
||||
|
||||
if( is_array($matches) && !empty($matches)) {
|
||||
foreach($matches as $match) {
|
||||
if( is_file($dir.$match) ) unlink($dir.$match);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( count(glob("$dir/*")) === 0) {
|
||||
rmdir( $dir );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @resize a local image
|
||||
***/
|
||||
function resize_image( $file, $crop ) {
|
||||
|
||||
|
||||
$targ_x1 = $crop[0];
|
||||
$targ_y1 = $crop[1];
|
||||
$targ_x2 = $crop[2];
|
||||
@@ -425,12 +431,12 @@ class UM_Files {
|
||||
|
||||
imagecopy( $dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2 );
|
||||
imagejpeg( $dst_r, $this->path_only( $file ) . basename( $file ), 100);
|
||||
|
||||
|
||||
$split = explode('/ultimatemember/temp/', $file);
|
||||
return $this->upload_temp_url . $split[1];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @make a user folder for uploads
|
||||
***/
|
||||
@@ -441,34 +447,34 @@ class UM_Files {
|
||||
umask($old);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @new user upload
|
||||
***/
|
||||
function new_user_upload( $user_id, $source, $key ) {
|
||||
|
||||
|
||||
// if he does not have uploads dir yet
|
||||
$this->new_user( $user_id );
|
||||
|
||||
|
||||
if ( is_user_logged_in() && ( get_current_user_id() != $user_id ) && !um_user_can('can_edit_everyone') ) {
|
||||
wp_die( __('Unauthorized to do this attempt.','ultimatemember') );
|
||||
}
|
||||
|
||||
|
||||
if ( !is_user_logged_in() && ( $key == 'profile_photo' || $key == 'cover_photo' ) ) {
|
||||
wp_die( __('Unauthorized to do this attempt.','ultimatemember') );
|
||||
}
|
||||
|
||||
|
||||
// name and extension stuff
|
||||
$source_name = basename( $source );
|
||||
|
||||
|
||||
if ( $key == 'profile_photo' ) {
|
||||
$source_name = 'profile_photo.jpg';
|
||||
}
|
||||
|
||||
|
||||
if ( $key == 'cover_photo' ) {
|
||||
$source_name = 'cover_photo.jpg';
|
||||
}
|
||||
|
||||
|
||||
$ext = '.' . pathinfo($source_name, PATHINFO_EXTENSION);
|
||||
$name = str_replace( $ext, '', $source_name );
|
||||
$filename = $name . $ext;
|
||||
@@ -478,60 +484,60 @@ class UM_Files {
|
||||
unlink( $this->upload_basedir . $user_id . '/' . $filename );
|
||||
}
|
||||
copy( $source, $this->upload_basedir . $user_id . '/' . $filename );
|
||||
|
||||
|
||||
// thumbs
|
||||
if ( $key == 'profile_photo' ) {
|
||||
|
||||
|
||||
list($w, $h) = @getimagesize( $source );
|
||||
|
||||
|
||||
$sizes = um_get_option('photo_thumb_sizes');
|
||||
foreach( $sizes as $size ) {
|
||||
|
||||
|
||||
if ( file_exists( $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext ) ) {
|
||||
unlink( $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext );
|
||||
}
|
||||
|
||||
|
||||
if ( $size < $w ) {
|
||||
|
||||
$thumb_s = imagecreatefromjpeg( $source );
|
||||
$thumb = imagecreatetruecolor( $size, $size );
|
||||
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $size, $w, $h );
|
||||
imagejpeg( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 100);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// removes a synced profile photo
|
||||
delete_user_meta( $user_id, 'synced_profile_photo' );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( $key == 'cover_photo' ) {
|
||||
|
||||
|
||||
list($w, $h) = @getimagesize( $source );
|
||||
|
||||
|
||||
$sizes = um_get_option('cover_thumb_sizes');
|
||||
foreach( $sizes as $size ) {
|
||||
|
||||
|
||||
$ratio = round( $w / $h, 2 );
|
||||
$height = round( $size / $ratio, 2 );
|
||||
|
||||
|
||||
if ( file_exists( $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext ) ) {
|
||||
unlink( $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext );
|
||||
}
|
||||
|
||||
|
||||
if ( $size < $w ) {
|
||||
|
||||
$thumb_s = imagecreatefromjpeg( $source );
|
||||
$thumb = imagecreatetruecolor( $size, $height );
|
||||
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $height, $w, $h );
|
||||
imagejpeg( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 100);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// clean up temp
|
||||
@@ -542,26 +548,26 @@ class UM_Files {
|
||||
// update user's meta
|
||||
do_action('um_before_upload_db_meta', $user_id, $key );
|
||||
do_action("um_before_upload_db_meta_{$key}", $user_id );
|
||||
|
||||
|
||||
update_user_meta( $user_id, $key, $filename );
|
||||
|
||||
|
||||
do_action('um_after_upload_db_meta', $user_id, $key );
|
||||
do_action("um_after_upload_db_meta_{$key}", $user_id );
|
||||
|
||||
|
||||
// the url of upload
|
||||
return $this->upload_baseurl . $user_id . '/' . $filename;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Remove a directory
|
||||
***/
|
||||
function remove_dir($dir) {
|
||||
function remove_dir($dir) {
|
||||
if ( file_exists( $dir ) ) {
|
||||
foreach(glob($dir . '/*') as $file) {
|
||||
if(is_dir($file)) $this->remove_dir($file); else unlink($file);
|
||||
foreach(glob($dir . '/*') as $file) {
|
||||
if(is_dir($file)) $this->remove_dir($file); else unlink($file);
|
||||
} rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-9
@@ -14,7 +14,7 @@ class UM_Permalinks {
|
||||
|
||||
remove_action( 'wp_head', 'rel_canonical' );
|
||||
add_action('wp_head', array(&$this, 'um_rel_canonical_'), 9 );
|
||||
|
||||
|
||||
$this->current_url = $this->get_current_url();
|
||||
|
||||
}
|
||||
@@ -35,14 +35,14 @@ class UM_Permalinks {
|
||||
echo "<link rel='canonical' href='$link' />\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$link = get_permalink( $id );
|
||||
if ( $page = get_query_var('cpage') )
|
||||
$link = get_comments_pagenum_link( $page );
|
||||
echo "<link rel='canonical' href='$link' />\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Get query as array
|
||||
***/
|
||||
@@ -63,7 +63,7 @@ class UM_Permalinks {
|
||||
$um_get_option = get_option('um_options');
|
||||
$server_name_method = ( $um_get_option['current_url_method'] ) ? $um_get_option['current_url_method'] : 'SERVER_NAME';
|
||||
$um_port_forwarding_url = ( isset( $um_get_option['um_port_forwarding_url'] ) ) ? $um_get_option['um_port_forwarding_url']: '';
|
||||
|
||||
|
||||
if ( !isset( $_SERVER['SERVER_NAME'] ) )
|
||||
return '';
|
||||
|
||||
@@ -83,17 +83,17 @@ class UM_Permalinks {
|
||||
|
||||
if ( $um_port_forwarding_url == 1 && isset( $_SERVER["SERVER_PORT"] ) ) {
|
||||
$page_url .= $_SERVER[ $server_name_method ].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||||
|
||||
|
||||
} else {
|
||||
$page_url .= $_SERVER[ $server_name_method ].$_SERVER["REQUEST_URI"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ( $no_query_params == true ) {
|
||||
$page_url = strtok($page_url, '?');
|
||||
}
|
||||
|
||||
|
||||
|
||||
return apply_filters( 'um_get_current_page_url', $page_url );
|
||||
}
|
||||
@@ -118,6 +118,21 @@ class UM_Permalinks {
|
||||
|
||||
$ultimatemember->user->approve();
|
||||
$redirect = ( um_user('url_email_activate') ) ? um_user('url_email_activate') : um_get_core_page('login', 'account_active');
|
||||
$login = (bool) um_user('login_email_activate');
|
||||
|
||||
// log in automatically
|
||||
if ( !is_user_logged_in() && $login ) {
|
||||
$user = get_userdata($user_id);
|
||||
$user_id = $user->ID;
|
||||
|
||||
// update wp user
|
||||
wp_set_current_user( $user_id, $user_login );
|
||||
wp_set_auth_cookie( $user_id );
|
||||
|
||||
ob_start();
|
||||
do_action( 'wp_login', $user_login );
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
um_reset_user();
|
||||
|
||||
@@ -185,8 +200,8 @@ class UM_Permalinks {
|
||||
|
||||
// WPML compatibility
|
||||
if ( function_exists('icl_object_id') ) {
|
||||
|
||||
|
||||
|
||||
|
||||
$language_code = ICL_LANGUAGE_CODE;
|
||||
$lang_post_id = icl_object_id( $page_id , 'page', true, $language_code );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user