Example #1
0
    function thumbnails()
    {
        global $wpdb, $current_user;
        if (!is_user_logged_in()) {
            exit;
        }
        $back_image = '' . SP_CDM_PLUGIN_URL . 'images/my_projects_folder.png';
        $back_image = apply_filters('spcdm/files/images/back_button', $back_image);
        $folder_image = '' . SP_CDM_PLUGIN_URL . 'images/my_projects_folder.png';
        $folder_image = apply_filters('spcdm/files/images/folder_button', $folder_image);
        if (function_exists('cdmFindGroups')) {
            $find_groups = cdmFindGroups($_GET['uid'], 1);
        }
        $current_user_projects = sp_cdm_get_user_projects($_GET['uid']);
        if ($_REQUEST['search'] != "") {
            $search_project .= " AND " . $wpdb->prefix . "sp_cu_project.name LIKE '%" . $_REQUEST['search'] . "%' ";
        } else {
            if ($_GET['pid'] == '' or $_GET['pid'] == 'undefined') {
                $search_project .= " AND " . $wpdb->prefix . "sp_cu_project.parent = '0' ";
            } else {
                $search_project .= " AND " . $wpdb->prefix . "sp_cu_project.parent = '" . $_GET['pid'] . "' ";
            }
        }
        if (get_option('sp_cu_hide_project') == 1) {
            $r_projects_query = "SELECT " . $wpdb->prefix . "sp_cu.name,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.id,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.pid ,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.uid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.parent,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu_project.name AS project_name,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu_project.parent\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t \r\n\r\n\t\t\t\t\t\t\t\t\t\tFROM " . $wpdb->prefix . "sp_cu   \r\n\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $wpdb->prefix . "sp_cu_project  ON " . $wpdb->prefix . "sp_cu.pid = " . $wpdb->prefix . "sp_cu_project.id\r\n\r\n\t\t\t\t\t\t\t\t\t\tWHERE (" . $wpdb->prefix . "sp_cu.uid = '" . $_GET['uid'] . "'  " . $find_groups . ")\r\n\r\n\t\t\t\t\t\t\t\t\t\tAND pid != 0\r\n\r\n\t\t\t\t\t\t\t\t\t\tAND  " . $wpdb->prefix . "sp_cu.parent = 0 \r\n\r\n\t\t\t\t\t\t\t\t\t\t" . $sub_projects . "";
            if ($_GET['pid'] == 0 or $_GET['pid'] == '') {
                $r_projects_query = apply_filters('sp_cdm_projects_query', $r_projects_query, $_GET['uid']);
            }
            $r_projects_query .= "\t" . $search_project . "\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\tGROUP BY pid\r\n\r\n\t\t\t\t\t\t\t\t\t\tORDER by date desc";
            if (get_option('sp_cu_release_the_kraken') == 1) {
                unset($r_projects_query);
                $r_projects_query = "SELECT \t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.id,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.id AS pid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.uid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu_project.name AS project_name,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t  " . $wpdb->prefix . "sp_cu_project.parent\r\n\t\t\t\t\t\t\t\t\t\tFROM " . $wpdb->prefix . "sp_cu_project\r\n\t\t\t\t\t\t\t\t\t\tWHERE id != ''\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t" . $search_project . " ORDER by name\r\n";
            }
            $r_projects = $wpdb->get_results($r_projects_query, ARRAY_A);
        } else {
            $r_projects_groups_addon = apply_filters('sp_cdm_projects_query', $r_projects_groups_addon, $_GET['uid']);
            $search_project = apply_filters('sp_cdm_search_project_query', $search_project);
            //echo $r_projects_groups_addon ;
            if ($_GET['pid'] == 0 or $_GET['pid'] == '') {
                $user_query = " AND " . $wpdb->prefix . "sp_cu_project.uid = '" . $_GET['uid'] . "' ";
            }
            $r_projects_query = "SELECT \r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.id,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.id AS pid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.uid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu_project.name AS project_name,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t  " . $wpdb->prefix . "sp_cu_project.parent\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t \r\n\r\n\t\t\t\t\t\t\t\t\t\tFROM " . $wpdb->prefix . "sp_cu_project\r\n\r\n\t\t\t\t\t\t\t\t\t  WHERE (" . $wpdb->prefix . "sp_cu_project.id != '' " . $user_query . " " . $find_groups . " " . $r_projects_groups_addon . ")\t\t\t\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\t\t\t" . $search_project . "\r\n\r\n\t\t\t\t\t\t\t\t\t\t";
            $r_projects_query .= "\r\n\r\n\t\t\t\t\t\t\t\t\t\tORDER by name";
            $r_projects_query = apply_filters('sp_cdm_project_query_final', $r_projects_query);
            if (get_option('sp_cu_release_the_kraken') == 1) {
                unset($r_projects_query);
                $r_projects_query = "SELECT \t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.id,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.id AS pid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $wpdb->prefix . "sp_cu_project.uid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu_project.name AS project_name,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t  " . $wpdb->prefix . "sp_cu_project.parent\r\n\t\t\t\t\t\t\t\t\t\tFROM " . $wpdb->prefix . "sp_cu_project\r\n\t\t\t\t\t\t\t\t\t\tWHERE id != ''\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t" . $search_project . " ORDER by name\r\n";
            }
            $r_projects = $wpdb->get_results($r_projects_query, ARRAY_A);
        }
        if ($_GET['pid'] == 'drafts') {
            unset($r_projects);
        }
        echo '
		 <script type="text/javascript">
		 
		 jQuery( document ).ready(function() {
	
	jQuery(".cdm-hover-thumb").hover(function() {
			
		
			jQuery(this).before("<div  class=cdm-preview-image><img src=" + jQuery(this).attr("rel") + " ></div>");
		}, function () {
			jQuery(".cdm-preview-image").remove();
    });
  });
		 </script>
		 
		  <div id="dlg_cdm_thumbnails">';
        if ($_GET['pid'] == '') {
            $jscriptpid = "''";
        } else {
            $jscriptpid = "'" . $_GET['pid'] . "'";
        }
        echo '<div class="sp-cdm-r-head">';
        do_action('spdm_file_list_column_before_sort');
        echo '

	<div style="float:right">' . __("Sort by", "sp-cdm") . ': <a href="javascript:sp_cdm_sort(\'name\',' . $_GET['pid'] . ')">' . __("Name", "sp-cdm") . '</a>   <a href="javascript:sp_cdm_sort(\'date\',' . $_GET['pid'] . ')">' . __("Date", "sp-cdm") . '</a></div>

	
		

		';
        echo '

		
		</div>	

		

		';
        if ($_GET['pid'] != "0" && $_GET['pid'] != '' && (get_option('sp_cu_user_projects') == 1 and get_option('sp_cu_user_projects_modify') != 1 or current_user_can('manage_options'))) {
            $r_project_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "sp_cu_project where id = " . $_GET['pid'] . "", ARRAY_A);
            if ($r_project_info[0]['uid'] == $_GET['uid'] && get_option('sp_cu_user_delete_folders') != 1) {
                echo '<div style="padding-right:10px">';
                echo '<a href="javascript:sp_cu_dialog(\'#edit_category_' . $_GET['pid'] . '\',550,130)"><img src="' . SP_CDM_PLUGIN_URL . 'images/application_edit.png"> ' . __("Edit Folder Name", "sp-cdm") . '</a>';
                echo '<a href="javascript:sp_cu_remove_project()" style="margin-left:20px"> <img src="' . SP_CDM_PLUGIN_URL . 'images/delete_small.png">  ' . __("Remove Folder", "sp-cdm") . ' </a>';
                do_action('cdm/ajax/folder/navigation', $_GET['pid']);
                echo '<div style="display:none">	

		

		

		<script type="text/javascript">

		

			

function sp_cu_edit_project(){

	

	

	

	if(jQuery("#edit_project_name_' . $_GET['pid'] . '").val() == ""){

		

		alert("Please enter a project name");

	}else{

	jQuery.ajax({

   type: "POST",

   url: "' . SP_CDM_PLUGIN_URL . 'ajax.php?function=save-category",

   data: "name=" + jQuery("#edit_project_name_' . $_GET['pid'] . '").val() + "&id=" +  jQuery("#edit_project_id_' . $_GET['pid'] . '").val(),

   success: function(msg){

   jQuery("#cmd_file_thumbs").load("' . SP_CDM_PLUGIN_URL . 'ajax.php?function=file-list&uid=' . $_GET['uid'] . '&pid=' . $_GET['pid'] . '");

   jQuery("#edit_category").dialog("close");

   alert(msg);	

  

   }

 });

	}

}



function sp_cu_remove_project(){

	

	jQuery( "#delete_category_' . $_GET['pid'] . '" ).dialog({

			resizable: false,

			height:240,

			width:440,

			modal: true,

			buttons: {

				"Delete all items": function() {

						

							

						jQuery.ajax({

					   type: "POST",

					   url: "' . SP_CDM_PLUGIN_URL . 'ajax.php?function=remove-category",

					   data: "id=' . $_GET['pid'] . '" ,

					   success: function(msg){

					   
					   
					   jQuery.removeCookie("pid");
						
					  cdm_ajax_search();


					 

					 

					  

					   }

					 });

					 

					jQuery( this ).dialog( "close" );	

						

				},

				Cancel: function() {

					jQuery( this ).dialog( "close" );

				}

			}

		});

	

	

	



	

}



		</script>	

		<div id="delete_category_' . $_GET['pid'] . '" title="' . __("Delete Category?", "sp-cdm") . '">

	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>' . __("Are you sure you would like to delete this category? Doing so will remove all files related to this category.", "sp-cdm") . '</p>

		</div>



		

		

				<div id="edit_category_' . $_GET['pid'] . '">			

			

			<input type="hidden"  name="edit_project_id" id="edit_project_id_' . $_GET['pid'] . '" value="' . $_GET['pid'] . '">		

			' . sp_cdm_folder_name() . ' ' . __("Name", "sp-cdm") . ': <input value="' . stripslashes($r_project_info[0]['name']) . '" id="edit_project_name_' . $_GET['pid'] . '" type="text" name="name"  style="width:200px !important"> 

			<input type="submit" value="' . __("Save", "sp-cdm") . ' ' . sp_cdm_folder_name() . '" onclick="sp_cu_edit_project()">

			

			</div>

			

		

		

		</div>

		

		


		

		';
            }
        }
        echo '				<div class="sp_isotope_filter">';
        do_action('spdm_file_responsive_top', $_GET['pid']);
        if ($_GET['pid'] != 0) {
            $query_project = $wpdb->get_results("SELECT *\r\n\r\n\t\r\n\r\n\t\t\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\t\t FROM " . $wpdb->prefix . "sp_cu_project\r\n\r\n\t\t\t\t\t\t\t\t\tWHERE  id = '" . $_GET['pid'] . "'\r\n\r\n\t\t\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\t\t ", ARRAY_A);
            do_action('spdm_file_list_column_before_folder_back');
            echo '

				<div class="dlg_cdm_thumbnail_folder">

				<a href="javascript:sp_cdm_load_project(' . $query_project[0]['parent'] . ')"><img src="' . $back_image . '">

				<div class="dlg_cdm_thumb_title">

				&laquo; ' . __("Go Back", "sp-cdm") . '

				</div>

				</a>

				</div>

		

			

		

		';
        }
        $r_projects = apply_filters('sp_cdm_project_array_filter', $r_projects);
        if (count($r_projects) > 0) {
            for ($i = 0; $i < count($r_projects); $i++) {
                if ($r_projects[$i]['project_name'] != "" && in_array($r_projects[$i]['pid'], $current_user_projects) or get_option('sp_cu_release_the_kraken') == 1) {
                    echo '

		<div class="dlg_cdm_thumbnail_folder">

				<a href="javascript:sp_cdm_load_project(' . $r_projects[$i]['pid'] . ')"><img src="' . $folder_image . '">

				<div class="dlg_cdm_thumb_title">

				' . stripslashes($r_projects[$i]['project_name']) . '

				</div>

				</a>';
                    do_action('spdm_file_thumbs_column_before_folder', $r_projects[$i]['pid']);
                    echo '

				</div>

		

		';
                }
            }
        }
        if ($_GET['sort'] == '') {
            $sort = spdm_ajax::order_by();
        } else {
            $sort = $_GET['sort'];
        }
        if ($_GET['pid'] == "" or $_GET['pid'] == "0" or $_GET['pid'] == "undefined" or $_GET['pid'] == "null") {
            if ($_REQUEST['search'] != "") {
                $search_file .= " AND (name LIKE '%" . $_REQUEST['search'] . "%' or  tags LIKE '%" . $_REQUEST['search'] . "%')  ";
                $r_projects_groups_addon_search = str_replace("wp_sp_cu_project.id", "pid", $r_projects_groups_addon);
            } else {
                $search_file .= " AND pid = 0  AND parent = 0  ";
            }
            $search_file = apply_filters("sp_cdm_file_search_query", $search_file, $_GET['pid']);
            $query = "SELECT *  FROM " . $wpdb->prefix . "sp_cu   where (uid = '" . $_GET['uid'] . "' " . $r_projects_groups_addon_search . ")  \t " . $search_file . " order by " . $sort . " ";
            $query = apply_filters('sp_cdm_query_string', $query);
            $r = $wpdb->get_results($query, ARRAY_A);
        } else {
            $search_file .= " where (pid = '" . $_GET['pid'] . "')";
            if ($_REQUEST['search'] != "") {
                $search_file .= " AND (name LIKE '%" . $_REQUEST['search'] . "%' or  tags LIKE '%" . $_REQUEST['search'] . "%')  ";
            } else {
                $search_file .= "  AND parent = 0   ";
            }
            $search_file = apply_filters("sp_cdm_file_search_query", $search_file, $_GET['pid']);
            $query = "SELECT *  FROM " . $wpdb->prefix . "sp_cu   " . $search_file . "  order by " . $sort . "  ";
            $query = apply_filters("sp_cdm_file_main_responsive_query", $query, $_GET['pid']);
            $r = $wpdb->get_results($query, ARRAY_A);
        }
        if (get_option('sp_cu_release_the_kraken') == 1) {
            unset($r);
            unset($search_file);
            if ($_GET['pid'] == '') {
                $_GET['pid'] = 0;
            }
            if ($_GET['pid'] == "" or $_GET['pid'] == "0" or $_GET['pid'] == "undefined" or $_GET['pid'] == "null") {
                $search_file .= " AND (pid = '0') ";
            } else {
                $search_file .= " AND (pid = '" . $_GET['pid'] . "') ";
            }
            $search_file = apply_filters("sp_cdm_file_search_query", $search_file, $_GET['pid']);
            if ($_REQUEST['search'] != "") {
                unset($search_file);
                $search_file .= " AND (name LIKE '%" . $_REQUEST['search'] . "%' or  tags LIKE '%" . $_REQUEST['search'] . "%')  ";
            }
            $query = "SELECT *  FROM " . $wpdb->prefix . "sp_cu  where id != ''   " . $search_file . "  order by " . $sort . "  ";
            $r = $wpdb->get_results($query, ARRAY_A);
        }
        if ($_REQUEST['search'] == "") {
            $r = apply_filters('sp_cdm_file_loop_array', $r, $_GET['pid']);
        }
        for ($i = 0; $i < count($r); $i++) {
            $ext = preg_replace('/^.*\\./', '', $r[$i]['file']);
            $images_arr = array("jpg", "png", "jpeg", "gif", "bmp");
            if (get_option('sp_cu_user_projects_thumbs_pdf') == 1 && class_exists('imagick')) {
                $info = new Imagick();
                $formats = $info->queryFormats();
            } else {
                $formats = array();
            }
            if (in_array(strtolower($ext), $images_arr)) {
                if (get_option('sp_cu_overide_upload_path') != '' && get_option('sp_cu_overide_upload_url') == '') {
                    $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/package_labled.png">';
                } else {
                    $img = '<img src="' . sp_cdm_thumbnail('' . SP_CDM_UPLOADS_DIR_URL . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '', NULL, 70) . '">';
                }
            } elseif (in_array($ext, array('mp4', 'ogg', 'webm', 'avi', 'mpg', 'mpeg', 'mkv'))) {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/video.png" >';
            } elseif ($ext == 'xls' or $ext == 'xlsx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_excel.png">';
            } elseif ($ext == 'doc' or $ext == 'docx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_word.png">';
            } elseif ($ext == 'pub' or $ext == 'pubx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_publisher.png">';
            } elseif ($ext == 'ppt' or $ext == 'pptx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_powerpoint.png">';
            } elseif ($ext == 'adb' or $ext == 'accdb') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_access.png">';
            } elseif (in_array(strtoupper($ext), $formats)) {
                if (file_exists('' . SP_CDM_UPLOADS_DIR . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '_small.png')) {
                    $img = '<img src="' . sp_cdm_thumbnail('' . SP_CDM_UPLOADS_DIR_URL . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '_small.png', NULL, 70) . '">';
                } else {
                    $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';
                }
            } elseif ($ext == 'pdf') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';
            } else {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/package_labled.png">';
            }
            if ($_REQUEST['search'] != "" && sp_cdm_get_project_name($r[$i]['pid']) != false) {
                $project_name = ' <br><em>(' . sp_cdm_folder_name() . ': ' . sp_cdm_get_project_name($r[$i]['pid']) . ')</em> ';
            } else {
                $project_name = '';
            }
            $img = apply_filters('sp_cdm_viewfile_image', $img, $r[$i]);
            $ext = preg_replace('/^.*\\./', '', $r[$i]['file']);
            $r_cat = $wpdb->get_results("SELECT name  FROM " . $wpdb->prefix . "sp_cu_cats   where id = '" . $r[$i]['cid'] . "' ", ARRAY_A);
            if ($r_cat[0]['name'] == '') {
                $cat = stripslashes($r_cat[0]['name']);
            } else {
                $cat = '';
            }
            if ($_REQUEST['search'] != "" && sp_cdm_get_project_name($r[$i]['pid']) != false) {
                $project_name = ' <em>(' . sp_cdm_folder_name() . ': ' . sp_cdm_get_project_name($r[$i]['pid']) . ')</em> ';
            } else {
                $project_name = '';
            }
            if (get_option('sp_cu_file_direct_access') == 1) {
                $file_link = 'window.open(\'' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[$i]['id'] . '|' . $r[$i]['date'] . '|' . $r[$i]['file']) . '\'); void(0)';
            } else {
                $file_link = 'cdmViewFile(' . $r[$i]['id'] . ')';
            }
            if (in_array($r[$i]['pid'], $current_user_projects) or $r[$i]['pid'] == 0 or get_option('sp_cu_release_the_kraken') == 1) {
                $file_link = apply_filters('spcdm/file_list/link', $file_link, $r[$i]);
                echo '<div class="dlg_cdm_thumbnail_folder">

			<div class="dlg_cdm_thumbnail_image">

				<a href="javascript:' . $file_link . '" ><div class="cdm_img_container">' . $img . '</div>

				<div class="dlg_cdm_thumb_title">

				' . stripslashes($r[$i]['name']) . '' . $project_name . '

				</div>

				</a>

				</div>';
                do_action('spdm_file_thumbs_column_before_file', $r[$i]['id']);
                echo '

				</div>';
            }
        }
        echo '<div style="clear:both"></div></div></div>';
    }
        function sp_client_upload_admin()
        {
            global $wpdb;
            $html = '';
            $user_id = @$_REQUEST['user_id'];
            if (@$_GET['dlg-delete-file'] != "") {
                $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where  id = " . $_GET['dlg-delete-file'] . "", ARRAY_A);
                @unlink('' . SP_CDM_UPLOADS_DIR . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '');
                $wpdb->query("\r\n\r\n\tDELETE FROM " . $wpdb->prefix . "sp_cu WHERE id = " . $_GET['dlg-delete-file'] . "\r\n\r\n\t");
            }
            if ($user_id != "") {
                echo '<h2>' . __("User Uploads", "sp-cdm") . '</h2><a name="downloads"></a>';
                $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where uid = {$user_id}  and parent = 0 order by date desc", ARRAY_A);
                $delete_page = 'user-edit.php?user_id=' . $user_id . '';
                $download_user = '******' . SP_CDM_PLUGIN_URL . 'ajax.php?function=download-archive&id=' . $user_id . '" class="button">' . __("Click to download all files", "sp-cdm") . '</a>';
            } else {
                $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where  parent = 0 order by id desc LIMIT 150", ARRAY_A);
                $html .= '<form id="your-profile">';
                $delete_page = 'admin.php?page=sp-client-document-manager';
                $download_user = '';
            }
            if ($r == FALSE) {
                $html .= '<p style="color:red">' . __("No Uploads Exist!", "sp-cdm") . '</p>';
            } else {
                //show uploaded documents
                $html .= '

<script type="text/javascript">



function sp_client_upload_email_vendor(){

	



    	jQuery.ajax({

			 

		  type: "POST",

		  url:  "' . SP_CDM_PLUGIN_URL . 'ajax.php?function=email-vendor" ,

		 

		 data:  jQuery("#your-profile" ).serialize(),

		  success: function(msg){

   								jQuery("#updateme").empty();

								jQuery("#updateme").append( msg);

								

							  }

 		});	

	

	return false;

}



function sp_cdm_showFile(file){

			

		  var url = "' . SP_CDM_PLUGIN_URL . 'ajax.php?function=view-file&id=" + file;

		  

		 

            // show a spinner or something via css

            var dialog = jQuery(\'<div style="display:none" class="loading viewFileDialog"></div>\').appendTo(\'body\');

          

		  



     var fileArray = new Array();      

	 var obj_file_info =   jQuery.getJSON("' . SP_CDM_PLUGIN_URL . 'ajax.php?function=get-file-info&type=name&id=" + file, function(data) {

   



	

		

  	fileArray[name] =data.name;

	var final_title = fileArray[name];

       });

		 



		 

		 var final_title = fileArray[name];

		

		      dialog.dialog({

               

                close: function(event, ui) {

                    // remove div with all data and events

                    dialog.remove();

                },

                modal: true,

				height:"auto",

				width:850,

				title: final_title 

            });

			

			 // load remote content

            dialog.load(

                url, 

                {}, // omit this param object to issue a GET request instead a POST request, otherwise you may provide post parameters within the object

                function (responseText, textStatus, XMLHttpRequest) {

                    // remove the loading class

                    dialog.removeClass(\'loading\');

                }

            );

			

			

		



		}

</script>

' . $download_user . '

  <table class="wp-list-table widefat fixed posts" cellspacing="0">

	<thead>

	<tr>

	<th style="width:30px">' . __("ID", "sp-cdm") . '</th>	

<th style="width:80px">' . __("Thumbnail", "sp-cdm") . '</th>	

<th>' . __("File Name", "sp-cdm") . '</th>

<th>' . __("User", "sp-cdm") . '</th>

<th>' . __("Date", "sp-cdm") . '</th>

<th>' . __("Download", "sp-cdm") . '</th>

<th>' . __("Email", "sp-cdm") . '</th>

</tr>

	</thead>





';
                for ($i = 0; $i < count($r); $i++) {
                    if ($r[$i]['name'] == "") {
                        $name = $r[$i]['file'];
                    } else {
                        $name = $r[$i]['name'];
                    }
                    $r_user = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "users where ID = " . $r[$i]['uid'] . "", ARRAY_A);
                    if (get_option('sp_cu_js_redirect') == 1) {
                        $target = 'target="_blank"';
                    } else {
                        $target = ' ';
                    }
                    $ext = preg_replace('/^.*\\./', '', $r[$i]['file']);
                    $images_arr = array("jpg", "png", "jpeg", "gif", "bmp");
                    if (in_array(strtolower($ext), $images_arr)) {
                        if (get_option('sp_cu_overide_upload_path') != '' && get_option('sp_cu_overide_upload_url') == '') {
                            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/package_labled.png">';
                        } else {
                            $img = '<img src="' . sp_cdm_thumbnail('' . SP_CDM_UPLOADS_DIR_URL . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '', 80, 80) . '">';
                        }
                    } elseif ($ext == 'xls' or $ext == 'xlsx') {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_excel.png">';
                    } elseif ($ext == 'doc' or $ext == 'docx') {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_word.png">';
                    } elseif ($ext == 'pub' or $ext == 'pubx') {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_publisher.png">';
                    } elseif ($ext == 'ppt' or $ext == 'pptx') {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_powerpoint.png">';
                    } elseif ($ext == 'adb' or $ext == 'accdb') {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_access.png">';
                    } elseif (($ext == 'pdf' or $ext == 'psd' or $ext == 'html' or $ext == 'eps') && get_option('sp_cu_user_projects_thumbs_pdf') == 1) {
                        if (file_exists('' . SP_CDM_UPLOADS_DIR . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '_small.png')) {
                            $img = '<img src="' . SP_CDM_UPLOADS_DIR_URL . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '_small.png">';
                        } else {
                            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';
                        }
                    } elseif ($ext == 'pdf') {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';
                    } else {
                        $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/package_labled.png">';
                    }
                    $img = apply_filters('sp_cdm_viewfile_image', $img, $r[$i]);
                    $html .= '

	

 <tr>

 <td>' . $r[$i]['id'] . '</td>

 <td>' . $img . '</td>

    <td ><strong>' . stripslashes($name) . '</strong>';
                    if (@CU_PREMIUM == 1) {
                        $html .= sp_cdm_get_form_fields($r[$i]['id']);
                    } else {
                        $html .= '<br><em>' . __("Notes: ", "sp-cdm") . ' ' . stripslashes($r[$i]['notes']) . '</em>';
                    }
                    if ($r[$i]['tags'] != "") {
                        $html .= '<br><strong>' . __("Tags ", "sp-cdm") . '</strong><em>: ' . $r[$i]['tags'] . '</em>';
                    }
                    $html .= '

	

	

	</td>

	<td><a href="user-edit.php?user_id=' . $r[$i]['uid'] . '">' . $r_user[0]['display_name'] . '</a></td>

	 <td >' . date('F jS Y h:i A', strtotime($r[$i]['date'])) . '</td>

   

    <td><a style="margin-right:15px" href="javascript:cdmViewFile(' . $r[$i]['id'] . ')" >' . __("View", "sp-cdm") . '</a> <a href="' . $delete_page . '&dlg-delete-file=' . $r[$i]['id'] . '#downloads">' . __("Delete", "sp-cdm") . '</a> </td>

<td><input type="checkbox" name="vendor_email[]" value="' . $r[$i]['id'] . '"></td>	</tr>





  

  ';
                }
                $html .= '</table>

			

				<div style="text-align:right">

			<div id="updateme"></div>

				' . __("Choose  the files you want to send above, type a message and choose a vendor then click submit:", "sp-cdm") . '  <select name="vendor">

				';
                if ($_POST['submit-vendor'] != "") {
                    //	print_r($_POST);
                }
                $vendors = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "options   where option_name  LIKE 'sp_client_upload_vendors%'  order by option_name", ARRAY_A);
                for ($i = 0; $i < count($vendors); $i++) {
                    $vendor_info[$i] = unserialize($vendors[$i]['option_value']);
                    $html .= '<option value="' . $vendor_info[$i]['email'] . '">' . $vendor_info[$i]['name'] . '</option>';
                }
                $html .= '</select> ' . __("Message:", "sp-cdm") . ' <input type="text" name="vendor-message"> <select name="vendor_attach"><option value="1">' . __("Attach to email:", "sp-cdm") . ' </option><option value="0">' . __("Send links to files", "sp-cdm") . ' </option><option value="3">' . __("Attach and link to to files", "sp-cdm") . ' </option></select> <input type="submit" name="submit-vendor" value="' . __("Email vendor files!", "sp-cdm") . '" onclick="sp_client_upload_email_vendor();return false;"> 

				</div>

				';
            }
            if ($user_id != "") {
                echo $html;
            } else {
                $html .= '</form>';
                return $html;
            }
        }
Example #3
0
		

		';
            }
        }
        if ($_GET['pid'] == "" or $_GET['pid'] == "") {
            $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where (uid = '" . $_GET['uid'] . "' " . $find_groups . ")  AND pid = 0 \tAND parent = 0  " . $search_file . " order by date desc", ARRAY_A);
        } else {
            $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where pid = '" . $_GET['pid'] . "' AND parent = 0   " . $search_file . "  order by date desc", ARRAY_A);
        }
        for ($i = 0; $i < count($r); $i++) {
            $ext = preg_replace('/^.*\\./', '', $r[$i]['file']);
            $images_arr = array("jpg", "png", "jpeg", "gif", "bmp");
            if (in_array(strtolower($ext), $images_arr)) {
                $img = '<img src="' . sp_cdm_thumbnail('' . SP_CDM_UPLOADS_DIR_URL . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '', 80, 80) . '">';
            } elseif ($ext == 'xls' or $ext == 'xlsx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_excel.png">';
            } elseif ($ext == 'doc' or $ext == 'docx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_word.png">';
            } elseif ($ext == 'pub' or $ext == 'pubx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_publisher.png">';
            } elseif ($ext == 'ppt' or $ext == 'pptx') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_powerpoint.png">';
            } elseif ($ext == 'adb' or $ext == 'accdb') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_access.png">';
            } elseif (($ext == 'pdf' or $ext == 'psd' or $ext == 'html' or $ext == 'eps') && get_option('sp_cu_user_projects_thumbs_pdf') == 1) {
                if (file_exists('' . SP_CDM_UPLOADS_DIR . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '_small.png')) {
                    $img = '<img src="' . SP_CDM_UPLOADS_DIR_URL . '' . $r[$i]['uid'] . '/' . $r[$i]['file'] . '_small.png">';
                } else {
                    $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';