،تلقينا ببالغ الأسى خبر وفاة المشمولة برحمة لله
،صاحبة السمو الملكي الأميرة للا لطيفة
،حرم المغفور له جلالة الملك الحسن الثاني طيب لله مثواه
و والدة صاحب الجلالة الملك محمد السادس نصره لله
. و أيده و أطال عمره، و أصحاب السمو الملكي الأمراء و الأميرات
،وعلى إثر هذا المصاب الأليم، تتقدم شركة المدى القابضة
،عنها وعن مؤسسة المدى و الشركات التابعة
ونيابة عن جميع مستخدمي شركة و مجموعة المدى، بخالص التعازي
و المواساة لأمير المؤمنين جلالة الملك محمد السادس نصره لله ولكل
الأمراء والأميرات وكافة أفراد الأسرة الملكية الشريفة؛
داعين العلي القدير بأن يشمل الفقيدة بواسع رحمته
ويسكنها فسيح جناته و راجين من لله العلي القدير أن يرزق جلالة
،الملك وكافة أفراد الأسرة الملكية الشريفة الصبر والسلوان
،وأن يطيل في عمر سيدنا صاحب الجلالة الملك محمد السادس
.حفظه لله وأدام عزه ونصره

class Shokola_Reports_test { /*function test(){ $html2pdf = new Html2Pdf(); $html2pdf->writeHTML('

HelloWorld

This is my first test'); $html2pdf->setDefaultFont('Arial'); $filename = 'test.pdf'; $html2pdf->output(); $headers = array('Content-Type: text/html; charset=UTF-8', ''); $content = 'Bonjour,

'; $content .= 'Vous trouverez ci-joint le rapport d\'activité pour le mois de'; $content .= 'Ce mail a été envoyé automatiquement'; //wp_mail('romain@shokola.com', '[Almada] Rapport mensuel', $content, $headers); }*/ public function __construct() { add_action('upgrader_process_complete', array($this, 'get_process_details_after_plugin_update'), 10, 2); add_action('post_updated', array($this, 'get_post_updated_details'), 10, 3); add_action('save_post', array($this, 'get_post_created_details'), 10, 3); add_action('init', array($this, 'get_countries_from_IP_address')); add_action('activated_plugin', array($this, 'get_activated_plugin_details'), 10, 2); add_action('deactivated_plugin', array($this, 'get_deactivated_plugin_details'), 10, 2); add_action('deleted_plugin', array($this, 'get_deleted_plugin_details'), 10, 2); add_action('admin_init', array($this, 'build_manually_report'), 10, 2); //add_action('admin_init', array($this, 'build_report')); add_action('send_report_monthly', array($this, 'build_report')); if (!wp_next_scheduled('send_report_monthly')) { wp_schedule_event(time(), 'daily', 'send_report_monthly'); } } /** * Get current WP Version * * @return string|void */ public function get_current_wp_version() { return get_bloginfo('version'); } /** * Get the last WP Version from API * * @return mixed */ public function get_last_wp_version() { $url = 'https://api.wordpress.org/core/version-check/1.7/'; $response = wp_remote_get($url); $json = $response['body']; $obj = json_decode($json); return $obj->offers[0]->version; } /** * @param $post_ID * @param WP_POST $post_after * @param WP_POST $post_before */ public function get_post_updated_details($post_ID, \WP_POST $post_after, \WP_POST $post_before) { $context = array( 'context' => 'update', 'post_title' => $post_after->post_title, 'post_type' => $post_after->post_type, 'user' => get_current_user_id(), 'date' => current_time('d/m/Y H:i:s'), 'post_content_before' => $post_before->post_content, 'post_content_after' => $post_after->post_content ); $database_details = $this->get_option(); $database_details[current_time('Y')][current_time('m')]['post'][current_time('d')][] = $context; $this->update_option($database_details); } /** * Get datas from database * * @return mixed|void */ public function get_option() { return get_option($this->option_name); } /** * Update datas in database * * @param array $datas */ public function update_option($datas) { update_option($this->option_name, $datas); } public function get_post_created_details($post_id, $post, $updated) { } /** * Get actions details after installed/updated/removed plugin * * @param \WP_Upgrader $upgrader * @param $data */ public function get_process_details_after_plugin_update(\WP_Upgrader $plugin_upgrader_instance, $arr_data) { if (isset($arr_data['action']) && 'install' == $arr_data['action'] && !$plugin_upgrader_instance->bulk) { $upgrader_skin_result = isset($plugin_upgrader_instance->skin->result) && is_array($plugin_upgrader_instance->skin->result) ? $plugin_upgrader_instance->skin->result : array(); $plugin_slug = isset($upgrader_skin_result['destination_name']) ? $upgrader_skin_result['destination_name'] : ''; // Upgrader contains current info $context = array( 'context' => 'install', 'plugin_slug' => $plugin_slug, 'plugin_name' => $plugin_slug, 'date' => current_time('d/m/Y H:i:s'), 'user' => get_current_user_id() ); $database_options = $this->get_option(); $database_options[current_time('Y')][current_time('m')]['plugins'][current_time('d')][] = $context; $this->update_option($database_options); } if (isset($arr_data['action']) && 'update' == $arr_data['action'] && !$plugin_upgrader_instance->bulk) { // No plugin info in instance, so get it ourself $plugin_data = array(); if (file_exists(WP_PLUGIN_DIR . '/' . $arr_data['plugin'])) { $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $arr_data['plugin'], true, false); } // autoptimize/autoptimize.php $plugin_slug = dirname($arr_data['plugin']); $context = array( 'context' => 'update', 'plugin_slug' => $plugin_slug, 'plugin_name' => $plugin_data['Name'], 'plugin_title' => $plugin_data['Title'], 'plugin_description' => $plugin_data['Description'], 'plugin_author' => $plugin_data['Author'], 'plugin_version' => $plugin_data['Version'], 'plugin_url' => $plugin_data['PluginURI'], 'date' => current_time('d/m/Y H:i:s') ); $database_options = $this->get_option(); $database_options[current_time('Y')][current_time('m')]['plugins'][current_time('d')][] = $context; $this->update_option($database_options); } if (isset($arr_data['bulk']) && $arr_data['bulk'] && isset($arr_data['action']) && 'update' == $arr_data['action']) { $plugins_updated = isset($arr_data['plugins']) ? (array)$arr_data['plugins'] : array(); foreach ($plugins_updated as $plugin_name) { $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_name, true, false); $plugin_slug = dirname($plugin_name); $context = array( 'context' => 'update', 'plugin_slug' => $plugin_slug, 'plugin_name' => $plugin_data['Name'], 'plugin_title' => $plugin_data['Title'], 'plugin_version' => $plugin_data['Version'], 'plugin_url' => $plugin_data['PluginURI'], 'user' => get_current_user_id(), 'date' => current_time('d/m/Y H:i:s') ); $database_options = $this->get_option(); $database_options[current_time('Y')][current_time('m')]['plugins'][current_time('d')][] = $context; $this->update_option($database_options); }// End foreach(). }// End if(). } /** * Get countries which visited website from IP address */ public function get_countries_from_IP_address() { if (is_admin()) { return; } $ip = $_SERVER["REMOTE_ADDR"]; $ip_datas = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip)); $countryName = $ip_datas->geoplugin_countryName; $database_content = $this->get_option(); $count = $database_content[current_time('Y')][current_time('m')]['visit'][$countryName]; $database_content[current_time('Y')][current_time('m')]['visit'][$countryName] = isset ($count) ? $count + 1 : 1; $this->update_option($database_content); } /** * Fired after any plugin is activated. * * @param string $plugin Path to the plugin file relative to the plugins directory. * @param bool $network_activation Whether to enable the plugin for all sites in the network or just the current site. Multisite only. */ public function get_activated_plugin_details($plugin, $network_activation) { $context = array( 'context' => 'activate', 'plugin_name' => $plugin, 'date' => current_time('d/m/Y H:i:s'), 'user' => get_current_user_id(), ); $database_options = $this->get_option(); $database_options[current_time('Y')][current_time('m')]['plugins'][current_time('d')][] = $context; $this->update_option($database_options); } /** * Fired after any plugin is deactivated. * * @param string $plugin Path to the plugin file relative to the plugins directory. * @param bool $network_activation Whether to disable the plugin for all sites in the network or just the current site. Multisite only. */ public function get_deactivated_plugin_details($plugin, $network_activation) { $context = array( 'context' => 'deactivate', 'plugin_name' => $plugin, 'date' => current_time('d/m/Y H:i:s'), 'user' => get_current_user_id(), ); $database_options = $this->get_option(); $database_options[current_time('Y')][current_time('m')]['plugins'][current_time('d')][] = $context; $this->update_option($database_options); } public function get_deleted_plugin_details($plugin, $uninstallable_plugins) { $context = array( 'context' => 'delete', 'plugin_name' => $plugin, 'date' => current_time('d/m/Y H:i:s'), 'user' => get_current_user_id(), ); $database_options = $this->get_option(); $database_options[current_time('Y')][current_time('m')]['plugins'][current_time('d')][] = $context; $this->update_option($database_options); } /** * Build text file with all datas * */ public function build_report() { $database_content = $this->get_option(); $prev_month = new DateTime('NOW'); $prev_month->modify('first day of last month'); $last_month = date_i18n('m', $prev_month->getTimestamp()); $last_month_full = date_i18n('F', $prev_month->getTimestamp()); $last_year = date_i18n('Y', $prev_month->getTimestamp()); $datas_for_last_month = $database_content[$last_year][$last_month]; ob_start(); include('templates/content_pdf.php'); $content = ob_get_contents(); ob_end_clean(); $upload_dir = wp_upload_dir()['basedir'] . '/'; $html2pdf = new Html2Pdf(); $html2pdf->writeHTML($content); $html2pdf->setDefaultFont('Arial'); $filename = $upload_dir . 'rapport_mensuel_' . $last_month . '_' . $last_year . '.pdf'; $html2pdf->output(); // Send mail $headers = array(); //$headers[] = 'Content-Type: text/html; charset=UTF-8'; //$headers[] = 'Bcc: admintech@shokola.com'; //$headers[] = 'Bcc: jeanyves@shokola.com'; //$headers[] = 'Bcc: leo@shokola.com'; //$headers = array('Content-Type: text/html; charset=UTF-8', 'Bcc: leo@shokola.com, jeanyves@shokola.com, admintech@shokola.com, k.jbal@almada.ma'); $content = 'Bonjour,

'; $content .= 'Vous trouverez ci-joint le rapport d\'activité pour le mois de ' . $last_month_full . ' ' . $last_year . '

'; $content .= 'Ce mail a été envoyé automatiquement'; wp_mail('romain@shokola.com', '[Almada] Rapport mensuel - ' . $last_month_full . ' ' . $last_year, $content, $headers, array($filename)); //wp_mail('y.sadki@almada.ma', '[Almada] Rapport mensuel - ' . $last_month_full . ' ' . $last_year, $content, $headers, array($filename)); /*if (ENV == 'prod') { wp_mail('y.sadki@almada.ma', '[Almada] Rapport mensuel - ' . $last_month_full . ' ' . $last_year, $content, $headers, array($filename)); wp_mail('leo@shokola.com', '[Almada] Rapport mensuel - ' . $last_month_full . ' ' . $last_year, $content, array('Content-Type: text/html; charset=UTF-8'), array($filename)); } else { wp_mail('y.sadki@almada.ma', '[Almada] Rapport mensuel - ' . $last_month_full . ' ' . $last_year, $content, $headers, array($filename)); wp_mail('leo@shokola.com', '[Almada] Rapport mensuel - ' . $last_month_full . ' ' . $last_year, $content, array('Content-Type: text/html; charset=UTF-8'), array($filename)); }*/ } public function build_manually_report(){ $database_content = $this->get_option(); /*$test = " ";*/ $this->update_option($database_content); $prev_month = new DateTime('NOW'); $prev_month->modify('first day of last month'); $last_month = date_i18n('m', $prev_month->getTimestamp()); $last_month_full = date_i18n('F', $prev_month->getTimestamp()); $last_year = date_i18n('Y', $prev_month->getTimestamp()); $datas_for_last_month = $database_content[$last_year][$last_month]; ob_start(); include('templates/content_pdf.php'); /*$content = '
Rapport dactivité mensuel

Rapport réalisé par Shokola - Confidentiel Al Mada

[[page_cu]]/[[page_nb]]
Date : 14/07/2024
Version du CMS utilisée :