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; } }
function view_file() { global $wpdb, $current_user, $cdm_comments, $cdm_google, $cdm_log; if (!is_user_logged_in()) { exit; } $file_types = array(); $r = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "sp_cu where id = %d order by date desc", $_GET['id']), ARRAY_A); $ext = substr(strrchr($r[0]['file'], '.'), 1); $stream_file_types = get_option('sp_cu_stream_file_types'); if ($stream_file_types != '') { $file_types = explode(",", $stream_file_types); } $html .= '<div id="view_file_refresh"> '; $html .= '<div class="sp_cu_manage">'; $html = apply_filters('sp_cdm_view_file_first_add_button', $html, $r); if (CU_PREMIUM == 1 && get_option('sp_cu_user_uploads_disable') != 1 && get_option('sp_cu_user_disable_revisions') != 1 && cdm_file_permissions($r[0]['pid']) == 1) { if ($r[0]['form_id'] == '' or $r[0]['form_id'] == 0) { $revision_button = sp_cdm_revision_button(); $html .= apply_filters('sp_cdm_viewfile_revision_button', $revision_button, $r); } } if (class_exists('cdmProductivityUser')) { $html .= '<span id="cdm_comment_button_holder">' . $cdm_comments->button() . '</span>'; } $html = apply_filters('sp_cdm_view_file_add_button', $html, $r); if (class_exists('cdmProductivityGoogle')) { $shortlink_button = '<span id="cdm_shortlink_button_holder">' . $cdm_google->short_link_button($r[0]['id'], '' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '') . '</span>'; $html .= apply_filters('sp_cdm_viewfile_shortlink_button', $shortlink_button, $r); } if (get_option('sp_cu_js_redirect') == 1 or in_array($ext, $file_types)) { $target = 'target="_blank"'; } else { $target = ' '; } $download_url = '<a ' . $target . ' href="' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '" title="Download" style="margin-right:15px" ><img src="' . SP_CDM_PLUGIN_URL . 'images/download.png"> ' . __("Download File", "sp-cdm") . '</a> '; $html .= apply_filters('sp_cdm_viewfile_download_url', $download_url, $r); if (cdm_user_can_delete($current_user->ID) == true && cdm_delete_permission($r[0]['pid']) == 1) { $delete_button = ' <a href="javascript:sp_cu_confirm_delete(\'' . get_option('sp_cu_delete') . '\',200,\'' . SP_CDM_PLUGIN_URL . 'ajax.php?function=delete-file&dlg-delete-file=' . $r[0]['id'] . '\');" title="Delete" ><img src="' . SP_CDM_PLUGIN_URL . 'images/delete.png">' . __("Delete File", "sp-cdm") . '</a>'; $html .= apply_filters('sp_cdm_viewfile_delete_button', $delete_button, $r); } $html .= ' <div style="clear:both"></div> <em>' . date('F jS Y h:i A', strtotime($r[0]['date'])) . ' • File ID: #' . $r[0]['id'] . '</em> </div>'; $html .= ' <script type="text/javascript"> jQuery(".viewFileTabs").responsiveTabs({ startCollapsed: false }); </script>'; $html = apply_filters('cdm/viewfile/under_date', $html, $r); $html .= '<div class="viewFileTabs"> <ul> <li><a href="#cdm-file-main">' . __("File Info", "sp-cdm") . '</a></li>'; $html = apply_filters('sp_cdm_view_file_after_file_info_tab', $html, $r); if (function_exists('sp_cdm_revision_add') && get_option('sp_cu_user_disable_revisions') != 1) { if ($r[0]['form_id'] == '' or $r[0]['form_id'] == 0) { $html .= '<li><a href="#cdm-file-revisions">' . __("Revisions", "sp-cdm") . '</a></li>'; } } if (class_exists('cdmProductivityUser')) { $html .= '<li><a href="#cdm-file-comments">' . __("Comments", "sp-cdm") . '</a></li>'; } if (class_exists('cdmProductivityLog')) { if (get_option('sp_cu_log_admin_only') == 1 && current_user_can('manage_options') or (get_option('sp_cu_log_admin_only') == 0 or get_option('sp_cu_log_admin_only') == '')) { $html .= '<li><a href="#cdm-file-log">' . __("Download Log", "sp-cdm") . '</a></li>'; } } $html = apply_filters('sp_cdm_view_file_tab', $html, $r); $html .= '</ul> '; $html = apply_filters('sp_cdm_view_file_content', $html, $r); if (function_exists('sp_cdm_revision_add') && get_option('sp_cu_user_disable_revisions') != 1) { if ($r[0]['form_id'] == '' or $r[0]['form_id'] == 0) { $html .= '<div id="cdm-file-revisions"><div id="cdm_comments"><h4>' . __("Revision History", "sp-cdm") . '</h4> ' . sp_cdm_file_history($r[0]['id']) . '</div></div>'; } } if (class_exists('cdmProductivityUser')) { $html .= '<div id="cdm-file-comments"><div id="cdm_comments_container">' . $cdm_comments->view($r[0]['id']) . '</div></div>'; } if (class_exists('cdmProductivityLog')) { $html .= '<div id="cdm-file-log">' . $cdm_log->view($r[0]['id']) . '</div>'; } $html .= '<div id="cdm-file-main">'; if (get_option('sp_cu_wp_folder') == '') { $wp_con_folder = '/'; } else { $wp_con_folder = get_option('sp_cu_wp_folder'); } //print_r($r); $ext = substr(strrchr($r[0]['file'], '.'), 1); if ($r[0]['pid'] != 0) { $projecter = $wpdb->get_results("SELECT *\r\n\r\n\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\t WHERE id = '" . $r[0]['pid'] . "'\r\n\r\n\t\t\t\t\t\t\t\t\t ", ARRAY_A); $project_title = '' . stripslashes($projecter[0]['name']) . ''; } else { $project_title = '' . __("None", "sp-cdm") . ''; } if ($ext == 'png' or $ext == 'jpg' or $ext = 'jpeg' or $ext = 'gif') { $icon = '<td width="160"><img src="' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '" width="150"></td>'; } else { $icon = ''; } $ext = preg_replace('/^.*\\./', '', $r[0]['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[0]['uid'] . '/' . $r[0]['file'] . '', 250) . '">'; } } 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[0]['uid'] . '/' . $r[0]['file'] . '_big.png')) { $img = '<img src="' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '_big.png" width="250">'; } else { $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">'; } } elseif ($ext == 'pdf' or $ext == 'xod') { $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[0]); $file_info .= ' <div id="sp_cu_viewfile"> <div class="sp_cu_item"> <div class="cdm-two-column"><div class="l-column">'; $info_left_column .= ' <a ' . $target . ' href="' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '" title="Download" style="margin-right:15px" > ' . $img . ' </a> '; $info_left_column = apply_filters('sp_cdm_viewfile_replace_file_info', $info_left_column, $r); $file_info .= $info_left_column; $file_info .= '</div><div class="r-column">'; $info_right_column .= '<div class="sp_su_project"> <strong>' . __("File Name", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['name']) . '<br> </div> <div class="sp_su_project"> <strong>' . sp_cdm_folder_name() . ': </strong>' . $project_title . ' </div> <div class="sp_su_project"> <strong>' . __("File Type ", "sp-cdm") . ': </strong>' . $ext . ' </div> <div class="sp_su_project"> <strong>' . __("File Size ", "sp-cdm") . ': </strong>' . cdm_file_size('' . SP_CDM_UPLOADS_DIR . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '') . ' </div> '; $extra_file_info = ''; $info_right_column .= apply_filters('sp_cdm_file_view_info', $extra_file_info, $r[0]); if (CU_PREMIUM == 1) { if ($r[0]['cid'] != '' && $r[0]['cid'] != 0) { } } if ($r[0]['tags'] != "") { $info_right_column .= ' <div class="sp_su_notes"> <strong>' . __("Tags ", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['tags']) . ' </div>'; } if ($r[0]['notes'] != "") { $info_right_column .= ' <div class="sp_su_notes"> <strong>' . __("Notes ", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['notes']) . ' </div>'; } if (CU_PREMIUM == 1) { if (sp_cdm_get_form_fields($r[0]['id']) != '') { $info_right_column .= ' <div class="sp_su_notes"> ' . sp_cdm_get_form_fields($r[0]['id']) . ' </div>'; } } else { if ($r[0]['notes'] != "") { $info_right_column .= ' <div class="sp_su_notes"> <strong>' . __("Notes: ", "sp-cdm") . ':</strong> <em>' . stripslashes($r[0]['notes']) . '</em> </div>'; } } $info_right_column = apply_filters('sp_cdm_view_file_notes', $info_right_column, $r); $file_info .= $info_right_column; $file_info .= ' </div><div style="clear:both"></div> </div></div>'; $file_info = apply_filters('sp_cdm_viewfile_replace_file_infos', $file_info, $r, $info_left_column, $info_right_column); $html .= $file_info; $html .= '</div></div> </div> </div> '; $html = apply_filters('sp_cdm_viewfile', $html, $r); return $html; }
function sp_cu_process_email($id, $email) { global $wpdb; $r = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "sp_cu where id = '" . $id . "' order by date desc", ARRAY_A); if ($r[0]['pid'] != "") { $r_project = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "sp_cu_project where id = " . $r[0]['pid'] . "", ARRAY_A); } if ($r[0]['cid'] != "") { $r_cats = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "sp_cu_cats where id = " . $r[0]['cid'] . "", ARRAY_A); } if (@CU_PREMIUM == 1) { $notes = stripslashes(sp_cdm_get_form_fields($r[0]['id'])); } else { $notes = stripslashes($r[0]['notes']); } $user_info = get_userdata($r[0]['uid']); $message = nl2br($email); $message = apply_filters('sp_cdm_shortcode_email_before', $message, $r, $r_project, $r_cats); $message = str_replace('[file]', '<a href="' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '">' . $r[0]['file'] . '</a>', $message); $message = str_replace('[file_directory]', sp_cdm_folder_link($r[0]['pid']), $message); $message = str_replace('[file_directory_shortlink]', sp_cdm_short_url(sp_cdm_folder_link($r[0]['pid'])), $message); $message = str_replace('[file_name]', $r[0]['file'], $message); $message = str_replace('[file_real_path]', '' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '', $message); $message = str_replace('[file_in_document_area]', '<a href="' . sp_cdm_file_link($id) . '">' . __("View File", "sp-cdm") . '</a>', $message); $message = str_replace('[file_shortlink]', sp_cdm_short_link($id), $message); $message = str_replace('[notes]', $notes, $message); $message = str_replace('[user]', $user_info->display_name, $message); $message = str_replace('[uid]', $user_info->ID, $message); $message = str_replace('[project]', stripslashes($r_project[0]['name']), $message); $message = str_replace('[category]', stripslashes($r_cats[0]['name']), $message); $message = str_replace('[user_profile]', '<a href="' . admin_url('user-edit.php?user_id=' . $r[0]['uid'] . '') . '">' . admin_url('user-edit.php?user_id=' . $r[0]['uid'] . '') . '</a>', $message); $message = str_replace('[client_documents]', '<a href="' . admin_url('admin.php?page=sp-client-document-manager') . '">' . admin_url('admin.php?page=sp-client-document-manager') . '</a>', $message); $message = apply_filters('sp_cdm_shortcode_email_after', $message, $r, $r_project, $r_cats); return $message; }
</div>'; if ($r[0]['tags'] != "") { $html .= ' <div class="sp_su_notes"> <strong>' . __("Tags ", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['tags']) . ' </div>'; } if (CU_PREMIUM == 1) { $html .= ' <div class="sp_su_notes"> ' . sp_cdm_get_form_fields($r[0]['id']) . ' </div>'; } else { if ($r[0]['notes'] != "") { $html .= ' <div class="sp_su_notes"> <strong>' . __("Notes: ", "sp-cdm") . ':</strong> <em>' . stripslashes($r[0]['notes']) . '</em> </div>'; } } $html .= '