예제 #1
0
 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;
 }
예제 #2
0
function sp_cdm_short_link($id)
{
    global $wpdb;
    $url = sp_cdm_file_link($id);
    $longUrl = $url;
    $apiKey = get_option('sp_cu_google_api_key');
    $postData = array('longUrl' => $longUrl, 'key' => $apiKey);
    $jsonData = json_encode($postData);
    $curlObj = curl_init();
    curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
    curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curlObj, CURLOPT_HEADER, 0);
    curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
    curl_setopt($curlObj, CURLOPT_POST, 1);
    curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
    $response = curl_exec($curlObj);
    $json = json_decode($response);
    curl_close($curlObj);
    return $json->id;
}