Esempio n. 1
0
 function get_loop_contacts_rcl($contacts, $days)
 {
     global $wpdb, $user_ID;
     $interval = $days * 24 * 3600;
     $sql_int = '';
     $contact_list = array();
     if ($days > 0) {
         $sql_int = "AND time_mess > (NOW() - INTERVAL {$interval} SECOND)";
     }
     if (!$contacts) {
         return '<h3>' . __('Contacts not found!', 'wp-recall') . '</h3>';
     }
     $rcl_action_users = $wpdb->get_results($wpdb->prepare("SELECT user,time_action FROM " . RCL_PREF . "user_action WHERE user IN (" . rcl_format_in($contacts) . ")", $contacts));
     if ($days >= 0) {
         $cntctslist = implode(',', $contacts);
         $su_list = $wpdb->get_results("\n\t\t\tSELECT author_mess,time_mess,adressat_mess,status_mess FROM (\n\t\t\tSELECT * FROM " . RCL_PREF . "private_message WHERE adressat_mess IN ({$cntctslist}) AND author_mess = '{$user_ID}' {$sql_int}\n\t\t\tOR author_mess IN ({$cntctslist}) AND adressat_mess = '{$user_ID}' {$sql_int} ORDER BY time_mess DESC\n\t\t\t) TBL GROUP BY author_mess,adressat_mess");
         if ($su_list) {
             foreach ((array) $su_list as $s) {
                 $list[] = (array) $s;
             }
             $list = rcl_multisort_array((array) $list, 'time_mess', SORT_ASC);
             foreach ((array) $list as $l) {
                 if ($l['author_mess'] != $user_ID) {
                     $s_contact = $l['author_mess'];
                 }
                 if ($l['adressat_mess'] != $user_ID) {
                     $s_contact = $l['adressat_mess'];
                 }
                 $contact_list[$s_contact]['time'] = $l['time_mess'];
                 $contact_list[$s_contact]['contact'] = $s_contact;
                 $contact_list[$s_contact]['status'] = $l['status_mess'];
             }
             $contact_list = rcl_multisort_array((array) $contact_list, 'time', SORT_DESC);
         } else {
             $contacts = false;
             $contacts = apply_filters('rcl_chat_contacts', $contacts);
             if ($contacts) {
                 foreach ($contacts as $c) {
                     $contact_list[]['contact'] = $c;
                 }
             }
         }
     } else {
         foreach ((array) $contacts as $c) {
             $contact_list[]['contact'] = $c;
         }
     }
     $name_users = $wpdb->get_results($wpdb->prepare("SELECT ID,display_name FROM {$wpdb->users} WHERE ID IN (" . rcl_format_in($contacts) . ")", $contacts));
     foreach ((array) $name_users as $name) {
         $names[$name->ID] = $name->display_name;
     }
     $privat_block = '';
     if ($contact_list) {
         foreach ($contact_list as $data) {
             if (!$names[$data['contact']]) {
                 continue;
             }
             foreach ((array) $rcl_action_users as $action) {
                 if ($action->user == $data['contact']) {
                     $time_action = $action->time_action;
                     break;
                 }
             }
             $last_action = rcl_get_useraction($time_action);
             $privat_block .= '<div class="single_correspond history-' . $data['contact'];
             if ($data['status'] == 0) {
                 $privat_block .= ' redline';
             }
             $privat_block .= '">';
             $privat_block .= '<div class="floatright">';
             if (!$last_action) {
                 $privat_block .= '<div class="status_author_mess online"><i class="fa fa-circle"></i></div>';
             } else {
                 $privat_block .= '<div class="status_author_mess offline"><i class="fa fa-circle"></i></div>';
             }
             $redirect_url = rcl_format_url(get_author_posts_url($data['contact']), 'privat');
             $privat_block .= '<span user_id="' . $data['contact'] . '" class="author-avatar"><a href="' . $redirect_url . '">' . get_avatar($data['contact'], 40) . '</a></span><a href="#" class="recall-button ';
             if ($days > 0) {
                 $privat_block .= 'del_history';
             } else {
                 $privat_block .= 'remove_black_list';
             }
             $privat_block .= '" data-contact="' . $data['contact'] . '"><i class="fa fa-remove"></i></a>
                         </div>
                         <p><a href="' . $redirect_url . '">' . $names[$data['contact']] . '</a>';
             if (isset($data['time'])) {
                 $privat_block .= '<br/><small>' . __('Last message', 'wp-recall') . ': ' . $data['time'] . '</small>';
             } else {
                 $privat_block .= '<br/><small>' . __('The chat history is missing', 'wp-recall') . '</small>';
             }
             $privat_block .= '</p></div>';
         }
     }
     if (!$privat_block) {
         $privat_block = '<h3>' . __('Contacts not found!', 'wp-recall') . '</h3>';
     }
     return $privat_block;
 }
Esempio n. 2
0
function rcl_upload_box()
{
    global $rcl_options, $user_ID;
    require_once ABSPATH . "wp-admin" . '/includes/image.php';
    require_once ABSPATH . "wp-admin" . '/includes/file.php';
    require_once ABSPATH . "wp-admin" . '/includes/media.php';
    if ($rcl_options['user_public_access_recall'] && !$user_ID) {
        return false;
    }
    $maxsize = isset($rcl_options['max_sizes_attachment']) && $rcl_options['max_sizes_attachment'] ? explode(',', $rcl_options['max_sizes_attachment']) : array(800, 600);
    $files = array();
    $valid_types = array("gif", "jpg", "png", "jpeg");
    if (isset($_POST['url_image'])) {
        $url_image = $_POST['url_image'];
        $filename = basename($url_image);
        if ($url_image) {
            $img = @file_get_contents($url_image);
            if ($img) {
                file_put_contents($dir_path . $filename, $img);
            } else {
                $res['error'] = "Загрузка изображения не удалась!";
                echo json_encode($res);
                exit;
            }
        }
        $files[] = array('tmp_name' => $dir_path . $filename, 'name' => $filename);
    } else {
        foreach ($_FILES['editor_upload'] as $key => $fls) {
            foreach ($fls as $k => $data) {
                $files[$k][$key] = $data;
            }
        }
        $files = rcl_multisort_array($files, 'name', SORT_ASC);
    }
    $user_dir = $user_ID ? $user_ID : $_COOKIE['PHPSESSID'];
    foreach ($files as $k => $file) {
        $image = getimagesize($file['tmp_name']);
        $mime = explode('/', $image['mime']);
        if (!in_array($mime[1], $valid_types)) {
            echo json_encode(array('error' => 'Недозволенное расширение файла. Используйте только: .gif, .png, .jpg'));
            exit;
        }
        $dir_path = RCL_UPLOAD_PATH . 'users-temp/';
        $dir_url = RCL_UPLOAD_URL . 'users-temp/';
        if (!is_dir($dir_path)) {
            mkdir($dir_path);
            chmod($dir_path, 0755);
        }
        $dir_path = RCL_UPLOAD_PATH . 'users-temp/' . $user_dir . '/';
        $dir_url = RCL_UPLOAD_URL . 'users-temp/' . $user_dir . '/';
        if (!is_dir($dir_path)) {
            mkdir($dir_path);
            chmod($dir_path, 0755);
        }
        $filename = str_replace(array('`', ']', '[', '\'', ' '), '', basename($file['name']));
        $filepath = $dir_path . $filename;
        $fileurl = $dir_url . $filename;
        //if(stripos($mime[1],'gif')===false){
        if ($image[0] > $maxsize[0] || $image[1] > $maxsize[1]) {
            rcl_crop($file['tmp_name'], $maxsize[0], $maxsize[1], $filepath);
        } else {
            if (copy($file['tmp_name'], $dir_path . $filename)) {
                unlink($file['tmp_name']);
            }
        }
        //$crop = 1;
        $html = '<img class="aligncenter" src=' . $fileurl . '>';
        /*}else{
        			$name = explode('.',$filename);
        			$thumb_name = $name[0].'-thumb.'.$name[1];
        			$crop->get_crop($file['tmp_name'],$image[0],$image[1],$dir_path.$thumb_name);
        			if(copy($file['tmp_name'], $dir_path.$filename)){
        				unlink($file['tmp_name']);
        			}
        			$thumb_url = $dir_url.$thumb_name;
        			$crop = 0;
        			$html = get_html_gif_image($thumb_url);
        		}*/
        //if($crop) $html .= '<input type="button" class="get-crop-image recall-button" value="Обрезать" onclick="return rcl_crop(this);"/>';
        $html .= '<input type="hidden" name="post_content[][image]" value="' . $fileurl . '"/>';
        $res[$k]['content'] = $html;
        //$res[$k]['crop'] = $crop;
    }
    echo json_encode($res);
    exit;
}