$plugin) { $is_active = in_array($key, $active_plugins); //filter for only armember ones, may get some others if using our naming convention if (strpos(strtolower($plugin["Title"]), "armember") !== false) { $name = substr($key, 0, strpos($key, "/")); $plugins[] = array("name" => $name, "version" => $plugin["Version"], "is_active" => $is_active); } } $plugins = json_encode($plugins); //get theme info $theme = wp_get_theme(); $theme_name = $theme->get("Name"); $theme_uri = $theme->get("ThemeURI"); $theme_version = $theme->get("Version"); $theme_author = $theme->get("Author"); $theme_author_uri = $theme->get("AuthorURI"); $im = is_multisite(); $sortorder = get_option("armSortOrder"); $post = array("wp" => get_bloginfo("version"), "php" => phpversion(), "mysql" => $wpdb->db_version(), "plugins" => $plugins, "tn" => $theme_name, "tu" => $theme_uri, "tv" => $theme_version, "ta" => $theme_author, "tau" => $theme_author_uri, "im" => $im, "sortorder" => $sortorder); return $post; } function armgetapiurl() { $api_url = 'https://arpluginshop.com/'; return $api_url; } function checksite($str) { update_option('arm_wp_get_version', $str); } function arm_delete_member_activities() { global $wp, $wpdb, $current_user, $arm_errors, $ARMember, $arm_members_class, $arm_member_forms, $arm_global_settings; $delete_act = $wpdb->query("DELETE FROM `".$ARMember->tbl_arm_activity."` WHERE `arm_type`!='membership'"); if ($delete_act) { $response = array('type' => 'success', 'msg' => __('Member activities has been deleted successfully.', 'ARMember')); } else { $response = array('type' => 'error', 'msg' => __('There is a error while deleting member activities, please try again.', 'ARMember')); } echo json_encode($response); die(); } function arm_get_activity_by($field = '', $value = '', $limit = '', $object_type = ARRAY_A) { global $wp, $wpdb, $current_user, $arm_errors, $ARMember, $arm_global_settings, $arm_subscription_plans; $object_type = !empty($object_type) ? $object_type : ARRAY_A; $limit = (!empty($limit)) ? " LIMIT " . $limit : ""; $result = false; if (!empty($field) && $value != '') { $result = $wpdb->get_results("SELECT * FROM `".$ARMember->tbl_arm_activity."` WHERE `$field`='$value' ORDER BY `arm_activity_id` DESC $limit", $object_type); } return $result; } function arm_crop_image() { $_POST['update_meta'] = isset($_POST['update_meta']) ? $_POST['update_meta'] : ''; $user_id = get_current_user_id(); /*this change need to confirm with multisite*/ $_POST['src'] = MEMBERSHIPLITE_UPLOAD_URL.'/'.basename($_POST['src']); $info = getimagesize(MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($_POST['src'])); $file = $_POST['src']; if(isset($_POST['cord'])) { $crop = explode(',', $_POST['cord']); $targ_x1 = $crop[0]; $targ_y1 = $crop[1]; $targ_x2 = $crop[2]; $targ_y2 = $crop[3]; } else { $ofile = MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($_POST['src']); $orgnl_hw = getimagesize($ofile); $orgnl_w = $orgnl_hw[0]; $orgnl_h = $orgnl_hw[1]; $targ_x1 = 0; $targ_y1 = 0; $targ_x2 = $orgnl_w; $targ_y2 = $orgnl_h; } if ($_POST['type'] == 'profile') { if ($_POST['update_meta'] != 'no') { update_user_meta($user_id, 'avatar', $file); do_action('arm_upload_bp_avatar', $user_id); } $thumb_w = 220; $thumb_h = 220; } else if ($_POST['type'] == 'cover') { $thumb_w = 918; $thumb_h = 320; if ($_POST['update_meta'] != 'no') { update_user_meta($user_id, 'profile_cover', $file); do_action('arm_upload_bp_profile_cover', $user_id); } } $file = MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($_POST['src']); if ($info['mime'] == 'image/gif') { $img_r = imagecreatefromgif($file); $dst_r = imagecreatetruecolor($targ_x2, $targ_y2); imagecopy($dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2); imagegif($dst_r, MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($file)); $original_info = getimagesize($file); $original_w = $original_info[0]; $original_h = $original_info[1]; $original_img = imagecreatefromgif($file); $thumb_img = imagecreatetruecolor($thumb_w, $thumb_h); imagecopy($thumb_img, $original_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $original_w, $original_h); imagegif($thumb_img, MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($file)); } else if ($info['mime'] == 'image/png') { $img_r = imagecreatefrompng($file); $dst_r = imagecreatetruecolor($targ_x2, $targ_y2); imagealphablending($dst_r, false); imagesavealpha($dst_r, true); imagecopy($dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2); imagepng($dst_r, MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($file)); $original_info = getimagesize($file); $original_w = $original_info[0]; $original_h = $original_info[1]; $original_img = imagecreatefrompng($file); $thumb_img = imagecreatetruecolor($thumb_w, $thumb_h); imagealphablending($thumb_img, false); imagesavealpha($thumb_img, true); imagecopyresampled($thumb_img, $original_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $original_w, $original_h); imagepng($thumb_img, MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($file)); } else { $img_r = imagecreatefromjpeg($file); $dst_r = imagecreatetruecolor($targ_x2, $targ_y2); imagecopy($dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2); imagejpeg($dst_r, MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($file), 100); $original_info = getimagesize($file); $original_w = $original_info[0]; $original_h = $original_info[1]; $original_img = imagecreatefromjpeg($file); $thumb_img = imagecreatetruecolor($thumb_w, $thumb_h); imagecopyresampled($thumb_img, $original_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $original_w, $original_h); imagejpeg($thumb_img, MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($file)); } if ($_POST['type'] == 'profile') { if ($_POST['update_meta'] != 'no') { update_user_meta($user_id, 'avatar', $_POST['src']); do_action('arm_after_upload_bp_avatar', $user_id); } } else if ($_POST['type'] == 'cover') { if ($_POST['update_meta'] != 'no') { update_user_meta($user_id, 'profile_cover', $_POST['src']); do_action('arm_after_upload_bp_profile_cover', $user_id); } } echo $_POST['src']; die(); } function path_only($file) { return trailingslashit(dirname($file)); } function arm_allowed_wp_mime_types() { $mimes = get_allowed_mime_types(); ksort($mimes); $mcount = count($mimes); $third = ceil($mcount / 3); $c = 0; $mimes['exe'] = ''; unset($mimes['exe']); $allowed_mimes = array(); foreach( $mimes as $ext => $type ){ if( strpos($ext, '|') !== false ){ $exts = explode('|',$ext); foreach( $exts as $extension){ if( $extension != '' ){ array_push($allowed_mimes,$extension); } } } else { array_push($allowed_mimes,$ext); } } return $allowed_mimes; } function arm_upload_front() { $upload_dir = MEMBERSHIPLITE_UPLOAD_DIR.'/'; $upload_url = MEMBERSHIPLITE_UPLOAD_URL.'/'; $arm_allowed_mimes = $this->arm_allowed_wp_mime_types(); $file_name = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false); $denyExts = array("php", "php3", "php4", "php5", "pl", "py", "jsp", "asp", "exe", "cgi"); $response = ""; if ($file_name) { $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext) - 1] ); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { file_put_contents($upload_dir . $file_name, file_get_contents('php://input')); $response = $upload_url . $file_name; } echo $response; exit; } else { $files = $_FILES['armfileselect']; $file_size = (isset($_REQUEST['allow_size'])) ? $_REQUEST['allow_size'] : ''; $file_name = $_REQUEST['fname']; $file_type_new = $_FILES['armfileselect']['type']; $file_size_new = $_FILES['armfileselect']['size']; $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext)-1] ); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { if (!empty($file_size) && ($file_size_new > $file_size)) { $response = "
".__('File size not allowed', 'ARMember')."
"; } else { move_uploaded_file($files['tmp_name'], $upload_dir . $file_name); $response = $upload_url . $file_name; echo "" . $upload_url . $file_name . "
"; } } /*else { echo "file type not allowed
"; }*/ } exit; } function arm_upload_cover() { $upload_dir = MEMBERSHIPLITE_UPLOAD_DIR.'/'; $upload_url = MEMBERSHIPLITE_UPLOAD_URL.'/'; $arm_allowed_mimes = $this->arm_allowed_wp_mime_types(); $file_name = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false); $response = ""; $userID = get_current_user_id(); $denyExts = array("php", "php3", "php4", "php5", "pl", "py", "jsp", "asp", "exe", "cgi"); if ($file_name && !empty($userID) && $userID != 0) { $oldCover = get_user_meta($userID, 'profile_cover', true); $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext) - 1] ); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { file_put_contents($upload_dir . $file_name, file_get_contents('php://input')); $response = $upload_url . $file_name; echo $response; exit; } } else { $files = $_FILES['armfileselect']; $file_size = (isset($_REQUEST['allow_size'])) ? $_REQUEST['allow_size'] : ''; $file_name = $_REQUEST['fname']; $file_type_new = $_FILES['armfileselect']['type']; $file_size_new = $_FILES['armfileselect']['size']; $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext) - 1] ); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { if (!empty($file_size) && ($file_size_new > $file_size)) { $response = "" . __('File size not allowed', 'ARMember') . "
"; } else { move_uploaded_file($files['tmp_name'], $upload_dir . $file_name); $response = $upload_url . $file_name; echo "" . $upload_url . $file_name . "
"; } } /*else { echo "file type not allowed
"; }*/ } exit; } function arm_upload_profile() { $upload_dir = MEMBERSHIPLITE_UPLOAD_DIR.'/'; $upload_url = MEMBERSHIPLITE_UPLOAD_URL.'/'; $arm_allowed_mimes = $this->arm_allowed_wp_mime_types(); $file_name = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false); $response = ""; $userID = get_current_user_id(); $denyExts = array("php", "php3", "php4", "php5", "pl", "py", "jsp", "asp", "exe", "cgi"); if ($file_name && !empty($userID) && $userID != 0) { $oldCover = get_user_meta($userID, 'profile_cover', true); $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext) - 1] ); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { file_put_contents($upload_dir . $file_name, file_get_contents('php://input')); $response = $upload_url . $file_name; echo $response; exit; } } else { $files = $_FILES['armfileselect']; $file_size = (isset($_REQUEST['allow_size'])) ? $_REQUEST['allow_size'] : ''; $file_name = $_REQUEST['fname']; $file_type_new = $_FILES['armfileselect']['type']; $file_size_new = $_FILES['armfileselect']['size']; $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext) - 1] ); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { if (!empty($file_size) && ($file_size_new > $file_size)) { $response = "" . __('File size not allowed', 'ARMember') . "
"; } else { move_uploaded_file($files['tmp_name'], $upload_dir . $file_name); $response = $upload_url . $file_name; echo "" . $upload_url . $file_name . "
"; } } /*else { echo "file type not allowed
"; }*/ } exit; } function arm_import_user() { $upload_dir = MEMBERSHIPLITE_UPLOAD_DIR.'/'; $upload_url = MEMBERSHIPLITE_UPLOAD_URL.'/'; $arm_allowed_mimes = $this->arm_allowed_wp_mime_types(); $file_name = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false); $response = ""; $userID = get_current_user_id(); if ($file_name && !empty($userID) && $userID != 0) { $checkext = explode(".", $file_name); $ext = strtolower( $checkext[count($checkext) - 1] ); $denyExts = array("php", "php3", "php4", "php5", "pl", "py", "jsp", "asp", "exe", "cgi"); if (!in_array($ext, $denyExts) && in_array($ext,$arm_allowed_mimes)) { file_put_contents($upload_dir . $file_name, file_get_contents('php://input')); $response = $upload_url . $file_name; echo $response; exit; } } echo $response; exit; } } } global $arm_members_activity; $arm_members_activity = new ARM_members_activity();