function ymind_activate()
{
    get_currentuserinfo();
    global $current_user, $wpdb;
    if (!get_option('ymind_redirect_url')) {
        //delete cookie and log ou5
        $url = get_option('siteurl') . '/wp-login.php';
        $mail_subject = '' . __('Multiple Users Detected on user account', 'ymind') . '';
        $mail_message = '' . __('Your User Account was accessed from two seperate IP addresses at the same time. Click the following link to reactivate your account:', 'ymind') . ' [activation_link]';
        $email_offender = '0';
        $timeout_minutes = 5;
        $timeout_logins = 2;
        $lockout_option = 1;
        $lockout_minutes = 5;
        $login_error = '' . __('Your account has been locked out.', 'ymind') . '';
        $activation_url = get_option('siteurl') . '/wp-login.php';
        add_option('ymind_redirect_url', $url);
        add_option('ymind_email_offender', $email_offender);
        add_option('ymind_mail_subject', $mail_subject);
        add_option('ymind_mail_message', $mail_message);
        add_option('ymind_timeout_minutes', $timeout_minutes);
        add_option('ymind_timeout_logins', $timeout_logins);
        add_option('ymind_lockout_option', $lockout_option);
        add_option('ymind_locked_out_error', $login_error);
        add_option('ymind_lockout_minutes', $lockout_minutes);
        add_option('ymind_activate_redirect', $activation_url);
    }
    ymind_mysql_import(YMIND_SQL_IMPORT_FILE);
}
/**
 * WP eCommerce checkout class
 *
 * These are the class for the WP eCommerce checkout
 * The checkout class handles dispaying the checkout form fields
 *
 * @package wp-e-commerce
 * @subpackage wpsc-checkout-classes 
*/
function wpsc_google_checkout_submit()
{
    global $wpdb, $wpsc_cart, $current_user;
    $wpsc_checkout = new wpsc_checkout();
    $purchase_log_id = $wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN('" . $_SESSION['wpsc_sessionid'] . "') LIMIT 1");
    //$purchase_log_id = 1;
    get_currentuserinfo();
    //	exit('<pre>'.print_r($current_user, true).'</pre>');
    if ($current_user->display_name != '') {
        foreach ($wpsc_checkout->checkout_items as $checkoutfield) {
            //	exit(print_r($checkoutfield,true));
            if ($checkoutfield->unique_name == 'billingfirstname') {
                $checkoutfield->value = $current_user->display_name;
            }
        }
    }
    if ($current_user->user_email != '') {
        foreach ($wpsc_checkout->checkout_items as $checkoutfield) {
            //	exit(print_r($checkoutfield,true));
            if ($checkoutfield->unique_name == 'billingemail') {
                $checkoutfield->value = $current_user->user_email;
            }
        }
    }
    $wpsc_checkout->save_forms_to_db($purchase_log_id);
    $wpsc_cart->save_to_db($purchase_log_id);
    $wpsc_cart->submit_stock_claims($purchase_log_id);
}
        protected function get_wp_login_form($args = array())
        {
            $defaults = array('echo' => false, 'redirect' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'form_id' => 'loginform', 'label_username' => _x('Username', 'shortcode simple login', 'the7mk2'), 'label_password' => _x('Password', 'shortcode simple login', 'the7mk2'), 'label_remember' => _x('Remember Me', 'shortcode simple login', 'the7mk2'), 'label_log_in' => _x('Log In', 'shortcode simple login', 'the7mk2'), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => '', 'value_remember' => false);
            $args = wp_parse_args($args, apply_filters('login_form_defaults', $defaults));
            if (is_user_logged_in()) {
                global $user_identity;
                get_currentuserinfo();
                $form = '<p class="logged-in-as">' . sprintf(_x('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'shortcode simple login', 'the7mk2'), get_edit_user_link(), $user_identity, wp_logout_url(apply_filters('the_permalink', get_permalink()))) . '</p>';
            } else {
                $login_form_top = apply_filters('login_form_top', '', $args);
                $login_form_middle = apply_filters('login_form_middle', '', $args);
                $login_form_bottom = apply_filters('login_form_bottom', '', $args);
                $form = '
					<form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url(site_url('wp-login.php', 'login_post')) . '" method="post">
						' . $login_form_top . '
						<p class="login-username">
							<label class="assistive-text" for="' . esc_attr($args['id_username']) . '">' . esc_html($args['label_username']) . '</label>
							<input type="text" name="log" placeholder="' . esc_attr($args['label_username']) . '" id="' . esc_attr($args['id_username']) . '" class="input" value="' . esc_attr($args['value_username']) . '" size="20" />
						</p>
						<p class="login-password">
							<label class="assistive-text" for="' . esc_attr($args['id_password']) . '">' . esc_html($args['label_password']) . '</label>
							<input type="password" name="pwd" placeholder="' . esc_attr($args['label_password']) . '" id="' . esc_attr($args['id_password']) . '" class="input" value="" size="20" />
						</p>
						' . $login_form_middle . '
						' . ($args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr($args['id_remember']) . '" value="forever"' . ($args['value_remember'] ? ' checked="checked"' : '') . ' /> ' . esc_html($args['label_remember']) . '</label></p>' : '') . '
						<p class="login-submit">
							<input type="submit" name="wp-submit" id="' . esc_attr($args['id_submit']) . '" class="button-primary" value="' . esc_attr($args['label_log_in']) . '" />
							<input type="hidden" name="redirect_to" value="' . esc_url($args['redirect']) . '" />
						</p>
						' . $login_form_bottom . '
					</form>';
            }
            return $form;
        }
function ym_log_transaction($action_id = 1, $data = false, $user_id = 0)
{
    get_currentuserinfo();
    global $wpdb, $current_user;
    global $ym_this_transaction_id;
    if (is_array($data)) {
        $data = serialize($data);
    }
    $sql = 'INSERT INTO ' . $wpdb->prefix . 'ym_transaction (
			transaction_id
			, user_id
			, action_id
			, data
			, unixtime
		)
		VALUES (
			' . $ym_this_transaction_id . '
			, "' . (int) $user_id . '"
			, "' . $action_id . '"
			, "' . mysql_real_escape_string($data) . '"
			, UNIX_TIMESTAMP()
		)';
    $wpdb->query($sql);
    $id = $wpdb->insert_id;
    if (!$ym_this_transaction_id) {
        $ym_this_transaction_id = $id;
        $sql = 'UPDATE ' . $wpdb->prefix . 'ym_transaction SET transaction_id = ' . $id . ' WHERE id = ' . $id;
        $wpdb->query($sql);
    }
    return $id;
}
Example #5
0
/**
 * check if multi-user ebabled
 * 
 * @param mixed $cond
 */
function wpdm_multi_user($cond = '')
{
    global $wpdb, $current_user;
    get_currentuserinfo();
    $ismu = get_option('wpdm_multi_user') == 1 && !$current_user->caps['administrator'] ? true : false;
    return $ismu && $cond ? $cond : $ismu;
}
Example #6
0
function jakoblist_add()
{
    /*####################################################################################
    	# This function provides add end edit functionality. If there's an ID in the URL the #
    	# corrensponding database entry will be edited; if there's no ID a new entry is      #
    	# created.                                                                           #
    	#####################################################################################*/
    global $wpdb;
    //Important! DBQueries don't work without this!
    global $current_user;
    get_currentuserinfo();
    $id = $_GET["id"];
    $thetitle = $_POST["title"];
    $theauthor = $_POST["author"];
    $thepublisher = $_POST["publisher"];
    $theinfo = $_POST["info"];
    $theprice = str_replace(',', '.', $_POST["price"]);
    $thecreation = current_time('mysql');
    $thecreator = $current_user->user_login;
    $themodification = current_time('mysql');
    $themodificator = $current_user->user_login;
    $table_name = $wpdb->prefix . "jakoblist";
    $_POST['active'] ? $active = 1 : ($active = 0);
    if (!$id == '1') {
        $wpdb->insert($table_name, array('created' => $thecreation, 'createdby' => $thecreator, 'title' => $thetitle, 'author' => $theauthor, 'publisher' => $thepublisher, 'info' => $theinfo, 'price' => $theprice, 'active' => $active));
    } else {
        $wpdb->update($wpdb->prefix . 'jakoblist', array('title' => $thetitle, 'modifiedby' => $themodificator, 'modified' => $themodification, 'author' => $theauthor, 'publisher' => $thepublisher, 'info' => $theinfo, 'price' => $theprice, 'active' => $active), array('id' => $id));
    }
}
 /**
  * A custom function to get the entries and sort them
  *
  * @since 1.2
  * @returns array() $cols SQL results
  */
 function get_forms($orderby = 'form_id', $order = 'ASC', $per_page, $offset = 0, $search = '')
 {
     global $wpdb, $current_user;
     get_currentuserinfo();
     // Save current user ID
     $user_id = $current_user->ID;
     // Get the Form Order type settings, if any
     $user_form_order_type = get_user_meta($user_id, 'vfb-form-order-type', true);
     // Get the Form Order settings, if any
     $user_form_order = get_user_meta($user_id, 'vfb-form-order');
     foreach ($user_form_order as $form_order) {
         $form_order = implode(',', $form_order);
     }
     $where = '';
     // Forms type filter
     $where .= $this->get_form_status() && 'all' !== $this->get_form_status() ? $wpdb->prepare(' AND forms.form_status = %s', $this->get_form_status()) : '';
     // Always display all forms, unless an Form Type filter is set
     if (!$this->get_form_status() || in_array($this->get_form_status(), array('all', 'draft'))) {
         $where .= $wpdb->prepare(' AND forms.form_status IN("%s", "%s")', 'publish', 'draft');
     }
     $sql_order = sanitize_sql_orderby("{$orderby} {$order}");
     if (in_array($user_form_order_type, array('order', ''))) {
         $sql_order = isset($form_order) ? "FIELD( form_id, {$form_order} )" : sanitize_sql_orderby('form_id DESC');
     } else {
         $sql_order = sanitize_sql_orderby('form_title ASC');
     }
     $cols = $wpdb->get_results("SELECT forms.form_id, forms.form_title, forms.form_status FROM {$this->form_table_name} AS forms WHERE 1=1 {$where} {$search} ORDER BY {$sql_order}");
     return $cols;
 }
Example #8
0
function get_user_info($i)
{
    // return meta_key value
    global $current_user;
    get_currentuserinfo();
    return $current_user->{$i};
}
Example #9
0
 function GenerateCSV()
 {
     # constructor
     global $current_user;
     get_currentuserinfo();
     $this->current_user = $current_user;
     $this->month = mysql_real_escape_string($_GET['month']);
     // MM-YYYY
     if ($this->month == '') {
         $this->month = $this->get_current_month_year();
     }
     $userid = $this->get_userid(mysql_real_escape_string($_GET['user']));
     if ($userid != '') {
         $this->user = $userid;
         // username
     } else {
         $this->user = $this->current_user->ID;
     }
     $this->last_x_months = mysql_real_escape_string($_GET['last']);
     if ($this->last_x_months == '') {
         $this->last_x_months = 6;
     } else {
         if ($this->last_x_months < 2) {
             $this->last_x_months = 2;
         } else {
             if ($this->last_x_months > 12) {
                 $this->last_x_months = 12;
             }
         }
     }
     $this->view();
 }
function comments_template($file = '/comments.php')
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
    if (is_single() || is_page() || $withcomments) {
        $req = get_settings('require_name_email');
        $comment_author = isset($_COOKIE['comment_author_' . COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_' . COOKIEHASH])) : '';
        $comment_author_email = isset($_COOKIE['comment_author_email_' . COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_' . COOKIEHASH])) : '';
        $comment_author_url = isset($_COOKIE['comment_author_url_' . COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_' . COOKIEHASH])) : '';
        if (empty($comment_author)) {
            $comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = '{$post->ID}' AND comment_approved = '1' ORDER BY comment_date");
        } else {
            $author_db = $wpdb->escape($comment_author);
            $email_db = $wpdb->escape($comment_author_email);
            $comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = '{$post->ID}' AND ( comment_approved = '1' OR ( comment_author = '{$author_db}' AND comment_author_email = '{$email_db}' AND comment_approved = '0' ) ) ORDER BY comment_date");
        }
        get_currentuserinfo();
        define('COMMENTS_TEMPLATE', true);
        $include = apply_filters('comments_template', TEMPLATEPATH . $file);
        if (file_exists($include)) {
            require $include;
        } else {
            require ABSPATH . 'wp-content/themes/default/comments.php';
        }
    }
}
function jobman_store_comment()
{
    global $current_user;
    get_currentuserinfo();
    $comment = array('comment_post_ID' => $_REQUEST['interview'], 'comment_content' => $_REQUEST['comment'], 'user_id' => $current_user->ID);
    wp_insert_comment($comment);
}
function UserEngageScript_widget($meta)
{
    global $user_login, $user_email;
    get_currentuserinfo();
    $output = "\n\t<script>\n\t\twindow.civchat = {\n\t\t\tapiKey: \"{$meta}\",\n\t\t\tname: \"{$user_login}\",\n\t\t\temail: \"{$user_email}\"\n\t};\n\t</script>";
    echo $output;
}
Example #13
0
function sendTestEmail()
{
    global $current_user, $wpdb;
    get_currentuserinfo();
    //from site settings
    $thisBlogName = get_bloginfo('name');
    $thisBlogUrl = site_url();
    $test_adminmail = $current_user->user_email;
    //fabricated for testing
    $test_username = '******';
    $test_password = '******';
    //posted vars from ajax
    $test_fromreply = $_POST['test_email'];
    $test_loginurl = $_POST['test_loginurl'];
    $test_mailsubject = $_POST['test_mailhead'];
    $test_mailtext = $_POST['test_mailtext'];
    //replace instances of shortcodes
    $emailkeywords = array('[sitename]', '[siteurl]', '[siteloginurl]', '[username]', '[password]', '[useremail]', '[fromreply]');
    $emailreplaces = array($thisBlogName, '<a href="' . $thisBlogUrl . '">' . $thisBlogUrl . '</a>', '<a href="' . $test_loginurl . '">' . $test_loginurl . '</a>', $test_username, $test_password, $test_fromreply, $test_fromreply);
    $subject = str_replace($emailkeywords, $emailreplaces, $test_mailsubject);
    $message = str_replace($emailkeywords, $emailreplaces, $test_mailtext);
    //create valid header
    $headers = 'From: ' . $test_fromreply . ' <' . $test_fromreply . '>' . "\r\n";
    //filter to create html email
    add_filter('wp_mail_content_type', create_function('', 'return "text/html"; '));
    //send email
    wp_mail($test_adminmail, $subject, $message, $headers);
    exit;
}
Example #14
0
function shiftnav_basic_user_profile($atts)
{
    extract(shortcode_atts(array('id' => -1), $atts));
    $_user = '';
    if ($id == -1) {
        $id = get_current_user_id();
        if ($id == 0) {
            return '';
        }
        global $current_user;
        get_currentuserinfo();
        $_user = $current_user;
    } else {
        $_user = get_userdata($id);
    }
    if (!$_user) {
        return '';
    }
    $html = '<div class="shiftnav-basic-user-profile shiftnav-basic-user-profile-' . $id . '">';
    $default = '';
    $html .= get_avatar($id, 40, $default, 'User Profile Image');
    $html .= '<span class="shiftnav-basic-user-profile-name">' . $_user->display_name . '</span>';
    $html .= '</div>';
    return $html;
}
 function run()
 {
     get_remote_help();
     if (isset($_POST['epl_load_feedback_form']) && isset($_POST['epl_load_feedback_form']) == 1) {
         global $current_user;
         get_currentuserinfo();
         $data = array();
         $data['name'] = $current_user->first_name . ' ' . $current_user->last_name;
         $data['email'] = $current_user->user_email;
         $data['section'] = $_POST['section'];
         $r = $this->epl->load_view('admin/feedback-form', $data, true);
     } elseif (isset($_POST['epl_send_feedback']) && isset($_POST['epl_send_feedback']) == 1) {
         $headers = 'From: ' . $_POST['name'] . "<{$_POST['email']}>" . "\r\n" . 'Reply-To: ' . "<{$_POST['email']}>" . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         $_POST['section'] = str_replace('_section__', '', $_POST['section']);
         $r = wp_mail('*****@*****.**', 'Events Planner Feedback: ' . $_POST['reason'] . ': ' . $_POST['section'], esc_attr($_POST['message']), $headers);
         if ($r) {
             $r = 'Mail Sent, thank you very much.  We will get back to you soon!';
         } else {
             $r = 'Sorry but something went wrong.  Please try again.';
             echo $this->epl_util->epl_invoke_error(0);
             die;
         }
     } elseif ($_REQUEST['epl_action'] == 'epl_pricing_type') {
         $this->pricing_type = (int) $_REQUEST['_epl_pricing_type'];
         $r = $this->time_price_section();
     } elseif ($_POST['epl_action'] == 'recurrence_preview' || $_POST['epl_action'] == 'recurrence_process') {
         $this->r_mode = $_POST['epl_action'];
         $this->erm = $this->epl->load_model('epl-recurrence-model');
         $r = $this->erm->recurrence_dates_from_post($this->fields, $this->data['values'], $this->r_mode);
     }
     echo $this->epl_util->epl_response(array('html' => $r));
     die;
 }
 /**
  * Creates the filters and actions for the admin panel
  * 
  * @return null;
  */
 function userAccessManagerAP()
 {
     global $userAccessManager, $current_user;
     if (!isset($userAccessManager)) {
         return;
     }
     $userAccessManager->setAtAdminPanel();
     $uamOptions = $userAccessManager->getAdminOptions();
     if ($userAccessManager->isDatabaseUpdateNecessary()) {
         $link = 'admin.php?page=uam_setup';
         add_action('admin_notices', create_function('', 'echo \'<div id="message" class="error"><p><strong>' . sprintf(TXT_UAM_NEED_DATABASE_UPDATE, $link) . '</strong></p></div>\';'));
     }
     get_currentuserinfo();
     $curUserdata = get_userdata($current_user->ID);
     $uamAccessHandler = $userAccessManager->getAccessHandler();
     if ($uamAccessHandler->checkUserAccess() || $uamOptions['authors_can_add_posts_to_groups'] == 'true') {
         //Admin actions
         if (function_exists('add_action')) {
             add_action('admin_print_styles', array(&$userAccessManager, 'addStyles'));
             add_action('wp_print_scripts', array(&$userAccessManager, 'addScripts'));
             add_action('manage_posts_custom_column', array(&$userAccessManager, 'addPostColumn'), 10, 2);
             add_action('manage_pages_custom_column', array(&$userAccessManager, 'addPostColumn'), 10, 2);
             add_action('save_post', array(&$userAccessManager, 'savePostData'));
             add_action('manage_media_custom_column', array(&$userAccessManager, 'addPostColumn'), 10, 2);
             //Actions are only called when the attachment content is modified so we can't use it.
             //add_action('add_attachment', array(&$userAccessManager, 'savePostData'));
             //add_action('edit_attachment', array(&$userAccessManager, 'savePostData'));
             add_action('edit_user_profile', array(&$userAccessManager, 'showUserProfile'));
             add_action('profile_update', array(&$userAccessManager, 'saveUserData'));
             add_action('edit_category_form', array(&$userAccessManager, 'showCategoryEditForm'));
             add_action('create_category', array(&$userAccessManager, 'saveCategoryData'));
             add_action('edit_category', array(&$userAccessManager, 'saveCategoryData'));
         }
         //Admin filters
         if (function_exists('add_filter')) {
             //The filter we use instead of add|edit_attachment action, reason see top
             add_filter('attachment_fields_to_save', array(&$userAccessManager, 'saveAttachmentData'));
             add_filter('manage_posts_columns', array(&$userAccessManager, 'addPostColumnsHeader'));
             add_filter('manage_pages_columns', array(&$userAccessManager, 'addPostColumnsHeader'));
             add_filter('manage_users_columns', array(&$userAccessManager, 'addUserColumnsHeader'), 10);
             add_filter('manage_users_custom_column', array(&$userAccessManager, 'addUserColumn'), 10, 3);
             add_filter('manage_edit-category_columns', array(&$userAccessManager, 'addCategoryColumnsHeader'));
             add_filter('manage_category_custom_column', array(&$userAccessManager, 'addCategoryColumn'), 10, 3);
         }
         if ($uamOptions['lock_file'] == 'true') {
             add_action('media_meta', array(&$userAccessManager, 'showMediaFile'), 10, 2);
             add_filter('manage_media_columns', array(&$userAccessManager, 'addPostColumnsHeader'));
         }
     }
     //Clean up at deleting should be always done.
     if (function_exists('add_action')) {
         add_action('update_option_permalink_structure', array(&$userAccessManager, 'updatePermalink'));
         add_action('wp_dashboard_setup', array(&$userAccessManager, 'setupAdminDashboard'));
         add_action('delete_post', array(&$userAccessManager, 'removePostData'));
         add_action('delete_attachment', array(&$userAccessManager, 'removePostData'));
         add_action('delete_user', array(&$userAccessManager, 'removeUserData'));
         add_action('delete_category', array(&$userAccessManager, 'removeCategoryData'), 10, 2);
     }
     $userAccessManager->noRightsToEditContent();
 }
Example #17
0
function wppa_get_user($type = 'login')
{
    global $current_user;
    if (is_user_logged_in()) {
        get_currentuserinfo();
        switch ($type) {
            case 'login':
                return $current_user->user_login;
                break;
            case 'display':
                return $current_user->display_name;
                break;
            case 'id':
                return $current_user->ID;
                break;
            case 'firstlast':
                return $current_user->user_firstname . ' ' . $current_user->user_lastname;
                break;
            default:
                wppa_dbg_msg('Un-implemented type: ' . $type . ' in wppa_get_user()', 'red', 'force');
                return '';
        }
    } else {
        return $_SERVER['REMOTE_ADDR'];
    }
}
Example #18
0
/**
 * Sends a message to subscribed users informing them of a new PM
 * 
 * @global $current_user
 * @param $message_id
 */
function cpm_mail_new($message_id)
{
    global $current_user;
    get_currentuserinfo();
    $message = cpm_getMessageInfo($message_id);
    foreach ($message['users'] as $user_id) {
        if ($current_user->ID != $user_id && cpm_userCheckSubscription($user_id, $message['thread_id'])) {
            $user = get_user_by('id', $user_id);
            if ($user) {
                $to = $user->user_email;
                //$to = '*****@*****.**'; /** @todo Remove this: DEBUG */
                $from_name = get_option('cpm_email_from_name');
                $from_email = get_option('cpm_email_from_email');
                $subject = get_option('cpm_email_subject');
                $contents = nl2br(get_option('cpm_email_body'));
                $replace['%sender%'] = $current_user->display_name;
                $replace['%subject%'] = $message['subject'];
                $replace['%recipient%'] = $user->display_name;
                $replace['%blog_name%'] = get_bloginfo('name');
                $replace['%blog_email%'] = get_bloginfo('admin_email');
                $replace['%pm_link%'] = cpm_buildURL(array('cpm_action' => 'read', 'cpm_id' => $message['thread_id'])) . '#cpm-message-' . $message['id'];
                $replace['%message%'] = $message['message'];
                list($from_name, $from_email, $subject, $contents) = str_replace(array_keys($replace), $replace, array($from_name, $from_email, $subject, $contents));
                $headers = "MIME-Version: 1.0\n" . 'From: ' . $from_name . ' <' . $from_email . '>' . "\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
                wp_mail($to, $subject, $contents, $headers);
                do_action('cpm_mail', $message_id, $user->ID);
            }
        }
    }
}
Example #19
0
 /**
  * Gets the current logged in user's profile
  * 
  * @return object
  */
 private function get_current_user()
 {
     global $current_user;
     get_currentuserinfo();
     // no need to check return value - we know a user is logged in
     return $current_user;
 }
Example #20
0
function zopimme()
{
    global $current_user, $zopimshown;
    get_currentuserinfo();
    $code = get_option('zopimCode');
    if (($code == "" || $code == "zopim") && !ereg("zopim", $_GET["page"]) && !ereg("zopim", $_SERVER["SERVER_NAME"])) {
        return;
    }
    // dont show this more than once
    if (isset($zopimshown) && $zopimshown == 1) {
        return;
    }
    $zopimshown = 1;
    echo "<!--Start of Zopim Live Chat Script-->\n<script type=\"text/javascript\">\nwindow.\$zopim||(function(d,s){var z=\$zopim=function(c){z._.push(c)},\$=z.s=\nd.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.\n_.push(o)};z._=[];z.set._=[];\$.async=!0;\$.setAttribute('charset','utf-8');\n\$.src='//cdn.zopim.com/?" . $code . "';z.t=+new Date;\$.\ntype='text/javascript';e.parentNode.insertBefore(\$,e)})(document,'script');\n</script>";
    echo '<script>';
    if (isset($current_user)) {
        $firstname = $current_user->display_name;
        $useremail = $current_user->user_email;
        if ($firstname != "" && $useremail != "") {
            echo "\$zopim(function(){\$zopim.livechat.set({name: '{$firstname}', email: '{$useremail}'}); });";
        }
    }
    echo zopim_get_widget_options();
    echo '</script>';
    echo "<!--End of Zopim Live Chat Script-->";
}
function Medieteknik_post_tweet($tweet, $hashtag)
{
    //get current user
    global $user_ID;
    get_currentuserinfo();
    //get the saved token for this user
    $token = get_usermeta($user_ID, 'twitter_token');
    $secret = get_usermeta($user_ID, 'twitter_token_secret');
    $oauth = new TwitterOAuth($token, $secret);
    $url = 'http://api.twitter.com/1/statuses/update.xml';
    if ($hashtag && strpos(strtolower($tweet), '#medieteknik') == false) {
        //add the hashtag
        $tweet = rtrim($tweet) . ' #medieteknik';
    }
    $params = array('status' => $tweet);
    $reply = $oauth->oauth_request($url, 'POST', $params);
    //Check our request came out ok
    if ($reply['status'] != 200) {
        if ($reply['status'] == 403) {
            die('Twitter tillåter endast 150 statusuppdateringar i timmen. Försök igen senare');
        } else {
            die('Något är galet med twitter. Försök igen senare eller kontakta sidansvarig');
        }
    }
    header('location: index.php');
}
Example #22
0
function getHTML($attachment)
{
    $attach_id = $attachment['id'];
    $file = '';
    $html = '';
    if (isset($attachment['data']['file'])) {
        $file = explode('/', $attachment['data']['file']);
        $file = array_slice($file, 0, count($file) - 1);
        $path = implode('/', $file);
        if (is_page_template('user_dashboard_add_step1.php')) {
            $image = $attachment['data']['sizes']['thumbnail']['file'];
        } else {
            $image = $attachment['data']['sizes']['wpestate_property_listings']['file'];
        }
        $post = get_post($attach_id);
        $dir = wp_upload_dir();
        $path = $dir['baseurl'] . '/' . $path;
        $html = '';
        global $current_user;
        get_currentuserinfo();
        //if( is_page_template('user_dashboard_profile.php') ){
        //  update_user_meta($userID, 'custom_picture', $path.'/'.$image);
        // }
        $userID = $current_user->ID;
        $html .= $path . '/' . $image;
    }
    return $html;
}
/**
 * Retrieve the current user object.
 *
 * @since 2.0.3
 *
 * @return WP_User Current user WP_User object
 */
function wp_get_current_user() {
	global $current_user;

	get_currentuserinfo();

	return $current_user;
}
/**
*  Saves keyword and referer info to db
*
*
*/
function save_keyword($keyword, $referer)
{
    global $wpdb;
    if (!$keyword) {
        return false;
    }
    $date = date('YmdHi');
    $referer_info = parse_url($referer);
    $mySearch =& new WP_Query("s={$keyword} & showposts=-1");
    $NumResults = $mySearch->post_count;
    if (is_user_logged_in()) {
        global $current_user;
        get_currentuserinfo();
        $user = $current_user->ID;
    } else {
        $user = '******';
    }
    $search_count = search_count($keyword, $user);
    $repeat_coount = repeat_count($keyword, $user);
    if ($repeat_coount != null) {
        if (is_numeric($user)) {
            $row = $wpdb->get_var("SELECT id FROM " . SS_TABLE . " WHERE keywords = '" . mysql_escape_string($keyword) . "' and user='******'");
        } else {
            $row = $wpdb->get_var("SELECT id FROM " . SS_TABLE . " WHERE keywords = '" . mysql_escape_string($keyword) . "'");
        }
        $wpdb->update(SS_TABLE, array('query_date' => $date, 'repeat_count' => ++$repeat_coount, 'search_count' => $NumResults), array('id' => $row), array('%s', '%s', '%s', '%s', '%s', '%d', '%d'));
    } else {
        $wpdb->insert(SS_TABLE, array('keywords' => $keyword, 'query_date' => $date, 'source' => $referer_info['host'], 'user' => $user, 'agent' => $_SERVER['HTTP_USER_AGENT'], 'repeat_count' => 0, 'search_count' => $NumResults), array('%s', '%s', '%s', '%s', '%s', '%d', '%d'));
    }
}
function response_tracker($actions, $comment)
{
    global $current_user;
    get_currentuserinfo();
    $current = get_comment_meta($comment->comment_ID, 'tracker_comment_status', true);
    $responded = get_comment_meta($comment->comment_ID, 'tracker_responded_flag', true);
    if ($current == "") {
        $current = "todo";
    }
    // TODO: this is a hack... need a better way to mark the below.
    // I am using an empty span and it's class to designate the current status.
    // This class is then used via jQuery in response-tracker.js to set the
    // colour of the comment block when the page load completes.
    if ($current == 'replied') {
        $curstatusclass = 'trackerstatusreplied';
    } elseif ($current == 'ignore' || $comment->comment_author == $current_user->user_login) {
        $curstatusclass = 'trackerstatusignored';
    } elseif ($responded) {
        $curstatusclass = 'trackerstatusresponded';
    } else {
        $curstatusclass = 'trackerstatustodo';
    }
    $actions['status'] = "<span class='{$curstatusclass}'> </span>";
    $actions['status'] .= "Mark: (";
    foreach (array('todo', 'replied', 'ignore') as $status) {
        $class = "trackerstatusaction trackeraction{$status}";
        $class .= $status == $current ? " trackercurrentselected" : "";
        $onclick = "onClick='setCommentStatus(this, {$comment->comment_ID}, \"{$status}\");'";
        $actions['status'] .= " <span class='{$class}' {$onclick}>" . ucfirst($status) . "</span>";
    }
    $actions['status'] .= " )";
    return $actions;
}
/**
 * Gets the number of purchases for a variably priced download
 *
 * @since       1.0.6
 * @param       int $download_id The ID for this download
 * @param       int $price_id The price ID for this item
 * @param       string $user_email The email for the purchaser
 * @return      mixed $purchases
 */
function edd_pl_get_file_purchases($download_id = 0, $price_id = 0, $user_email = false)
{
    global $post;
    $post_old = $post;
    $scope = edd_get_option('edd_purchase_limit_scope') ? edd_get_option('edd_purchase_limit_scope') : 'site-wide';
    // Retrieve all sales of this download
    $query_args = array('download' => $download_id, 'number' => -1);
    // Override global search if site-wide isn't selected
    if ($scope != 'site-wide') {
        if (!$user_email) {
            get_currentuserinfo();
        }
        $query_args['s'] = $user_email;
    }
    // Get all purchases for this download
    $query = new EDD_Payments_Query($query_args);
    $payments = $query->get_payments();
    $purchased = 0;
    // Count purchases
    foreach ($payments as $payment_id => $payment_data) {
        foreach ($payment_data->cart_details as $cart_item) {
            if (isset($cart_item['item_number']['options']['price_id']) && (int) $cart_item['item_number']['options']['price_id'] == (int) $price_id) {
                $purchased++;
            }
        }
    }
    wp_reset_postdata();
    $post = $post_old;
    return $purchased;
}
function jobman_display_login()
{
    global $current_user;
    get_currentuserinfo();
    $options = get_option('jobman_options');
    $content = '';
    if (is_user_logged_in()) {
        $loggedin_html = '<div id="jobman_loggedin"><span class="message">';
        $loggedin_html .= apply_filters('jobman_loggedin_msg', sprintf(__('Welcome, %1s!', 'jobman'), $current_user->display_name));
        $loggedin_html .= '</span>';
        $loggedin_html .= '</div>';
        $content .= apply_filters('jobman_loggedin_html', $loggedin_html);
    } else {
        $login_html = '<form action="" method="post">';
        $login_html .= '<div id="jobman_login">';
        $login_html .= '<span class="message">';
        $login_html .= apply_filters('jobman_login_msg', __("If you've registered with us previously, please login now. If you'd like to register, please click the 'Register' link below.", 'jobman'));
        $login_html .= '</span>';
        $login_html .= '<label class="username" for="jobman_username">' . __('Username', 'jobman') . '</label>: ';
        $login_html .= '<input type="text" name="jobman_username" id="jobman_username" class="username" />';
        $login_html .= '<label class="password" for="jobman_password">' . __('Password', 'jobman') . '</label>: ';
        $login_html .= '<input type="password" name="jobman_password" id="jobman_password" class="password" />';
        $login_html .= '<input class="submit" type="submit" name="submit" value="' . __('Login', 'jobman') . '" />';
        $login_html .= '<span><a href="' . get_page_link($options['register_page']) . '">' . __('Register', 'jobman') . '</a> | <a href="' . wp_lostpassword_url(urlencode(jobman_current_url())) . '">' . __('Forgot your password?', 'jobman') . '</a></span></div>';
        $login_html .= '</form>';
        $content .= apply_filters('jobman_login_html', $login_html);
    }
    return $content;
}
function getEntryOptionKeyForGF($entry)
{
    global $current_user;
    get_currentuserinfo();
    $option_key = $current_user->user_login . '_GF_' . $form['id'] . '_entry';
    return $option_key;
}
 function run()
 {
     //get_remote_help();
     if (isset($_POST['epl_load_feedback_form']) && isset($_POST['epl_load_feedback_form']) == 1) {
         global $current_user;
         get_currentuserinfo();
         $data = array();
         $data['name'] = $current_user->first_name . ' ' . $current_user->last_name;
         $data['email'] = $current_user->user_email;
         $data['section'] = $_POST['section'];
         $r = $this->epl->load_view('admin/feedback-form', $data, true);
     } elseif ($_REQUEST['epl_action'] == 'epl_attendee_list') {
         //$r = $this->ecm->epl_attendee_list( isset( $_REQUEST['table_view'] ) );
     } elseif ($_REQUEST['epl_action'] == 'epl_pricing_type') {
         $this->pricing_type = (int) $_REQUEST['_epl_pricing_type'];
         $r = $this->time_price_section();
     } elseif ($_REQUEST['epl_action'] == 'load_fullcalendar') {
         $r = $this->fullcalendar();
     } elseif ($_REQUEST['epl_action'] == 'import_discount') {
         $r = $this->discount_section(true);
     } elseif ($_REQUEST['epl_action'] == 'bulk_action') {
         $r = $this->bulk_action(true);
     } elseif ($_POST['epl_action'] == 'recurrence_preview' || $_POST['epl_action'] == 'recurrence_process') {
         $this->r_mode = $_POST['epl_action'];
         $this->ercm = $this->epl->load_model('epl-recurrence-model');
         $r = $this->ercm->recurrence_dates_from_post($this->fields, $this->data['values'], $this->r_mode);
     }
     echo $this->epl_util->epl_response(array('html' => $r));
     die;
 }
Example #30
-1
function wpmp_add_product()
{
    if (wp_verify_nonce($_POST['__product_wpmp'], 'wpmp-product') && $_POST['task'] == '') {
        if ($_POST['post_type'] == "wpmarketplace") {
            global $current_user, $wpdb;
            get_currentuserinfo();
            $my_post = array('post_title' => $_POST['product']['post_title'], 'post_content' => $_POST['product']['post_content'], 'post_excerpt' => $_POST['product']['post_excerpt'], 'post_status' => "draft", 'post_author' => $current_user->ID, 'post_type' => "wpmarketplace");
            //echo $_POST['id'];
            if ($_POST['id']) {
                //update post
                $my_post['ID'] = $_REQUEST['id'];
                wp_update_post($my_post);
                $postid = $_REQUEST['id'];
            } else {
                //insert post
                $postid = wp_insert_post($my_post);
            }
            update_post_meta($postid, "wpmp_list_opts", $_POST['wpmp_list']);
            foreach ($_POST['wpmp_list'] as $k => $v) {
                update_post_meta($postid, $k, $v);
            }
            //echo $_POST['wpmp_list']['fimage'];
            if ($_POST['wpmp_list']['fimage']) {
                $wp_filetype = wp_check_filetype(basename($_POST['wpmp_list']['fimage']), null);
                $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($_POST['wpmp_list']['fimage'])), 'post_content' => '', 'guid' => $_POST['wpmp_list']['fimage'], 'post_status' => 'inherit');
                $attach_id = wp_insert_attachment($attachment, $_POST['wpmp_list']['fimage'], $postid);
                set_post_thumbnail($postid, $attach_id);
            }
        }
        //echo $_SERVER['HTTP_REFERER'];
        header("Location: " . $_SERVER['HTTP_REFERER']);
        die;
    }
}