Esempio n. 1
0
 function __construct()
 {
     global $wpdb;
     $this->bmp_table = $wpdb->base_prefix . 'rt_rtm_media';
     add_action('admin_menu', array($this, 'menu'));
     add_action('wp_ajax_bp_media_rt_db_migration', array($this, 'migrate_to_new_db'));
     $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING);
     $hide = filter_input(INPUT_GET, 'hide', FILTER_SANITIZE_STRING);
     if (isset($page) && 'rtmedia-migration' === $page && isset($hide) && 'true' === $hide) {
         $this->hide_migration_notice();
         $http_referer = rtm_get_server_var('HTTP_REFERER', 'FILTER_SANITIZE_URL');
         wp_safe_redirect(esc_url_raw($http_referer));
     }
     if (false !== rtmedia_get_site_option('rt_migration_hide_notice')) {
         return true;
     }
     $force = filter_input(INPUT_GET, 'force', FILTER_SANITIZE_STRING);
     if (isset($force) && 'true' === $force) {
         $pending = false;
     } else {
         $pending = rtmedia_get_site_option('rtMigration-pending-count');
     }
     if (false === $pending) {
         $total = $this->get_total_count();
         $done = $this->get_done_count();
         $pending = $total - $done;
         if ($pending < 0) {
             $pending = 0;
         }
         rtmedia_update_site_option('rtMigration-pending-count', $pending);
     }
     if ($pending > 0) {
         if (!(isset($page) && 'rtmedia-migration' === $page)) {
             add_action('admin_notices', array(&$this, 'add_migration_notice'));
         }
     }
 }
Esempio n. 2
0
 static function register_scripts()
 {
     if (!wp_script_is('plupload-all')) {
         wp_enqueue_script('plupload-all');
     }
     wp_enqueue_script('rtmedia-backbone', RTMEDIA_URL . 'app/assets/js/rtMedia.backbone.js', array('plupload-all', 'backbone'), RTMEDIA_VERSION, true);
     if (is_rtmedia_album_gallery()) {
         $template_url = esc_url(add_query_arg(array('action' => 'rtmedia_get_template', 'template' => 'album-gallery-item'), admin_url('admin-ajax.php')), null, '');
     } else {
         $template_url = esc_url(add_query_arg(array('action' => 'rtmedia_get_template', 'template' => apply_filters('rtmedia_backbone_template_filter', 'media-gallery-item')), admin_url('admin-ajax.php')), null, '');
     }
     wp_localize_script('rtmedia-backbone', 'template_url', $template_url);
     $request_uri = rtm_get_server_var('REQUEST_URI', 'FILTER_SANITIZE_URL');
     $url = trailingslashit($request_uri);
     $rtmedia_slug = '/' . RTMEDIA_MEDIA_SLUG;
     // check position of media slug from end of the URL
     if (strrpos($url, $rtmedia_slug) !== false) {
         // split the url upto the last occurance of media slug
         $url_upload = substr($url, 0, strrpos($url, $rtmedia_slug));
         $url = trailingslashit($url_upload) . 'upload/';
     } else {
         $url = trailingslashit($url) . 'upload/';
     }
     $params = array('url' => $url, 'runtimes' => 'html5,flash,html4', 'browse_button' => apply_filters('rtmedia_upload_button_id', 'rtMedia-upload-button'), 'container' => 'rtmedia-upload-container', 'drop_element' => 'drag-drop-area', 'filters' => apply_filters('rtmedia_plupload_files_filter', array(array('title' => 'Media Files', 'extensions' => get_rtmedia_allowed_upload_type()))), 'max_file_size' => wp_max_upload_size() / (1024 * 1024) . 'M', 'multipart' => true, 'urlstream_upload' => true, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'file_data_name' => 'rtmedia_file', 'multi_selection' => true, 'multipart_params' => apply_filters('rtmedia-multi-params', array('redirect' => 'no', 'action' => 'wp_handle_upload', '_wp_http_referer' => $request_uri, 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator(false, true))), 'max_file_size_msg' => apply_filters('rtmedia_plupload_file_size_msg', min(array(ini_get('upload_max_filesize'), ini_get('post_max_size')))));
     if (wp_is_mobile()) {
         $params['multi_selection'] = false;
     }
     $params = apply_filters('rtmedia_modify_upload_params', $params);
     global $rtmedia;
     $rtmedia_extns = array();
     foreach ($rtmedia->allowed_types as $allowed_types_key => $allowed_types_value) {
         $rtmedia_extns[$allowed_types_key] = $allowed_types_value['extn'];
     }
     wp_localize_script('rtmedia-backbone', 'rtmedia_exteansions', $rtmedia_extns);
     wp_localize_script('rtmedia-backbone', 'rtMedia_plupload_config', $params);
     wp_localize_script('rtmedia-backbone', 'rMedia_loading_file', admin_url('/images/loading.gif'));
 }
Esempio n. 3
0
 function single_delete()
 {
     global $rtmedia_query;
     $nonce = isset($_REQUEST['rtmedia_media_nonce']) ? wp_unslash($_REQUEST['rtmedia_media_nonce']) : '';
     if (wp_verify_nonce($nonce, 'rtmedia_' . $rtmedia_query->media[0]->id)) {
         // do_action('rtmedia_before_delete_media',$rtmedia_query->media[ 0 ]->id);
         $id = $_POST;
         unset($id['rtmedia_media_nonce']);
         unset($id['_wp_http_referer']);
         $media = new RTMediaMedia();
         $media_model = new RTMediaModel();
         $media_obj = $media_model->get(array('id' => $rtmedia_query->media[0]->id));
         $media->delete($rtmedia_query->media[0]->id);
         $post = get_post($rtmedia_query->media[0]);
         $context = '';
         if (function_exists('bp_get_group_permalink') && isset($media_obj[0]) && isset($media_obj[0]->context) && 'group' === $media_obj[0]->context) {
             $group = groups_get_group(array('group_id' => $media_obj[0]->context_id));
             $parent_link = bp_get_group_permalink($group);
             $context = 'group';
         } else {
             if (function_exists('bp_core_get_user_domain')) {
                 $parent_link = bp_core_get_user_domain($post->media_author);
                 $context = 'profile';
             } else {
                 $parent_link = get_author_posts_url($post->media_author);
             }
         }
         $redirect_url = rtm_get_server_var('HTTP_REFERER', 'FILTER_SANITIZE_URL');
         if (strpos($redirect_url, '/' . $rtmedia_query->media[0]->id) > 0) {
             if ('profile' === $context && isset($rtmedia_query->media[0]->album_id) && intval($rtmedia_query->media[0]->album_id) > 0) {
                 $redirect_url = trailingslashit($parent_link) . RTMEDIA_MEDIA_SLUG . '/' . $rtmedia_query->media[0]->album_id;
             } else {
                 $redirect_url = trailingslashit($parent_link) . RTMEDIA_MEDIA_SLUG . '/';
             }
         }
         $redirect_url = apply_filters('rtmedia_before_delete_media_redirect', $redirect_url);
         wp_safe_redirect(esc_url_raw($redirect_url));
         die;
     } else {
         esc_html_e('Ooops !!! Invalid access. No nonce was found !!', 'buddypress-media');
     }
 }
Esempio n. 4
0
 function template_redirect($create_activity = true)
 {
     ob_start();
     if (!count($_POST)) {
         // @codingStandardsIgnoreLine
         include get_404_template();
     } else {
         $nonce = $mode = '';
         $_activity_id = -1;
         if (isset($_REQUEST['rtmedia_upload_nonce'])) {
             $nonce = sanitize_text_field(wp_unslash($_REQUEST['rtmedia_upload_nonce']));
         }
         if (isset($_REQUEST['mode'])) {
             $mode = sanitize_text_field(wp_unslash($_REQUEST['mode']));
         }
         if (isset($_REQUEST['activity_id'])) {
             $_activity_id = sanitize_text_field($_REQUEST['activity_id']);
         }
         $_redirect_url = filter_input(INPUT_POST, 'redirect', FILTER_SANITIZE_NUMBER_INT);
         $rtupload = false;
         $activity_id = -1;
         $redirect_url = '';
         if (wp_verify_nonce($nonce, 'rtmedia_upload_nonce')) {
             $model = new RTMediaUploadModel();
             do_action('rtmedia_upload_set_post_object');
             $this->upload = $model->set_post_object();
             if (-1 !== $_activity_id) {
                 $this->upload['activity_id'] = $_activity_id;
                 $activity_id = $_activity_id;
             }
             //if media upload is being made for a group, identify the group privacy and set media privacy accordingly
             if (isset($this->upload['context']) && isset($this->upload['context_id']) && 'group' === $this->upload['context'] && function_exists('groups_get_group')) {
                 $group = groups_get_group(array('group_id' => $this->upload['context_id']));
                 if (isset($group->status) && 'public' !== $group->status) {
                     // if group is not public, then set media privacy as 20, so only the group members can see the images
                     $this->upload['privacy'] = '20';
                 } else {
                     // if group is public, then set media privacy as 0
                     $this->upload['privacy'] = '0';
                 }
             }
             $this->upload = apply_filters('rtmedia_media_param_before_upload', $this->upload);
             $rtupload = new RTMediaUpload($this->upload);
             $media_obj = new RTMediaMedia();
             $media = $media_obj->model->get(array('id' => $rtupload->media_ids[0]));
             $rtmedia_nav = new RTMediaNav();
             $perma_link = '';
             if (isset($media) && count($media) > 0) {
                 $perma_link = get_rtmedia_permalink($media[0]->id);
                 if ('photo' === $media[0]->media_type) {
                     $thumb_image = rtmedia_image('rt_media_thumbnail', $rtupload->media_ids[0], false);
                 } elseif ('music' === $media[0]->media_type) {
                     $thumb_image = $media[0]->cover_art;
                 } else {
                     $thumb_image = '';
                 }
                 if ('group' === $media[0]->context) {
                     $rtmedia_nav->refresh_counts($media[0]->context_id, array('context' => $media[0]->context, 'context_id' => $media[0]->context_id));
                 } else {
                     $rtmedia_nav->refresh_counts($media[0]->media_author, array('context' => 'profile', 'media_author' => $media[0]->media_author));
                 }
                 if (false !== $create_activity && class_exists('BuddyPress') && bp_is_active('activity')) {
                     $allow_single_activity = apply_filters('rtmedia_media_single_activity', false);
                     // Following will not apply to activity uploads. For first time activity won't be generated.
                     // Create activity first and pass activity id in response.
                     // todo fixme rtmedia_media_single_activity filter. It will create 2 activity with same media if uploaded from activity page.
                     $_rtmedia_update = filter_input(INPUT_POST, 'rtmedia_update', FILTER_SANITIZE_STRING);
                     if (-1 === intval($activity_id) && !(isset($_rtmedia_update) && 'true' === $_rtmedia_update) || $allow_single_activity) {
                         $activity_id = $media_obj->insert_activity($media[0]->media_id, $media[0]);
                     } else {
                         $media_obj->model->update(array('activity_id' => $activity_id), array('id' => $rtupload->media_ids[0]));
                         //
                         $same_medias = $media_obj->model->get(array('activity_id' => $activity_id));
                         $update_activity_media = array();
                         foreach ($same_medias as $a_media) {
                             $update_activity_media[] = $a_media->id;
                         }
                         $privacy = filter_input(INPUT_POST, 'privacy', FILTER_SANITIZE_NUMBER_INT);
                         if (empty($privacy)) {
                             $privacy = 0;
                         }
                         $obj_activity = new RTMediaActivity($update_activity_media, $privacy, false);
                         global $wpdb, $bp;
                         $user = get_userdata($same_medias[0]->media_author);
                         $username = '******' . esc_url(get_rtmedia_user_link($same_medias[0]->media_author)) . '">' . esc_html($user->user_nicename) . '</a>';
                         $action = sprintf(esc_html__('%s added %d %s', 'buddypress-media'), $username, count($same_medias), RTMEDIA_MEDIA_SLUG);
                         $action = apply_filters('rtmedia_buddypress_action_text_fitler_multiple_media', $action, $username, count($same_medias), $user->user_nicename);
                         $wpdb->update($bp->activity->table_name, array('type' => 'rtmedia_update', 'content' => $obj_activity->create_activity_html(), 'action' => $action), array('id' => $activity_id));
                     }
                     // update group last active
                     if ('group' === $media[0]->context) {
                         RTMediaGroup::update_last_active($media[0]->context_id);
                     }
                 }
             }
             if (isset($this->upload['rtmedia_simple_file_upload']) && true == $this->upload['rtmedia_simple_file_upload']) {
                 if (isset($media) && count($media) > 0) {
                     if (isset($_redirect_url)) {
                         if (intval($_redirect_url) > 1) {
                             //bulkurl
                             if ('group' === $media[0]->context) {
                                 $redirect_url = trailingslashit(get_rtmedia_group_link($media[0]->context_id)) . RTMEDIA_MEDIA_SLUG;
                             } else {
                                 $redirect_url = trailingslashit(get_rtmedia_user_link($media[0]->media_author)) . RTMEDIA_MEDIA_SLUG;
                             }
                         } else {
                             $redirect_url = get_rtmedia_permalink($media[0]->id);
                         }
                         $redirect_url = apply_filters('rtmedia_simple_file_upload_redirect_url_filter', $redirect_url);
                         wp_safe_redirect(esc_url_raw($redirect_url));
                         die;
                     }
                     return $media;
                 }
                 return false;
             }
         }
         $redirect_url = '';
         if (isset($_redirect_url) && is_numeric($_redirect_url)) {
             if (intval($_redirect_url) > 1) {
                 //bulkurl
                 if ('group' === $media[0]->context) {
                     $redirect_url = trailingslashit(get_rtmedia_group_link($media[0]->context_id)) . RTMEDIA_MEDIA_SLUG;
                 } else {
                     $redirect_url = trailingslashit(get_rtmedia_user_link($media[0]->media_author)) . RTMEDIA_MEDIA_SLUG;
                 }
             } else {
                 $redirect_url = get_rtmedia_permalink($media[0]->id);
             }
         }
         // Ha ha ha
         ob_end_clean();
         //check for simpe
         $rtmedia_update = filter_input(INPUT_POST, 'rtmedia_update', FILTER_SANITIZE_STRING);
         $_user_agent = rtm_get_server_var('HTTP_USER_AGENT', 'FILTER_SANITIZE_STRING');
         /**
          * if(redirect)
          *
          */
         if (!empty($rtmedia_update) && 'true' === $rtmedia_update) {
             if (preg_match('/(?i)msie [1-9]/', $_user_agent)) {
                 // if IE(<=9) set content type = text/plain
                 header('Content-type: text/plain');
             } else {
                 header('Content-type: application/json');
             }
             echo wp_json_encode($rtupload->media_ids);
         } else {
             // Media Upload Case - on album/post/profile/group
             if (isset($media[0])) {
                 $data = array('media_id' => $media[0]->id, 'activity_id' => $activity_id, 'redirect_url' => $redirect_url, 'permalink' => $perma_link, 'cover_art' => $thumb_image);
             } else {
                 $data = array();
             }
             if (preg_match('/(?i)msie [1-9]/', $_user_agent)) {
                 // if IE(<=9) set content type = text/plain
                 header('Content-type: text/plain');
             } else {
                 header('Content-type: application/json');
             }
             echo wp_json_encode(apply_filters('rtmedia_upload_endpoint_response', $data));
         }
         die;
     }
 }
Esempio n. 5
0
        /**
         * Generate rtmedia admin form.
         *
         * @global type $current_user
         *
         * @param  string $form
         *
         * @return void
         */
        public function get_form($form = '')
        {
            //todo: nonce required
            if (empty($form)) {
                $form = filter_input(INPUT_POST, 'form' . FILTER_SANITIZE_STRING);
                $form = isset($form) ? $form : 'premium_support';
            }
            $meta_title = '';
            switch ($form) {
                case 'bug_report':
                    $meta_title = esc_html__('Submit a Bug Report', 'buddypress-media');
                    break;
                case 'new_feature':
                    $meta_title = esc_html__('Submit a New Feature Request', 'buddypress-media');
                    break;
                case 'premium_support':
                    $meta_title = esc_html__('Submit Support Request', 'buddypress-media');
                    break;
            }
            if ('premium_support' === $form) {
                if (!has_filter('rtmedia_license_tabs') && !has_action('rtmedia_addon_license_details')) {
                    $content = '<h3 class="rtm-option-title">' . esc_html($meta_title) . '</h3>';
                    $content .= '<p>' . sprintf(esc_html__('If your site has some issues due to rtMedia and you want support, feel free to create a support topic on %s', 'buddypress-media'), '<a target="_blank" href="http://community.rtcamp.com/c/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">' . esc_html__('Community Forum', 'buddypress-media') . '</a>.') . '</p>';
                    $content .= '<p>' . sprintf(esc_html__('If you have any suggestions, enhancements or bug reports, then you can open a new issue on %s', 'buddypress-media'), '<a target="_blank" href="https://github.com/rtCamp/rtmedia/issues/new">' . esc_html__('GitHub', 'buddypress-media') . '</a>.') . '</p>';
                    echo $content;
                    // @codingStandardsIgnoreLine
                } else {
                    $website = filter_input(INPUT_POST, 'website', FILTER_SANITIZE_URL);
                    $subject = filter_input(INPUT_POST, 'subject', FILTER_SANITIZE_STRING);
                    $details = filter_input(INPUT_POST, 'details', FILTER_SANITIZE_STRING);
                    $server_addr = rtm_get_server_var('SERVER_ADDR', 'FILTER_VALIDATE_IP');
                    $remote_addr = rtm_get_server_var('REMOTE_ADDR', 'FILTER_VALIDATE_IP');
                    $server_software = rtm_get_server_var('SERVER_SOFTWARE', 'FILTER_SANITIZE_STRING');
                    $http_user_agent = rtm_get_server_var('HTTP_USER_AGENT', 'FILTER_SANITIZE_STRING');
                    ?>
					<h3 class="rtm-option-title"><?php 
                    echo esc_html($meta_title);
                    ?>
</h3>
					<div id="support-form" class="bp-media-form rtm-support-form rtm-option-wrapper">

						<div class="rtm-form-filed clearfix">
							<label class="bp-media-label"
							       for="name"><?php 
                    esc_html_e('Name', 'buddypress-media');
                    ?>
</label>
							<input class="bp-media-input" id="name" type="text" name="name" value="" required/>
							<span class="rtm-tooltip">
								<i class="dashicons dashicons-info rtmicon"></i>
								<span class="rtm-tip">
									<?php 
                    esc_html_e('Use actual user name which used during purchased.', 'buddypress-media');
                    ?>
								</span>
							</span>
						</div>

						<div class="rtm-form-filed clearfix">
							<label class="bp-media-label"
							       for="email"><?php 
                    esc_html_e('Email', 'buddypress-media');
                    ?>
</label>
							<input id="email" class="bp-media-input" type="text" name="email" value="" required/>
							<span class="rtm-tooltip">
								<i class="dashicons dashicons-info rtmicon"></i>
								<span class="rtm-tip">
									<?php 
                    esc_html_e('Use email id which used during purchased', 'buddypress-media');
                    ?>
								</span>
							</span>
						</div>

						<div class="rtm-form-filed clearfix">
							<label class="bp-media-label"
							       for="website"><?php 
                    esc_html_e('Website', 'buddypress-media');
                    ?>
</label>
							<input id="website" class="bp-media-input" type="text" name="website"
							       value="<?php 
                    echo esc_url(isset($website) ? $website : get_bloginfo('url'));
                    ?>
"
							       required/>
						</div>

						<div class="rtm-form-filed clearfix">
							<label class="bp-media-label"
							       for="subject"><?php 
                    esc_html_e('Subject', 'buddypress-media');
                    ?>
</label>
							<input id="subject" class="bp-media-input" type="text" name="subject"
							       value="<?php 
                    echo esc_attr(isset($subject) ? esc_attr($subject) : '');
                    ?>
"
							       required/>
						</div>

						<div class="rtm-form-filed clearfix">
							<label class="bp-media-label"
							       for="details"><?php 
                    esc_html_e('Details', 'buddypress-media');
                    ?>
</label>
							<textarea id="details" class="bp-media-textarea" name="details"
							          required><?php 
                    echo esc_html(isset($details) ? esc_textarea($details) : '');
                    ?>
</textarea>

							<input type="hidden" name="request_type" value="<?php 
                    echo esc_attr($form);
                    ?>
"/>
							<input type="hidden" name="request_id"
							       value="<?php 
                    echo esc_attr(wp_create_nonce(date('YmdHis')));
                    ?>
"/>
							<input type="hidden" name="server_address" value="<?php 
                    echo esc_attr($server_addr);
                    ?>
"/>
							<input type="hidden" name="ip_address" value="<?php 
                    echo esc_attr($remote_addr);
                    ?>
"/>
							<input type="hidden" name="server_type" value="<?php 
                    echo esc_attr($server_software);
                    ?>
"/>
							<input type="hidden" name="user_agent" value="<?php 
                    echo esc_attr($http_user_agent);
                    ?>
"/>
							<input type="hidden" name="debuglog_temp_path" id="debuglog_temp_path" />
						</div>

						<div class="rtm-form-filed clearfix">
							<label class="bp-media-label"
							       for="subject"><?php 
                    esc_html_e('Attachement', 'buddypress-media');
                    ?>
</label>
							<input id="debuglog" class="bp-media-input" type="file" name="debuglog" />
							<span class="rtm-tooltip">
								<i class="dashicons dashicons-info rtmicon"></i>
								<span class="rtm-tip">
									<?php 
                    esc_html_e('Allowed file types are : images, documents and texts.', 'buddypress-media');
                    ?>
								</span>
							</span>
						</div>
					</div><!-- .submit-bug-box -->

					<div class="rtm-form-filed rtm-button-wrapper clearfix">
						<?php 
                    wp_nonce_field('rtmedia-support-request', 'support_wpnonce');
                    ?>
						<?php 
                    submit_button('Submit', 'primary', 'rtmedia-submit-request', false);
                    ?>
						<?php 
                    submit_button('Cancel', 'secondary', 'cancel-request', false);
                    ?>
					</div>

					<?php 
                }
            }
        }
Esempio n. 6
0
 /**
  * Takes username and password, if succesful returns a access token
  */
 function rtmedia_api_process_wp_login_request()
 {
     //Login Errors and Messages
     $ec_user_pass_missing = 200001;
     $msg_user_pass_missing = esc_html__('username/password empty', 'buddypress-media');
     $ec_incorrect_username = 200002;
     $msg_incorrect_username = esc_html__('incorrect username', 'buddypress-media');
     $ec_incorrect_pass = 200003;
     $msg_incorrect_pass = esc_html__('incorrect password', 'buddypress-media');
     $ec_login_success = 200004;
     $msg_login_success = esc_html__('login success', 'buddypress-media');
     $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
     $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
     if (empty($username) || empty($password)) {
         wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_user_pass_missing, $msg_user_pass_missing));
     } else {
         $user_login = wp_authenticate(trim($username), trim($password));
         if (is_wp_error($user_login)) {
             $incorrect_password = !empty($user_login->errors['incorrect_password']) ? true : false;
             $incorrect_username = !empty($user_login->errors['invalid_username']) ? true : false;
             if ($incorrect_password) {
                 wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_incorrect_pass, $msg_incorrect_pass));
             } elseif ($incorrect_username) {
                 wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_incorrect_username, $msg_incorrect_username));
             }
         } else {
             $access_token = $this->rtmediajsonapifunction->rtmedia_api_get_user_token($user_login->ID, $user_login->data->user_login);
             $data = array('access_token' => $access_token);
             $rtmapilogin = new RTMediaApiLogin();
             //update all tokens for user to exired on each login
             $rtmapilogin->update(array('status' => 'FALSE'), array('user_id' => $user_login->ID));
             $remote_addr = rtm_get_server_var('REMOTE_ADDR', 'FILTER_VALIDATE_IP');
             $login_details = array('user_id' => intval($user_login->ID), 'ip' => $remote_addr, 'token' => sanitize_text_field($access_token), 'token_time' => date('Y-m-d H:i:s'));
             $rtmapilogin->insert($login_details);
             wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_login_success, $msg_login_success, $data));
         }
     }
 }
Esempio n. 7
0
<?php

/* * **************************************
 * Main.php
 *
 * The main template file, that loads the header, footer and sidebar
 * apart from loading the appropriate rtMedia template
 * *************************************** */
// by default it is not an ajax request
global $rt_ajax_request;
$rt_ajax_request = false;
//todo sanitize and fix $_SERVER variable usage
// check if it is an ajax request
$_rt_ajax_request = rtm_get_server_var('HTTP_X_REQUESTED_WITH', 'FILTER_SANITIZE_STRING');
if ('xmlhttprequest' === strtolower($_rt_ajax_request)) {
    $rt_ajax_request = true;
}
?>
	<div id="buddypress">
<?php 
//if it's not an ajax request, load headers
if (!$rt_ajax_request) {
    // if this is a BuddyPress page, set template type to
    // buddypress to load appropriate headers
    if (class_exists('BuddyPress') && !bp_is_blog_page() && apply_filters('rtm_main_template_buddypress_enable', true)) {
        $template_type = 'buddypress';
    } else {
        $template_type = '';
    }
    //get_header( $template_type );
    if ('buddypress' === $template_type) {
Esempio n. 8
0
 /**
  * rtmedia settings.
  *
  * @access public
  * @global BPMediaAddon $rtmedia_addon
  *
  * @param               void
  *
  * @return void
  */
 public function settings()
 {
     //todo: nonce required
     global $rtmedia, $rtmedia_addon, $rtmedia_save_setting_single;
     $options = rtmedia_get_site_option('rtmedia-options');
     $options = $this->sanitize_options($options);
     $rtmedia->options = $options;
     // Save Settings first then proceed.
     $rtmedia_option_save = filter_input(INPUT_POST, 'rtmedia-options-save', FILTER_SANITIZE_STRING);
     if (isset($rtmedia_option_save) && current_user_can('manage_options')) {
         $options = filter_input(INPUT_POST, 'rtmedia-options', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
         $options = $this->sanitize_before_save_options($options);
         $options = apply_filters('rtmedia_pro_options_save_settings', $options);
         $is_rewrite_rule_flush = apply_filters('rtmedia_flush_rewrite_rule', false);
         rtmedia_update_site_option('rtmedia-options', $options);
         do_action('rtmedia_save_admin_settings', $options);
         if ($is_rewrite_rule_flush) {
             flush_rewrite_rules(false);
         }
         $settings_saved = '';
         $setting_save = filter_input(INPUT_GET, 'settings-saved', FILTER_SANITIZE_STRING);
         if (!isset($setting_save)) {
             $settings_saved = '&settings-saved=true';
         }
         $http_referer = rtm_get_server_var('HTTP_REFERER', 'FILTER_SANITIZE_URL');
         if (isset($http_referer)) {
             wp_redirect($http_referer . $settings_saved);
         }
         global $rtmedia;
         $rtmedia->options = $options;
     }
     if (function_exists('add_settings_section')) {
         $rtmedia_addon = new RTMediaAddon();
         add_settings_section('rtm-addons', esc_html__('BuddyPress Media Addons for Photos', 'buddypress-media'), array($rtmedia_addon, 'get_addons'), 'rtmedia-addons');
         $rtmedia_support = new RTMediaSupport(false);
         add_settings_section('rtm-support', esc_html__('Support', 'buddypress-media'), array($rtmedia_support, 'get_support_content'), 'rtmedia-support');
         $rtmedia_themes = new RTMediaThemes();
         add_settings_section('rtm-themes', esc_html__('rtMedia Themes', 'buddypress-media'), array($rtmedia_themes, 'get_themes'), 'rtmedia-themes');
     }
     if (!isset($rtmedia_save_setting_single)) {
         $rtmedia_save_setting_single = true;
     }
 }
Esempio n. 9
0
 function process()
 {
     if (!isset($this->action_query->id)) {
         return;
     }
     $nonce = filter_input(INPUT_POST, 'featured_nonce', FILTER_SANITIZE_STRING);
     if (!wp_verify_nonce($nonce, 'rtm_media_featured_nonce' . $this->media->id)) {
         $return['nonce'] = true;
         wp_send_json($return);
     }
     $return = array();
     $return['nonce'] = false;
     $this->model = new RTMediaModel();
     $actions = $this->model->get(array('id' => $this->action_query->id));
     $this->get();
     if (1 === intval($this->settings[$actions[0]->media_type])) {
         if ($this->action_query->id === $this->featured) {
             $this->set(0);
             $return['next'] = $this->label;
             $return['action'] = false;
         } else {
             $this->set($this->action_query->id);
             $return['next'] = $this->undo_label;
             $return['action'] = true;
         }
         $return['status'] = true;
         global $rtmedia_points_media_id;
         $rtmedia_points_media_id = $this->action_query->id;
         do_action('rtmedia_after_set_featured', $this);
     } else {
         $return['status'] = false;
         $return['error'] = esc_html__('Media type is not allowed', 'buddypress-media');
     }
     $is_json = filter_input(INPUT_POST, 'json', FILTER_SANITIZE_STRING);
     if (!empty($is_json) && 'true' === $is_json) {
         wp_send_json($return);
     } else {
         $url = rtm_get_server_var('HTTP_REFERER', 'FILTER_SANITIZE_URL');
         wp_safe_redirect(esc_url_raw($url));
     }
 }
Esempio n. 10
0
 function process()
 {
     $actions = $this->model->get(array('id' => $this->action_query->id));
     $like_nonce = filter_input(INPUT_POST, 'like_nonce', FILTER_SANITIZE_STRING);
     if (!wp_verify_nonce($like_nonce, 'rtm_media_like_nonce' . $this->media->id)) {
         die;
     }
     $rtmediainteraction = new RTMediaInteractionModel();
     $user_id = $this->interactor;
     $media_id = $this->action_query->id;
     $action = $this->action;
     $check_action = $rtmediainteraction->check($user_id, $media_id, $action);
     if ($check_action) {
         $results = $rtmediainteraction->get_row($user_id, $media_id, $action);
         $row = $results[0];
         $curr_value = $row->value;
         if (1 === intval($curr_value)) {
             $value = '0';
             $this->increase = false;
         } else {
             $value = '1';
             $this->increase = true;
         }
         $update_data = array('value' => $value);
         $where_columns = array('user_id' => $user_id, 'media_id' => $media_id, 'action' => $action);
         $update = $rtmediainteraction->update($update_data, $where_columns);
     } else {
         $value = '1';
         $columns = array('user_id' => $user_id, 'media_id' => $media_id, 'action' => $action, 'value' => $value);
         $insert_id = $rtmediainteraction->insert($columns);
         $this->increase = true;
     }
     $actionwa = $this->action . 's';
     $return = array();
     $actions = intval($actions[0]->{$actionwa});
     if (true === $this->increase) {
         $actions++;
         $return['next'] = apply_filters('rtmedia_' . $this->action . '_label_text', $this->undo_label);
     } else {
         $actions--;
         $return['next'] = apply_filters('rtmedia_' . $this->action . '_label_text', $this->label);
     }
     $like_html = '<span class="rtmedia-like-counter"></span>';
     if ($actions > 0 && function_exists('rtmedia_who_like_html')) {
         $like_html = rtmedia_who_like_html($actions, $this->increase);
     }
     /* label for "person/people like this" in media popup" */
     if (1 === $actions) {
         $return['person_text'] = apply_filters('rtmedia_' . $this->action . '_person_label_text', $like_html);
     } else {
         $return['person_text'] = apply_filters('rtmedia_' . $this->action . '_person_label_text', $like_html);
     }
     if ($actions < 0) {
         $actions = 0;
     }
     $return['count'] = $actions;
     $this->model->update(array('likes' => $actions), array('id' => $this->action_query->id));
     global $rtmedia_points_media_id;
     $rtmedia_points_media_id = $this->action_query->id;
     do_action('rtmedia_after_like_media', $this);
     $is_json = filter_input(INPUT_POST, 'json', FILTER_SANITIZE_STRING);
     if (!empty($is_json) && 'true' === $is_json) {
         wp_send_json($return);
     } else {
         $url = rtm_get_server_var('HTTP_REFERER', 'FILTER_SANITIZE_URL');
         wp_safe_redirect(esc_url_raw($url));
         die;
     }
     return $actions;
 }
Esempio n. 11
0
 function bp_after_activity_post_form()
 {
     $url_raw = rtm_get_server_var('REQUEST_URI', 'FILTER_SANITIZE_URL');
     $url = trailingslashit($url_raw);
     $slug_split = explode('/', $url);
     // check position of media slug for end of the URL
     if (RTMEDIA_MEDIA_SLUG === $slug_split[count($slug_split) - 1]) {
         // replace media slug with the blank space
         $slug_split[count($slug_split) - 1] = '';
         $url_upload = implode('/', $slug_split);
         $url = trailingslashit($url_upload) . 'upload/';
     } else {
         $url = trailingslashit($url) . 'upload/';
     }
     if (rtmedia_is_uploader_view_allowed(true, 'activity')) {
         $params = array('url' => $url, 'runtimes' => 'html5,flash,html4', 'browse_button' => apply_filters('rtmedia_upload_button_id', 'rtmedia-add-media-button-post-update'), 'container' => 'rtmedia-whts-new-upload-container', 'drop_element' => 'whats-new-textarea', 'filters' => apply_filters('rtmedia_plupload_files_filter', array(array('title' => esc_html__('Media Files', 'buddypress-media'), 'extensions' => get_rtmedia_allowed_upload_type()))), 'max_file_size' => wp_max_upload_size() / (1024 * 1024) . 'M', 'multipart' => true, 'urlstream_upload' => true, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'file_data_name' => 'rtmedia_file', 'multi_selection' => true, 'multipart_params' => apply_filters('rtmedia-multi-params', array('redirect' => 'no', 'rtmedia_update' => 'true', 'action' => 'wp_handle_upload', '_wp_http_referer' => $url_raw, 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator(false, true))), 'max_file_size_msg' => apply_filters('rtmedia_plupload_file_size_msg', min(array(ini_get('upload_max_filesize'), ini_get('post_max_size')))));
         if (wp_is_mobile()) {
             $params['multi_selection'] = false;
         }
         $params = apply_filters('rtmedia_modify_upload_params', $params);
         wp_enqueue_script('rtmedia-backbone', false, '', false, true);
         $is_album = is_rtmedia_album() ? true : false;
         $is_edit_allowed = is_rtmedia_edit_allowed() ? true : false;
         wp_localize_script('rtmedia-backbone', 'is_album', $is_album);
         wp_localize_script('rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed);
         wp_localize_script('rtmedia-backbone', 'rtMedia_update_plupload_config', $params);
         $upload_view = new RTMediaUploadView(array('activity' => true));
         $upload_view->render('uploader');
     } else {
         echo "<div class='rtmedia-upload-not-allowed'>" . wp_kses(apply_filters('rtmedia_upload_not_allowed_message', esc_html__('You are not allowed to upload/attach media.', 'buddypress-media'), 'activity'), RTMediaUpload::$wp_kses_allowed_tags) . '</div>';
     }
 }
Esempio n. 12
0
 /**
  * Hook into the template_include filter to load custom template files
  *
  * @param string $template Template file path of the default template
  *
  * @return string File path of the template file to be loaded
  */
 function template_include($template)
 {
     // if it is not our route, return the default template early
     if (!$this->is_template()) {
         return $template;
     }
     // otherwise, apply a filter to the template,
     // pass the template  and slug to the function hooking here
     // so it can load a custom template
     $template_load = new RTMediaTemplate();
     global $new_rt_template;
     $new_rt_template = $template_load->set_template($template);
     $new_rt_template = apply_filters('rtmedia_' . $this->slug . '_include', $new_rt_template);
     global $rt_ajax_request;
     $rt_ajax_request = false;
     $req_with = rtm_get_server_var('HTTP_X_REQUESTED_WITH', 'FILTER_SANITIZE_STRING');
     // check if it is an ajax request
     if (!empty($req_with) && strtolower($req_with) === 'xmlhttprequest') {
         $rt_ajax_request = true;
     }
     if ($rt_ajax_request) {
         return $new_rt_template;
     }
     if (function_exists('bp_set_theme_compat_active')) {
         bp_set_theme_compat_active(apply_filters('rtmedia_main_template_set_theme_compat', true));
     }
     add_filter('the_content', array(&$this, 'rt_replace_the_content'));
     $this->rt_theme_compat_reset_post();
     return apply_filters('rtmedia_main_template_include', $template, $new_rt_template);
 }