Plugin Directory

Changeset 3176965


Ignore:
Timestamp:
10/28/2024 11:40:22 AM (17 months ago)
Author:
seuroficial
Message:

v2.2.14

Location:
seur/trunk
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • seur/trunk/classes/PDFGenerator.php

    r3120329 r3176965  
    260260
    261261        $seed .= uniqid('', true);
    262         $seed .= mt_rand(0, mt_getrandmax());
     262        $seed .= wp_rand(0, mt_getrandmax());
    263263        $seed .= __FILE__;
    264264        $seed .= $this->bufferlen;
    265265
    266266        if (isset($_SERVER['REMOTE_ADDR'])) {
    267             $seed .= $_SERVER['REMOTE_ADDR'];
     267            $seed .= sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
    268268        }
    269269        if (isset($_SERVER['HTTP_USER_AGENT'])) {
    270             $seed .= $_SERVER['HTTP_USER_AGENT'];
     270            $seed .= sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT']));
    271271        }
    272272        if (isset($_SERVER['HTTP_ACCEPT'])) {
    273             $seed .= $_SERVER['HTTP_ACCEPT'];
     273            $seed .= sanitize_text_field(wp_unslash($_SERVER['HTTP_ACCEPT']));
    274274        }
    275275        if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
    276             $seed .= $_SERVER['HTTP_ACCEPT_ENCODING'];
     276            $seed .= sanitize_text_field(wp_unslash($_SERVER['HTTP_ACCEPT_ENCODING']));
    277277        }
    278278        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    279             $seed .= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     279            $seed .= sanitize_text_field(wp_unslash($_SERVER['HTTP_ACCEPT_LANGUAGE']));
    280280        }
    281281        if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
    282             $seed .= $_SERVER['HTTP_ACCEPT_CHARSET'];
    283         }
    284 
    285         $seed .= mt_rand(0, mt_getrandmax());
     282            $seed .= sanitize_text_field(wp_unslash($_SERVER['HTTP_ACCEPT_CHARSET']));
     283        }
     284
     285        $seed .= wp_rand(0, mt_getrandmax());
    286286        $seed .= uniqid('', true);
    287287        $seed .= microtime();
  • seur/trunk/classes/PDFMerger.php

    r3120329 r3176965  
    4949        $tcpdfPath = SEUR_PLUGIN_PATH . 'classes/tcpdf/tcpdf.php';
    5050        if (!file_exists($tcpdfPath)) {
    51             echo 'File not exists: '.$tcpdfPath;
     51            echo 'File not exists: '.esc_attr($tcpdfPath);
    5252            die;
    5353        }
     
    7676        else
    7777        {
    78             throw new \exception("Could not locate PDF on '$filepath'");
     78            throw new \exception("Could not locate PDF on '".esc_attr($filepath)."'.");
    7979        }
    8080
     
    121121                foreach($filepages as $page)
    122122                {
    123                     if(!$template = $fpdi->importPage($page)): throw new exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); endif;
     123                    if (!$template = $fpdi->importPage($page)) {
     124                        throw new exception("Could not load page '".esc_attr($page)."' in PDF '".esc_attr($filename)."'. Check that the page exists.");
     125                    }
    124126                    $size = $fpdi->getTemplateSize($template);
    125127                    $orientation = ($size['h'] > $size['w']) ? 'P' : 'L';
     
    151153            else
    152154            {
    153                 throw new exception("Error outputting PDF to '$outputmode'.");
     155                throw new exception("Error outputting PDF to '".esc_attr($outputmode)."'.");
    154156                return false;
    155157            }
     
    206208                $y = $ind[1]; //end page
    207209
    208                 if($x > $y): throw new exception("Starting page, '$x' is greater than ending page '$y'."); return false; endif;
     210                if($x > $y): throw new exception("Starting page, '".esc_attr($x)."' is greater than ending page '".esc_attr($y)."'."); return false; endif;
    209211
    210212                //add middle pages
  • seur/trunk/classes/class-seur-collections.php

    r3159775 r3176965  
    215215        return json_decode( $result, true );
    216216    }
     217
     218    /**
     219     * Cancelar una recogida
     220     *
     221     * @param string $reference - La referencia de la recogida a cancelar
     222     * @return mixed|false
     223     */
     224    public function cancel_collection( $reference ) {
     225        // URL de la API para cancelar la recogida
     226        $url_cancel = $this->seur_adr . '/cancel';
     227
     228        // Preparar los datos de la solicitud de cancelación
     229        $data = wp_json_encode( array( 'codes' => array( $reference ) ) );
     230
     231        // Encabezados de la solicitud
     232        $headers = array(
     233            'Content-Type'  => 'application/json;charset=UTF-8',
     234            'Accept'        => 'application/json',
     235            'Authorization' => seur()->get_token_b(),
     236        );
     237
     238        if ( seur()->log_is_acive() ) {
     239            seur()->slog( 'Cancelando recogida con referencia: ' . $reference );
     240            seur()->slog( 'Data enviada: ' . print_r( $data, true ) );
     241        }
     242
     243        // Configuración de la solicitud
     244        $args = array(
     245            'method'      => 'POST',
     246            'timeout'     => 45,
     247            'httpversion' => '1.0',
     248            'user-agent'  => 'WooCommerce',
     249            'headers'     => $headers,
     250            'body'        => $data,
     251        );
     252
     253        // Enviar la solicitud a la API
     254        $response      = wp_remote_post(
     255            $url_cancel,
     256            $args
     257        );
     258        $response_body = wp_remote_retrieve_body( $response );
     259        $result        = json_decode( wp_json_encode( $response_body ), true );
     260        return json_decode( $result, true );
     261
     262    }
    217263}
    218264function seur_collections( $data ) {
    219     $collection = new Seur_Collections();
    220     $result     = $collection->collection_remote_post( $data );
    221     return $result;
    222 }
     265    return ( new Seur_Collections() )->collection_remote_post( $data );
     266}
     267
     268function seur_cancel_collection( $reference ) {
     269    return ( new Seur_Collections() )->cancel_collection( $reference );
     270}
     271
  • seur/trunk/classes/class-seur-global.php

    r3159775 r3176965  
    148148        return get_option( 'seur_save_date_cold' );
    149149    }
     150
     151    public function cancel_collection( $type ) {
     152        update_option( 'seur_save_collection_' . $type, '' );
     153    }
     154
     155    public function cancel_reference( $type ) {
     156        update_option( 'seur_save_reference_' . $type, '' );
     157    }
     158
     159    public function cancel_date_normal() {
     160        update_option( 'seur_save_date_normal', '' );
     161    }
     162
     163    public function cancel_date_cold() {
     164        update_option( 'seur_save_date_cold', '' );
     165    }
     166
    150167
    151168    public function is_test() {
     
    226243        update_option( 'seur_api_token', $token );
    227244
    228         if ( $this->log_is_acive() ) {
    229             $this->slog( '$result: ' . print_r( $result, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
    230             $this->slog( 'Token: ' . $token );
    231             $this->slog( '/*****************************/' );
    232             $this->slog( 'sending Token confirmation mail' );
    233             $this->slog( '/*****************************/' );
    234             $to      = get_bloginfo( 'admin_email' );
    235             $subject = 'API Seur Guardada correctamente';
    236             $body    = 'Se ha generado de forma correcta un nuevo Token. El nuevo token es: ' . $token;
    237             $headers = array( 'Content-Type: text/html; charset=UTF-8' );
    238             wp_mail( $to, $subject, $body, $headers );
    239         }
    240245        return $token;
    241246    }
     
    355360     * @param $data array
    356361     * @param $action string
    357      * @param $implode bool
     362     * @param $queryparams bool
     363     * @param $file bool
    358364     *
    359365     * @return mixed json
    360366     * */
    361     public function sendCurl($url, $header, $data, $action, $queryparams = false, $file = false) {
    362         if ($action=='POST') {
    363             $curl = curl_init($url);
    364             /* headers didn't need to be set, cURL automatically sets headers when
    365                you pass an ARRAY into CURLOPT_POSTFIELDS -> (content-type: multipart/form-data; content-length...) */
    366             curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    367 
     367    public function sendCurl($url, $header, $data, $action, $queryparams = false, $file = false)
     368    {
     369        // Prepare the args for the request
     370        $args = array(
     371            'headers' => $header,
     372            'timeout' => 45,
     373            'sslverify' => false,
     374            'body' => null, // We'll set this later
     375            'user-agent' => 'WooCommerce',
     376            'httpversion' => '1.0',
     377        );
     378
     379        if ($action == 'POST') {
    368380            if ($queryparams) {
    369                 curl_setopt($curl, CURLOPT_POSTFIELDS, implode('&', $data));  // este para el token
     381                // For token or query params, we use URL-encoded data
     382                $args['body'] = implode('&', $data);
    370383            } elseif ($file) {
    371                 curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
     384                // For file upload, pass the data directly
     385                $args['body'] = $data;
    372386            } else {
    373                 curl_setopt($curl, CURLOPT_POST, true);  // application/x-www-form-urlencoded
    374                 curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
    375             }
     387                // For regular POST, we send JSON-encoded data
     388                $args['body'] = json_encode($data);
     389                $args['headers']['Content-Type'] = 'application/json';
     390            }
     391
     392            // Perform the POST request
     393            $response = wp_remote_post($url, $args);
     394
    376395        } else {
    377             $curl = curl_init($url . '?'. http_build_query($data));
    378             curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    379             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $action);
    380         }
    381 
    382         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    383         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    384         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    385 
    386         $result = curl_exec($curl);
    387         if (json_decode($result) !==null ){
    388             $result = json_decode($result);
    389         }
    390 
    391         if (curl_errno($curl)){
    392             $this->log->log(WC_Log_Levels::ERROR, "CURL ERROR: ".curl_error($curl));
    393             curl_close($curl);
     396            // For other methods like GET, PUT, DELETE
     397            $args['method'] = $action;
     398            $url_with_params = $url . '?' . http_build_query($data);
     399
     400            // Perform the custom request
     401            $response = wp_remote_get($url_with_params, $args);
     402        }
     403
     404        // Handle the response
     405        if (is_wp_error($response)) {
     406            $error_message = $response->get_error_message();
     407            $this->log->log(WC_Log_Levels::ERROR, "HTTP ERROR: $error_message");
    394408            return false;
    395409        }
    396         if (isset($result->error) || isset($result->errors)) {
    397             $this->log->log(WC_Log_Levels::ERROR, "CURL url: ".$url ."<br>
    398                 header: ". json_encode($header) ."<br>
    399                 params: ". json_encode($data) ."<br>
    400                 result: ". json_encode($result)
    401             );
    402         }
    403 
    404         curl_close($curl);
    405         return $result;
     410
     411        $result = wp_remote_retrieve_body($response);
     412        $decoded_result = json_decode($result, true);
     413
     414        if (json_last_error() === JSON_ERROR_NONE) {
     415            return $decoded_result;
     416        } else {
     417            $this->log->log(WC_Log_Levels::ERROR, "Invalid JSON response: " . $result);
     418            return $result;  // Return raw result if not JSON
     419        }
    406420    }
    407421
     
    423437            return false;
    424438
    425         $headers[] = "Accept: */*";
    426         $headers[] = "Content-Type: application/json";
    427         $headers[] = "Authorization: ".$token;
     439        $headers = [
     440            'Content-Type' => 'application/json;charset=UTF-8',
     441            'Accept' => 'application/json',
     442            'Authorization' => $token,
     443        ];
    428444
    429445        $data = [
     
    439455        }
    440456
    441         if (!isset($response->data)) {
     457        if (!isset($response['data'])) {
    442458            return false;
    443459        }
    444         return $response->data;
     460        return $response['data'];
    445461    }
    446462
     
    631647    {
    632648        $deliveryDate = new DateTime('tomorrow');
    633         $deliveryDay = strtolower(date('l', $deliveryDate->getTimestamp()));
     649        $deliveryDay = strtolower(gmdate('l', $deliveryDate->getTimestamp()));
    634650        if ($deliveryDay == 'sunday') {
    635651            $deliveryDate->add(new \DateInterval('P1D'));
     
    681697                return false;
    682698
    683             $headers[] = "Accept: */*";
    684             $headers[] = "Content-Type: application/json";
    685             $headers[] = "Authorization: ".$token;
     699            $headers = [
     700                'Content-Type' => 'application/json;charset=UTF-8',
     701                'Accept' => 'application/json',
     702                'Authorization' => $token,
     703            ];
    686704
    687705            $response = $this->sendCurl($url, $headers, $preparedData, "POST");
    688706
    689707            $message = '';
    690             if (isset($response->errors)) {
    691                 $message = 'addShipment Error: '.$response->errors[0]->detail;
    692             }
    693 
    694             if (isset($response->error)) {
    695                 $message = 'addShipment Error: '.$response->error;
     708            if (isset($response['errors'])) {
     709                $message = 'addShipment Error: '.$response['errors'][0]['detail'];
     710            }
     711
     712            if (isset($response['error'])) {
     713                $message = 'addShipment Error: '.$response['error'];
    696714            }
    697715
     
    725743    public function getLabel($response, $is_pdf, $label_data, $order_id)
    726744    {
    727         if (is_array($response) && isset($response['response'])) {
     745        global $wp_filesystem;
     746        if ( is_array($response) && isset($response['response'])) {
    728747            $response = $response['response'];
    729748        }
     
    737756                return false;
    738757
    739             $headers[] = "Accept: */*";
    740             $headers[] = "Content-Type: application/json";
    741             $headers[] = "Authorization: ".$token;
     758            $headers = [
     759                'Content-Type' => 'application/json;charset=UTF-8',
     760                'Accept' => 'application/json',
     761                'Authorization' => $token,
     762            ];
    742763
    743764            $type = new PrinterType();
     
    749770
    750771            $data = [
    751                 'code' => $response->data->shipmentCode,
     772                'code' => $response['data']['shipmentCode'],
    752773                'type' => $printerType,
    753774                'entity' => 'EXPEDITIONS'
     
    759780            $responseLabel = $this->sendCurl($urlws, $headers, $data, "GET");
    760781
    761             if (isset($responseLabel->errors)) {
    762                 $message = 'getLabel Error: '.$responseLabel->errors[0]->detail;
     782            if (isset($responseLabel['errors'])) {
     783                $message = 'getLabel Error: '.$responseLabel['errors'][0]['detail'];
    763784                $this->log->log(WC_Log_Levels::ERROR, $message);
    764785                return [ 'status'=> false,
     
    769790            $upload_url = seur_upload_url( 'labels' );
    770791
    771             if (!is_writable($upload_dir)) {
     792            if (! $wp_filesystem->is_writable($upload_dir)) {
    772793                $message = 'getLabel Error: '.$upload_dir . ' is NOT writable';
    773794                $this->log->log(WC_Log_Levels::ERROR, $message);
     
    781802            $content = '';
    782803            // Generate file/s with then content of the labels
    783             foreach ($responseLabel->data as $data) {
     804            foreach ($responseLabel['data'] as $data) {
    784805                if ($is_pdf) {
    785                     $content = base64_decode($data->pdf);
     806                    $content = base64_decode($data['pdf']);
    786807                } else {
    787                     $content = $data->label;
     808                    $content = $data['label'];
    788809                }
    789810
    790811                // When merging labels, all labels are written to the same file. A suffix is added in other case.
    791                 $label_file = 'label_order_id_' . $order_id . '_' . date( 'd-m-Y' );
     812                $label_file = 'label_order_id_' . $order_id . '_' . gmdate( 'd-m-Y' );
    792813                if ( !$merge_labels ) {
    793814                    $label_file .= ($cont == 1 ? '' : '_' . $cont);
     
    797818                $upload_path = $upload_dir . '/' . $label_file;
    798819
    799                 if ( false === file_put_contents($upload_path, $content, FILE_APPEND) ) {
    800                     $message = 'getLabel Error file_put_contents: '.$upload_path;
    801                     $this->log->log(WC_Log_Levels::ERROR, $message);
    802                     return [ 'status'=> false,
    803                         'message' => $message ];
    804                 }
     820                if ( ! $wp_filesystem->put_contents( $upload_path, $content, FS_CHMOD_FILE | FILE_APPEND ) ) {
     821                    $message = 'getLabel Error file_put_contents: ' . $upload_path;
     822                    $this->log->log( WC_Log_Levels::ERROR, $message );
     823                    return [
     824                        'status'  => false,
     825                        'message' => $message,
     826                    ];
     827                }
    805828                if (!in_array($label_file, $label_files)) {
    806829                    $label_files[] = $label_file;
     
    860883                if (! $labelid ) {
    861884                    $result = false;
    862                     $message = $responseLabel->out->mensaje;
     885                    $message = $responseLabel['out']['mensaje'];
    863886                }
    864887                $seur_label[] = [
     
    874897            $order->update_meta_data('_seur_shipping_id_number', $label_data['order_id_seur'] );
    875898            $order->update_meta_data('_seur_label_id_number', $labelids);
     899            $order->update_meta_data( '_seur_shipping_order_label_downloaded', 'yes');
    876900            $order->save_meta_data();
    877901
    878             $expeditionCode = $response->data->shipmentCode;
    879             $ecbs = $response->data->ecbs;
    880             $parcelNumbers = $response->data->parcelNumbers;
     902            $expeditionCode = $response['data']['shipmentCode'];
     903            $ecbs = $response['data']['ecbs'];
     904            $parcelNumbers = $response['data']['parcelNumbers'];
    881905
    882906            $this->log->log(WC_Log_Levels::INFO, "getLabel OK");
     
    910934            $datepickup = explode(' ', $pickup_data['date']);
    911935            $datepickup = $datepickup[0];
    912             if (strtotime(date('Y-m-d')) == strtotime($datepickup))
     936            if (strtotime(gmdate('Y-m-d')) == strtotime($datepickup))
    913937                $make_pickup = false;
    914938        }
     
    952976    public function is_seur_order($order_id) {
    953977        global $wpdb;
    954         $query = "SELECT distinct o.order_id
     978        return $wpdb->get_results($wpdb->prepare(
     979            "SELECT distinct o.order_id
    955980            FROM {$wpdb->prefix}woocommerce_order_items o
    956981            inner join {$wpdb->prefix}woocommerce_order_itemmeta om on om.order_item_id = o.order_item_id
    957             where om.meta_key = 'method_id' and (om.meta_value like '%seur%')
    958             AND o.order_id = ".$order_id;
    959         return $wpdb->get_results( $query );
     982            where om.meta_key = %s and (om.meta_value like %s)
     983            AND o.order_id = %d",
     984            ['method_id', '%seur%', $order_id])
     985        );
    960986    }
    961987
    962988    public function is_seur_local_method($custom_rate_id) {
    963989        global $wpdb;
    964         $query = "SELECT ID
     990        return $wpdb->get_results($wpdb->prepare(
     991            "SELECT ID
    965992            FROM {$wpdb->prefix}seur_custom_rates
    966             where rate like '%2SHOP' and ID = ".$custom_rate_id;
    967         return $wpdb->get_results( $query );
     993            where rate like %s and ID = %d",
     994            ['%2SHOP', $custom_rate_id])
     995        );
    968996    }
    969997
     
    10121040    public function has_label($post_order_int) {
    10131041        $order = seur_get_order($post_order_int);
    1014         $has_label = $order->get_meta('_seur_shipping_order_label_downloaded', true );
    10151042        $label_ids = seur_get_labels_ids( $order->get_id() );
    1016         return $has_label && (!empty($label_ids));
     1043        return (!empty($label_ids));
    10171044    }
    10181045}
  • seur/trunk/classes/class-seur-scheduled-actions.php

    r3119152 r3176965  
    1010    exit; // Exit if accessed directly.
    1111}
     12require_once ABSPATH . 'wp-content/plugins/woocommerce/packages/action-scheduler/action-scheduler.php';
    1213
    1314class Seur_Scheduled_Actions {
     
    2021
    2122    public function seur_token_schedule() {
    22         if ( false === as_next_scheduled_action( 'seur_get_token_hook' ) ) {
     23        //if ( false === as_next_scheduled_action( 'seur_get_token_hook' ) ) {
    2324            as_schedule_recurring_action( strtotime( 'now' ), 1200, 'seur_get_token_hook' );
    24         }
     25        //}
    2526    }
    2627
  • seur/trunk/classes/class-seur-seguimiento.php

    r3159775 r3176965  
    176176    global $wpdb;
    177177    $tabla  = $wpdb->prefix . 'seur_status';
    178     $sql    = "SELECT * FROM ". $tabla ." WHERE cod_situ = '".$eventCode."'";
    179     $result = $wpdb->get_results($sql);
     178    $result = $wpdb->get_results($wpdb->prepare(
     179        "SELECT * FROM %s WHERE cod_situ = %s",
     180        [$tabla, $eventCode]));
    180181    return $result ? (array)$result[0] : [];
    181182}
     
    197198    $tabla  = $wpdb->prefix . 'wc_order_stats';
    198199    if ($expeditionStatusKey = getExpeditionStatusKey($expeditionStatus)) {
    199         $wpdb->query("UPDATE " . $tabla . " SET status='" . $expeditionStatusKey . "' WHERE order_id = '" . $order_id . "'");
     200        $wpdb->query($wpdb->prepare(
     201            "UPDATE %s SET status=%s WHERE order_id = %d",
     202            [$tabla, $expeditionStatusKey, $order_id])
     203        );
    200204        $order = wc_get_order($order_id);
    201205        $order->update_status($expeditionStatusKey);
  • seur/trunk/classes/tcpdf/include/tcpdf_filters.php

    r3120329 r3176965  
    472472     */
    473473    public static function Error($msg) {
    474         throw new Exception('TCPDF_PARSER ERROR: '.$msg);
     474        throw new Exception('TCPDF_PARSER ERROR: '.esc_attr($msg));
    475475    }
    476476
  • seur/trunk/classes/tcpdf/include/tcpdf_fonts.php

    r3130893 r3176965  
    7171     */
    7272    public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) {
     73        global $wp_filesystem;
     74
    7375        if (!TCPDF_STATIC::file_exists($fontfile)) {
    7476            // Could not find file
     
    103105        $fmetric['ctg'] = $font_name.'.ctg.z';
    104106        // get font data
    105         $font = file_get_contents($fontfile);
     107        $font = $wp_filesystem->get_contents( $fontfile );
    106108        $fmetric['originalsize'] = strlen($font);
    107109        // autodetect font type
     
    187189            // store compressed font
    188190            $fmetric['file'] .= '.z';
    189             $fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['file'], 'wb');
     191            $outfile = $outpath . $fmetric['file'];
     192            $compressed_data = gzcompress($data);
     193            $wp_filesystem->put_contents( $outfile, $compressed_data, FS_CHMOD_FILE );
     194            /*$fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['file'], 'wb');
    190195            fwrite($fp, gzcompress($data));
    191             fclose($fp);
     196            fclose($fp);*/
    192197            // get font info
    193198            $fmetric['Flags'] = $flags;
     
    367372                    // store compressed font
    368373                    $fmetric['file'] .= '.z';
    369                     $fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['file'], 'wb');
     374                    $outfile = $outpath . $fmetric['file'];
     375                    $compressed_font = gzcompress($font);
     376                    $wp_filesystem->put_contents( $outfile, $compressed_font, FS_CHMOD_FILE );
     377                    /*$fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['file'], 'wb');
    370378                    fwrite($fp, gzcompress($font));
    371                     fclose($fp);
     379                    fclose($fp);*/
    372380                }
    373381            }
     
    886894                }
    887895                // store compressed CIDToGIDMap
    888                 $fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['ctg'], 'wb');
     896                $outfile = $outpath . $fmetric['ctg'];
     897                $compressed_data = gzcompress($cidtogidmap);
     898                $wp_filesystem->put_contents( $outfile, $compressed_data, FS_CHMOD_FILE );
     899
     900                /*$fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['ctg'], 'wb');
    889901                fwrite($fp, gzcompress($cidtogidmap));
    890                 fclose($fp);
     902                fclose($fp);*/
    891903            }
    892904        }
     
    912924        $pfile .= '// --- EOF ---'."\n";
    913925        // store file
    914         $fp = TCPDF_STATIC::fopenLocal($outpath.$font_name.'.php', 'w');
     926        $outfile = $outpath . $font_name . '.php';
     927        $wp_filesystem->put_contents( $outfile, $pfile, FS_CHMOD_FILE );
     928
     929        /*$fp = TCPDF_STATIC::fopenLocal($outpath.$font_name.'.php', 'w');
    915930        fwrite($fp, $pfile);
    916         fclose($fp);
     931        fclose($fp);*/
    917932        // return TCPDF font name
    918933        return $font_name;
  • seur/trunk/classes/tcpdf/include/tcpdf_images.php

    r3120329 r3176965  
    1 <?php
    2 //============================================================+
    3 // File name   : tcpdf_images.php
    4 // Version     : 1.0.005
    5 // Begin       : 2002-08-03
    6 // Last Update : 2014-11-15
    7 // Author      : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
    8 // License     : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
    9 // -------------------------------------------------------------------
    10 // Copyright (C) 2002-2014 Nicola Asuni - Tecnick.com LTD
    11 //
    12 // This file is part of TCPDF software library.
    13 //
    14 // TCPDF is free software: you can redistribute it and/or modify it
    15 // under the terms of the GNU Lesser General Public License as
    16 // published by the Free Software Foundation, either version 3 of the
    17 // License, or (at your option) any later version.
    18 //
    19 // TCPDF is distributed in the hope that it will be useful, but
    20 // WITHOUT ANY WARRANTY; without even the implied warranty of
    21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    22 // See the GNU Lesser General Public License for more details.
    23 //
    24 // You should have received a copy of the License
    25 // along with TCPDF. If not, see
    26 // <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
    27 //
    28 // See LICENSE.TXT file for more information.
    29 // -------------------------------------------------------------------
    30 //
    31 // Description :
    32 //   Static image methods used by the TCPDF class.
    33 //
    34 //============================================================+
    35 
    36 /**
    37  * @file
    38  * This is a PHP class that contains static image methods for the TCPDF class.<br>
    39  * @package com.tecnick.tcpdf
    40  * @author Nicola Asuni
    41  * @version 1.0.005
    42  */
    43 
    44 /**
    45  * @class TCPDF_IMAGES
    46  * Static image methods used by the TCPDF class.
    47  * @package com.tecnick.tcpdf
    48  * @brief PHP class for generating PDF documents without requiring external extensions.
    49  * @version 1.0.005
    50  * @author Nicola Asuni - [email protected]
    51  */
    52 class TCPDF_IMAGES {
    53 
    54     /**
    55      * Array of hinheritable SVG properties.
    56      * @since 5.0.000 (2010-05-02)
    57      * @public static
    58      */
    59     public static $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'display', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
    60 
    61 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    62 
    63     /**
    64      * Return the image type given the file name or array returned by getimagesize() function.
    65      * @param $imgfile (string) image file name
    66      * @param $iminfo (array) array of image information returned by getimagesize() function.
    67      * @return string image type
    68      * @since 4.8.017 (2009-11-27)
    69      * @public static
    70      */
    71     public static function getImageFileType($imgfile, $iminfo=array()) {
    72         $type = '';
    73         if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
    74             $mime = explode('/', $iminfo['mime']);
    75             if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
    76                 $type = strtolower(trim($mime[1]));
    77             }
    78         }
    79         if (empty($type)) {
    80             $fileinfo = pathinfo($imgfile);
    81             if (isset($fileinfo['extension']) AND (!TCPDF_STATIC::empty_string($fileinfo['extension']))) {
    82                 $type = strtolower(trim($fileinfo['extension']));
    83             }
    84         }
    85         if ($type == 'jpg') {
    86             $type = 'jpeg';
    87         }
    88         return $type;
    89     }
    90 
    91     /**
    92      * Set the transparency for the given GD image.
    93      * @param $new_image (image) GD image object
    94      * @param $image (image) GD image object.
    95      * return GD image object.
    96      * @since 4.9.016 (2010-04-20)
    97      * @public static
    98      */
    99     public static function setGDImageTransparency($new_image, $image) {
    100         // default transparency color (white)
    101         $tcol = array('red' => 255, 'green' => 255, 'blue' => 255);
    102         // transparency index
    103         $tid = imagecolortransparent($image);
    104         $palletsize = imagecolorstotal($image);
    105         if (($tid >= 0) AND ($tid < $palletsize)) {
    106             // get the colors for the transparency index
    107             $tcol = imagecolorsforindex($image, $tid);
    108         }
    109         $tid = imagecolorallocate($new_image, $tcol['red'], $tcol['green'], $tcol['blue']);
    110         imagefill($new_image, 0, 0, $tid);
    111         imagecolortransparent($new_image, $tid);
    112         return $new_image;
    113     }
    114 
    115     /**
    116      * Convert the loaded image to a PNG and then return a structure for the PDF creator.
    117      * This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
    118      * @param $image (image) Image object.
    119      * @param $tempfile (string) Temporary file name.
    120      * return image PNG image object.
    121      * @since 4.9.016 (2010-04-20)
    122      * @public static
    123      */
    124     public static function _toPNG($image, $tempfile) {
    125         // turn off interlaced mode
    126         imageinterlace($image, 0);
    127         // create temporary PNG image
    128         imagepng($image, $tempfile);
    129         // remove image from memory
    130         imagedestroy($image);
    131         // get PNG image data
    132         $retvars = self::_parsepng($tempfile);
    133         // tidy up by removing temporary image
    134         unlink($tempfile);
    135         return $retvars;
    136     }
    137 
    138     /**
    139      * Convert the loaded image to a JPEG and then return a structure for the PDF creator.
    140      * This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
    141      * @param $image (image) Image object.
    142      * @param $quality (int) JPEG quality.
    143      * @param $tempfile (string) Temporary file name.
    144      * return image JPEG image object.
    145      * @public static
    146      */
    147     public static function _toJPEG($image, $quality, $tempfile) {
    148         imagejpeg($image, $tempfile, $quality);
    149         imagedestroy($image);
    150         $retvars = self::_parsejpeg($tempfile);
    151         // tidy up by removing temporary image
    152         unlink($tempfile);
    153         return $retvars;
    154     }
    155 
    156     /**
    157      * Extract info from a JPEG file without using the GD library.
    158      * @param $file (string) image file to parse
    159      * @return array structure containing the image data
    160      * @public static
    161      */
    162     public static function _parsejpeg($file) {
    163         // check if is a local file
    164         if (!@TCPDF_STATIC::file_exists($file)) {
    165             return false;
    166         }
    167         $a = getimagesize($file);
    168         if (empty($a)) {
    169             //Missing or incorrect image file
    170             return false;
    171         }
    172         if ($a[2] != 2) {
    173             // Not a JPEG file
    174             return false;
    175         }
    176         // bits per pixel
    177         $bpc = isset($a['bits']) ? intval($a['bits']) : 8;
    178         // number of image channels
    179         if (!isset($a['channels'])) {
    180             $channels = 3;
    181         } else {
    182             $channels = intval($a['channels']);
    183         }
    184         // default colour space
    185         switch ($channels) {
    186             case 1: {
    187                 $colspace = 'DeviceGray';
    188                 break;
    189             }
    190             case 3: {
    191                 $colspace = 'DeviceRGB';
    192                 break;
    193             }
    194             case 4: {
    195                 $colspace = 'DeviceCMYK';
    196                 break;
    197             }
    198             default: {
    199                 $channels = 3;
    200                 $colspace = 'DeviceRGB';
    201                 break;
    202             }
    203         }
    204         // get file content
    205         $data = file_get_contents($file);
    206         // check for embedded ICC profile
    207         $icc = array();
    208         $offset = 0;
    209         while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
    210             // get ICC sequence length
    211             $length = (TCPDF_STATIC::_getUSHORT($data, ($pos - 2)) - 16);
    212             // marker sequence number
    213             $msn = max(1, ord($data[($pos + 12)]));
    214             // number of markers (total of APP2 used)
    215             $nom = max(1, ord($data[($pos + 13)]));
    216             // get sequence segment
    217             $icc[($msn - 1)] = substr($data, ($pos + 14), $length);
    218             // move forward to next sequence
    219             $offset = ($pos + 14 + $length);
    220         }
    221         // order and compact ICC segments
    222         if (count($icc) > 0) {
    223             ksort($icc);
    224             $icc = implode('', $icc);
    225             if ((ord($icc[36]) != 0x61) OR (ord($icc[37]) != 0x63) OR (ord($icc[38]) != 0x73) OR (ord($icc[39]) != 0x70)) {
    226                 // invalid ICC profile
    227                 $icc = false;
    228             }
    229         } else {
    230             $icc = false;
    231         }
    232         return array('w' => $a[0], 'h' => $a[1], 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data);
    233     }
    234 
    235     /**
    236      * Extract info from a PNG file without using the GD library.
    237      * @param $file (string) image file to parse
    238      * @return array structure containing the image data
    239      * @public static
    240      */
    241     public static function _parsepng($file) {
    242         $f = @fopen($file, 'rb');
    243         if ($f === false) {
    244             // Can't open image file
    245             return false;
    246         }
    247         //Check signature
    248         if (fread($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
    249             // Not a PNG file
    250             return false;
    251         }
    252         //Read header chunk
    253         fread($f, 4);
    254         if (fread($f, 4) != 'IHDR') {
    255             //Incorrect PNG file
    256             return false;
    257         }
    258         $w = TCPDF_STATIC::_freadint($f);
    259         $h = TCPDF_STATIC::_freadint($f);
    260         $bpc = ord(fread($f, 1));
    261         $ct = ord(fread($f, 1));
    262         if ($ct == 0) {
    263             $colspace = 'DeviceGray';
    264         } elseif ($ct == 2) {
    265             $colspace = 'DeviceRGB';
    266         } elseif ($ct == 3) {
    267             $colspace = 'Indexed';
    268         } else {
    269             // alpha channel
    270             fclose($f);
    271             return 'pngalpha';
    272         }
    273         if (ord(fread($f, 1)) != 0) {
    274             // Unknown compression method
    275             fclose($f);
    276             return false;
    277         }
    278         if (ord(fread($f, 1)) != 0) {
    279             // Unknown filter method
    280             fclose($f);
    281             return false;
    282         }
    283         if (ord(fread($f, 1)) != 0) {
    284             // Interlacing not supported
    285             fclose($f);
    286             return false;
    287         }
    288         fread($f, 4);
    289         $channels = ($ct == 2 ? 3 : 1);
    290         $parms = '/DecodeParms << /Predictor 15 /Colors '.$channels.' /BitsPerComponent '.$bpc.' /Columns '.$w.' >>';
    291         //Scan chunks looking for palette, transparency and image data
    292         $pal = '';
    293         $trns = '';
    294         $data = '';
    295         $icc = false;
    296         $n = TCPDF_STATIC::_freadint($f);
    297         do {
    298             $type = fread($f, 4);
    299             if ($type == 'PLTE') {
    300                 // read palette
    301                 $pal = TCPDF_STATIC::rfread($f, $n);
    302                 fread($f, 4);
    303             } elseif ($type == 'tRNS') {
    304                 // read transparency info
    305                 $t = TCPDF_STATIC::rfread($f, $n);
    306                 if ($ct == 0) { // DeviceGray
    307                     $trns = array(ord($t[1]));
    308                 } elseif ($ct == 2) { // DeviceRGB
    309                     $trns = array(ord($t[1]), ord($t[3]), ord($t[5]));
    310                 } else { // Indexed
    311                     if ($n > 0) {
    312                         $trns = array();
    313                         for ($i = 0; $i < $n; ++ $i) {
    314                             $trns[] = ord($t[$i]);
    315                         }
    316                     }
    317                 }
    318                 fread($f, 4);
    319             } elseif ($type == 'IDAT') {
    320                 // read image data block
    321                 $data .= TCPDF_STATIC::rfread($f, $n);
    322                 fread($f, 4);
    323             } elseif ($type == 'iCCP') {
    324                 // skip profile name
    325                 $len = 0;
    326                 while ((ord(fread($f, 1)) != 0) AND ($len < 80)) {
    327                     ++$len;
    328                 }
    329                 // get compression method
    330                 if (ord(fread($f, 1)) != 0) {
    331                     // Unknown filter method
    332                     fclose($f);
    333                     return false;
    334                 }
    335                 // read ICC Color Profile
    336                 $icc = TCPDF_STATIC::rfread($f, ($n - $len - 2));
    337                 // decompress profile
    338                 $icc = gzuncompress($icc);
    339                 fread($f, 4);
    340             } elseif ($type == 'IEND') {
    341                 break;
    342             } else {
    343                 TCPDF_STATIC::rfread($f, $n + 4);
    344             }
    345             $n = TCPDF_STATIC::_freadint($f);
    346         } while ($n);
    347         if (($colspace == 'Indexed') AND (empty($pal))) {
    348             // Missing palette
    349             fclose($f);
    350             return false;
    351         }
    352         fclose($f);
    353         return array('w' => $w, 'h' => $h, 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'FlateDecode', 'parms' => $parms, 'pal' => $pal, 'trns' => $trns, 'data' => $data);
    354     }
    355 
    356 } // END OF TCPDF_IMAGES CLASS
    357 
    358 //============================================================+
    359 // END OF FILE
    360 //============================================================+
     1<?php /* Not used */
  • seur/trunk/classes/tcpdf/include/tcpdf_static.php

    r3159775 r3176965  
    394394     */
    395395    public static function getFormattedDate($time) {
    396         return substr_replace(date('YmdHisO', intval($time)), '\'', (0 - 2), 0).'\'';
     396        return substr_replace(gmdate('YmdHisO', intval($time)), '\'', (0 - 2), 0).'\'';
    397397    }
    398398
     
    406406     */
    407407    public static function getRandomSeed($seed='') {
    408         $rnd = uniqid(rand().microtime(true), true);
     408        $rnd = uniqid(wp_rand().microtime(true), true);
    409409        if (function_exists('posix_getpid')) {
    410410            $rnd .= posix_getpid();
     
    15251525        // TEX patterns are available at:
    15261526        // http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
    1527         $data = file_get_contents($file);
     1527        $response = wp_remote_get($file);
     1528        if (is_wp_error($response)) {
     1529            $error_message = $response->get_error_message();
     1530            $data = '';
     1531        } else {
     1532            $data = wp_remote_retrieve_body($response);  // Get the content of the response
     1533        }
     1534
    15281535        $patterns = array();
    15291536        // remove comments
     
    18161823     */
    18171824    public static function fopenLocal($filename, $mode) {
     1825        global $wp_filesystem;
     1826
     1827
    18181828        if (strpos($filename, '://') === false) {
    18191829            $filename = 'file://'.$filename;
     
    18211831            return false;
    18221832        }
    1823         return fopen($filename, $mode);
     1833        // Ahora utiliza WP_Filesystem para abrir el archivo
     1834        if ( ! $wp_filesystem->exists( $filename ) ) {
     1835            return false; // Si el archivo no existe, devuelve false
     1836        }
     1837
     1838        // Abre el archivo usando la API WP_Filesystem
     1839        $file_contents = $wp_filesystem->get_contents( $filename );
     1840
     1841        // Si no se pudo obtener el contenido, devuelve false
     1842        if ( $file_contents === false ) {
     1843            return false;
     1844        }
     1845
     1846        // Si el modo es de escritura o lectura, puedes manejar los modos
     1847        if ( $mode == 'r' ) {
     1848            return $file_contents; // Devuelve el contenido del archivo si el modo es lectura
     1849        } elseif ( $mode == 'w' ) {
     1850            return $wp_filesystem->put_contents( $filename, '', FS_CHMOD_FILE ); // Crea un archivo vacío si el modo es escritura
     1851        }
     1852
     1853        return false; // Si el modo no es soportado, devuelve false
    18241854    }
    18251855
     
    18271857     * Check if the URL exist.
    18281858     * @param url (string) URL to check.
    1829      * @return Returns TRUE if the URL exists; FALSE otherwise.
    1830      * @public static
    1831      */
    1832     public static function url_exists($url) {
    1833         $crs = curl_init();
    1834         // encode query params in URL to get right response form the server
    1835         $url = self::encodeUrlQuery($url);
    1836         curl_setopt($crs, CURLOPT_URL, $url);
    1837         curl_setopt($crs, CURLOPT_NOBODY, true);
    1838         curl_setopt($crs, CURLOPT_FAILONERROR, true);
    1839         if (ini_get('open_basedir') == '') {
    1840             curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
     1859     * @return boolean TRUE if the URL exists; FALSE otherwise.
     1860     * @public static
     1861     */
     1862    public static function url_exists($url) {
     1863        $url = self::encodeUrlQuery($url);
     1864        $args = array(
     1865            'timeout'     => 30,  // Timeout for the request
     1866            'redirection' => 5,   // Number of allowed redirects
     1867            'sslverify'   => false,  // Skip SSL verification (use with caution)
     1868            'user-agent'  => 'tc-lib-file'  // Custom user agent
     1869        );
     1870        $response = wp_remote_head($url, $args);
     1871
     1872        if (is_wp_error($response)) {
     1873            return false;
    18411874        }
    1842         curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
    1843         curl_setopt($crs, CURLOPT_TIMEOUT, 30);
    1844         curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
    1845         curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
    1846         curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
    1847         curl_exec($crs);
    1848         $code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
    1849         curl_close($crs);
    1850         return ($code == 200);
    1851     }
     1875
     1876        $response_code = wp_remote_retrieve_response_code($response);
     1877        return ($response_code == 200);
     1878    }
    18521879
    18531880    /**
     
    18941921     * @param $file (string) Name of the file or URL to read.
    18951922     * @return The function returns the read data or FALSE on failure.
    1896      * @author Nicola Asuni
    18971923     * @since 6.0.025
    18981924     * @public static
    18991925     */
    1900     public static function fileGetContents($file) {
    1901         $alt = array($file);
    1902         //
    1903         if ((strlen($file) > 1)
    1904             && ($file[0] === '/')
    1905             && ($file[1] !== '/')
    1906             && !empty($_SERVER['DOCUMENT_ROOT'])
    1907             && ($_SERVER['DOCUMENT_ROOT'] !== '/')
    1908         ) {
    1909             $findroot = strpos($file, $_SERVER['DOCUMENT_ROOT']);
    1910             if (($findroot === false) || ($findroot > 1)) {
    1911             $alt[] = htmlspecialchars_decode(urldecode($_SERVER['DOCUMENT_ROOT'].$file));
    1912             }
    1913         }
    1914         //
    1915         $protocol = 'http';
    1916         if (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
    1917             $protocol .= 's';
    1918         }
    1919         //
    1920         $url = $file;
    1921         if (preg_match('%^//%', $url) && !empty($_SERVER['HTTP_HOST'])) {
    1922             $url = $protocol.':'.str_replace(' ', '%20', $url);
    1923         }
    1924         $url = htmlspecialchars_decode($url);
    1925         $alt[] = $url;
    1926         //
    1927         if (preg_match('%^(https?)://%', $url)
    1928             && empty($_SERVER['HTTP_HOST'])
    1929             && empty($_SERVER['DOCUMENT_ROOT'])
    1930         ) {
    1931             $urldata = parse_url($url);
    1932             if (empty($urldata['query'])) {
    1933                 $host = $protocol.'://'.$_SERVER['HTTP_HOST'];
    1934                 if (strpos($url, $host) === 0) {
    1935                     // convert URL to full server path
    1936                     $tmp = str_replace($host, $_SERVER['DOCUMENT_ROOT'], $url);
    1937                     $alt[] = htmlspecialchars_decode(urldecode($tmp));
    1938                 }
    1939             }
    1940         }
    1941         //
    1942         if (isset($_SERVER['SCRIPT_URI'])
    1943             && !preg_match('%^(https?|ftp)://%', $file)
    1944             && !preg_match('%^//%', $file)
    1945         ) {
    1946             $urldata = @parse_url($_SERVER['SCRIPT_URI']);
    1947             $alt[] = $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file;
    1948         }
    1949         //
    1950         $alt = array_unique($alt);
    1951         foreach ($alt as $path) {
    1952             if (!self::file_exists($path)) {
    1953                 continue;
    1954             }
    1955             $ret = @file_get_contents($path);
    1956             if ( $ret != false ) {
    1957                 return $ret;
    1958             }
    1959             // try to use CURL for URLs
    1960             if (!ini_get('allow_url_fopen')
    1961                 && function_exists('curl_init')
    1962                 && preg_match('%^(https?|ftp)://%', $path)
    1963             ) {
    1964                 // try to get remote file data using cURL
    1965                 $crs = curl_init();
    1966                 curl_setopt($crs, CURLOPT_URL, $path);
    1967                 curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
    1968                 curl_setopt($crs, CURLOPT_FAILONERROR, true);
    1969                 curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
    1970                 if (ini_get('open_basedir') == '') {
    1971                     curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
     1926    public static function fileGetContents($file) {
     1927        global $wp_filesystem;
     1928
     1929        $alt = array($file);
     1930
     1931        // Check if it's an absolute file path on the server
     1932        $document_root = sanitize_text_field(wp_unslash($_SERVER['DOCUMENT_ROOT']??''));
     1933        if ((strlen($file) > 1)
     1934            && ($file[0] === '/')
     1935            && ($file[1] !== '/')
     1936            && !empty($document_root)
     1937            && ($document_root !== '/')
     1938        ) {
     1939            $findroot = strpos($file, );
     1940            if (($findroot === false) || ($findroot > 1)) {
     1941                $alt[] = htmlspecialchars_decode(urldecode(document_root.$file));
     1942            }
     1943        }
     1944
     1945        // Determine protocol (http or https)
     1946        $protocol = 'http';
     1947        $https = sanitize_text_field(wp_unslash($_SERVER['HTTPS']??''));
     1948        if (!empty($https) && (strtolower(https) != 'off')) {
     1949            $protocol .= 's';
     1950        }
     1951
     1952        // Build the URL for remote access
     1953        $url = sanitize_text_field($file);
     1954        $http_host = sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST']??''));
     1955        if (preg_match('%^//%', $url) && !empty($http_host)) {
     1956            $url = $protocol.':'.str_replace(' ', '%20', $url);
     1957        }
     1958        $url = htmlspecialchars_decode($url);
     1959        $alt[] = $url;
     1960
     1961        // Handle local URL transformations for remote files
     1962        if (preg_match('%^(https?)://%', $url) && empty($http_host) && empty($document_root)) {
     1963            $urldata = parse_url($url);
     1964            if (empty($urldata['query'])) {
     1965                $host = $protocol.'://'.$http_host;
     1966                if (strpos($url, $host) === 0) {
     1967                    $tmp = str_replace($host, $document_root, $url);
     1968                    $alt[] = htmlspecialchars_decode(urldecode($tmp));
    19721969                }
    1973                 curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
    1974                 curl_setopt($crs, CURLOPT_TIMEOUT, 30);
    1975                 curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
    1976                 curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
    1977                 curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
    1978                 $ret = curl_exec($crs);
    1979                 curl_close($crs);
    1980                 if ($ret !== false) {
    1981                     return $ret;
    1982                 }
    1983             }
    1984         }
    1985         return false;
    1986     }
    1987 
    1988     /**
     1970            }
     1971        }
     1972
     1973        // Construct full URL if necessary
     1974        $script_uri = sanitize_text_field(wp_unslash($_SERVER['SCRIPT_URI']??''));
     1975        if (isset($script_uri)
     1976            && !preg_match('%^(https?|ftp)://%', $file)
     1977            && !preg_match('%^//%', $file)
     1978        ) {
     1979            $urldata = parse_url($script_uri);
     1980            $alt[] = $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').sanitize_text_field($file);
     1981        }
     1982
     1983        // Unique paths
     1984        $alt = array_unique($alt);
     1985
     1986        foreach ($alt as $path) {
     1987            if (!self::file_exists($path)) {
     1988                continue;
     1989            }
     1990
     1991            // Check if it's a local file
     1992            if (!preg_match('%^(https?|ftp)://%', $path)) {
     1993                $ret = $wp_filesystem->get_contents( $path );
     1994                if ($ret !== false) {
     1995                    return $ret;
     1996                }
     1997            } else {
     1998                // Use wp_remote_get for remote URLs
     1999                $response = wp_remote_get($path, array(
     2000                    'timeout' => 30,
     2001                    'sslverify' => false,
     2002                    'user-agent' => 'tc-lib-file',
     2003                ));
     2004
     2005                if (is_wp_error($response)) {
     2006                    continue;
     2007                }
     2008
     2009                // Retrieve the body of the response
     2010                $ret = wp_remote_retrieve_body($response);
     2011                if ($ret !== false) {
     2012                    return $ret;
     2013                }
     2014            }
     2015        }
     2016
     2017        return false;
     2018    }
     2019
     2020    /**
    19892021     * Get ULONG from string (Big Endian 32-bit unsigned integer).
    19902022     * @param $str (string) string from where to extract value
     
    21002132     * @public static
    21012133     */
    2102     public static function rfread($handle, $length) {
    2103         $data = fread($handle, $length);
    2104         if ($data === false) {
    2105             return false;
    2106         }
    2107         $rest = ($length - strlen($data));
    2108         if (($rest > 0) && !feof($handle)) {
    2109             $data .= self::rfread($handle, $rest);
    2110         }
    2111         return $data;
    2112     }
     2134    public static function rfread($handle, $length) {
     2135        global $wp_filesystem;
     2136        if (!is_object($wp_filesystem)) {
     2137            require_once(ABSPATH . 'wp-admin/includes/file.php');
     2138            WP_Filesystem();
     2139        }
     2140        $data = $wp_filesystem->fread($handle, $length);
     2141        if ($data === false) {
     2142            return false;
     2143        }
     2144        $rest = ($length - strlen($data));
     2145        if (($rest > 0) && ! $wp_filesystem->feof($handle)) {
     2146            $data .= self::rfread($handle, $rest);
     2147        }
     2148        return $data;
     2149    }
    21132150
    21142151    /**
     
    21182155     * @public static
    21192156     */
    2120     public static function _freadint($f) {
    2121         $a = unpack('Ni', fread($f, 4));
    2122         return $a['i'];
    2123     }
     2157    public static function _freadint($f) {
     2158        global $wp_filesystem;
     2159        if (!is_object($wp_filesystem)) {
     2160            require_once(ABSPATH . 'wp-admin/includes/file.php');
     2161            WP_Filesystem();
     2162        }
     2163        // Leer 4 bytes usando WP_Filesystem
     2164        $data = $wp_filesystem->fread($f, 4);
     2165        $a = unpack('Ni', $data);
     2166        return $a['i'];
     2167    }
    21242168
    21252169   
  • seur/trunk/classes/tcpdf/tcpdf.php

    r3159775 r3176965  
    116116// TCPDF static color methods and data
    117117require_once(dirname(__FILE__).'/include/tcpdf_colors.php');
    118 // TCPDF static image methods and data
    119 require_once(dirname(__FILE__).'/include/tcpdf_images.php');
    120118// TCPDF static methods and data
    121119require_once(dirname(__FILE__).'/include/tcpdf_static.php');
     
    29472945        $this->_destroy(true);
    29482946        if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) {
    2949             die('<strong>TCPDF ERROR: </strong>'.$msg);
     2947            die('<strong>TCPDF ERROR: </strong>'. esc_attr($msg));
    29502948        } else {
    2951             throw new Exception('TCPDF ERROR: '.$msg);
     2949            throw new Exception('TCPDF ERROR: '. esc_attr($msg));
    29522950        }
    29532951    }
     
    68936891        }
    68946892        if (!empty($imgdata)) {
    6895             // copy image to cache
    6896             $original_file = $file;
    6897             $file = TCPDF_STATIC::getObjFilename('img', $this->file_id);
    6898             $fp = TCPDF_STATIC::fopenLocal($file, 'w');
    6899             if (!$fp) {
    6900                 $this->Error('Unable to write file: '.$file);
    6901             }
    6902             fwrite($fp, $imgdata);
    6903             fclose($fp);
    6904             unset($imgdata);
    6905             $imsize = @getimagesize($file);
    6906             if ($imsize === FALSE) {
    6907                 unlink($file);
    6908                 $file = $original_file;
    6909             }
    6910         }
     6893            global $wp_filesystem;
     6894            WP_Filesystem();
     6895            // Copy image to cache
     6896            $original_file = $file;
     6897            $file = TCPDF_STATIC::getObjFilename('img', $this->file_id);
     6898            if (!$wp_filesystem->put_contents($file, $imgdata, FS_CHMOD_FILE)) {
     6899                $this->Error('Unable to write file: ' . $file);
     6900            }
     6901            unset($imgdata);
     6902            $imsize = @getimagesize($file);
     6903            if ($imsize === false) {
     6904                $wp_filesystem->delete($file);
     6905                $file = $original_file;
     6906            }
     6907        }
    69116908        if ($imsize === FALSE) {
    69126909            if (($w > 0) AND ($h > 0)) {
     
    75847581            $name = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $name);
    75857582        }
    7586         if ($this->sign) {
    7587             // *** apply digital signature to the document ***
    7588             // get the document content
    7589             $pdfdoc = $this->getBuffer();
    7590             // remove last newline
    7591             $pdfdoc = substr($pdfdoc, 0, -1);
    7592             // remove filler space
    7593             $byterange_string_len = strlen(TCPDF_STATIC::$byterange_string);
    7594             // define the ByteRange
    7595             $byte_range = array();
    7596             $byte_range[0] = 0;
    7597             $byte_range[1] = strpos($pdfdoc, TCPDF_STATIC::$byterange_string) + $byterange_string_len + 10;
    7598             $byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
    7599             $byte_range[3] = strlen($pdfdoc) - $byte_range[2];
    7600             $pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
    7601             // replace the ByteRange
    7602             $byterange = sprintf('/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
    7603             $byterange .= str_repeat(' ', ($byterange_string_len - strlen($byterange)));
    7604             $pdfdoc = str_replace(TCPDF_STATIC::$byterange_string, $byterange, $pdfdoc);
    7605             // write the document to a temporary folder
    7606             $tempdoc = TCPDF_STATIC::getObjFilename('doc', $this->file_id);
    7607             $f = TCPDF_STATIC::fopenLocal($tempdoc, 'wb');
    7608             if (!$f) {
    7609                 $this->Error('Unable to create temporary file: '.$tempdoc);
    7610             }
    7611             $pdfdoc_length = strlen($pdfdoc);
    7612             fwrite($f, $pdfdoc, $pdfdoc_length);
    7613             fclose($f);
    7614             // get digital signature via openssl library
    7615             $tempsign = TCPDF_STATIC::getObjFilename('sig', $this->file_id);
    7616             if (empty($this->signature_data['extracerts'])) {
    7617                 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED);
    7618             } else {
    7619                 openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED, $this->signature_data['extracerts']);
    7620             }
    7621             // read signature
    7622             $signature = file_get_contents($tempsign);
    7623             // extract signature
    7624             $signature = substr($signature, $pdfdoc_length);
    7625             $signature = substr($signature, (strpos($signature, "%%EOF\n\n------") + 13));
    7626             $tmparr = explode("\n\n", $signature);
    7627             $signature = $tmparr[1];
    7628             // decode signature
    7629             $signature = base64_decode(trim($signature));
    7630             // add TSA timestamp to signature
    7631             $signature = $this->applyTSA($signature);
    7632             // convert signature to hex
    7633             $signature = current(unpack('H*', $signature));
    7634             $signature = str_pad($signature, $this->signature_max_length, '0');
    7635             // Add signature to the document
    7636             $this->buffer = substr($pdfdoc, 0, $byte_range[1]).'<'.$signature.'>'.substr($pdfdoc, $byte_range[1]);
    7637             $this->bufferlen = strlen($this->buffer);
    7638         }
     7583        if ($this->sign) {
     7584            global $wp_filesystem;
     7585            WP_Filesystem();
     7586            // *** apply digital signature to the document ***
     7587            // get the document content
     7588            $pdfdoc = $this->getBuffer();
     7589            // remove last newline
     7590            $pdfdoc = substr($pdfdoc, 0, -1);
     7591            // remove filler space
     7592            $byterange_string_len = strlen(TCPDF_STATIC::$byterange_string);
     7593            // define the ByteRange
     7594            $byte_range = array();
     7595            $byte_range[0] = 0;
     7596            $byte_range[1] = strpos($pdfdoc, TCPDF_STATIC::$byterange_string) + $byterange_string_len + 10;
     7597            $byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
     7598            $byte_range[3] = strlen($pdfdoc) - $byte_range[2];
     7599            $pdfdoc = substr($pdfdoc, 0, $byte_range[1]) . substr($pdfdoc, $byte_range[2]);
     7600            // replace the ByteRange
     7601            $byterange = sprintf('/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
     7602            $byterange .= str_repeat(' ', ($byterange_string_len - strlen($byterange)));
     7603            $pdfdoc = str_replace(TCPDF_STATIC::$byterange_string, $byterange, $pdfdoc);
     7604            // write the document to a temporary folder
     7605            $tempdoc = TCPDF_STATIC::getObjFilename('doc', $this->file_id);
     7606            if ( ! $wp_filesystem->put_contents($tempdoc, $pdfdoc, FS_CHMOD_FILE) ) {
     7607                $this->Error('Unable to create temporary file: ' . $tempdoc);
     7608            }
     7609            // get digital signature via openssl library
     7610            $tempsign = TCPDF_STATIC::getObjFilename('sig', $this->file_id);
     7611            if (empty($this->signature_data['extracerts'])) {
     7612                openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED);
     7613            } else {
     7614                openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED, $this->signature_data['extracerts']);
     7615            }
     7616            // read the signature using WP_Filesystem
     7617            $signature = $wp_filesystem->get_contents($tempsign);
     7618            // extract signature
     7619            $signature = substr($signature, strlen($pdfdoc));
     7620            $signature = substr($signature, (strpos($signature, "%%EOF\n\n------") + 13));
     7621            $tmparr = explode("\n\n", $signature);
     7622            $signature = $tmparr[1];
     7623            // decode signature
     7624            $signature = base64_decode(trim($signature));
     7625            // add TSA timestamp to signature
     7626            $signature = $this->applyTSA($signature);
     7627            // convert signature to hex
     7628            $signature = current(unpack('H*', $signature));
     7629            $signature = str_pad($signature, $this->signature_max_length, '0');
     7630            // add signature to the document
     7631            $this->buffer = substr($pdfdoc, 0, $byte_range[1]) . '<' . $signature . '>' . substr($pdfdoc, $byte_range[1]);
     7632            $this->bufferlen = strlen($this->buffer);
     7633        }
    76397634        switch($dest) {
    76407635            case 'I': {
     
    76927687            case 'F':
    76937688            case 'FI':
    7694             case 'FD': {
    7695                 // save PDF to a local file
    7696                 $f = TCPDF_STATIC::fopenLocal($name, 'wb');
    7697                 if (!$f) {
    7698                     $this->Error('Unable to create output file: '.$name);
    7699                 }
    7700                 fwrite($f, $this->getBuffer(), $this->bufferlen);
    7701                 fclose($f);
    7702                 if ($dest == 'FI') {
    7703                     // send headers to browser
    7704                     header('Content-Type: application/pdf');
    7705                     header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
    7706                     //header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
    7707                     header('Pragma: public');
    7708                     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    7709                     header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    7710                     header('Content-Disposition: inline; filename="'.basename($name).'"');
    7711                     TCPDF_STATIC::sendOutputData(file_get_contents($name), filesize($name));
    7712                 } elseif ($dest == 'FD') {
    7713                     // send headers to browser
    7714                     if (ob_get_contents()) {
    7715                         $this->Error('Some data has already been output, can\'t send PDF file');
    7716                     }
    7717                     header('Content-Description: File Transfer');
    7718                     if (headers_sent()) {
    7719                         $this->Error('Some data has already been output to browser, can\'t send PDF file');
    7720                     }
    7721                     header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
     7689            case 'FD': {
     7690                global $wp_filesystem;
     7691                WP_Filesystem();
     7692                // save PDF to a local file using WP_Filesystem
     7693                if ( ! $wp_filesystem->put_contents( $name, $this->getBuffer(), FS_CHMOD_FILE ) ) {
     7694                    $this->Error( 'Unable to create output file: ' . $name );
     7695                }
     7696                if ($dest == 'FI') {
     7697                    // send headers to browser
     7698                    header('Content-Type: application/pdf');
     7699                    header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
     7700                    header('Pragma: public');
     7701                    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
     7702                    header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
     7703                    header('Content-Disposition: inline; filename="'.basename($name).'"');
     7704                    $file_data = $wp_filesystem->get_contents($name);
     7705                    $file_size = $wp_filesystem->size($name);
     7706                    TCPDF_STATIC::sendOutputData($file_data, $file_size);
     7707                } elseif ($dest == 'FD') {
     7708                    if (ob_get_contents()) {
     7709                        $this->Error('Some data has already been output, can\'t send PDF file');
     7710                    }
     7711                    header('Content-Description: File Transfer');
     7712                    if (headers_sent()) {
     7713                        $this->Error('Some data has already been output to browser, can\'t send PDF file');
     7714                    }
     7715                    header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
    77227716                    header('Pragma: public');
    77237717                    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
     
    77277721                        header('Content-Type: application/force-download');
    77287722                        header('Content-Type: application/octet-stream', false);
    7729                         header('Content-Type: application/download', false);
    7730                         header('Content-Type: application/pdf', false);
    7731                     } else {
    7732                         header('Content-Type: application/pdf');
    7733                     }
    7734                     // use the Content-Disposition header to supply a recommended filename
    7735                     header('Content-Disposition: attachment; filename="'.basename($name).'"');
    7736                     header('Content-Transfer-Encoding: binary');
    7737                     TCPDF_STATIC::sendOutputData(file_get_contents($name), filesize($name));
    7738                 }
    7739                 break;
    7740             }
     7723                        header('Content-Type: application/download', false);
     7724                        header('Content-Type: application/pdf', false);
     7725                    } else {
     7726                        header('Content-Type: application/pdf');
     7727                    }
     7728                    header('Content-Disposition: attachment; filename="'.basename($name).'"');
     7729                    header('Content-Transfer-Encoding: binary');
     7730                    $file_data = $wp_filesystem->get_contents($name);
     7731                    $file_size = $wp_filesystem->size($name);
     7732                    TCPDF_STATIC::sendOutputData($file_data, $file_size);
     7733                }
     7734                break;
     7735            }
    77417736            case 'E': {
    77427737                // return PDF as base64 mime multi-part email attachment (RFC 2045)
     
    88208815            // search and get font file to embedd
    88218816            $fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']);
    8822             if (!TCPDF_STATIC::empty_string($fontfile)) {
    8823                 $font = file_get_contents($fontfile);
    8824                 $compressed = (substr($file, -2) == '.z');
    8825                 if ((!$compressed) AND (isset($info['length2']))) {
    8826                     $header = (ord($font[0]) == 128);
    8827                     if ($header) {
    8828                         // strip first binary header
    8829                         $font = substr($font, 6);
    8830                     }
    8831                     if ($header AND (ord($font[$info['length1']]) == 128)) {
    8832                         // strip second binary header
    8833                         $font = substr($font, 0, $info['length1']).substr($font, ($info['length1'] + 6));
    8834                     }
    8835                 } elseif ($info['subset'] AND ((!$compressed) OR ($compressed AND function_exists('gzcompress')))) {
    8836                     if ($compressed) {
    8837                         // uncompress font
    8838                         $font = gzuncompress($font);
    8839                     }
    8840                     // merge subset characters
    8841                     $subsetchars = array(); // used chars
    8842                     foreach ($info['fontkeys'] as $fontkey) {
    8843                         $fontinfo = $this->getFontBuffer($fontkey);
    8844                         $subsetchars += $fontinfo['subsetchars'];
    8845                     }
    8846                     // rebuild a font subset
    8847                     $font = TCPDF_FONTS::_getTrueTypeFontSubset($font, $subsetchars);
    8848                     // calculate new font length
    8849                     $info['length1'] = strlen($font);
    8850                     if ($compressed) {
    8851                         // recompress font
    8852                         $font = gzcompress($font);
    8853                     }
    8854                 }
     8817            if (!TCPDF_STATIC::empty_string($fontfile)) {
     8818                global $wp_filesystem;
     8819                WP_Filesystem();
     8820
     8821                // Read the font file content using WP_Filesystem
     8822                $font = $wp_filesystem->get_contents($fontfile);
     8823                if ($font === false) {
     8824                    $this->Error('Unable to read font file: ' . $fontfile);
     8825                }
     8826                $compressed = (substr($file, -2) == '.z');
     8827                if ((!$compressed) && (isset($info['length2']))) {
     8828                    $header = (ord($font[0]) == 128);
     8829                    if ($header) {
     8830                        // strip first binary header
     8831                        $font = substr($font, 6);
     8832                    }
     8833                    if ($header && (ord($font[$info['length1']]) == 128)) {
     8834                        // strip second binary header
     8835                        $font = substr($font, 0, $info['length1']).substr($font, ($info['length1'] + 6));
     8836                    }
     8837                } elseif ($info['subset'] && ((!$compressed) || ($compressed && function_exists('gzcompress')))) {
     8838                    if ($compressed) {
     8839                        // uncompress font
     8840                        $font = gzuncompress($font);
     8841                    }
     8842                    // merge subset characters
     8843                    $subsetchars = array(); // used chars
     8844                    foreach ($info['fontkeys'] as $fontkey) {
     8845                        $fontinfo = $this->getFontBuffer($fontkey);
     8846                        $subsetchars += $fontinfo['subsetchars'];
     8847                    }
     8848                    // rebuild a font subset
     8849                    $font = TCPDF_FONTS::_getTrueTypeFontSubset($font, $subsetchars);
     8850                    // calculate new font length
     8851                    $info['length1'] = strlen($font);
     8852                    if ($compressed) {
     8853                        // recompress font
     8854                        $font = gzcompress($font);
     8855                    }
     8856                }
    88558857                $this->_newobj();
    88568858                $this->FontFiles[$file]['n'] = $this->n;
     
    89618963     */
    89628964    protected function _puttruetypeunicode($font) {
     8965        global $wp_filesystem;
     8966
    89638967        $fontname = '';
    89648968        if ($font['subset']) {
     
    90419045                $this->Error('Font file not found: '.$ctgfile);
    90429046            }
    9043             $stream = $this->_getrawstream(file_get_contents($fontfile));
     9047            $stream = $this->_getrawstream( $wp_filesystem->get_contents( $fontfile ) );
    90449048            $out = '<< /Length '.strlen($stream).'';
    90459049            if (substr($fontfile, -2) == '.z') { // check file extension
     
    97079711     */
    97089712    protected function _putcatalog() {
     9713        global $wp_filesystem;
     9714
    97099715        // put XMP
    97109716        $xmpobj = $this->_putXMP();
     
    97129718        if ($this->pdfa_mode OR $this->force_srgb) {
    97139719            $iccobj = $this->_newobj();
    9714             $icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc');
     9720            $icc_path = dirname(__FILE__) . '/include/sRGB.icc';
     9721            $icc = $wp_filesystem->get_contents( $icc_path );
    97159722            $filter = '';
    97169723            if ($this->compress) {
     
    1077810785     */
    1077910786    protected function _generateencryptionkey() {
     10787        global $wp_filesystem;
     10788
    1078010789        $keybytelen = ($this->encryptdata['Length'] / 8);
    1078110790        if (!$this->encryptdata['pubkey']) { // standard mode
     
    1085010859                }
    1085110860                $envelope_length = strlen($envelope);
    10852                 fwrite($f, $envelope, $envelope_length);
    10853                 fclose($f);
     10861                $wp_filesystem->put_contents( $tempkeyfile, $envelope, FS_CHMOD_FILE );
     10862                //fwrite($f, $envelope, $envelope_length);
     10863                //fclose($f);
    1085410864                $tempencfile = TCPDF_STATIC::getObjFilename('enc', $this->file_id);
    1085510865                if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey['c'], array(), PKCS7_BINARY | PKCS7_DETACHED)) {
     
    1085710867                }
    1085810868                // read encryption signature
    10859                 $signature = file_get_contents($tempencfile, false, null, $envelope_length);
    10860                 // extract signature
     10869                $signature = substr( $wp_filesystem->get_contents( $tempencfile ), $envelope_length );              // extract signature
    1086110870                $signature = substr($signature, strpos($signature, 'Content-Disposition'));
    1086210871                $tmparr = explode("\n\n", $signature);
     
    1246412473            $title = preg_replace("/[\r]+/si", '', $title);
    1246512474            $title = preg_replace("/[\n]+/si", "\n", $title);
    12466             $title = strip_tags($title);
     12475            $title = wp_strip_all_tags($title);
    1246712476            $title = $this->stringTrim($title);
    1246812477            $out = '<</Title '.$this->_textstring($title, $oid);
     
    1888818897                    $type = '';
    1888918898                } else {
    18890                     if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
     18899                    $document_root = sanitize_text_field(wp_unslash($_SERVER['DOCUMENT_ROOT'] ?? ''));
     18900
     18901                    if (($imgsrc[0] === '/') AND !empty($document_root) AND ($document_root != '/')) {
    1889118902                        // fix image path
    18892                         $findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
     18903                        $findroot = strpos($imgsrc, $document_root);
    1889318904                        if (($findroot === false) OR ($findroot > 1)) {
    18894                             if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
    18895                                 $imgsrc = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$imgsrc;
     18905                            if (substr($document_root, -1) == '/') {
     18906                                $imgsrc = substr($document_root, 0, -1).$imgsrc;
    1889618907                            } else {
    18897                                 $imgsrc = $_SERVER['DOCUMENT_ROOT'].$imgsrc;
     18908                                $imgsrc = $document_root.$imgsrc;
    1889818909                            }
    1889918910                        }
     
    2428024291                    } else {
    2428124292                        // fix image path
     24293                        $document_root = sanitize_text_field(wp_unslash($_SERVER['DOCUMENT_ROOT']??''));
    2428224294                        if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) {
    2428324295                            // replace relative path with full server path
    2428424296                            $img = $this->svgdir.'/'.$img;
    2428524297                        }
    24286                         if (($img[0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
    24287                             $findroot = strpos($img, $_SERVER['DOCUMENT_ROOT']);
     24298                        if (($img[0] == '/') AND !empty($document_root) AND ($document_root != '/')) {
     24299                            $findroot = strpos($img, $document_root);
    2428824300                            if (($findroot === false) OR ($findroot > 1)) {
    24289                                 if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
    24290                                     $img = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$img;
     24301                                if (substr($document_root, -1) == '/') {
     24302                                    $img = substr($document_root, 0, -1).$img;
    2429124303                                } else {
    24292                                     $img = $_SERVER['DOCUMENT_ROOT'].$img;
     24304                                    $img = $document_root.$img;
    2429324305                                }
    2429424306                            }
  • seur/trunk/classes/tcpdf/tcpdf_autoconfig.php

    r3120329 r3176965  
    4242
    4343// DOCUMENT_ROOT fix for IIS Webserver
    44 if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
    45     if(isset($_SERVER['SCRIPT_FILENAME'])) {
    46         $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
    47     } elseif(isset($_SERVER['PATH_TRANSLATED'])) {
    48         $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
    49     } else {
    50         // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
    51         $_SERVER['DOCUMENT_ROOT'] = '/';
    52     }
    53 }
    54 $_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']);
    55 if (substr($_SERVER['DOCUMENT_ROOT'], -1) != '/') {
    56     $_SERVER['DOCUMENT_ROOT'] .= '/';
    57 }
     44$php_self = sanitize_text_field(wp_unslash($_SERVER['PHP_SELF'] ?? ''));
     45$script_filename = sanitize_text_field(wp_unslash($_SERVER['SCRIPT_FILENAME'] ?? ''));
     46$path_translated = sanitize_text_field(wp_unslash($_SERVER['PATH_TRANSLATED'] ?? ''));
     47$document_root = sanitize_text_field(wp_unslash($_SERVER['DOCUMENT_ROOT'] ?? ''));
     48
     49if (empty($document_root)) {
     50    if (!empty($script_filename)) {
     51        $document_root = str_replace('\\', '/',
     52            substr($script_filename, 0, -strlen($php_self)));
     53    } elseif (!empty($path_translated)) {
     54        $document_root = str_replace('\\', '/',
     55            substr(str_replace('\\\\', '\\', $path_translated), 0, -strlen($php_self)));
     56    } else {
     57        $document_root = '/';  // Default to root if all else fails
     58    }
     59}
     60$document_root = rtrim(str_replace('//', '/', $document_root), '/') . '/';
     61$_SERVER['DOCUMENT_ROOT'] = $document_root;
    5862
    5963// Load main configuration file only if the K_TCPDF_EXTERNAL_CONFIG constant is set to false.
     
    7781}
    7882
     83
    7984if (!defined('K_PATH_URL')) {
    80     $k_path_url = K_PATH_MAIN; // default value for console mode
    81     if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
    82         if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND (strtolower($_SERVER['HTTPS']) != 'off')) {
    83             $k_path_url = 'https://';
    84         } else {
    85             $k_path_url = 'http://';
    86         }
    87         $k_path_url .= $_SERVER['HTTP_HOST'];
    88         $k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
    89     }
    90     define ('K_PATH_URL', $k_path_url);
     85    $k_path_url = K_PATH_MAIN; // Default value for console mode
     86    $http_host = sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'] ?? ''));
     87    $https_flag = sanitize_text_field(wp_unslash($_SERVER['HTTPS'] ?? ''));
     88    $document_root = sanitize_text_field(wp_unslash($_SERVER['DOCUMENT_ROOT'] ?? ''));
     89
     90    if (!empty($http_host)) {
     91        $k_path_url = (strtolower($https_flag) === 'on') ? 'https://' : 'http://';
     92        $k_path_url .= $http_host;
     93        $k_path_url .= str_replace('\\', '/', substr(K_PATH_MAIN, strlen($document_root) - 1));
     94    }
     95    define('K_PATH_URL', $k_path_url);
    9196}
    9297
  • seur/trunk/classes/tcpdf/tcpdi.php

    r3120329 r3176965  
    118118     */
    119119    function _getPdfParser($filename) {
    120         $data = file_get_contents($filename);
    121         return new tcpdi_parser($data, $filename, PDF_PARSER_ERROR_HANDLER_EXCEPTION);
     120        global $wp_filesystem;
     121        if (empty($wp_filesystem)) {
     122            require_once(ABSPATH . '/wp-admin/includes/file.php');
     123            WP_Filesystem();
     124        }
     125        $data = $wp_filesystem->get_contents($filename);
     126        return new tcpdi_parser($data, $filename, PDF_PARSER_ERROR_HANDLER_EXCEPTION);
    122127    }
    123128   
  • seur/trunk/classes/tcpdf/tcpdi_parser.php

    r3120329 r3176965  
    14201420        // exit program and print error.
    14211421        if ($this->errorHandler == PDF_PARSER_ERROR_HANDLER_PHP_DIE) {
    1422           die("<strong>TCPDI_PARSER ERROR [{$this->uniqueid}]: </strong>".$msg);
     1422          die("<strong>TCPDI_PARSER ERROR [".esc_attr($this->uniqueid)."]: </strong>".esc_attr($msg));
    14231423        }
    14241424        elseif ($this->errorHandler == PDF_PARSER_ERROR_HANDLER_EXCEPTION) {
    1425           throw new TCPdiParserException($msg);
     1425          throw new TCPdiParserException(esc_attr($msg));
    14261426        }
    14271427        else {
    1428           die("<strong>TCPDI_PARSER ERROR [{$this->uniqueid}]: </strong>".$msg);
     1428          die("<strong>TCPDI_PARSER ERROR [".esc_attr($this->uniqueid)."]: </strong>".esc_attr($msg));
    14291429        }
    14301430    }
  • seur/trunk/core/functions/functions.php

    r3159775 r3176965  
    5353 */
    5454function seur_api_check_url_exists( $url ) {
    55     $exception_message = '';
    56     try {
    57         $curl_client = curl_init($url);
    58     } catch ( Exception $e ) {
    59         $exception_message = $e->getMessage();
    60     }
    61     if ( ! $exception_message ) {
    62         return true;
    63     } else {
    64         return false;
    65     }
     55    /*
     56    $response = wp_remote_head( $url );
     57    if ( is_wp_error( $response ) ) {
     58        return false;
     59    }
     60    $status_code = wp_remote_retrieve_response_code( $response );
     61    return ( $status_code >= 200 && $status_code < 400 );
     62    */
     63    return true;
    6664}
    6765
     
    15101508            $response['data']['ecbs'] = $ecbs;
    15111509            $response['data']['parcelNumbers'] = $parcelNumbers;
    1512             $response = json_decode(json_encode($response));
     1510            //$response = json_decode(json_encode($response));
    15131511        }
    15141512
     
    15311529        $order->update_meta_data('_seur_label_trackingNumber', $trackingNumber );
    15321530        $order->update_meta_data('_seur_label_id_number', $result['label_ids']);
     1531        $order->update_meta_data('_seur_shipping_order_label_downloaded', 'yes');
    15331532        $order->save_meta_data();
    15341533
     
    15661565    $preparedData['seur_shipping_method']     = $seur_shipping_method;
    15671566    //$preparedData['seur_shipping_method_id']  = $seur_shipping_method_id;
    1568     $preparedData['date']                     = date( 'd-m-Y' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
     1567    $preparedData['date']                     = gmdate( 'd-m-Y' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
    15691568    $preparedData['mobile_shipping']          = cleanPhone($order->get_meta('_shipping_mobile_phone', true ));
    15701569    $preparedData['mobile_billing']           = cleanPhone($order->get_meta('_billing_mobile_phone', true ));
     
    17341733            return 'Error 1: postcode not found';
    17351734        } else { // postalCode and country exist.
    1736             $fran = $fran[0]->depot;
     1735            $fran = $fran[0]['depot'];
    17371736            if ( '74' === $fran || '77' === $fran || '56' === $fran || '35' === $fran || '38' === $fran || '52' === $fran || '60' === $fran || '70' === $fran ) {
    17381737                $shipping_class = SHIPPING_CLASS_NACIONAL_FRANQUICIAS;
     
    17481747
    17491748    $preparedData['seur_saturday_shipping'] = '';
    1750     if ( 0 === (int) $shipping_class && 'Friday' === date( 'l' ) ) { // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
     1749    if ( 0 === (int) $shipping_class && 'Friday' === gmdate( 'l' ) ) { // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
    17511750        if (( 'ES' === $customer_country || 'AD' === $customer_country || 'PT' === $customer_country ) &&
    17521751            ( '3' === $preparedData['seur_service'] || '9' === $preparedData['seur_service'] ) ) {
  • seur/trunk/core/help/seur-help-tabs.php

    r3119152 r3176965  
    7272        array(
    7373            'id'      => 'seur_manifest_help_tab',
    74             'title'   => __( 'Manifest' ),
     74            'title'   => __( 'Manifest', 'seur' ),
    7575            'content' => '<p>' . __( 'Download the list of packages with the content of the deliveries notified to SEUR as from the date you choose.', 'seur' ) . '</p>
    7676                        <p>' . __( 'If you must hand over a list to the carrier, remember to print two copies: one for you and one for the carrier', 'seur' ) . '</p>',
     
    150150            array(
    151151                'id'      => 'seur_label_help_tab',
    152                 'title'   => __( 'Label List' ),
     152                'title'   => __( 'Label List', 'seur' ),
    153153                'content' => '<p>' . __( 'From this screen you can get the order labels requested from menu WooCommerce > Orders.', 'seur' ) . '</p>',
    154154            )
  • seur/trunk/core/installer.php

    r3119152 r3176965  
    6363    $products = get_seur_product();
    6464
    65     $sql = "SELECT option_name, option_value as custom_name
    66             FROM ".$wpdb->prefix."options
    67             where option_name like '%_custom_name_field' and option_value != ''";
    68     $ratesCustomNames = $wpdb->get_results( $sql ); //custom names
     65    $ratesCustomNames = $wpdb->get_results($wpdb->prepare("
     66        SELECT option_name, option_value as custom_name
     67        FROM ".$wpdb->prefix."options
     68        where option_name like %s and option_value != ''
     69    ", ['%_custom_name_field'])); //custom names
    6970
    7071    foreach ($products as $code => $product) {
     
    7879    }
    7980
    80     $sql = "select order_id, order_item_name
     81    $ordersShippingMethods = $wpdb->get_results($wpdb->prepare("
     82        select order_id, order_item_name
    8183            from ".$wpdb->prefix . "woocommerce_order_items
    82             where order_item_type = 'shipping'";
    83     $ordersShippingMethods = $wpdb->get_results( $sql ); //custom names
     84            where order_item_type = %s
     85    ", ['shipping']));
    8486    foreach ($ordersShippingMethods as $orderShippingMethod) {
    8587        $rateName = $orderShippingMethod->order_item_name;
  • seur/trunk/core/labels-cpt/labels-cpt.php

    r3159775 r3176965  
    167167            $url_upload_dir  = get_site_option( 'seur_uploads_url_labels' );
    168168            $label_file_name = get_post_meta($label_id, '_seur_shipping_order_label_file_name', true );
    169             echo '<a href="' . $url_upload_dir . '/' . $label_file_name . '" class="button" download>' . esc_html__( ' Open ', 'seur' ) . '</a>';
     169            echo '<a href="' . esc_url( $url_upload_dir . '/' . $label_file_name ) . '" class="button" download>' . esc_html__( ' Open ', 'seur' ) . '</a>';
    170170            break;
    171171    }
     
    353353function seur_bulk_actions_labels_screen( $bulk_actions ) {
    354354
    355     $bulk_actions['download_seur_label']  = __( 'Download  SEUR Labels', 'download_seur_label' );
    356     $bulk_actions['update_seur_tracking'] = __( 'Update SEUR Tracking', 'update_seur_tracking' );
    357     $bulk_actions['generate_seur_manifest'] = __( 'Generate Manifest', 'generate_seur_manifest' );
     355    $bulk_actions['download_seur_label']  = __( 'Download  SEUR Labels', 'seur' );
     356    $bulk_actions['update_seur_tracking'] = __( 'Update SEUR Tracking', 'seur' );
     357    $bulk_actions['generate_seur_manifest'] = __( 'Generate Manifest', 'seur' );
    358358    return $bulk_actions;
    359359}
     
    368368 */
    369369function seur_bulk_actions_handler( $redirect_to, $doaction, $labels_ids ) {
    370     if ( 'download_seur_label' !== $doaction && 'update_seur_tracking' !== $doaction && 'generate_seur_manifest' != $doaction ) {
     370    global $wp_filesystem;
     371
     372    if ( 'download_seur_label' !== $doaction && 'update_seur_tracking' !== $doaction && 'generate_seur_manifest' != $doaction ) {
    371373        return $redirect_to;
    372374    }
    373375    if ( 'download_seur_label' === $doaction ) {
    374376
    375         $date = date( 'd-m-Y-H-i-s' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
     377        $date = gmdate( 'd-m-Y-H-i-s' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
    376378        $type = seur_get_file_type(seur()->get_option( 'seur_tipo_etiqueta_field' ));
    377379        $bulk_label_name = 'label_bulk_' . $date . seur_get_file_type_extension($type);
     
    413415
    414416        if ($type=='TERMICA') {
    415             file_put_contents( $upload_path, $fp);
     417            $wp_filesystem->put_contents( $upload_path, $fp, FS_CHMOD_FILE);
    416418        } else {
    417419            $pdf->merge('file', $upload_path);
     
    483485            $manifest['postalcode'] = get_option( 'seur_postal_field' );
    484486            $manifest['city'] = get_option( 'seur_poblacion_field' );
    485             $manifest['date'] = date('d/m/Y');
    486             $manifest['hour'] = date('H:i');
     487            $manifest['date'] = gmdate('d/m/Y');
     488            $manifest['hour'] = gmdate('H:i');
    487489
    488490            $manifest_header = getManifestHeader($manifest);
     
    501503            $pdf->AddPage('P', 'A4');
    502504            $pdf->writeHTML($manifest_content, false, false, false, false, 'P');
    503             $pdf->Output("Manifiesto_".$ccc."_".date('YmdHis').".pdf", 'I');
     505            $pdf->Output("Manifiesto_".$ccc."_".gmdate('YmdHis').".pdf", 'I');
    504506        }
    505507
     
    665667    <table style="padding:2px; border:1px solid #000;">
    666668        <tr>
    667             <td colspan="2" style="border-bottom:1px solid #000;border-right:1px solid #000;">INFORME DE DETALLE DE ENVIOS Y BULTOS de '.date('d/m/Y').'</td>
     669            <td colspan="2" style="border-bottom:1px solid #000;border-right:1px solid #000;">INFORME DE DETALLE DE ENVIOS Y BULTOS de '.gmdate('d/m/Y').'</td>
    668670            <td style="border-bottom:1px solid #000;">TOTAL GENERAL </td>
    669671        </tr>
     
    712714        $url_to_dir       = seur_upload_url( 'labels' ); ?>
    713715        <div class="notice notice-success is-dismissible">
    714             <p><?php echo esc_html__( 'Bulk Print ready, please press Download Bulk Labels button for download the file. ' ) . '<a href="' . $url_to_dir . '/' . esc_html( $file_name ) . '" class="button" download>' . esc_html__( ' Download Bulk Labels ', 'seur' ) . '</a>'; ?></p>
     716            <p>
     717                <?php echo esc_html__( 'Bulk Print ready, please press Download Bulk Labels button for download the file.', 'seur' ) . ' <a href="' . esc_url( $url_to_dir . '/' . esc_html( $file_name ) ) . '" class="button" download>' . esc_html__( ' Download Bulk Labels ', 'seur' ) . '</a>'; ?>
     718            </p>
    715719        </div>
    716720        <?php
  • seur/trunk/core/pages/about.php

    r2643080 r3176965  
    1717            <?php
    1818            // translators: SEUR Version.
    19             printf( esc_html__( 'Welcome to SEUR %s' ), esc_html( SEUR_OFFICIAL_VERSION ) );
     19            printf( esc_html__( 'Welcome to SEUR %s', 'seur' ), esc_html( SEUR_OFFICIAL_VERSION ) );
    2020            ?>
    2121        </h1>
     
    2929            <?php
    3030            // translators: Seur version.
    31             printf( esc_html__( 'Version %s' ), esc_html( SEUR_OFFICIAL_VERSION ) );
     31            printf( esc_html__( 'Version %s', 'seur' ), esc_html( SEUR_OFFICIAL_VERSION ) );
    3232            ?>
    3333        </div>
  • seur/trunk/core/pages/rates/custom-name-rates.php

    r3119152 r3176965  
    55    <br>
    66
    7     <p><?php _e( 'Custom Names for Seur Rates', 'seur' ); ?></p>
     7    <p><?php esc_html_e( 'Custom Names for Seur Rates', 'seur' ); ?></p>
    88
    99    <hr>
     
    1212    if ( isset( $_POST['seur_custom_name_rates_post'] ) &&
    1313        ( ! isset( $_POST['seur_custom_name_rates_nonce_field'] )  ||
    14             ! wp_verify_nonce( $_POST['seur_custom_name_rates_nonce_field'], 'seur_custom_name_rates' ) )
     14            ! wp_verify_nonce( sanitize_text_field(wp_unslash($_POST['seur_custom_name_rates_nonce_field'])), 'seur_custom_name_rates' ) )
    1515    ) {
    1616        print 'Sorry, your nonce did not verify.';
     
    2121    if (  isset( $_POST['seur_custom_name_rates_post'] ) ) {
    2222        foreach ($products as $custom_name => $product) {
    23             update_option ($product['field'].'_custom_name_field', sanitize_text_field($_POST[$product['field'].'_custom_name_field']));
     23            update_option ($product['field'].'_custom_name_field',
     24                sanitize_text_field(wp_unslash(isset($_POST[$product['field'].'_custom_name_field'])??''))
     25            );
    2426        }
    2527    }
     
    3234                <tbody>
    3335                    <?php foreach ($products as $custom_name => $product) {
    34                         echo '<tr>
    35                         <th scope="row">' . $custom_name . '</th>
    36                         <td><input
    37                             title="' . $custom_name . '"
    38                             type="text" name="' . $product['field'] . '_custom_name_field"
    39                             value="' . (get_option($product['field'].'_custom_name_field') ?? '') . '" size="40"></td>
    40                         </tr>';
     36                        echo '<tr>
     37                            <th scope="row">' . esc_html( $custom_name ) . '</th>
     38                            <td><input
     39                                title="' . esc_attr( $custom_name ) . '"
     40                                type="text" name="' . esc_attr( $product['field'] ) . '_custom_name_field"
     41                                value="' . esc_attr( get_option( $product['field'] . '_custom_name_field' ) ?? '' ) . '" size="40"></td>
     42                          </tr>';
     43
    4144                    } ?>
    4245                    <input type="hidden" name="seur_custom_name_rates_post" value="true" >
     
    4548            </table>
    4649
    47             <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Update Options', 'seur' ); ?>"></p>
     50            <p class="submit">
     51                <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Update Options', 'seur' ); ?>">
     52            </p>
    4853        </form>
    4954    </div>
  • seur/trunk/core/pages/rates/limit-price-weight-rates.php

    r3119152 r3176965  
    2828                    $products = seur()->get_products();
    2929                    foreach ( $products as $code => $product ) {
    30                         if (isset( $_POST['seur_limit_price_weight_rates_post'] )) {
     30                        if (isset( $_POST['seur_limit_price_weight_rates_post']) && isset( $_POST[$product['field'] . '_max_price_field'] ) ) {
    3131                            $max_price_value = sanitize_text_field( wp_unslash( $_POST[$product['field'] . '_max_price_field'] ) );
    3232                            update_option( $product['field'] . '_max_price_field', $max_price_value );
     
    3434
    3535                        $max_price_field = get_option($product['field'] . '_max_price_field');
    36                         echo '<tr>
    37                             <th scope="row">'.$code.'</th>
    38                             <td><input title="'. $code.'" type="text"
    39                                 name="'.$product['field'].'_max_price_field"
    40                                 value="'. ($max_price_field ? esc_html( $max_price_field ):'').'" size="40">
     36                        echo '<tr>
     37                            <th scope="row">' . esc_html( $code ) . '</th>
     38                            <td><input title="' . esc_attr( $code ) . '" type="text"
     39                                name="' . esc_attr( $product['field'] ) . '_max_price_field"
     40                                value="' . ( $max_price_field ? esc_html( $max_price_field ) : '' ) . '" size="40">
    4141                            </td>
    4242                        </tr>';
  • seur/trunk/core/pages/rates/seur-add-form.php

    r3119152 r3176965  
    1717    $rates_type = get_option( 'seur_rates_type_field' );
    1818
    19     $min       = __( 'Min '.$rates_type.' (=)', 'seur' );
    20     $title_min = __( 'The product '.$rates_type.' is equal or mayor of this field', 'seur' );
    21     $max       = __( 'Max '.$rates_type.' (<)', 'seur' );
    22     $title_max = __( 'The product '.$rates_type.' is minor of this field', 'seur' );
     19    // translators: %s is the type of rate (e.g., weight, price).
     20    $min = sprintf( __( 'Min %s (=)', 'seur' ), esc_html( $rates_type ) );
     21
     22    // translators: %s is the type of rate (e.g., weight, price).
     23    $title_min = sprintf( __( 'The product %s is equal or greater than this field', 'seur' ), esc_html( $rates_type ) );
     24
     25    // translators: %s is the type of rate (e.g., weight, price).
     26    $max = sprintf( __( 'Max %s (<)', 'seur' ), esc_html( $rates_type ) );
     27
     28    // translators: %s is the type of rate (e.g., weight, price).
     29    $title_max = sprintf( __( 'The product %s is less than this field', 'seur' ), esc_html( $rates_type ) );
     30
    2331    ?>
    2432    <style type="text/css">
     
    4048                <td><?php esc_html_e( 'Rate', 'seur' ); ?></td>
    4149                <td>
    42                     <select class="select rate" id="rate"  title="<?php esc_html_e( 'Select Rate to apply', 'seur' ); ?>" name="rate">
    43                         <option value="Select"><?php esc_html_e( 'Select a Rate', 'seur' ); ?></option>
     50                    <select class="select rate" id="rate"  title="<?php esc_html_e( 'Select Rate to apply', 'seur' ); ?>" name="rate" required>
     51                        <option value=""><?php esc_html_e( 'Select a Rate', 'seur' ); ?></option>
    4452                        <?php
    4553                        $registros = seur()->get_products();
     
    5361                <td><?php esc_html_e( 'Country', 'seur' ); ?></td>
    5462                <td id="countryid">
    55                     <select class="select country" id="country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="country">
     63                    <select class="select country" id="country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="country" required>
    5664                        <?php
    57                         echo '<option value="Select">' . esc_html__( 'Select a Country', 'seur' ) . '</option>';
     65                        echo '<option value="">' . esc_html__( 'Select a Country', 'seur' ) . '</option>';
    5866                        echo '<option value="ES">' . esc_html__( 'Spain', 'seur' ) . '</option>';
    5967                        ?>
     
    7381            <tr>
    7482                <td><?php echo esc_html( $min ); ?></td>
    75                 <td><input title="<?php echo esc_html( $title_min ); ?>" type='text' name='min<?php echo $rates_type; ?>' class='form-control' placeholder='EX : 0.50' required=""></td>
     83                <td>
     84                    <input title="<?php echo esc_html( $title_min ); ?>" type='text' name='min<?php echo esc_attr( $rates_type ); ?>' class='form-control' placeholder='EX : 0.50' required="">
     85                </td>
    7686            </tr>
    7787            <tr>
    7888                <td><?php echo esc_html( $max ); ?></td>
    79                 <td><input title="<?php echo esc_html( $title_max ); ?>" type='text' name='max<?php echo $rates_type; ?>' class='form-control' placeholder='EX : 100.50' required=""></td>
     89                <td>
     90                    <input title="<?php echo esc_html( $title_max ); ?>" type='text' name='max<?php echo esc_attr( $rates_type ); ?>' class='form-control' placeholder='EX : 100.50' required="">
     91                </td>
    8092            </tr>
    8193            <tr>
  • seur/trunk/core/pages/rates/seur-country-state-process.php

    r3130893 r3176965  
    1717        $countries = $products[$rate]['pais'];
    1818        $options = seur()->getCountries($countries);
    19         echo '<select class="select country" id="country" title="' . esc_html__( 'Select Country', 'seur' ) . '" name="country">';
    20         echo '<option value="NULL">' . esc_html__( 'Select', 'seur' ) . '</option>';
     19        echo '<select class="select country" id="country" title="' . esc_html__( 'Select Country', 'seur' ) . '" name="country" required>';
     20        echo '<option value="">' . esc_html__( 'Select', 'seur' ) . '</option>';
    2121        if (count($countries)==1 && $countries[0] !=='ES') {
    2222            echo '<option value="*">' . esc_html__( 'All Countries', 'seur' ) . '</option>';
    2323        }
    2424        foreach ($options as $code => $country) {
    25             echo '<option value="'.$code.'">' . esc_html__( $country, 'seur' ) . '</option>';
     25            echo '<option value="' . esc_attr( $code ) . '">' . esc_html( $country ) . '</option>';
    2626        }
    2727        echo '</select>';
     
    4747            $title = 'Type State';
    4848            $placeholder = 'EX : State';
    49             $value = 'required=""';
     49            $value = '';
    5050            if ( '*' === $country) {
    5151                $title = 'No needed';
     
    5353                $value = 'value="*" readonly';
    5454            }
    55             echo '<input title="' . esc_html__( $title, 'seur' ) . '" type="text" name="state"
    56                  class="form-control" placeholder="' . esc_html__( $placeholder , 'seur' ) . '" '.$value.'
    57                  >';
     55            echo '<input title="' . esc_html( $title ) . '" type="text" name="state"
     56                 class="form-control" placeholder="' . esc_html( $placeholder ) . '" value="' . esc_attr( $value ) . '">';
     57
     58
    5859        }
    5960        unset( $country );
  • seur/trunk/core/pages/rates/seur-custom-rates.php

    r3119152 r3176965  
    2828                    <th class="manage-column"><?php esc_html_e( 'State', 'seur' ); ?></th>
    2929                    <th class="manage-column"><?php esc_html_e( 'Postcode', 'seur' ); ?></th>
    30                     <th class="manage-column"><?php esc_html_e( 'Min '. $rates_type, 'seur' ); ?></th>
    31                     <th class="manage-column"><?php esc_html_e( 'Max '.$rates_type, 'seur' ); ?></th>
     30                    <?php // translators: %s is the type of rate (e.g., weight, price). ?>
     31                    <th class="manage-column"><?php printf( esc_html__( 'Min %s', 'seur' ), esc_html( $rates_type ) ); ?></th>
     32                    <?php // translators: %s is the type of rate (e.g., weight, price). ?>
     33                    <th class="manage-column"><?php printf( esc_html__( 'Max %s', 'seur' ), esc_html( $rates_type ) ); ?></th>
    3234                    <th class="manage-column"><?php esc_html_e( 'Rate Price', 'seur' ); ?></th>
    3335                    <th class="manage-column"><?php esc_html_e( 'edit', 'seur' ); ?></th>
     
    8486                        <th class="manage-column"><?php esc_html_e( 'State', 'seur' ); ?></th>
    8587                        <th class="manage-column"><?php esc_html_e( 'Postcode', 'seur' ); ?></th>
    86                         <th class="manage-column"><?php esc_html_e( 'Min '. $rates_type, 'seur' ); ?></th>
    87                         <th class="manage-column"><?php esc_html_e( 'Max '. $rates_type, 'seur' ); ?></th>
    88                         <th class="manage-column"><?php esc_html_e( 'Rate Price', 'seur' ); ?></th>
     88                        <?php /* translators: %s is the type of rate (e.g., weight, price) */ ?>
     89                        <th class="manage-column"><?php printf( esc_html__( 'Min %s', 'seur' ), esc_html( $rates_type ) ); ?></th>
     90                        <?php /* translators: %s is the type of rate (e.g., weight, price) */ ?>
     91                        <th class="manage-column"><?php printf( esc_html__( 'Max %s', 'seur' ), esc_html( $rates_type ) ); ?></th>
     92                        <th class="manage-column"><?php esc_html_e( 'Rate Price', 'seur' ); ?></th>
    8993                        <th class="manage-column"><?php esc_html_e( 'edit', 'seur' ); ?></th>
    9094                        <th class="manage-column"><?php esc_html_e( 'delete', 'seur' ); ?></th>
  • seur/trunk/core/pages/rates/seur-edit-form.php

    r3159775 r3176965  
    2727    }
    2828    $rates_type = get_option( 'seur_rates_type_field' );
    29     $min       = __( 'Min '.$rates_type.' (=)', 'seur' );
    30     $title_min = __( 'The product '.$rates_type.' is equal or mayor of this field', 'seur' );
    31     $max       = __( 'Max '.$rates_type.' (<)', 'seur' );
    32     $title_max = __( 'The product '.$rates_type.' is minor of this field', 'seur' );
    33     ?>
     29    // translators: %s is the type of rate (e.g., weight, price).
     30    $min = sprintf( __( 'Min %s (=)', 'seur' ), esc_html( $rates_type ) );
     31
     32    // translators: %s is the type of rate (e.g., weight, price).
     33    $title_min = sprintf( __( 'The product %s is equal or greater than this field', 'seur' ), esc_html( $rates_type ) );
     34
     35    // translators: %s is the type of rate (e.g., weight, price).
     36    $max = sprintf( __( 'Max %s (<)', 'seur' ), esc_html( $rates_type ) );
     37
     38    // translators: %s is the type of rate (e.g., weight, price).
     39    $title_max = sprintf( __( 'The product %s is less than this field', 'seur' ), esc_html( $rates_type ) );
     40
     41
     42    ?>
    3443    <style type="text/css">
    3544    #dis{
     
    6271                <td><?php esc_html_e( 'Country', 'seur' ); ?></td>
    6372                <td id="countryid">
    64                     <select class="select country" value="Select" id="country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="country">
     73                    <select class="select country" value="Select" id="country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="country" required>
    6574                        <?php
    6675                        if ( 'ES' === $getrate->country || 'PT' === $getrate->country || 'AD' === $getrate->country ) {
     
    136145            <tr>
    137146                <td><?php echo esc_html( $min ); ?></td>
    138                 <td><input title="<?php echo esc_html( $title_min ); ?>" type='text' name='min<?php echo $rates_type; ?>' value='<?php echo esc_html( $min_value ); ?>' class='form-control' placeholder='EX : 0.50' required=""></td>
     147                <td>
     148                    <input title="<?php echo esc_html( $title_min ); ?>" type='text' name='min<?php echo esc_attr( $rates_type ); ?>' value='<?php echo esc_html( $min_value ); ?>' class='form-control' placeholder='EX : 0.50' required="">
     149                </td>
    139150            </tr>
    140151            <tr>
    141152                <td><?php echo esc_html( $max ); ?></td>
    142                 <td><input title="<?php echo esc_html( $title_max ); ?>" type='text' name='max<?php echo $rates_type; ?>' value='<?php echo esc_html( $max_value ); ?>' class='form-control' placeholder='EX : 100.34' required=""></td>
     153                <td>
     154                    <input title="<?php echo esc_html( $title_max ); ?>" type='text' name='max<?php echo esc_attr( $rates_type ); ?>' value='<?php echo esc_html( $max_value ); ?>' class='form-control' placeholder='EX : 100.34' required="">
     155                </td>
    143156            </tr>
    144157            <tr>
  • seur/trunk/core/pages/rates/seur-import-custom-rates.php

    r3120329 r3176965  
    99    exit; // Exit if accessed directly.
    1010}
     11
    1112$rates_type = get_option( 'seur_rates_type_field' );
    12 ?>
    13 
    14 <?php
    15 if ( isset( $_POST['import_custom_rates'] ) ) {
    16     try{
    17         // Validar que el archivo fue subido sin errores
    18         if ( isset( $_FILES['csv_file'] ) && $_FILES['csv_file']['error'] === UPLOAD_ERR_OK ) {
    19             $file = $_FILES['csv_file'];
    20 
    21             // Validar que el archivo es un CSV
    22             $file_type = wp_check_filetype( $file['name'] );
    23             if ( $file_type['ext'] !== 'csv' ) {
    24                 echo '<div class="notice notice-error"><p>El archivo subido no es un CSV.</p></div>';
    25             } else {
    26                 // Mover el archivo a una ubicación temporal
    27                 $upload_dir = wp_upload_dir();
    28                 $upload_path = $upload_dir['basedir'] . '/seur_import_custom_rates_csv/';
    29                 if ( ! file_exists( $upload_path ) ) {
    30                     wp_mkdir_p( $upload_path );
    31                 }
    32 
    33                 $uploaded_file = $upload_path . basename( $file['name'] );
    34                 if ( move_uploaded_file( $file['tmp_name'], $uploaded_file ) ) {
    35                     // Procesar el archivo CSV
    36                     $result = seur_process_csv( $uploaded_file );
    37 
    38                     if ( $result['error'] ) {
    39                         if(is_array($result['message'])){
    40                             echo '<div class="notice notice-error">';
    41                             echo '<ul>';
    42                             foreach($result['message'] as $message){
    43                                 echo '<li>' . esc_html( $message ) . '</li>';
    44                             }
    45                             echo '</ul>';
    46                             echo '</div>';
    47                         }else{
    48                             echo '<div class="notice notice-error"><p>' . esc_html( $result['message'] ) . '</p></div>';
    49                         }
    50                     } else {
    51                         echo '<div class="notice notice-success"><p>' . esc_html( $result['message'] ) . '</p></div>';
    52                     }
    53                 } else {
    54                     echo '<div class="notice notice-error"><p>Error al mover el archivo subido.</p></div>';
    55                 }
    56             }
    57         } else {
    58             echo '<div class="notice notice-error"><p>Error al subir el archivo.</p></div>';
    59         }
    60     }catch ( Exception $e ) {
    61         echo '<div class="notice notice-error"><p>' . esc_html( $e->getMessage() ) . '</p></div>';
    62     }
    63 
     13
     14// Verificar si el formulario fue enviado y si el nonce es válido
     15if ( isset( $_POST['import_custom_rates'] ) && check_admin_referer( 'seur_import_custom_rates_nonce', 'seur_import_custom_rates_nonce_field' ) ) {
     16    try {
     17        // Validar que el archivo fue subido sin errores
     18        if ( isset( $_FILES['csv_file'] ) && isset( $_FILES['csv_file']['error'] ) && $_FILES['csv_file']['error'] === UPLOAD_ERR_OK ) {
     19            $file = $_FILES['csv_file'];
     20
     21            // Validar que el archivo es un CSV
     22            $file_type = wp_check_filetype( $file['name'] );
     23            if ( $file_type['ext'] !== 'csv' ) {
     24                echo '<div class="notice notice-error"><p>El archivo subido no es un CSV.</p></div>';
     25            } else {
     26                // Inicializar WP_Filesystem
     27                if ( ! function_exists( 'request_filesystem_credentials' ) ) {
     28                    require_once( ABSPATH . 'wp-admin/includes/file.php' );
     29                }
     30
     31                global $wp_filesystem;
     32
     33                if ( ! WP_Filesystem( request_filesystem_credentials( '', '', false, false, null ) ) ) {
     34                    echo '<div class="notice notice-error"><p>Error al inicializar WP_Filesystem.</p></div>';
     35                    return;
     36                }
     37
     38                // Mover el archivo a una ubicación temporal
     39                $upload_dir = wp_upload_dir();
     40                $upload_path = trailingslashit( $upload_dir['basedir'] ) . 'seur_import_custom_rates_csv/';
     41
     42                if ( ! $wp_filesystem->is_dir( $upload_path ) ) {
     43                    $wp_filesystem->mkdir( $upload_path );
     44                }
     45
     46                $uploaded_file = $upload_path . sanitize_file_name( $file['name'] );
     47
     48                if ( $wp_filesystem->put_contents( $uploaded_file, $wp_filesystem->get_contents( $file['tmp_name'] ), FS_CHMOD_FILE ) ) {
     49                    // Procesar el archivo CSV
     50                    $result = seur_process_csv( $uploaded_file );
     51
     52                    if ( $result['error'] ) {
     53                        if ( is_array( $result['message'] ) ) {
     54                            echo '<div class="notice notice-error">';
     55                            echo '<ul>';
     56                            foreach ( $result['message'] as $message ) {
     57                                echo '<li>' . esc_html( $message ) . '</li>';
     58                            }
     59                            echo '</ul>';
     60                            echo '</div>';
     61                        } else {
     62                            echo '<div class="notice notice-error"><p>' . esc_html( $result['message'] ) . '</p></div>';
     63                        }
     64                    } else {
     65                        echo '<div class="notice notice-success"><p>' . esc_html( $result['message'] ) . '</p></div>';
     66                    }
     67                } else {
     68                    echo '<div class="notice notice-error"><p>Error al mover el archivo subido.</p></div>';
     69                }
     70            }
     71        } else {
     72            echo '<div class="notice notice-error"><p>Error al subir el archivo.</p></div>';
     73        }
     74    } catch ( Exception $e ) {
     75        echo '<div class="notice notice-error"><p>' . esc_html( $e->getMessage() ) . '</p></div>';
     76    }
     77} else {
     78    echo '<div class="notice notice-error"><p>Error de seguridad. Por favor, recargue la página e inténtelo de nuevo.</p></div>';
    6479}
    6580
     
    7085    try {
    7186        // Definir las columnas esperadas
    72         $expected_columns = array('ID', 'type', 'country', 'state', 'postcode', 'minprice', 'maxprice', 'minweight', 'maxweight', 'rate', 'rateprice');
     87        $expected_columns = array( 'ID', 'type', 'country', 'state', 'postcode', 'minprice', 'maxprice', 'minweight', 'maxweight', 'rate', 'rateprice' );
    7388
    7489        // Iniciar una transacción
    75         $wpdb->query('START TRANSACTION');
    76 
    77         // Abrir el archivo CSV
    78         if ( ( $handle = fopen( $file_path, 'r' ) ) !== FALSE ) {
    79             // Leer la primera línea (encabezado)
    80             $header = fgetcsv( $handle, 1000, ',' );
    81             if ( $header === FALSE || $header !== $expected_columns ) {
    82                 fclose( $handle );
    83                 $wpdb->query('ROLLBACK'); // Revertir la transacción
     90        $wpdb->query( 'START TRANSACTION' );
     91
     92        // Leer el archivo CSV usando WP_Filesystem
     93        global $wp_filesystem;
     94        $file_contents = $wp_filesystem->get_contents( $file_path );
     95
     96        if ( $file_contents !== false ) {
     97            $csv_lines = explode( "\n", $file_contents );
     98            $header = str_getcsv( array_shift( $csv_lines ) ); // Obtener encabezado
     99
     100            if ( $header !== $expected_columns ) {
    84101                return [
    85                     'error' => true,
    86                     'message' => 'El archivo CSV no contiene las columnas correctas.'
     102                    'error'   => true,
     103                    'message' => 'El archivo CSV no contiene las columnas correctas.',
    87104                ];
    88105            }
     
    91108
    92109            // Definir los estados válidos de España
    93             $valid_states_es = array('*', 'AV', 'C', 'AB', 'A', 'AL', 'VI', 'O', 'BA', 'PM', 'B', 'BI', 'BU', 'CC', 'CA', 'CO', 'S', 'CS', 'CE', 'CR', 'CU', 'SS', 'GI', 'GR', 'GU', 'H', 'HU', 'J', 'LO', 'GC', 'LE', 'L', 'LU', 'MA', 'M', 'ML', 'MU', 'NA', 'OR', 'P', 'PO', 'SA', 'TF', 'SG', 'SE', 'SO', 'T', 'TE', 'TO', 'V', 'VA', 'ZA', 'Z');
     110            $valid_states_es = array( '*', 'AV', 'C', 'AB', 'A', 'AL', 'VI', 'O', 'BA', 'PM', 'B', 'BI', 'BU', 'CC', 'CA', 'CO', 'S', 'CS', 'CE', 'CR', 'CU', 'SS', 'GI', 'GR', 'GU', 'H', 'HU', 'J', 'LO', 'GC', 'LE', 'L', 'LU', 'MA', 'M', 'ML', 'MU', 'NA', 'OR', 'P', 'PO', 'SA', 'TF', 'SG', 'SE', 'SO', 'T', 'TE', 'TO', 'V', 'VA', 'ZA', 'Z' );
    94111
    95112            // Leer el resto del archivo línea por línea
    96             while ( ( $data = fgetcsv( $handle, 1000, ',' ) ) !== FALSE ) {
    97                 // Mapear los datos a las columnas
    98                 $record = array_combine($header, $data);
     113            foreach ( $csv_lines as $line ) {
     114                $data   = str_getcsv( $line );
     115                $record = array_combine( $header, $data );
    99116
    100117                // Validar el campo type si no está vacío
     
    170187            if ( !empty($error_messages) ) {
    171188                $wpdb->query('ROLLBACK'); // Revertir la transacción
    172                 fclose( $handle );
    173189                return [
    174190                    'error' => true,
     
    179195            // Confirmar la transacción si no hay errores
    180196            $wpdb->query('COMMIT');
    181             fclose( $handle );
    182197            return [
    183198                'error' => false,
     
    199214    }
    200215}
    201 
    202216?>
    203217
    204218<div class="container">
    205     <br />
     219    <br />
    206220    <h1>Importación de Tarifas</h1>
    207221    <p>Para importar o actualizar las tarifas personalizadas de SEUR, siga estos pasos:</p>
     
    215229
    216230    <h4>Campos Permitidos en el Archivo CSV</h4>
    217     <p>El archivo CSV para la importación de tarifas SEUR debe contener las siguientes columnas:</p>
    218231    <ul>
    219232        <li><strong>ID</strong> (Obligatorio para actualización): Identificador único de la tarifa. Utilizado para actualizar tarifas existentes.</li>
     
    236249        <!-- Formulario para subir un archivo CSV -->
    237250        <form method="post" action="admin.php?page=seur_rates_prices&tab=import_custom_rates" enctype="multipart/form-data">
     251            <?php wp_nonce_field( 'seur_import_custom_rates_nonce', 'seur_import_custom_rates_nonce_field' ); ?>
    238252            <input type="hidden" name="import_custom_rates" value="true" >
    239253            <label for="csv_file"><?php echo esc_html__( 'Seleccione el archivo CSV', 'seur' ); ?>:</label>
  • seur/trunk/core/pages/rates/seur-rates.php

    r3119152 r3176965  
    7272        <label>
    7373            <span class="screen-reader-text"><?php esc_html_e( 'Country', 'seur' ); ?></span>
    74             <select class="select country" id="country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="pais">
     74            <select class="select country" id="country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="pais" required>
    7575            <?php
    7676            if ( ! empty( $pais ) && 'ES' === $pais ) {
     
    9494                $selectedpt = '';
    9595            }
    96             echo '<option value="NULL">' . esc_html__( 'Select', 'seur' ) . '</option>';
     96            echo '<option value="">' . esc_html__( 'Select', 'seur' ) . '</option>';
    9797            echo '<option value="ES" ' . esc_html( $selectedes ) . '>' . esc_html__( 'Spain', 'seur' ) . '</option>';
    9898            echo '<option value="PT" ' . esc_html( $selectedpt ) . '>' . esc_html__( 'Portugal', 'seur' ) . '</option>';
     
    137137                        echo ' selected';
    138138                    }
    139                     echo 'value="'.$identifier.'">'.$code.'</option>';
     139                    echo 'value="' . esc_attr( $identifier ) . '">' . esc_html( $code ) . '</option>';
    140140                } ?>
    141141            </select>
  • seur/trunk/core/pages/setting-options/advanced-settings.php

    r3119152 r3176965  
    128128    <select id="label_type" name="seur_tipo_etiqueta_field">
    129129        <?php foreach ($types as $value => $label) : ?>
    130             <option value="<?php echo $value; ?>" <?php if ( $option === $value) {echo ' selected';} ?>><?php echo $label; ?></option>
     130            <option value="<?php echo esc_attr( $value ); ?>" <?php if ( $option === $value ) { echo ' selected'; } ?>><?php echo esc_html( $label ); ?></option>
    131131        <?php endforeach; ?>
    132132    </select>
  • seur/trunk/core/pages/setting-options/user-settings.php

    r3119152 r3176965  
    136136function seur_test_field() {
    137137    ?>
    138     <input type="checkbox" class="js-switch-test" title="<?php _e( 'Test Mode', 'seur' ); ?>" name="seur_test_field" value="1" <?php checked( 1, seur()->get_option( 'seur_test_field' ), true ); ?>/>
     138    <input type="checkbox" class="js-switch-test" title="<?php esc_attr_e( 'Test Mode', 'seur' ); ?>" name="seur_test_field" value="1" <?php checked( 1, seur()->get_option( 'seur_test_field' ), true ); ?>/>
    139139    <?php
    140140}
     
    142142function seur_log_field() {
    143143    ?>
    144     <input type="checkbox" class="js-switch-log" title="<?php _e( 'Enable Logs', 'seur' ); ?>" name="seur_log_field" value="1" <?php checked( 1, seur()->get_option( 'seur_log_field' ), true ); ?>/>
     144    <input type="checkbox" class="js-switch-log" title="<?php esc_attr_e( 'Enable Logs', 'seur' ); ?>" name="seur_log_field" value="1" <?php checked( 1, seur()->get_option( 'seur_log_field' ), true ); ?>/>
    145145    <?php
    146146}
  • seur/trunk/core/pages/seur-get-labels.php

    r3119152 r3176965  
    3333        exit;
    3434    }
    35     $change_service = isset($_GET['change'])?$_GET['change']:'0';
    36     $weight_unit = get_option( 'woocommerce_weight_unit' );
     35    $change_service = false;
     36    if ( isset( $_GET['change'] ) ) {
     37        $change_service = sanitize_text_field( wp_unslash( $_GET['change'] ) );
     38        $change_service = ($change_service == 1);
     39    }
     40
     41    $weight_unit = get_option( 'woocommerce_weight_unit' );
    3742    $wc_order2 = wc_get_order( $orderid2 );
    3843    $weight      = $wc_order2->get_meta('_seur_cart_weight', true );
     
    5863            <label><?php esc_html_e( 'Number of Packages', 'seur' ); ?></label><br />
    5964            <input title="<?php esc_html_e( 'Number of Packages', 'seur' ); ?>" type="text" name="seur-number-packages" class="form-control" placeholder="<?php esc_html_e( 'EX: 2', 'seur' ); ?>" value="<?php echo esc_html( $value ); ?>" required="" <?php if ( ! empty( $shop2 ) ) { echo esc_html( $disabled ); } ?> /><br />
    60             <input type="hidden" name="seur-change-service" value="<?php echo  $change_service; ?>"/>
    61             <?php wp_nonce_field( 'seur_get_label_action', 'seur_get_label_nonce_field' ); ?>
     65            <?php if ($change_service) {
     66                echo '<input type="hidden" name="seur-change-service" value="1"/>';
     67            }
     68            wp_nonce_field( 'seur_get_label_action', 'seur_get_label_nonce_field' ); ?>
    6269            <input type="submit" class="seur_label_submit button button-primary" value="<?php esc_html_e( 'Get labels', 'seur' ); ?>" />
    6370        </form>
     
    6976        $weight      = '';
    7077        $numpackages = '';
    71         $changeService = false;
     78        $changeService = isset($_POST['seur-change-service']);
    7279        if ( isset( $_POST['order-id'] ) && isset( $_POST['seur-weight'] ) && isset( $_POST['seur-number-packages'] ) ) {
    7380            $order_id    = sanitize_text_field( wp_unslash( $_POST['order-id'] ) );
    7481            $weight      = sanitize_text_field( wp_unslash( $_POST['seur-weight'] ) );
    7582            $numpackages = sanitize_text_field( wp_unslash( $_POST['seur-number-packages'] ) );
    76             $changeService = sanitize_text_field( wp_unslash( $_POST['seur-change-service'] ) );
    7783        }
    7884
  • seur/trunk/core/pages/seur-pickup.php

    r2847513 r3176965  
    66 */
    77
    8 if ( ! defined( 'ABSPATH' ) ) {
     8if (!defined('ABSPATH')) {
    99    exit; // Exit if accessed directly.
    1010}
     
    1515 * @param WP_Post $post Post Data.
    1616 */
    17 function seur_pickup( $post ) {
     17function seur_pickup($post)
     18{
     19    $error_message = ''; // Variable para almacenar el mensaje de error.
     20
     21    // Procesar solicitudes de recogida o cancelación
     22    if (isset($_POST['request_normal'])) {
     23        // Lógica para solicitar recogida normal
     24        $date = gmdate( 'Y-m-d' );
     25        $data = array(
     26            'type' => 'normal',
     27            'date' => $date,
     28            'mfrom' => '09:00:00', // Hora de ejemplo
     29            'mto' => '13:00:00',
     30            'efrom' => '16:00:00',
     31            'eto' => '19:00:00',
     32            'ref' => 'normal_' . seur()->get_option('seur_accountnumber_field') . gmdate('ymdHis'),
     33        );
     34        $result = seur_collections($data);
     35        if (isset($result['errors'])) {
     36            // Si hay errores, almacenar el mensaje
     37            $error_message = 'Error: ' . $result['errors'][0]['detail'];
     38        } else {
     39            seur()->save_collection($result['data']['collectionRef'], 'normal');
     40            seur()->save_reference($result['data']['reference'], 'normal');
     41            seur()->save_date_normal($date);
     42
     43            // Redirigir para refrescar la página solo si no hay error
     44            $url = sanitize_url( wp_unslash($_SERVER['REQUEST_URI']??''));
     45            if ( !empty($url) ) {
     46                wp_redirect( $url );
     47                exit;
     48            }
     49        }
     50    }
     51
     52    if (isset($_POST['request_cold'])) {
     53        // Lógica para solicitar recogida fría
     54        $date = gmdate( 'Y-m-d' );
     55        $data = array(
     56            'type' => 'cold',
     57            'date' => $date,
     58            'mfrom' => '09:00:00', // Hora de ejemplo
     59            'mto' => '13:00:00',
     60            'efrom' => '16:00:00',
     61            'eto' => '19:00:00',
     62            'ref' => 'cold_' . seur()->get_option('seur_accountnumber_field') . gmdate('ymdHis'),
     63        );
     64        $result = seur_collections($data);
     65        if (isset($result['errors'])) {
     66            // Si hay errores, almacenar el mensaje
     67            $error_message = 'Error: ' . $result['errors'][0]['detail'];
     68        } else {
     69            seur()->save_collection($result['data']['collectionRef'], 'cold');
     70            seur()->save_reference($result['data']['reference'], 'cold');
     71            seur()->save_date_cold($date);
     72
     73            // Redirigir para refrescar la página solo si no hay error
     74            $url = sanitize_url( wp_unslash($_SERVER['REQUEST_URI']??''));
     75            if ( !empty($url) ) {
     76                wp_redirect( $url );
     77                exit;
     78            }
     79        }
     80    }
     81
     82    if (isset($_POST['cancel_normal'])) {
     83        // Lógica para cancelar recogida normal
     84        // Obtener la referencia de la recogida normal
     85        $reference_normal = seur()->get_collection('normal');
     86        $result = seur_cancel_collection($reference_normal);
     87
     88        if (isset($result['errors'])) {
     89            // Si hay errores, almacenar el mensaje
     90            $error_message = 'Error: ' . $result['errors'][0]['detail'];
     91        } else {
     92            seur()->cancel_collection('normal');
     93            seur()->cancel_reference('normal');
     94            seur()->cancel_date_normal();
     95
     96            // Redirigir para refrescar la página
     97            $url = sanitize_url( wp_unslash($_SERVER['REQUEST_URI']??''));
     98            if ( !empty($url) ) {
     99                wp_redirect( $url );
     100                exit;
     101            }
     102        }
     103    }
     104
     105    if (isset($_POST['cancel_cold'])) {
     106        // Lógica para cancelar recogida fría
     107
     108        $reference_cold = seur()->get_collection('cold');
     109        $result = seur_cancel_collection($reference_cold);
     110
     111        if (isset($result['errors'])) {
     112            // Si hay errores, almacenar el mensaje
     113            $error_message = 'Error: ' . $result['errors'][0]['detail'];
     114        } else {
     115            seur()->cancel_collection('cold');
     116            seur()->cancel_reference('cold');
     117            seur()->cancel_date_cold();
     118
     119            // Redirigir para refrescar la página
     120            $url = sanitize_url( wp_unslash($_SERVER['REQUEST_URI']??''));
     121            if ( !empty($url) ) {
     122                wp_redirect( $url );
     123                exit;
     124            }
     125        }
     126    }
    18127
    19128    ?>
    20     <div class="wrap">
    21     <h1 class="wp-heading-inline"><?php esc_html_e( 'Collection', 'seur' ); ?></h1>
    22     <hr class="wp-header-end">
    23     <?php esc_html_e( 'Generate an order for us to pick up your customers orders.', 'seur' ); ?>
    24     <form method="post"  name="formulario" width="100%">
    25         <?php
    26         if ( ! isset( $_POST['type'] ) ) {
    27             wp_nonce_field( 'seur_pickup_action', 'seur_pickup_nonce_field' );
    28         } else {
    29             if ( ! isset( $_POST['seur_pickup_nonce_field'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['seur_pickup_nonce_field'] ) ), 'seur_pickup_action' ) ) {
     129    <div class="wrap">
     130        <h1 class="wp-heading-inline"><?php esc_html_e('Collection Management', 'seur'); ?></h1>
     131        <hr class="wp-header-end">
     132        <form method="post" name="formulario" style="width: 100%;">
     133            <?php
     134            wp_nonce_field('seur_pickup_action', 'seur_pickup_nonce_field');
     135
     136            if (isset($_POST['seur_pickup_nonce_field']) && !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['seur_pickup_nonce_field'])), 'seur_pickup_action')) {
    30137                print 'Sorry, your nonce did not verify.';
    31138                exit;
    32             } else {
    33 
    34                 $tipo            = sanitize_text_field( wp_unslash( $_POST['type'] ) );
    35                 $md              = sanitize_text_field( wp_unslash( $_POST['Md'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
    36                 $mh              = sanitize_text_field( wp_unslash( $_POST['Mh'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
    37                 $td              = sanitize_text_field( wp_unslash( $_POST['Td'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
    38                 $th              = sanitize_text_field( wp_unslash( $_POST['Th'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
    39                 $now             = date( 'Y-m-d' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
    40                 $ref             = $tipo . seur()->get_option( 'seur_accountnumber_field' ) . gmdate( 'ymdHis' ); // . gmdate( 'm' ) . gmdate( 'd' ) . gmdate( 'H' ) . gmdate( 'i' ) . gmdate( 's' );
    41                 $data            = array();
    42                 $data['type']    = $tipo; // cold, normal.
    43                 $data['date']    = $now; // '2021-09-08-12:00:00.000'.
    44                 $data['mfrom']   = $md; // '09:00:00'
    45                 $data['mto']     = $mh; // '13:00:00'
    46                 $data['efrom']   = $td; // '16:00:00'
    47                 $data['eto']     = $th; // '19:00:00'
    48                 $data['comment'] = ''; // 'ENVIO DE PRUEBA'
    49                 $data['ref']     = $ref;
    50                 $result          = seur_collections( $data );
    51                 if ( $data ) {
    52                     $collectionref = $result['data']['collectionRef'];
    53                     $reference     = $result['data']['reference'];
    54                     if ( strpos( $reference, 'normal' ) !== false ) {
    55                         seur()->slog( 'Es recogida normal' );
    56                         seur()->save_collection( $collectionref, 'normal' );
    57                         seur()->save_reference( $reference, 'normal' );
    58                         seur()->save_date_normal( seur()->today() );
    59 
    60                     }
    61                     if ( strpos( $reference, 'cold' ) !== false ) {
    62                         seur()->slog( 'Es recogida frio' );
    63                         seur()->slog( 'Es recogida normal' );
    64                         seur()->save_collection( $collectionref, 'cold' );
    65                         seur()->save_reference( $reference, 'cold' );
    66                         seur()->save_date_cold( seur()->today() );
    67                     }
    68                     if ( seur()->log_is_acive() ) {
    69                         seur()->slog( '$result: ' . print_r( $result, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
    70                         seur()->slog( '$collectionRef: ' . $collectionref );
    71                         seur()->slog( '$reference: ' . $reference );
    72                     }
    73                 } else {
    74                     if ( seur()->log_is_acive() ) {
    75                         seur()->slog( '$result: Ha habido un problema' );
    76                     }
    77                 }
    78139            }
    79         }
    80 
    81         /**
    82          * Comprobar si tiene una recogida para hoy y mostrar sus situaciones
    83          */
    84 
    85         $date              = seur()->today();
    86         $collection_normal = seur()->get_collection( 'normal' );
    87         $collection_cold   = seur()->get_collection( 'cold' );
    88         $reference_normal  = seur()->get_reference( 'normal' );
    89         $reference_cold    = seur()->get_reference( 'cold' );
    90         $date_normal       = seur()->get_date_normal();
    91         $date_cold         = seur()->get_date_cold();
    92         $normal            = false;
    93         $cold              = false;
    94 
    95         if ( $date === $date_normal ) {
    96 
    97             echo "<div style='color:#e53920;font-weight:bold; font-size:12px;'>";
    98             echo esc_html__( 'You have a collection today', 'seur' );
    99             echo '<br>';
    100             echo esc_html__( 'Reference: ', 'seur' ) . esc_html( $reference_normal );
    101             echo '<br>';
    102             echo esc_html__( 'Collection: ', 'seur' ) . esc_html( $collection_normal );
    103             echo '</div>';
    104             $normal = true;
    105         }
    106         if ( $date === $date_cold ) {
    107 
    108             echo "<div style='color:#e53920;font-weight:bold; font-size:12px;'>";
    109             echo esc_html__( 'You have a Cold collection today', 'seur' );
    110             echo '<br>';
    111             echo esc_html__( 'Cold Reference: ', 'seur' ) . esc_html( $reference_cold );
    112             echo '<br>';
    113             echo esc_html__( 'Cold Collection: ', 'seur' ) . esc_html( $collection_cold );
    114             echo '</div>';
    115             $cold = true;
    116         }
    117 
    118         if ( $date === $date_normal && $date === $date_cold ) {
    119             return;
    120         }
    121 
    122         // -------------------------------------------------
    123         // NO TIENE RECOGIDA -> CONTINUA EL PROCESO
    124         // -------------------------------------------------
    125 
    126         // ********************************************
    127         // ** PARAMETROS INFORMATIVOS DE LA RECOGIDA **
    128         // ********************************************
    129         ?>
    130         <table width='100%' style='color:ed734d;font-weight:bold; font-size:12px;'>
    131 
    132             <tr>
    133                 <td>
    134                     <table width='50%'>
    135                         <tr>
    136                             <td colspan="2"><?php esc_html_e( 'COLLECTION', 'seur' ); ?></div><hr></td>
    137                         </tr>
    138                         <tr>
    139                             <td colspan="2"><?php esc_html_e( 'Select type.', 'seur' ); ?></div></td></tr>
    140                         </tr>
    141                         <tr>
    142                             <td>
    143                                 <?php esc_html_e( 'Type:', 'seur' ); ?>&nbsp;&nbsp;&nbsp;
    144                                 <select id="manana_desde_type" name="type">
    145                                 <?php
    146                                 if ( ! $cold ) {
    147                                     ?>
    148                                     <option value="cold"><?php esc_html_e( 'Cold Shipping', 'seur' ); ?></option>
    149                                     <?php
    150                                 }
    151                                 if ( ! $normal ) {
    152                                     ?>
    153                                     <option value="normal"><?php esc_html_e( 'Normal Shipping', 'seur' ); ?></option>
    154                                     <?php
    155                                 }
    156                                 ?>
    157                                 </select>
    158                             </td>
    159                         </td>
    160                     </tr>
    161                     <tr>
    162                 <td colslpan="2"><br><?php esc_html_e( 'Enter a schedule for Collection', 'seur' ); ?><br />
    163                 <?php esc_html_e( 'The minimum margin between each schedule has to be 2 hours.', 'seur' ); ?></div></td></tr>
    164             <tr>
    165             <td>
    166                 <?php esc_html_e( 'Morning from:', 'seur' ); ?>&nbsp;&nbsp;&nbsp;
    167                 <select id="manana_desde_type" name="Md">
    168                 <option value="none"<?php if ( 'none' === $md ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>><?php esc_html_e( 'None', 'seur' ); ?></option>
    169                 <option value="09:00:00"<?php if ( '09:00:00' === $md ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>09:00</option>
    170                 <option value="10:01:00"<?php if ( '10:01:00' === $md ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>10:00</option>
    171                 <option value="11:02:00"<?php if ( '11:02:00' === $md ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>11:00</option>
    172                 <option value="12:03:00"<?php if ( '12:03:00' === $md ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>12:00</option>
    173             </select>
    174             &nbsp;&nbsp;&nbsp;
    175             <?php esc_html_e( 'to', 'seur' ); ?>&nbsp;&nbsp;&nbsp;
    176             <select id="manana_hasta_type" name="Mh">
    177                 <option value="none"<?php if ( 'none' === $mh ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>><?php esc_html_e( 'None', 'seur' ); ?></option>
    178                 <option value="11:00:00"<?php if ( '11:00:00' === $mh ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>11:00</option>
    179                 <option value="12:01:00"<?php if ( '12:01:00' === $mh ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>12:00</option>
    180                 <option value="13:02:00"<?php if ( '13:02:00' === $mh ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>13:00</option>
    181                 <option value="14:03:00"<?php if ( '14:03:00' === $mh ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>14:00</option>
    182                 <option value="15:04:00"<?php if ( '15:04:00' === $mh ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>15:00</option>
    183             </select>
    184             </td></tr><tr>
    185             <td><?php esc_html_e( 'Afternoon From:', 'seur' ); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    186             <select id="tarde_desde_type" name="Td">
    187                 <option value="none"<?php if ( 'none' === $td ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>><?php esc_html_e( 'None', 'seur' ); ?></option>
    188                 <option value="15:00:00"<?php if ( '15:00:00' === $td ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>15:00</option>
    189                 <option value="16:01:00"<?php if ( '16:01:00' === $td ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>16:00</option>
    190                 <option value="17:02:00"<?php if ( '17:02:00' === $td ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>17:00</option>
    191                 <option value="18:03:00"<?php if ( '18:03:00' === $td ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>18:00</option>
    192             </select>
    193             &nbsp;&nbsp;&nbsp;
    194             <?php esc_html_e( 'to', 'seur' ); ?>&nbsp;&nbsp;&nbsp;
    195             <select id="tarde_hasta_type" name="Th">
    196                 <option value="none"<?php if ( 'none' === $th ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>><?php esc_html_e( 'None', 'seur' ); ?></option>
    197                 <option value="17:00:00"<?php if ( '17:00:00' === $th ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>17:00</option>
    198                 <option value="18:01:00"<?php if ( '18:01:00' === $th ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>18:00</option>
    199                 <option value="19:02:00"<?php if ( '19:02:00' === $th ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>19:00</option>
    200                 <option value="20:03:00"<?php if ( '20:03:00' === $th ) { echo ' selected'; } // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>>20:00</option>
    201             </select>
    202             </td>
    203             </tr>
    204             <tr><td colslpan=2><br><?php esc_html_e( 'If the schedule is only of mornings, leave the afternoon schedules with null.', 'seur' ); ?>
    205                 <br><?php esc_html_e( 'If schedule is only of afternoon leave the morning hours with null.', 'seur' ); ?>
    206                 </div></td></tr>
    207             </tr>
    208         </table>
    209     </form>
    210     <?php
    211 
    212     // Si no está setado, boton Solicitar.
    213     if ( ! isset( $_POST['type'] ) ) {
    214         submit_button( __( 'Request', 'seur' ) );
    215         return;
    216     }
    217     ?>
    218     </div>
     140
     141            // Obtener los datos de las recogidas actuales
     142            $date = gmdate( 'Y-m-d' );
     143            $collection_normal = seur()->get_collection('normal');
     144            $collection_cold = seur()->get_collection('cold');
     145            $reference_normal = seur()->get_reference('normal');
     146            $reference_cold = seur()->get_reference('cold');
     147            $date_normal = seur()->get_date_normal();
     148            $date_cold = seur()->get_date_cold();
     149
     150            // Mostrar errores si existen
     151            if ($error_message) {
     152                echo "<div style='color: red; font-weight: bold; margin-top: 20px;'>" . esc_html( $error_message ) . "</div>";
     153            }
     154
     155            // Paneles para normal y frío
     156            ?>
     157            <div class="seur-collection-wrapper" style="display: flex; justify-content: space-between; gap: 20px;">
     158                <!-- Panel para recogida normal -->
     159                <div class="collection-panel" style="background-color: #f1f1f1; border: 1px solid #ddd; padding: 20px; width: 48%; border-radius: 5px;">
     160                    <h2 style="font-size: 18px; font-weight: bold; text-align: center;"><?php esc_html_e('Normal Collection', 'seur'); ?></h2>
     161
     162                    <!-- Mostrar recogida activa -->
     163                    <?php if ($date === $date_normal): ?>
     164                        <div style="background-color: #e0ffe0; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
     165                            <p><?php esc_html_e('You have a Normal collection today', 'seur'); ?></p>
     166                            <p><?php esc_html_e('Reference: ', 'seur'); echo esc_html($reference_normal); ?></p>
     167                            <p><?php esc_html_e('Collection: ', 'seur'); echo esc_html($collection_normal); ?></p>
     168                        </div>
     169                    <?php endif; ?>
     170
     171                    <!-- Botón de solicitar/cancelar recogida -->
     172                    <?php if ($date === $date_normal): ?>
     173                        <button name="cancel_normal" type="submit" style="width: 100%; background-color: #e53935; color: #fff; padding: 10px; border: none; border-radius: 5px; cursor: pointer;">
     174                            <?php esc_html_e('Cancel Normal Collection', 'seur'); ?>
     175                        </button>
     176                    <?php else: ?>
     177                        <button name="request_normal" type="submit" style="width: 100%; background-color: #4CAF50; color: #fff; padding: 10px; border: none; border-radius: 5px; cursor: pointer;">
     178                            <?php esc_html_e('Request Normal Collection', 'seur'); ?>
     179                        </button>
     180                    <?php endif; ?>
     181                </div>
     182
     183                <!-- Panel para recogida fría -->
     184                <div class="collection-panel" style="background-color: #f1f1f1; border: 1px solid #ddd; padding: 20px; width: 48%; border-radius: 5px;">
     185                    <h2 style="font-size: 18px; font-weight: bold; text-align: center;"><?php esc_html_e('Cold Collection', 'seur'); ?></h2>
     186
     187                    <!-- Mostrar recogida activa -->
     188                    <?php if ($date === $date_cold): ?>
     189                        <div style="background-color: #e0ffe0; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
     190                            <p><?php esc_html_e('You have a Cold collection today', 'seur'); ?></p>
     191                            <p><?php esc_html_e('Reference: ', 'seur'); echo esc_html($reference_cold); ?></p>
     192                            <p><?php esc_html_e('Collection: ', 'seur'); echo esc_html($collection_cold); ?></p>
     193                        </div>
     194                    <?php endif; ?>
     195
     196                    <!-- Botón de solicitar/cancelar recogida -->
     197                    <?php if ($date === $date_cold): ?>
     198                        <button name="cancel_cold" type="submit" style="width: 100%; background-color: #e53935; color: #fff; padding: 10px; border: none; border-radius: 5px; cursor: pointer;">
     199                            <?php esc_html_e('Cancel Cold Collection', 'seur'); ?>
     200                        </button>
     201                    <?php else: ?>
     202                        <button name="request_cold" type="submit" style="width: 100%; background-color: #4CAF50; color: #fff; padding: 10px; border: none; border-radius: 5px; cursor: pointer;">
     203                            <?php esc_html_e('Request Cold Collection', 'seur'); ?>
     204                        </button>
     205                    <?php endif; ?>
     206                </div>
     207            </div>
     208        </form>
     209    </div>
    219210    <?php
    220211}
  • seur/trunk/core/pages/seur-products-services.php

    r3119152 r3176965  
    1919    ?>
    2020<div class="wrap">
    21     <h2><?php echo esc_html__( 'Products / Services', 'woocommerce-seur' ); ?></h2>
     21    <h2><?php echo esc_html__( 'Products / Services', 'seur' ); ?></h2>
    2222
    23     <h2 class="screen-reader-text"><?php esc_html_e( 'Products / Services List', 'woocommerce-seur' ); ?></h2>
    24     <p><?php esc_html_e( 'These services and products might not be available in your commercial proposal. Please verify with your SEUR sales contact that you have all combinations enabled.', 'woocommerce-seur' ); ?></p>
    25     <p><?php esc_html_e( 'List of combinations of SEUR Services and Products available in the plugin.', 'woocommerce-seur' ); ?></p>
     23    <h2 class="screen-reader-text"><?php esc_html_e( 'Products / Services List', 'seur' ); ?></h2>
     24    <p><?php esc_html_e( 'These services and products might not be available in your commercial proposal. Please verify with your SEUR sales contact that you have all combinations enabled.', 'seur' ); ?></p>
     25    <p><?php esc_html_e( 'List of combinations of SEUR Services and Products available in the plugin.', 'seur' ); ?></p>
    2626    <table class="wp-list-table widefat fixed striped pages">
    2727        <thead>
    2828            <tr>
    29                 <th scope="col" id="response" class="manage-column column-author column-primary"><?php esc_html_e( 'Description', 'woocommerce-seur' ); ?></th>
    30                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Service', 'woocommerce-seur' ); ?></th>
    31                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Product', 'woocommerce-seur' ); ?></th>
    32                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Type', 'woocommerce-seur' ); ?></th>
    33                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'County', 'woocommerce-seur' ); ?></th>
    34                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'State', 'woocommerce-seur' ); ?></th>
     29                <th scope="col" id="response" class="manage-column column-author column-primary"><?php esc_html_e( 'Description', 'seur' ); ?></th>
     30                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Service', 'seur' ); ?></th>
     31                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Product', 'seur' ); ?></th>
     32                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Type', 'seur' ); ?></th>
     33                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'County', 'seur' ); ?></th>
     34                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'State', 'seur' ); ?></th>
    3535            </tr>
    3636        </thead>
     
    6161        <tfoot>
    6262            <tr>
    63                 <th scope="col" id="response" class="manage-column column-author column-primary"><?php esc_html_e( 'Description', 'woocommerce-seur' ); ?></th>
    64                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Service', 'woocommerce-seur' ); ?></th>
    65                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Product', 'woocommerce-seur' ); ?></th>
    66                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Type', 'woocommerce-seur' ); ?></th>
    67                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Zone', 'woocommerce-seur' ); ?></th>
    68                 <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'State', 'woocommerce-seur' ); ?></th>
     63                <th scope="col" id="response" class="manage-column column-author column-primary"><?php esc_html_e( 'Description', 'seur' ); ?></th>
     64                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Service', 'seur' ); ?></th>
     65                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Product', 'seur' ); ?></th>
     66                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Type', 'seur' ); ?></th>
     67                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'Zone', 'seur' ); ?></th>
     68                <th scope="col" id="author" class="manage-column column-author"><?php esc_html_e( 'State', 'seur' ); ?></th>
    6969            </tr>
    7070        </tfoot>
  • seur/trunk/core/pages/status/status-check.php

    r3119152 r3176965  
    601601                    foreach ( $products as $code => $product ) {
    602602                        echo '<tr>
    603                             <td data-export-label="'.$code.'">'.$code.'</td>';
     603                            <td data-export-label="'.esc_attr($code).'">'.esc_attr($code).'</td>';
    604604                        if ( seur_check_service_names($code) ) {
    605605                            echo '<td><span class="yes">&#10004;</span></td>';
  • seur/trunk/core/woocommerce/includes/class-seur_local_shipping_method.php

    r3159775 r3176965  
    3838        $this->instance_form_fields = array(
    3939            'title' => array(
    40                 'title'       => __( 'Method Title' ),
     40                'title'       => __( 'Method Title', 'seur' ),
    4141                'type'        => 'text',
    42                 'description' => __( 'This controls the title which the user sees during checkout.' ),
    43                 'default'     => __( 'SEUR Local Pickup' ),
     42                'description' => __( 'This controls the title which the user sees during checkout.', 'seur' ),
     43                'default'     => __( 'SEUR Local Pickup', 'seur' ),
    4444                'desc_tip'    => true,
    4545            ),
     
    338338            }
    339339            echo '<br />';
    340             esc_html_e( 'Choose a location:', 'woocommerce-seur' );
     340            esc_html_e( 'Choose a location:', 'seur' );
    341341            echo '<div id="controls"></div>';
    342342            echo '<div id="seur-gmap" style="with:300px;height:250px;"></div>';
     
    437437function seur_validation_2shop_fields() {
    438438
    439     $seur_cutom_rate_ID = $_POST['shipping_method'][0];
     439    $seur_cutom_rate_ID = sanitize_text_field( wp_unslash(isset($_POST['shipping_method'][0])??''));
    440440    if (seur()->is_seur_local_method($seur_cutom_rate_ID)) {
    441441        $seur_pickup     = sanitize_text_field( wp_unslash( $_POST['seur_pickup'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.NonceVerification.Missing
     
    459459
    460460    if ( ! empty( $_POST['seur_pickup'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
    461         seur()->slog( '$_POST: ' . print_r( $_POST, true ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
    462         seur()->slog( '$_POST["seur_pickup"]: ' . print_r( $_POST['seur_pickup'], true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
    463461        $id              = sanitize_text_field( wp_unslash( $_POST['seur_pickup'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
    464462        $seur_depot      = 'seur_depot_' . $id;
  • seur/trunk/core/woocommerce/includes/class-wc-shipping-seur.php

    r3159775 r3176965  
    306306            </th>
    307307            <td class="forminp">
    308                 <select name="woocommerce_seur_origin_country_state" id="woocommerce_seur_origin_country_state" style="width: 250px;" data-placeholder="<?php esc_html_e( 'Choose a country&hellip;', 'woocommerce' ); ?>" title="Country" class="chosen_select">
     308                <select name="woocommerce_seur_origin_country_state" id="woocommerce_seur_origin_country_state" style="width: 250px;" data-placeholder="<?php esc_html_e( 'Choose a country&hellip;', 'seur' ); ?>" title="Country" class="chosen_select">
    309309                <?php echo WC()->countries->country_dropdown_options( $this->origin_country, $this->origin_state ? $this->origin_state : '*' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
    310310                </select>
     
    617617    // if shipping rate is 0, concatenate ": $0.00" to the label
    618618    if ( floatval($method->cost) <= 0  ) {
    619         $label .= ': ' . wc_price(0) . ' - ' . __( 'Free shipping', 'woocommerce' );
     619        $label .= ': ' . wc_price(0) . ' - ' . __( 'Free shipping', 'seur' );
    620620    }
    621621
  • seur/trunk/core/woocommerce/includes/metabox/seur-metabox.php

    r3119152 r3176965  
    3737        $url             = esc_url( admin_url( add_query_arg( array( 'page' => 'seur_get_labels_from_order' ), 'admin.php' ) ) );
    3838        $arrayiframe     = array(
    39             '?TB_iframe' => 'true',
     39            'TB_iframe' => 'true',
    4040            'width'      => '400',
    4141            'height'     => '300',
     
    5252            $text = 'Get SEUR'.($k==1?' CHANGE':'').' Label'.($k==1?'s':'');
    5353            ?>
    54             <a class='thickbox button btn-seur-label' title='<?php esc_html_e( $text, 'seur' ); ?>'
    55                alt='<?php esc_html_e( $text, 'seur' ); ?>'
     54            <a class='thickbox button btn-seur-label' title='<?php echo esc_html( $text ); ?>'
     55               alt='<?php echo esc_html( $text ); ?>'
    5656               href='<?php echo esc_html( $final_get_label_url ); ?>'>
    57                 <?php esc_html_e( $text, 'seur' ); ?>
     57                <?php echo esc_html( $text ); ?>
    5858            </a>
    5959            <?php
     
    7171            $cont++;
    7272            ?>
    73             <a href="<?= esc_url( $url_upload_dir ) . '/' . esc_html( $label_file_name ) ?> " class="button btn-seur-label" download> <?= esc_html__( ' See SEUR Label ', 'seur' ) . $suffix ?> </a>
     73            <a href="<?php echo esc_url( $url_upload_dir ) . '/' . esc_html( $label_file_name ); ?> " class="button btn-seur-label" download>
     74                <?php echo esc_html__( ' See SEUR Label ', 'seur' ) . esc_html( $suffix ); ?>
     75            </a>
    7476            <?php
    7577        }
  • seur/trunk/core/woocommerce/includes/pages/seur-process-label.php

    r2643080 r3176965  
    66function seur_process_label_woocommerce() {
    77
    8     if ( $_POST ) {
    9         global $wpdb;
    108
    11         $table = $wpdb->prefix . 'seur_custom_rates';
    12 
    13         $seur_rate      = sanitize_text_field( wp_unslash( $_POST['rate'] ) );
    14         $seur_country   = sanitize_text_field( wp_unslash( $_POST['country'] ) );
    15         $seur_state     = sanitize_text_field( wp_unslash( $_POST['state'] ) );
    16         $seur_minprice  = sanitize_text_field( wp_unslash( $_POST['minprice'] ) );
    17         $seur_maxprice  = sanitize_text_field( wp_unslash( $_POST['maxprice'] ) );
    18         $seur_rateprice = sanitize_text_field( wp_unslash( $_POST['rateprice'] ) );
    19         $seur_postcode  = seur_sanitize_postcode( $_POST['postcode'], $seur_country );
    20 
    21         if ( empty( $seur_city ) ) {
    22             $seur_city = '*';
    23         }
    24         if ( empty( $seur_minprice ) ) {
    25             $seur_minprice = '0';
    26         }
    27         if ( empty( $seur_postcode ) || $seur_postcode == '00000' || $seur_postcode == '0000' || $seur_postcode == '*' ) {
    28             $seur_postcode = '*';
    29         }
    30         if ( empty( $seur_rateprice ) ) {
    31             $seur_rateprice = '0';
    32         }
    33         if ( empty( $seur_state ) ) {
    34             $seur_state = '0';
    35         }
    36         if ( empty( $seur_country ) ) {
    37             $seur_country = '*';
    38         }
    39         if ( empty( $seur_maxprice ) || $seur_maxprice == '*' || $seur_maxprice > '9999999' ) {
    40             $seur_maxprice = '9999999';
    41         }
    42 
    43         $wpdb->insert(
    44             $table,
    45             array(
    46                 'rate'      => $seur_rate,
    47                 'country'   => $seur_country,
    48                 'state'     => $seur_state,
    49                 'postcode'  => $seur_postcode,
    50                 'minprice'  => $seur_minprice,
    51                 'maxprice'  => $seur_maxprice,
    52                 'rateprice' => $seur_rateprice,
    53             ),
    54             array(
    55                 '%s',
    56                 '%s',
    57                 '%s',
    58                 '%s',
    59                 '%d',
    60                 '%d',
    61                 '%d',
    62             )
    63         );
    64         if ( $wpdb->insert_id ) {
    65             echo '<div class="notice notice-success">' . esc_html__( 'New rate successfully added', 'seur' ) . '</div>';
    66         } else {
    67             echo '<div class="notice notice notice-error">' . esc_html__( 'There was and error adding the new rate, please try again', 'seur' ) . '</div>';
    68         }
    69     } else {
    70         esc_html_e( "Sorry, you didn't post data.", 'seur' );
    71         exit;
    72     }
    739}
  • seur/trunk/core/woocommerce/includes/seur-woo-functions.php

    r3159775 r3176965  
    118118    $offset          = 8;
    119119    $updated_columns = array_slice( $columns, 0, $offset, true ) +
    120     array( 'total_weight' => esc_html__( 'Weight', 'woocommerce' ) ) +
     120    array( 'total_weight' => esc_html__( 'Weight', 'seur' ) ) +
    121121    array_slice( $columns, $offset, null, true );
    122122    return $updated_columns;
     
    135135        $weight = get_post_meta( $post->ID, '_seur_cart_weight', true );
    136136        if ( $weight > 0 ) {
    137             print $weight . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) );
     137            print esc_html( $weight ) . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) );
    138138        } else {
    139139            print 'N/A';
     
    145145        $weight = $order->get_meta(  '_seur_cart_weight', true );
    146146        if ( $weight > 0 ) {
    147             print $weight . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) );
     147            print esc_html( $weight ) . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) );
    148148        } else {
    149149            print 'N/A';
     
    163163            'public'                    => true,
    164164            'show_in_admin_status_list' => true, // show count All (12) , Completed (9) , Awaiting shipment (2) ...
    165             'label_count'               => _n_noop( __( 'Awaiting SEUR shipment <span class="count">(%s)</span>', '' ), __( 'Awaiting SEUR shipment <span class="count">(%s)</span>', 'seur' ) ),
     165            // translators: %s is the number of SEUR shipments awaiting processing.
     166            'label_count' => _n_noop(
     167                'Awaiting SEUR shipment <span class="count">(%s)</span>',  // Singular
     168                'Awaiting SEUR shipments <span class="count">(%s)</span>', // Plural
     169                'seur'
     170            ),
    166171        )
    167172    );
     
    200205            'public'                    => true,
    201206            'show_in_admin_status_list' => true, // show count All (12) , Completed (9) , Awaiting shipment (2) ...
    202             'label_count'               => _n_noop( __( 'Awaiting SEUR Label <span class="count">(%s)</span>', 'seur' ), __( 'Awaiting SEUR Label <span class="count">(%s)</span>', 'seur' ) ),
     207            // translators: %s is the number of SEUR labels awaiting processing.
     208            'label_count' => _n_noop(
     209                'Awaiting SEUR Label <span class="count">(%s)</span>',  // Singular
     210                'Awaiting SEUR Labels <span class="count">(%s)</span>', // Plural
     211                'seur'
     212            ),
    203213        )
    204214    );
     
    245255            'public'                    => true,
    246256            'show_in_admin_status_list' => true, // show count All (12) , Completed (9) , Awaiting shipment (2) ...
    247             'label_count'               => _n_noop( __( 'Awaiting SEUR Shipment <span class="count">(%s)</span>', 'seur' ), __( 'Awaiting SEUR Shipment <span class="count">(%s)</span>', 'seur' ) ),
     257            // translators: %s is the number of SEUR shipments awaiting processing.
     258            'label_count' => _n_noop(
     259                'Awaiting SEUR Shipment <span class="count">(%s)</span>',  // Singular
     260                'Awaiting SEUR Shipments <span class="count">(%s)</span>', // Plural
     261                'seur'
     262            ),
    248263        )
    249264    );
     
    358373
    359374    if ( isset( $_GET['post_status'] ) ) {
    360             $sendback = add_query_arg( 'post_status', sanitize_text_field( $_GET['post_status'] ), $sendback );
     375            $sendback = add_query_arg( 'post_status', sanitize_text_field(wp_unslash($_GET['post_status'])), $sendback );
    361376    }
    362377
     
    432447function seur_get_label_ajax() {
    433448
    434     $order_id  = absint( $_GET['order_id'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     449    $order_id  = absint(sanitize_text_field( wp_unslash( $_GET['order_id'])) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
    435450    $has_label = seur()->has_label($order_id);
    436451
     
    472487
    473488function seur_billing_mobil_phone_fields_display_admin_order_meta( $order ) {
    474     echo '<p><strong>' . __( 'Billing Mobile Phone' ) . ':</strong> ' . $order->get_meta( '_billing_mobile_phone', true ) . '</p>';
     489    echo '<p><strong>' . esc_html__( 'Billing Mobile Phone', 'seur' ) . ':</strong> ' . esc_html( $order->get_meta( '_billing_mobile_phone', true ) ) . '</p>';
    475490}
    476491
     
    494509
    495510function seur_shipping_mobil_phone_fields_display_admin_order_meta( $order ) {
    496     echo '<p><strong>' . esc_html__( 'Shipping Mobile Phone' ) . ':</strong> ' . $order->get_meta(  '_shipping_mobile_phone', true ) . '</p>';
     511    echo '<p><strong>' . esc_html__( 'Shipping Mobile Phone', 'seur' ) . ':</strong> ' . esc_html( $order->get_meta( '_shipping_mobile_phone', true ) ) . '</p>';
    497512}
    498513
     
    523538
    524539    if (seur_is_order_page($post_type)) { ?>
    525         <label for="dropdown_shop_order_seur_shipping_method" class="screen-reader-text"><?php _e( 'Seur Shippments', 'seur' ); ?></label>
     540        <label for="dropdown_shop_order_seur_shipping_method" class="screen-reader-text"><?php esc_attr_e( 'Seur Shippments', 'seur' ); ?></label>
    526541        <select name="_shop_order_seur_shipping_method" id="dropdown_shop_order_seur_shipping_method">
    527542            <option value=""><?php esc_html_e( 'All', 'seur' ); ?></option>
    528543            <option value="seur"
    529544            <?php
    530             if ( ( esc_attr( isset( $_GET['_shop_order_seur_shipping_method'] ) ) ) && ( esc_attr( $_GET['_shop_order_seur_shipping_method'] ) == 'seur' ) ) {
    531                 echo 'selected'; }
    532             ?>
     545            $_shop_order_seur_shipping_method = isset( $_GET['_shop_order_seur_shipping_method'] ) ? esc_attr( sanitize_text_field(wp_unslash($_GET['_shop_order_seur_shipping_method']))) : '';
     546            if ($_shop_order_seur_shipping_method == 'seur') {
     547                echo 'selected';
     548            }?>
    533549            ><?php esc_html_e( 'All Seur Shipping', 'seur' ); ?></option>
    534550            <?php
     
    539555                $shippment_sani = sanitize_title( $custom_name ); ?>
    540556                <option value="<?php echo esc_attr( $shippment_sani ); ?>"
    541                     <?php echo esc_attr( isset( $_GET['_shop_order_seur_shipping_method'] ) ? selected( $shippment_sani, $_GET['_shop_order_seur_shipping_method'], false ) : '' ); ?>>
     557                    <?php echo esc_attr( $_shop_order_seur_shipping_method !='' ? selected( $shippment_sani,$_shop_order_seur_shipping_method, false ) : '' ); ?>>
    542558                    <?php echo esc_html( !empty($custom_name) ? $custom_name : $code ); ?>
    543559                </option>
     
    565581            $custom_name = get_option($product['field'].'_custom_name_field')?get_option($product['field'].'_custom_name_field'):$code;
    566582            $shippment_sani = sanitize_title( $custom_name );
    567             if ( $shippment_sani == $_GET['_shop_order_seur_shipping_method']) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     583            if ( $shippment_sani == sanitize_text_field( wp_unslash( $_GET['_shop_order_seur_shipping_method']))) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    568584                $vars['meta_key'] = '_seur_shipping_method_service_real_name';
    569585                $vars['meta_value'] = $code;
     
    584600 */
    585601function seur_register_tracking_statuses() {
    586     foreach (Seur_Logistica_Seguimiento::tracking_statuses_arr as $tracking_status => $tracking_label) {
    587         $new_statuses_arr[$tracking_status] = $tracking_label;
    588         register_post_status(
    589             $tracking_status,
    590             array(
    591                 'label'                     => $tracking_label,
    592                 'public'                    => true,
    593                 'show_in_admin_status_list' => true, // show count All (12) , Completed (9) , Awaiting shipment (2) ...
    594                 'label_count'               => _n_noop( __( $tracking_label. ' <span class="count">(%s)</span>', '' ), __( $tracking_label. ' <span class="count">(%s)</span>', 'seur' ) ),
    595             )
    596         );
    597     }
    598 }
     602    foreach (Seur_Logistica_Seguimiento::tracking_statuses_arr as $tracking_status => $tracking_label) {
     603        $new_statuses_arr[$tracking_status] = $tracking_label;
     604        register_post_status(
     605            $tracking_status,
     606            array(
     607                'label'                     => $tracking_label,
     608                'public'                    => true,
     609                'show_in_admin_status_list'  => true, // show count All (12), Completed (9), Awaiting shipment (2) ...
     610                // translators: %s is the count of tracking labels.
     611                'label_count' => _n_noop(
     612                    'Tracking Label <span class="count">(%s)</span>',  // Singular
     613                    'Tracking Labels <span class="count">(%s)</span>',  // Plural
     614                    'seur'  // Text domain
     615                ),
     616            )
     617        );
     618    }
     619}
     620
    599621add_action( 'init', 'seur_register_tracking_statuses' );
    600622
  • seur/trunk/core/woocommerce/seur-woocommerce.php

    r2826393 r3176965  
    126126     */
    127127    public function wc_deactivated() {
    128         echo '<div class="error"><p>' . sprintf( esc_html__( 'WooCommerce SEUR Shipping requires %s to be installed and active.', 'seur' ), '<a href="http://www.woothemes.com/woocommerce/" target="_blank">WooCommerce</a>' ) . '</p></div>';
     128        /* translators: %s is the name of Woocommerce plugin */
     129        echo '<div class="error"><p>' . sprintf( esc_html__( 'WooCommerce SEUR Shipping requires %s to be installed and active.', 'seur' ), '<a href="http://www.woothemes.com/woocommerce/" target="_blank">WooCommerce</a>' ) . '</p></div>';
    129130    }
    130131
     
    194195        $zones_admin_url = add_query_arg( $query_args, get_admin_url() . 'admin.php' );
    195196        ?>
    196         <div class="notice notice-success is-dismissible wc-seur-notice">
    197             <p><?php echo sprintf( esc_html__( 'SEUR now supports shipping zones. The zone settings were added to a new SEUR method on the "Rest of the World" Zone. See the zones %1$shere%2$s ', 'seur' ), '<a href="' . esc_url( $zones_admin_url ) . '">', '</a>' ); ?></p>
    198         </div>
    199 
    200         <script type="application/javascript">
     197        <div class="notice notice-success is-dismissible wc-seur-notice">
     198            <p>
     199                <?php
     200                // translators: %1$s is the opening anchor tag, and %2$s is the closing anchor tag.
     201                echo sprintf( esc_html__( 'SEUR now supports shipping zones. The zone settings were added to a new SEUR method on the "Rest of the World" Zone. See the zones %1$shere%2$s', 'seur' ), '<a href="' . esc_url( $zones_admin_url ) . '">', '</a>' ); ?>
     202            </p>
     203        </div>
     204
     205
     206        <script type="application/javascript">
    201207            jQuery( '.notice.wc-seur-notice' ).on( 'click', '.notice-dismiss', function () {
    202208                wp.ajax.post('seur_dismiss_upgrade_notice');
  • seur/trunk/loader.php

    r3159775 r3176965  
    44 * Plugin URI: http://www.seur.com/
    55 * Description: Add SEUR shipping method to WooCommerce. The SEUR plugin for WooCommerce allows you to manage your order dispatches in a fast and easy way
    6  * Version: 2.2.12
     6 * Version: 2.2.14
    77 * Author: SEUR Oficial
    88 * Author URI: http://www.seur.com/
    9  * Tested up to: 6.2
     9 * Tested up to: 6.6.2
    1010 * WC requires at least: 3.0
    11  * WC tested up to: 7.4
     11 * WC tested up to: 9.1.4
    1212 * Text Domain: seur
    1313 * Domain Path: /languages/
     
    1818 **/
    1919
    20 define( 'SEUR_OFFICIAL_VERSION', '2.2.12' );
     20define( 'SEUR_OFFICIAL_VERSION', '2.2.14' );
    2121define( 'SEUR_DB_VERSION', '1.0.4' );
    2222define( 'SEUR_TABLE_VERSION', '1.0.4' );
     
    140140            ?>
    141141            <div id="message" class="updated woocommerce-message woocommerce-seur-messages">
    142                 <a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'seur-hide-new-version', 'hide-new-version-seur' ), 'seur_hide_new_version_nonce', '_seur_hide_new_version_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce-seur' ); ?></a>
     142                <a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'seur-hide-new-version', 'hide-new-version-seur' ), 'seur_hide_new_version_nonce', '_seur_hide_new_version_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'seur' ); ?></a>
    143143                <p>
    144                     <?php echo esc_html__( 'SEUR has been updated to version', 'woocommerce-seur' ) . ' ' . esc_html( SEUR_OFFICIAL_VERSION ); ?>
     144                    <?php echo esc_html__( 'SEUR has been updated to version', 'seur' ) . ' ' . esc_html( SEUR_OFFICIAL_VERSION ); ?>
    145145                </p>
    146146                <p>
    147147                    <?php
    148148                    // translators: Link to SEUR website with new features.
    149                     printf( wp_kses( __( 'Discover the improvements that have been made in this version, and how to take advantage of them <a href="%s" target="_blank">here</a>', 'woocommerce-seur' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( SEUR_POST_UPDATE_URL ) );
     149                    printf( wp_kses( __( 'Discover the improvements that have been made in this version, and how to take advantage of them <a href="%s" target="_blank">here</a>', 'seur' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( SEUR_POST_UPDATE_URL ) );
    150150                    ?>
    151151                </p>
     
    173173            ?>
    174174            <div id="message" class="updated woocommerce-message woocommerce-seur-messages">
    175                 <a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'seur-hide-new-v2', 'hide-new-v2-seur' ), 'seur_hide_new_v2_nonce', '_seur_hide_new_v2_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce-seur' ); ?></a>
     175                <a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'seur-hide-new-v2', 'hide-new-v2-seur' ), 'seur_hide_new_v2_nonce', '_seur_hide_new_v2_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'seur' ); ?></a>
    176176                <p>
    177                     <?php echo esc_html__( 'WARNING', 'woocommerce-seur' ); ?>
     177                    <?php echo esc_html__( 'WARNING', 'seur' ); ?>
    178178                </p>
    179179                <p>
    180180                    <?php
    181                     esc_html_e( 'You need to contact to SEUR for new credentials. Call to +34913228380 or email to [email protected]', 'woocommerce-seur' );
     181                    esc_html_e( 'You need to contact to SEUR for new credentials. Call to +34913228380 or email to [email protected]', 'seur' );
    182182                    ?>
    183183                </p>
  • seur/trunk/readme.txt

    r3159775 r3176965  
    11=== SEUR Oficial ===
    22Contributors: seuroficial
    3 Tags: woocommerce, shipping, seur, logistica, enviar paquete, pedidos, entregas
     3Tags: woocommerce, shipping, seur, logistica, enviar paquete
    44Requires at least: 4.0
    5 Tested up to: 6.2
    6 Stable tag: 2.2.12
     5Tested up to: 6.6.2
     6Stable tag: 2.2.14
    77WC requires at least: 3.0
    8 WC tested up to: 7.4
    9 License: GPLv2 or later
    10 License URI: http://www.gnu.org/licenses/gpl-2.0.html
     8WC tested up to: 9.1.4
     9License: GNU General Public License v3.0
     10License URI: http://www.gnu.org/licenses/gpl-3.0.html
    1111
    1212Add SEUR shipping method to WooCommerce. The SEUR plugin for WooCommerce allows you to manage your order dispatches in a fast and easy way
     
    9494== Changelog ==
    9595
     96== 2.2.14 ==
     97
     98* ADDED: New pick-up layout design and cancel pick-up functionality
     99* ADDED: Set downloaded label meta in other functions
     100* FIXED: Vulnerability Report CVE-2024-9438
     101* FIXED: Fix change value
     102* FIXED: Fix has label function
     103* FIXED: Fix required from rate state value
     104* REMOVED: Log token email
     105
     106== 2.2.13 ==
     107
     108* FIXED: Vulnerability Report CVE-2024-9438
     109
    96110== 2.2.12 ==
    97111
    98 * ADDED: Add new service 13:30 Documentos
     112* ADDED: Add new service 13:30 Frío
    99113* ADDED: PHP8.2 compatibility
    100114* CHANGED: Change _seur_2shop_codCentro value
Note: See TracChangeset for help on using the changeset viewer.