Plugin Directory

Changeset 3023994


Ignore:
Timestamp:
01/19/2024 10:32:30 AM (2 years ago)
Author:
pechenki
Message:
  • add log file
  • fix error
Location:
telsender/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • telsender/trunk/clasess/TelegramSend.php

    r2979054 r3023994  
    66    exit;
    77}
     8
     9use pechenki\Telsender\clasess\log;
     10
    811/**
    912 * curl sender
     
    2225     * @var false|mixed|string $Pechenki_key
    2326     */
    24     public $Pechenki_key;
    2527    /**
    2628     * @var mixed|string $Chat_id
     
    3133     */
    3234    public $Token;
    33     /**
    34      * @var bool $isSendPechenki
    35      */
    3635    public $isSendPechenki;
    3736    /**
     
    5756        $tscfwc_setting = new TscfwcSetting(get_option(TSCFWC_SETTING));
    5857
    59         $this->Pechenki_key = $tscfwc_setting->Option('tscfwc_setting_newtoken');
    6058        $this->Chat_id = $tscfwc_setting->Option('tscfwc_setting_chatid');
    6159        $this->Token = $tscfwc_setting->Option('tscfwc_setting_token');
     
    6462            $this->isSendPechenki = $opt['tscfwc_key'];
    6563        }
    66 
    6764
    6865    }
     
    114111
    115112        if (is_wp_error($return)) {
     113
     114            log::setLog( $return->get_error_message());
    116115
    117116            return json_encode(['ok' => false, 'curl_error_code' => $return->get_error_message()]);
  • telsender/trunk/clasess/TelsenderCore.php

    r2979054 r3023994  
    1818{
    1919
    20     public $version = '1.14.6';
     20    public $version = '1.14.9';
    2121
    2222    /**
     
    5858        if (!$this->tscfwc_enabled) return;
    5959
     60
     61        if ( $this->tscfwc_setLog){
     62            define('LOG_TS',true);
     63            $log = new log();
     64
     65        }
     66
    6067        add_action('wpforms_process_complete', array($this, 'tscfwc_wp_form'), 10, 4);
    6168        add_action('woocommerce_after_order_object_save', array($this, 'tscfwc_woocommerce_new_order_status'), 99, 2);
    6269        if ($this->tscfwc_setting_acsesform) {
    63             add_action("wpcf7_mail_sent", array($this, 'wpcf7_tscfwc'), 99, 1);
    64         }
     70            add_action("wpcf7_mail_sent", array($this, 'sendCF7'), 99, 1);
     71        }
     72
    6573
    6674    }
     
    218226     */
    219227
    220     public function wpcf7_tscfwc($ccg)
     228    public function sendCF7($ccg)
    221229    {
    222230
     
    305313            'tscfwc_setting_token' => $this->post('tscfwc_setting_token'),
    306314            'tscfwc_setting_chatid' => htmlentities($this->post('tscfwc_setting_chatid')),
     315            'tscfwc_setLog' => intval($this->post('tscfwc_setLog')),
    307316            'tscfwc_setting_wooc_template' => htmlentities($this->post('tscfwc_setting_wooc_template')),
    308317            'tscfwc_setting_setcheck' => array(
  • telsender/trunk/clasess/TelsenderWc.php

    r2979054 r3023994  
    8484                $res = preg_replace('/\{|\}/', '', $item);
    8585
     86                if (isset($this->order->data[$res])) {
    8687                    $_result = $this->order->data[$res];
    87                     if ($_result) {
    88                         $this->replace[$item] = $_result;
    89                     } else {
    90                         $this->replace[$item] = $this->order->get_meta($res) ?: '';
    91                     }
     88                }else{
     89                    $_result = null;
     90                }
     91
     92
     93                if ($_result) {
     94                    $this->replace[$item] = $_result;
     95                } else {
     96                    $this->replace[$item] = $this->order->get_meta($res) ?: '';
     97                }
     98
    9299
    93100
  • telsender/trunk/clasess/TscfwcSetting.php

    r2979054 r3023994  
    3737            'tscfwc_setting_wooc_template' => '',
    3838            'tscfwc_setting_acsesform' => [],
     39            'tscfwc_setLog' => false,
    3940            'tscfwc_setting_status_wc' => [
    4041                'wc-processing'
  • telsender/trunk/clasess/log.php

    r2979054 r3023994  
    33namespace pechenki\Telsender\clasess;
    44
    5 if ( ! defined( 'ABSPATH' ) ) {
     5if (!defined('ABSPATH')) {
    66    exit;
    77}
    8 class log{
    9    
    10     static $logNameOption = 'telsenderLog';
     8
     9class log
     10{
    1111
    1212
     13    const path = ABSPATH . "wp-content/uploads/telsender/error.log";
    1314
    14     public static function setLog($text){
    15 
    16         if($text){
    17             $log = [];
    18             $real = json_decode(self::getLog(),true)?:[];           
    19            
    20             $log['date'] = time(); 
    21             $log['data'] = $text;
    22             $real[]=$log;
    23             return update_option(self::$logNameOption,json_encode($real));
    24         }       
    25         return false;
     15    public function __construct()
     16    {
     17        $this->initLogFile();
    2618    }
    2719
    28     public static function getLog(){
    29         return get_option(self::$logNameOption);
     20    /**
     21     * @param $text
     22     * @return void
     23     */
     24    public static function setLog($text)
     25    {
     26        if (!defined('LOG_TS')) return;
     27
     28        if (is_array($text)) {
     29            $text = json_encode($text);
     30        }
     31        $file = fopen(self::path, "a+");
     32        echo fwrite($file, "\n" . date('Y-m-d h:i:s') . " :: " . $text);
     33        fclose($file);
    3034    }
    3135
    32     public static function clearLog(){
    33         return update_option(self::$logNameOption,'');
     36    /**
     37     * @return false|string
     38     */
     39    public static function getLog()
     40    {
     41
     42        if (!file_exists(self::path)) {
     43            return 'error none';
     44        }
     45        return trim(file_get_contents(self::path));
     46    }
     47
     48
     49    public static function clearLog()
     50    {
     51        return update_option(self::$logNameOption, '');
     52    }
     53
     54    /**
     55     * @return void
     56     */
     57    private function initLogFile()
     58    {
     59        if (file_exists(self::path)) return;
     60
     61        $upload = wp_upload_dir();
     62        $upload_dir = $upload['basedir'];
     63        $upload_dir = $upload_dir . '/telsender';
     64        if (!is_dir($upload_dir)) {
     65            mkdir($upload_dir, 0755);
     66        }
     67        try {
     68            fopen(self::path, 'x');
     69            file_put_contents($upload_dir . '/.htaccess', 'deny from all');
     70        }catch (\Exception $e){
     71
     72        }
     73
     74
    3475    }
    3576}
  • telsender/trunk/css/telsender.css

    r2979054 r3023994  
    3838
    3939#formsetinvendor input {
    40     border-radius: 0;
     40    border-radius: 5px;
    4141    margin: 1px 0;
    4242}
     
    801801    background: #006d8830;
    802802    border-radius: 5px;
     803    max-height: 450px;
     804    overflow: auto;
    803805}
    804806.telsenderSetting input[type="checkbox"]{
  • telsender/trunk/index.php

    r2979054 r3023994  
    88Description: Плагін відправляє заявки з форм у телеграм канал
    99Author: Pechenki
    10 Version: 1.14.8
     10Version: 1.14.9
    1111Author URI: https://coder.org.ua/dev/wordpress/telsender
    1212*/
  • telsender/trunk/readme.md

    r2979054 r3023994  
    33Tags: telegram, Сontact form 7 to telegram, Сontact form 7, wooccommerce to telegram, Wpforms to telegram, wpforms to telegram
    44Requires at least: 4.8
    5 Requires PHP: 5.6
    6 Tested up to: 6.3
    7 Stable tag: 1.14.7
     5Requires PHP: 7.4
     6Tested up to: 6.4
     7Stable tag: 1.14.9
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3737more details on the site
    3838
    39 https://pechenki.top/telsender.html
     39https://coder.org.ua/dev/wordpress/telsender
    4040
    4141== Screenshots ==
     
    4646
    4747== Changelog ==
     48= 1.14.9 =
     49- add log file
     50- fix error
     51
    4852= 1.14.8 =
    4953- add chat id from wooccommerce
  • telsender/trunk/readme.txt

    r2979054 r3023994  
    33Tags: telegram, Сontact form 7 to telegram, Сontact form 7, wooccommerce to telegram, Wpforms to telegram, wpforms to telegram
    44Requires at least: 4.8
    5 Requires PHP: 5.6
    6 Tested up to: 6.3
    7 Stable tag: 1.14.8
     5Requires PHP: 7.4
     6Tested up to: 6.4
     7Stable tag: 1.14.9
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6565more details on the site
    6666
    67 https://pechenki.top/telsender.html
     67https://coder.org.ua/dev/wordpress/telsender
    6868
    6969== Screenshots ==
     
    7474
    7575== Changelog ==
     76= 1.14.9 =
     77 - add log file
     78 - fix error
     79
    7680= 1.14.8 =
    7781 - add chat id from wooccommerce
  • telsender/trunk/template/list-shortcode-html.php

    r2952090 r3023994  
    1 <code><pre>
     1<pre>
    22woocommerce  - shortcode
    33/***/
     
    2222{customer_user_agent}
    2323</pre>
    24 </code>
     24
  • telsender/trunk/template/log.php

    r2867750 r3023994  
     1<?php
     2
     3use pechenki\Telsender\clasess\log;
     4?>
     5<hr>
    16<div class="log0wrap">
    2     <table>
    3         <tbody>
    4         <tr>
    5             <td>Date</td>
    6             <td>Content</td>
    7         </tr>
    8         <?php
    9         if (log::getLog()) {
    10             foreach (json_decode(log::getLog(), true) as $keyl => $valuel) {
    11                 $code = json_decode($valuel['data']);
     7    <p>Log</p>
     8    <pre><?php   echo log::getLog();  ?> </pre>
     9</div>
    1210
    13                 echo '<tr>';
    14                 echo '<td class="log-date">' . date("Y-m-d H:i:s", $valuel["date"]) . '</td>';
    15                 echo '<td  class="log-data">' . esc_attr($valuel['data']) . '</td>';
    16                 echo '</tr>';
    17             }
    18         }
    19         ?>
    20         </tbody>
    21     </table>
    22 </div>
     11<style>
     12    .log0wrap pre{
     13        overflow:auto;
     14        max-height: 300px;
     15    }
     16</style>
  • telsender/trunk/template/view.php

    r2979054 r3023994  
    44}
    55
    6 use pechenki\Telsender\clasess\log;
     6
    77
    88$caunt = 0;
     
    4949                            </label>
    5050                        </div>
     51
    5152                        <div>
    5253                            <label>
     
    5556                                          name="tscfwc_setting_chatid"
    5657                                          placeholder=""/></label>
     58                        </div>
     59
     60                        <div>
     61                            <input value="0" type="hidden" name="tscfwc_setLog" type="checkbox"/>
     62                            <input value="1" <?php echo checked($this->tscfwc_setLog); ?> name="tscfwc_setLog"
     63                                   type="checkbox"/>
     64                            <span>Log</span>
    5765                        </div>
    5866                    </fieldset>
     
    129137                </a>
    130138                <?php include 'list-shortcode-html.php'; ?>
     139                <?php $this->render('template/log', []); ?>
    131140            </td>
    132141
Note: See TracChangeset for help on using the changeset viewer.