prefix . 'panelorders'; // Vérifiez si la table existe déjà if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $charset_collate = $wpdb->get_charset_collate(); // Déclaration de création de table $sql = "CREATE TABLE $table_name ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, order_id VARCHAR(50) NOT NULL, client_whatsapp VARCHAR(50) NOT NULL, date DATETIME NOT NULL, link TEXT NOT NULL, charge DECIMAL(10, 2) NOT NULL, start_account INT(11) NULL, quantity INT(11) NOT NULL, service_name VARCHAR(100) NOT NULL, status VARCHAR(50) NOT NULL, remains INT(11) NOT NULL, panel VARCHAR(50) NOT NULL, api VARCHAR(50) NOT NULL, PRIMARY KEY (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); }else echo "table dega creer"; // Initialise un tableau vide pour stocker les données dans les options $data = array(); update_option('mon_plugin_data', $data); } // Enregistrez un menu dans le menu principal de WordPress add_action('admin_menu', 'mon_plugin_menu'); function mon_plugin_menu() { add_menu_page('autoexecute', 'AutoExecute', 'manage_options', 'mon-plugin-menu', 'mon_plugin_page', 'dashicons-admin-plugins'); // Ajoutez le sous-menu "Settings" avec l'option "manage_options" add_submenu_page('mon-plugin-menu', 'Settings', 'Settings', 'manage_options', 'mon-plugin-settings', 'mon_plugin_settings_page'); // Ajoutez un sous-menu pour la clé d'activation add_submenu_page('mon-plugin-menu', 'Activation Key', 'Activation Key', 'manage_options', 'activation-key', 'ayyah'); add_submenu_page('mon-plugin-menu', 'Video Installation', 'Video Installation', 'manage_options', 'autoexecute-installation', 'autoexecute_video'); add_submenu_page('mon-plugin-menu', 'free likes', 'free likes', 'manage_options', 'free-likes', 'freelikes'); } function autoexecute_video(){ ?>
Lien | Statut | $lien | $status | "; } } else { // Message si aucun statut n'est disponible echo "
---|---|
Aucun lien ou statut disponible. |
Activated
'; echo ''; } else { if (isset($_POST['activation_key'])) { $domain = $_SERVER['HTTP_HOST']; // Supprimez le préfixe "www." si présent $domain = preg_replace('/^www\./', '', $domain); // Récupérez la clé d'activation soumise par l'utilisateur $submitted_key = sanitize_text_field($_POST['activation_key']); // Vérifiez la clé d'activation avec une clé d'activation valide $_POST["plugin"]="autoexecute"; $_POST["w"]=$domain; $myarrayy = $_POST ; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://venoboost.com/services/insertKeys"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$myarrayy); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); curl_close ($ch); $item=json_decode($server_output); if ($item->actif=="ok") { // La clé d'activation est valide, activez le plugin update_option('order_paid', true); update_option("autoexecute_key",$submitted_key); echo 'Plugin activated successfully!
Invalid activation key. Please try again.
plugin crée par Nizar Lfadili
'; } function verifier($url,$api_key){ $a=new Api($url,$api_key); return $a->balance()->balance; } function is_value_in_plugin_data($value_to_find) { $data = get_option('mon_plugin_data'); // Récupérez les données // Parcourir les données pour trouver la valeur dans la colonne 3 (field3) foreach ($data as $entry) { if ($entry['Field3'] === $value_to_find) { // La valeur a été trouvée return true; } } // La boucle se termine sans avoir trouvé la valeur return false; } function mon_plugin_page() { $order_paid = get_option('order_paid'); if (!$order_paid) return; $data = get_option('mon_plugin_data'); if (isset($_GET['delete-row']) && is_numeric($_GET['delete-row'])) { $index = intval($_GET['delete-row']); if (isset($data[$index])) { unset($data[$index]); $data = array_values($data); // Réorganisez le tableau update_option('mon_plugin_data', $data); } wp_redirect(admin_url('admin.php?page=mon-plugin-menu')); exit(); } if (isset($_POST['submit'])) { $data = get_option('mon_plugin_data'); $field1 = sanitize_text_field($_POST['field1']); $field2 = sanitize_text_field($_POST['field2']); $field3 = sanitize_text_field($_POST['field3']); // Ajoutez les données dans le tableau if (verifier($_POST['field2'], $_POST['field3']) != null) { if (is_value_in_plugin_data(trim($_POST['field3']))) { echo 'API key already exists
Cannot connect to the server
Name | URL | API | Actions |
---|---|---|---|
' . esc_html($row['Field1']) . ' | '; echo '' . esc_html($row['Field2']) . ' | '; echo '' . esc_html($row['Field3']) . ' | '; echo 'Supprimer | '; echo '
'; woocommerce_wp_select(array( 'id' => '_custom_field1_select', 'label' => 'Panel:', 'options' => array_combine($field1_values, $field1_values), 'value' => $selected_value, )); echo '
'; echo ''; woocommerce_wp_text_input(array( 'id' => '_custom_service_id', 'label' => 'Service ID', 'value' => $service_id, )); echo '
'; $checkbox_value = get_post_meta($post->ID, '_custom_checkbox', true); echo ''; woocommerce_wp_checkbox(array( 'id' => '_custom_checkbox', 'label' => 'Hide', 'value' => $checkbox_value, )); echo '
'; echo ''; } add_action('woocommerce_product_options_inventory_product_data', 'add_custom_product_field1_select'); // Sauvegarder la valeur sélectionnée dans la liste déroulante "Field1" function save_custom_product_field1_and_service_id($product_id) { $order_paid=get_option('order_paid'); if(!$order_paid) return; $custom_field1_select = isset($_POST['_custom_field1_select']) ? sanitize_text_field($_POST['_custom_field1_select']) : ''; $custom_service_id = isset($_POST['_custom_service_id']) ? sanitize_text_field($_POST['_custom_service_id']) : ''; $check = isset($_POST['_custom_checkbox']) ? sanitize_text_field($_POST['_custom_checkbox']) : ''; // Mettre à jour la valeur de la liste déroulante "Field1" update_post_meta($product_id, '_custom_field1_select', $custom_field1_select); // Mettre à jour la valeur du champ "Service ID" update_post_meta($product_id, '_custom_service_id', $custom_service_id); update_post_meta($product_id, '_custom_checkbox', $check); } add_action('woocommerce_process_product_meta', 'save_custom_product_field1_and_service_id'); add_action('woocommerce_payment_complete', 'votre_fonction_apres_paiement_complet'); function get_values_by_field($field_name, $field_value) { $data = get_option('mon_plugin_data'); $results = array(); foreach ($data as $row) { if (isset($row['Field1']) && $row['Field1'] == $field_value) { $results[] = $row; } } return $results; } add_action('woocommerce_thankyou', 'votre_fonction_de_traitement'); function votre_fonction_de_traitement($order_id) { $order_paid=get_option('order_paid'); // Votre code personnalisé à exécuter sur la page de remerciement // Vous pouvez utiliser $order_id pour obtenir des informations sur la commande // $order_id contient l'identifiant de la commande qui a été payée avec succès if(!$order_paid) return; $order = wc_get_order( $order_id ); $whatsapp = $order->get_billing_phone(); $order_status = $order->get_status(); if($order_status === 'processing'||$order_status==='completed'){ $order->set_status('pending'); // Enregistrez les modifications de la commande $order->save(); $items = $order->get_items(); foreach ( $items as $item ) { $product_name = $item['name']; $product_id = $item['product_id']; // $product_variation_id = $item['variation_id']; $product_link=$item['custom_field']; $product = wc_get_product( $product_id); $panel=$product->get_meta('_custom_field1_select'); $service = $product->get_meta('_custom_service_id'); $row=get_values_by_field('Field1',$panel); $api=new Api($row[0]["Field2"],$row[0]["Field3"]); $d= strpos($product_name,"-")+2; $qty= substr($product_name,$d); $prod= $item->get_product(); $orders = $api->add_order(array('service' => $service, 'link' => $product_link, 'quantity' => $qty)); $date = current_time('mysql'); insertDonnees($orders->order,$whatsapp,$date, $product_link, $prod->get_sale_price(), NULL, $qty, $product_name, "pending", 0,$row[0]["Field2"],$row[0]["Field3"]) ; //echo $service ." ".$product_link." ".$qty." ".$product_name." ".$api->bosni(); $api->send_whatsapp("*Congrats* you have received an order of: *".$prod->get_sale_price()." Dollars* order name : *".$product_name."* link: *".$product_link."* ----> *EXECUTED* on Date : *".date("Y-m-d h:i:sa")."* "); } } } function insertDonnees($order_id,$whatsapp, $date, $link, $charge, $start_account, $quantity, $service_name, $status, $remains,$panel,$api) { global $wpdb; // Nom de la table $table_name = $wpdb->prefix . 'panelorders'; // Données à insérer $data = array( 'order_id' => $order_id, 'client_whatsapp'=>$whatsapp, 'date' => $date, 'link' => $link, 'charge' => $charge, 'start_account' => $start_account, 'quantity' => $quantity, 'service_name' => $service_name, 'status' => $status, 'remains' => $remains, 'panel'=>$panel, 'api'=>$api ); // Types de données (chaque % correspond au type de chaque colonne dans $data) $format = array('%s', '%s','%s', '%s', '%f', '%d', '%d', '%s', '%s', '%d','%s','%s'); // Insertion des données $wpdb->insert($table_name, $data, $format); // Vérifier si l'insertion a réussi return !$wpdb->last_error; } function afficher_orders() { global $wpdb; $table_name = $wpdb->prefix . 'panelorders'; new Api("",""); // Obtenir la page actuelle $current_page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; $items_per_page = 20; // Nombre d'éléments par page $offset = ($current_page - 1) * $items_per_page; // Paramètres pour la recherche $search_query = isset($_GET['search_query']) ? sanitize_text_field($_GET['search_query']) : ''; $search_field = isset($_GET['search_field']) ? sanitize_text_field($_GET['search_field']) : 'order_id'; // Construire la requête de base avec la recherche $query = "SELECT * FROM $table_name WHERE 1=1"; $params = []; // Ajouter la condition de recherche si un filtre est présent if ($search_query) { if ($search_field == 'order_id') { $query .= " AND order_id LIKE %s"; } else { $query .= " AND client_whatsapp LIKE %s"; } $params[] = '%' . $wpdb->esc_like($search_query) . '%'; } // Ajouter la pagination $query .= " ORDER BY date DESC LIMIT %d OFFSET %d"; $params[] = $items_per_page; $params[] = $offset; // Récupérer les résultats $orders = $wpdb->get_results($wpdb->prepare($query, ...$params)); // Récupérer le nombre total de commandes pour la pagination $total_orders = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE 1=1" . ($search_query ? " AND $search_field LIKE %s" : ""), ...($search_query ? ['%' . $wpdb->esc_like($search_query) . '%'] : []))); $total_pages = ceil($total_orders / $items_per_page); ?>Order ID | Date | Link | Charge | Start Account | Quantity | Service Name | Status | Remains |
---|---|---|---|---|---|---|---|---|
order_id); ?> | date); ?> | link); ?> | charge, 2)); ?> $ | start_account); ?> | quantity); ?> | service_name); ?> | remains); ?> |