namespace WPGEN; use Orhanerday\OpenAi\OpenAi; if (!class_exists('WPG_Moteur')) { final class WPG_Moteur { private static $instance = null; private $api_param; private $sous_titre = array(); private $paragraphe = array(); private $introduction = ''; private $conclusion = ''; private $slogan = ''; private $faq = ''; private $metadescription = ''; private $image_url = ''; private $metatitle = ''; private $heading = ''; private $current_api_key; private $who_is_me = ''; public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } public function __construct() { $this->api_param = $this->get_config_api(); } public function write_error($error_text) { goto xubIi; eNRsS: fclose($handle); goto wCg2C; QNaEC: fwrite($handle, $error_text . "\n"); goto eNRsS; xubIi: $log_file = WPGENERATOR_PLUGIN_DIR . '/wpg-log-file.txt'; goto Ie7DK; Ie7DK: $handle = fopen($log_file, 'a'); goto QNaEC; wCg2C: } public function write_json($name, $data) { goto BP0P1; fCdbk: return 'json write'; goto IetMq; hiwJf: $handle = fopen($filename, 'a'); goto FPxMF; BP0P1: $filename = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . $name . '.json'; goto hiwJf; lTnKH: fclose($handle); goto fCdbk; NdOO3: flock($handle, LOCK_UN); goto lTnKH; FPxMF: flock($handle, LOCK_EX); goto RZlV6; RZlV6: fwrite($handle, $data . "\n"); goto NdOO3; IetMq: } public function is_cle_openai_ok($cle_entrer) { goto CrNa8; zNNQM: global $wpdb; goto uB4SD; Q7MLu: $open_ai_info = $open_ai->getCURLInfo(); goto wM6Vx; wM6Vx: $status = 'OK'; goto zWIOD; zWIOD: $models = array(); goto dy1W4; dy1W4: if ($open_ai_info['http_code'] < 200 or $open_ai_info['http_code'] > 300) { if ($open_ai_info['http_code'] == 429 or $open_ai_info['http_code'] == 401) { $status = 'KO'; } } else { goto ogL82; DxY34: foreach (ACCEPTED_MODELS as $value) { if (in_array($value, $ids)) { $models[] = $value; } } goto dPw6A; ogL82: $model_data = $model_list['data']; goto E1xx0; E1xx0: $ids = array_column($model_data, 'id'); goto DxY34; dPw6A: } goto zNNQM; lWA0w: $data_key = ['tbl_api_key_val' => $cle_entrer, 'api_key_status' => $status, 'openai_model' => json_encode($models)]; goto zoKRU; zoKRU: $wpdb->insert($table_apikey, $data_key); goto OZs8g; vI33n: $model_list = json_decode($open_ai->listModels(), true); goto Q7MLu; z8FVX: $open_ai = new OpenAi($cle_entrer); goto vI33n; CrNa8: $cle_entrer = trim($cle_entrer); goto z8FVX; uB4SD: $table_apikey = $wpdb->get_blog_prefix() . 'tbl_apikey_liste'; goto lWA0w; OZs8g: } public function get_ligne_a_traiter() { goto ALyAH; n3h0O: return $row_single; goto Tq70_; OWa9S: $sql = "SELECT * FROM " . $wpdb->get_blog_prefix() . "posts" . " WHERE post_type='wpg_bulk' AND post_status='pending' ORDER BY post_modified ASC"; goto F9BNK; F9BNK: $row_single = $wpdb->get_row($sql); goto n3h0O; ALyAH: global $wpdb; goto OWa9S; Tq70_: } private function get_ligne_progress() { goto LSkbQ; gHRGV: $total_progress = count($result); goto ySWGz; NJ43H: $sql = "SELECT * FROM " . $wpdb->get_blog_prefix() . "posts" . " WHERE post_type='wpg_bulk' AND post_status='progress'"; goto jmTuQ; QU0rv: $now_date = current_time('timestamp'); goto yZKIv; D7BOY: if ($post) { goto RL3vK; U8eZp: $modified_date = $post->meta_value; goto D_0nK; D_0nK: if (abs(intval($now_date) - intval($modified_date)) < 50) { $this->write_error('Execution bulk too short: ' . abs($now_date - $modified_date) . ' secondes'); return false; } goto Yehio; RL3vK: $idPost = $post->ID; goto U8eZp; Yehio: } goto V4S97; ySWGz: $this->write_error('Check all progress'); goto kBbE6; jmTuQ: $result = $wpdb->get_results($sql); goto lC3lZ; LSkbQ: global $wpdb; goto QU0rv; kBbE6: foreach ($result as $post) { goto BqA6n; BqA6n: $idPost = $post->ID; goto J4AAi; J4AAi: $chk_finished = $this->check_bulk_progress_finished($idPost); goto P7ZcV; P7ZcV: if ($chk_finished === true) { $total_progress = $total_progress - 1; } else { goto oMycA; GguCi: $failed = false; goto ii03H; gm5AE: if ($valid_url !== false) { $time_failed = 750; $wpg_type_generate = 'rewrite_by_scrap'; } goto GguCi; jWnNT: $wpgKWurl = filter_var(get_post_meta($idPost, 'wpg_keyword_post', true), FILTER_SANITIZE_URL); goto zn7Ff; ii03H: if (abs($now_date - $modified_date) >= $time_failed) { $this->write_error('Progress trop long'); $failed = true; } goto dTOPG; oMycA: $modified_date = get_the_modified_time('U', $idPost); goto jWnNT; A3aFv: $time_failed = 500; goto gm5AE; dTOPG: if ($failed === true) { $this->sauvegarde_partielle($idPost); $total_progress = $total_progress - 1; } goto e9TxB; zn7Ff: $valid_url = filter_var($wpgKWurl, FILTER_VALIDATE_URL); goto thQhC; thQhC: $wpg_type_generate = 'generate_by_kw'; goto A3aFv; e9TxB: } goto DdT5F; DdT5F: } goto hWqVD; eb6mL: $result = $wpdb->get_results($sql); goto QXpZf; hWqVD: $sql = "SELECT ID, meta_value FROM " . $wpdb->get_blog_prefix() . "posts" . " JOIN " . $wpdb->get_blog_prefix() . "postmeta" . " WHERE ID = post_id AND post_type='wpg_bulk' AND post_status='progress' AND meta_key = 'wpg_bulk_start_time' ORDER BY meta_value DESC LIMIT 1"; goto YQrR_; yZKIv: $sql = "SELECT * FROM " . $wpdb->get_blog_prefix() . "posts" . " WHERE post_type='wpg_bulk' AND post_status='saving'"; goto eb6mL; YQrR_: $post = $wpdb->get_row($sql); goto D7BOY; V4S97: return $total_progress; goto Vs8WF; QXpZf: if ($result) { foreach ($result as $post) { goto S3ND_; S3ND_: $idPost = $post->ID; goto KxWd_; hLkrf: $time_failed = 300; goto VHphp; VHphp: if (abs($now_date - $modified_date) >= $time_failed) { $this->write_error('Saving trop long'); $this->mettre_a_jour_status_post($idPost, 'failed'); } goto CszWx; KxWd_: $modified_date = get_the_modified_time('U', $idPost); goto hLkrf; CszWx: } } goto NJ43H; lC3lZ: if (!$result) { return 0; } goto gHRGV; Vs8WF: } private function sauvegarde_partielle($post_id) { goto O493g; xbEex: if (file_exists($filename_inputs) && file_exists($filename_zen) && file_exists($filename_source)) { goto sDU9R; rjjJZ: $response = wp_remote_post($url, $args); goto Q3uUA; Q3uUA: return true; goto FGaxe; sDU9R: $this->mettre_a_jour_status_post($post_id, 'saving'); goto kzq35; MPzuC: $url = admin_url('admin-ajax.php'); goto rjjJZ; kzq35: $args = array('timeout' => 0.01, 'blocking' => false, 'cookies' => $_COOKIE, 'headers' => array('Cache-Control' => 'no-cache'), 'body' => array('action' => 'wpg_bulk_finished', 'nonce' => wp_create_nonce('wpg_bulk_finished'), 'post_id' => $post_id), 'sslverify' => apply_filters('https_local_ssl_verify', false)); goto MPzuC; FGaxe: } else { $this->mettre_a_jour_status_post($post_id, 'failed'); } goto UCkg5; eznai: $filename_zen = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'zen-' . $post_id . '.json'; goto Y99FE; O493g: $filename_inputs = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'inputs-' . $post_id . '.json'; goto eznai; Y99FE: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $post_id . '.json'; goto xbEex; UCkg5: } private function check_bulk_progress_finished($post_id) { goto yoc2h; GO2X_: $filename_zen = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'zen-' . $post_id . '.json'; goto VV4RG; yoc2h: $filename_inputs = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'inputs-' . $post_id . '.json'; goto GO2X_; VV4RG: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $post_id . '.json'; goto ZBYd8; BL_oy: return false; goto WcOQg; ZBYd8: if (file_exists($filename_inputs) && file_exists($filename_zen) && file_exists($filename_source)) { goto afWCB; vTe1W: $zen_file = trim($zenFile_content); goto aMIeL; gOXVy: for ($i = 0; $i < count($zen_tab); $i++) { $json_zen_tab = json_decode($zen_tab[$i], true); $keys = array_keys($json_zen_tab); $json_zen[$keys[0]] = $json_zen_tab[$keys[0]]; } goto yeS1_; afWCB: $inputs_content = file_get_contents($filename_inputs); goto yAFKy; yAFKy: $zenFile_content = file_get_contents($filename_zen); goto DwsYS; DwsYS: $sourceFile_content = file_get_contents($filename_source); goto kqNHn; o_L8q: $total_source = count($source_file); goto vTe1W; kqNHn: $inputs = json_decode($inputs_content, true); goto iSwlX; iSwlX: $source_file = json_decode($sourceFile_content, true); goto o_L8q; L_9Bb: return false; goto gIBe1; yeS1_: if (count($json_zen) == $total_source) { goto seOIs; Ehz0K: $url = admin_url('admin-ajax.php'); goto T4nIW; gEFnC: return true; goto puQED; seOIs: $this->mettre_a_jour_status_post($post_id, 'saving'); goto cIpIS; T4nIW: $response = wp_remote_post($url, $args); goto gEFnC; cIpIS: $args = array('timeout' => 0.01, 'blocking' => false, 'cookies' => $_COOKIE, 'headers' => array('Cache-Control' => 'no-cache'), 'body' => array('action' => 'wpg_bulk_finished', 'nonce' => wp_create_nonce('wpg_bulk_finished'), 'post_id' => $post_id), 'sslverify' => apply_filters('https_local_ssl_verify', false)); goto Ehz0K; puQED: } goto L_9Bb; aMIeL: $zen_tab = explode("\n", $zen_file); goto mL4Ib; mL4Ib: $json_zen = array(); goto gOXVy; gIBe1: } goto BL_oy; WcOQg: } public function get_config_api() { goto gkH4M; OYu2y: return $param_openai; goto moYM3; QfOxY: $param_openai = $wpdb->get_row($sql); goto OYu2y; gkH4M: global $wpdb; goto pljvl; tlCVZ: $sql = sprintf('SELECT * FROM ' . $wpgTable . ' WHERE tbl_name="tbl_g_config"'); goto QfOxY; pljvl: $wpgTable = $wpdb->get_blog_prefix() . 'tbl_config'; goto tlCVZ; moYM3: } private function get_an_row_apikey() { goto sMYTT; t70iR: return $param_openai; goto UV9y7; lGBei: $apk_list_table = $wpdb->get_blog_prefix() . 'tbl_apikey_liste'; goto QVsRP; QVsRP: $sql = sprintf('SELECT * FROM ' . $apk_list_table . ' WHERE api_key_status="OK" ORDER BY RAND()'); goto miZDl; sMYTT: global $wpdb; goto lGBei; miZDl: $param_openai = $wpdb->get_row($sql); goto t70iR; UV9y7: } private function get_apikeyById($id) { goto qjWa0; sYAlY: $apk_list_table = $wpdb->get_blog_prefix() . 'tbl_apikey_liste'; goto ZA0kF; oPv29: return $param_openai; goto qmNy7; mVOnS: $param_openai = $wpdb->get_row($sql); goto oPv29; ZA0kF: $sql = sprintf('SELECT * FROM ' . $apk_list_table . ' WHERE ID=' . $id); goto mVOnS; qjWa0: global $wpdb; goto sYAlY; qmNy7: } private function update_info_apk($apkId, $quota, $nb_task, $status) { goto GmWMQ; GmWMQ: global $wpdb; goto NEKrb; NEKrb: $table_name = $wpdb->get_blog_prefix() . "tbl_apikey_liste"; goto WPkXc; S2YQ4: $wpdb->query($sql); goto HnWka; WPkXc: $sql = "UPDATE {$table_name} SET tbl_api_quota_used = {$quota}, nb_task_progress = {$nb_task}, api_key_status = '{$status}' WHERE id = {$apkId}"; goto S2YQ4; HnWka: } private function setApkId() { goto M1cnL; Ho14i: if ($apk_row) { goto KCGFF; whbOv: $apk['apkId'] = $apk_row->tbl_api_key_val; goto WjdKi; WjdKi: $apk['apkModels'] = $apk_row->openai_model; goto fv9g0; KCGFF: $this->current_api_key = $apk_row; goto whbOv; fv9g0: } else { $apk['apkId'] = -1; } goto CTNiL; M1cnL: $apk_row = $this->get_an_row_apikey(); goto Ho14i; CTNiL: return $apk; goto PuPYK; PuPYK: } public function send_remote($param_info, $url) { goto bPYvF; c9mAi: if ($apikey != -1) { goto C3xY8; OdpMM: $response = wp_remote_post($url, $args); goto MJGzv; C3xY8: $args = array('headers' => array('Content-Type' => 'application/json'), 'body' => json_encode($data)); goto OdpMM; MJGzv: $response_code = wp_remote_retrieve_response_code($response); goto T_SuP; T_SuP: if (intval($response_code) === 200) { goto ZPKTq; LL62O: return $response; goto syotg; Ipwft: if ($response['code'] != 200) { $this->write_error('1:' . $body); return false; } goto LL62O; ZPKTq: $body = wp_remote_retrieve_body($response); goto f5UJy; f5UJy: $response = json_decode($body, true); goto Ipwft; syotg: } else { goto Wea8W; uk3qi: return false; goto IXQ8J; Wea8W: $body = wp_remote_retrieve_body($response); goto zAXCz; zAXCz: $this->write_error('2:' . $body); goto uk3qi; IXQ8J: } goto ZHF8U; ZHF8U: } else { goto v0WS9; TbzET: if ($param_info['postID'] != 0) { $this->mettre_a_jour_status_post($param_info['postId'], 'ko'); exit; } goto cZKvG; v0WS9: $this->write_error('3:' . $param_info['postID']); goto TbzET; cZKvG: return false; goto xQCbN; xQCbN: } goto f0V0z; QCqtP: $data = array_merge($data_fixe, $param_info); goto c9mAi; ObRDO: $wpg_licence = $this->api_param->tbl_licence; goto blmmi; blmmi: $wpg_langue = $this->api_param->tbl_language; goto b3BUC; bPYvF: if (!array_key_exists("apikey", $param_info)) { $apikey = $this->setApkId(); $apikey = $apikey['apkId']; } else { $apikey = $param_info['apikey']; } goto ObRDO; b3BUC: if (array_key_exists('langue_output', $param_info) && !empty($param_info['langue_output'])) { $wpg_langue = $param_info['langue_output']; } goto oPUFf; oPUFf: if (!isset($param_info['who_is_me'])) { $param_info['who_is_me'] = $this->who_is_me; } goto fVOsE; fVOsE: $data_fixe = array('apikey' => $apikey, 'licence' => $wpg_licence, 'langue' => $wpg_langue, 'url_plugin' => get_site_url(), 'domaine' => $_SERVER['SERVER_NAME']); goto QCqtP; f0V0z: } private function retrieve_content_openai($data, $engine, $type_generer) { goto WvU5S; lGtuI: return $content; goto e7JiM; xyZoz: $response = $this->send_remote($datas, GET_OPTIM_CONTENT); goto dCKkr; dCKkr: if ($response === false) { $content = '---'; } else { $content = $response['message']['optimized_content']; } goto lGtuI; wjhZv: switch ($engine) { case 'text-davinci-003': $content = trim($data->choices[0]->text); break; default: $content = trim($data->choices[0]->message->content); break; } goto yqEZL; yqEZL: $datas = ['content' => $content, 'type_generer' => $type_generer]; goto xyZoz; WvU5S: $content = ''; goto wjhZv; e7JiM: } private function get_custom_prompt($file_custom) { goto p63ke; WfxCu: $json = file_get_contents($filePath); goto qx7eW; WEu4q: $filePath = $directory . '/' . $file_custom; goto WfxCu; KTDpi: return $custom_content; goto dPL3D; qx7eW: $custom_content = json_decode($json, true); goto KTDpi; p63ke: $directory = WPGENERATOR_PLUGIN_DIR . '/admin/partials/prompts'; goto WEu4q; dPL3D: } private function set_info_completion($param_info) { goto pRItu; es15o: if ($apikey != -1) { goto bXKv2; cwCjj: $param_info['apikey'] = $apikey; goto iA_VZ; qJSca: if (isset($param_info['custom_prompt']) && $param_info['custom_prompt'] != 0) { $param_info['custom_prompt'] = $this->get_custom_prompt($param_info['custom_prompt']); } else { unset($param_info['custom_prompt']); } goto yE2zQ; bXKv2: if ($param_info['postID'] != 0) { if (isset($param_info['model_ai'])) { $model_ai = get_post_meta($param_info['postID'], 'wpg_model_engine', TRUE); if ($model_ai == '') { update_post_meta($param_info['postID'], 'wpg_model_engine', $param_info['model_ai']); } } elseif (!isset($param_info['model_ai'])) { $model_ai = get_post_meta($param_info['postID'], 'wpg_model_engine', TRUE); if ($model_ai != '') { $param_info['model_ai'] = $model_ai; } } } goto qJSca; iA_VZ: $param_info['prefered_model'] = $this->api_param->wpg_prefered_model; goto NVgVT; yE2zQ: $param_info['supported_models'] = $apk['apkModels']; goto cwCjj; m0HM1: return $info_completion; goto KDcyT; NVgVT: $info_completion = $this->send_remote($param_info, LINK_WP_GENERATOR); goto m0HM1; KDcyT: } else { return false; } goto eRDAo; U4pvF: $apikey = $apk['apkId']; goto es15o; pRItu: $apk = $this->setApkId(); goto U4pvF; eRDAo: } private function update_key_inline($key_val) { $data = array('key_value' => $key_val); $result = $this->send_remote($data, LINK_DESACTIVATE_KEY); } private function libere_key_iniline($key_val, $token) { $data = array('key_value' => $key_val, 'token_val' => $token); $result = $this->send_remote($data, LINK_LIBERATE_KEY); } private function json_validator($data) { if (!empty($data)) { return is_string($data) && is_array(json_decode($data, true)) ? true : false; } return false; } private function check_tries($idPost) { if ($idPost != 0) { goto HWRJl; DZP8B: update_post_meta($idPost, 'wpg_generate_tries', $tries); goto En_WB; HWRJl: $tries = intval(get_post_meta($idPost, 'wpg_generate_tries', true)); goto rVDuO; rVDuO: $tries++; goto DZP8B; En_WB: if ($tries > 4) { goto XNc0C; pDeuL: $this->mettre_a_jour_status_post($idPost, $status); goto dLGcJ; PxrcE: update_post_meta($idPost, 'wpg_generate_tries', 0); goto pDeuL; deY7v: if ($valid_url !== false) { $wpg_type_generate = 'rewrite_by_scrap'; } goto AJuQJ; AJuQJ: wp_update_post(array('ID' => $idPost, 'post_title' => $wpg_type_generate)); goto PxrcE; c71OB: $wpg_type_generate = 'generate_by_kw'; goto deY7v; dLGcJ: return 'stop'; goto Yr7sE; XNc0C: $status = 'retry'; goto Ki4Ik; Ki4Ik: $wpgKWurl = filter_var(get_post_meta($idPost, 'wpg_keyword_post', true), FILTER_SANITIZE_URL); goto ZmBbe; ZmBbe: $valid_url = filter_var($wpgKWurl, FILTER_VALIDATE_URL); goto c71OB; Yr7sE: } goto YXi_d; YXi_d: } return 'restart'; } private function generateur_completion($params) { if ($this->api_param->tbl_licence_is_valid == 1) { goto ahIJD; Gn5jA: if ($response !== false and $response['code'] == 200) { goto PjxGK; BXbwA: $open_ai->setTimeout(180); goto XRCgm; Qlm3T: if (isset($complete->error)) { } else { goto yc720; SQb9g: if ($engine !== 'image') { goto qkpgY; fVmYq: $content = $this->retrieve_content_openai($complete, $engine, $type_generer); goto DvO4A; qkpgY: $type_generer = $params['type_generer']; goto fVmYq; DvO4A: if (empty($content)) { $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle'] . ' : Error : Restart contenu vide'); return 'restart'; } goto zqY3d; zqY3d: } else { $content = $complete; } goto Td5O7; yc720: $engine = isset($response['message']['param']['model']) ? $response['message']['param']['model'] : 'image'; goto SQb9g; qjrU8: return $content; goto ZEc3F; Td5O7: if (property_exists($complete, 'usage') && property_exists($complete->usage, 'total_tokens')) { if ($is_gatis == 0) { goto qs2YV; qs2YV: $new_token = $this->current_api_key->tbl_api_quota_used + intval($complete->usage->total_tokens); goto DkOFT; GH7z4: $this->update_info_apk($this->current_api_key->ID, $new_token, $new_task, 'OK'); goto Y03OK; DkOFT: $new_task = $this->current_api_key->nb_task_progress; goto GH7z4; Y03OK: } elseif ($is_gatis == 1) { $this->libere_key_iniline($response['message']['apkval'], intval($complete->usage->total_tokens)); } } goto qjrU8; ZEc3F: } goto JYxUF; xMfp4: $open_ai_info = $open_ai->getCURLInfo(); goto Q3D8A; NieIu: if ($this->json_validator($complete) === false) { $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : retour nojson 2 and restart:' . $params['type_generer'] . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle'] . ' - complete :' . $complete); return 'restart'; } goto AVOmi; bXbNa: sleep($sleep_time); goto GUkav; QYHOF: $this->write_error('temps de pause: ' . $sleep_time); goto bXbNa; XRCgm: if ($params['img'] == 0) { switch ($response['message']['param']['model']) { case 'text-davinci-003': $complete = $open_ai->completion($response['message']['param']); break; default: $complete = $open_ai->chat($response['message']['param']); break; } $this->write_error('Date : ' . date('Y-m-d h:i:s') . ': ' . $params['type_generer'] . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle']); } else { $complete = $open_ai->image($response['message']['param']); $this->write_error('Date : ' . date('Y-m-d h:i:s') . ': ' . $params['type_generer'] . ' - postID:' . $params['postID']); } goto xMfp4; AVOmi: $complete = json_decode($complete); goto Qlm3T; PjxGK: $this->heading = $response['message']['heading']; goto TZmwB; TZmwB: $sleep_time = $response['message']['sleep_time']; goto QYHOF; Q3D8A: if ($open_ai_info['http_code'] < 200 or $open_ai_info['http_code'] > 300) { goto thx8a; D3xrq: $complete = json_decode($complete); goto emxAx; thx8a: if ($this->json_validator($complete) === false) { $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : retour nojson 1 and restart:' . $open_ai_info['http_code'] . '- Type:' . $params['type_generer'] . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle'] . ' - complete :' . $complete); return 'restart'; } goto D3xrq; XOI6R: return 'restart'; goto lT8Fi; emxAx: if ($open_ai_info['http_code'] == 429 or $open_ai_info['http_code'] == 401) { $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : error openai :' . $params['type_generer'] . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle'] . ' - complete :' . json_encode($complete)); if ($complete->error->type == "insufficient_quota" || $complete->error->code == "invalid_api_key" || $complete->error->type == "billing_not_active" || $complete->error->code == "account_deactivated") { goto GoIzI; yOkD9: if ($is_gatis == 0) { $this->update_info_apk($this->current_api_key->ID, $this->current_api_key->tbl_api_quota_used, $this->current_api_key->nb_task_progress, 'KO'); } elseif ($is_gatis == 1 && $new_status_apk == 'KO') { $this->update_key_inline($response['message']['apkval']); } goto zCH_m; GoIzI: $new_status_apk = 'KO'; goto yOkD9; zCH_m: return 'restart'; goto YAaHq; YAaHq: } } else { if (str_contains($complete->error->message, 'safety') === true) { if ($params['type_generer'] == 'image') { return 'safety'; } elseif ($params['type_generer'] == 'paragraphe') { if ($params['h2_pos'] != 'first') { return 'safety'; } } else { if ($params['postID'] !== 0) { $this->mettre_a_jour_status_post($params['postID'], 'safety'); } return 'stop'; } } } goto bW77r; bW77r: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : error openai restart:' . $params['type_generer'] . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle']); goto XOI6R; lT8Fi: } goto NieIu; GUkav: $open_ai = new OpenAi($response['message']['apkval']); goto BXbwA; JYxUF: } else { goto JI9NT; lhB7k: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle'] . ' : response pas bon'); goto zrXYa; zrXYa: return 'stop'; goto YL4I_; JI9NT: if ($params['postID'] != 0) { if ($response === false) { } elseif ($response['code'] == 410) { $new_status = 'quota'; $this->mettre_a_jour_status_post($params['postID'], $new_status); } elseif ($response['code'] == 403) { $new_status = 'licence'; $this->mettre_a_jour_status_post($params['postID'], $new_status); } elseif ($response['code'] == 401) { $new_status = 'failed'; $this->mettre_a_jour_status_post($params['postID'], $new_status); } else { } } goto lhB7k; YL4I_: } goto FyZKq; MiMt_: $heading = $response['message']['heading']; goto Z22wB; tUClZ: $response = $this->set_info_completion($params); goto YGJW4; ahIJD: if ($params['postID'] != 0) { goto dZnX7; dZnX7: global $wpdb; goto ukVr7; S7lqi: $post = $wpdb->get_row($sql); goto fU5ti; fU5ti: if ($post) { if ($post->post_status != 'progress' and $post->post_status != 'saving') { exit; } } else { exit; } goto AQq0d; ukVr7: $sql = "SELECT * FROM " . $wpdb->get_blog_prefix() . "posts" . " WHERE ID = " . $params['postID']; goto S7lqi; AQq0d: } goto tUClZ; YGJW4: if ($response === false) { if ($params['postID'] != 0) { $this->sauvegarde_partielle($params['postID']); exit; } } goto MiMt_; Z22wB: $is_gatis = 0; goto Gn5jA; FyZKq: } else { goto FLuTM; Wg8Mk: return 'stop'; goto psUi5; UWESk: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' - postID:' . $params['postID'] . ' KW:' . $params['mot_cle'] . ' : Licence non valide'); goto Wg8Mk; FLuTM: if ($params['postID'] != 0) { $this->mettre_a_jour_status_post($params['postID'], 'licence'); } goto UWESk; psUi5: } } public function generate_text($inputs) { goto Pg5wS; lPjQ0: do { $inputs['tries'] = $tries; $complete = $this->generateur_completion($inputs); if (is_string($complete) && $complete == 'restart') { goto M3hF5; QQZty: $tries++; goto ZaPIa; S0KjL: if ($tries > 4) { $complete = 'stop'; } goto ouznn; y6hZz: $inputs['model_ai'] = 'text-davinci-003'; goto QQZty; M3hF5: sleep(2 * $tries); goto y6hZz; ZaPIa: $this->write_error('Nb essai :' . $tries . ' Type :' . $inputs['type_generer']); goto S0KjL; ouznn: } } while (is_string($complete) && $complete == 'restart'); goto AMIRo; VzgtE: return $resultat; goto ZqHcc; Pg5wS: $tries = 1; goto lPjQ0; EV_fu: $resultat['type_generer'] = $type_generer; goto VzgtE; AMIRo: $type_generer = $inputs['type_generer']; goto DCz5c; YRGeq: $resultat[$type_generer] = $complete; goto ElpeD; DCz5c: if (is_string($complete) && $complete == 'stop') { exit; } goto gShDK; gShDK: if ($type_generer == 'paragraphe') { if ($complete == 'safety') { $complete = "\n

Votre demande a été rejetée en raison du système de modération d'OpenAI. Votre sujet peut contenir du texte qui n'est pas autorisé par la politique de modération.

"; } } goto YRGeq; ElpeD: $resultat['heading'] = $this->heading; goto EV_fu; ZqHcc: } public function generer_images($inputs) { goto G62SK; vSzMo: return $resultat; goto mCOhD; n4l38: if ($completeImage == 'safety') { for ($i = 0; $i < $inputs['nb_img_gen']; $i++) { $images[$i] = ''; } } else { for ($i = 0; $i < $inputs['nb_img_gen']; $i++) { $images[$i] = trim($completeImage->data[$i]->url); } } goto m2ngF; m2ngF: $resultat['error'] = ''; goto bYxU_; G62SK: $tries = 1; goto ZRG1K; ROt2r: if (is_string($completeImage) && $completeImage == 'stop') { exit; } goto n4l38; bYxU_: $resultat['url_images'] = $images; goto vSzMo; ZRG1K: do { $inputs['tries'] = $tries; $completeImage = $this->generateur_completion($inputs); if (is_string($completeImage) && $completeImage == 'restart') { goto bv2UG; bv2UG: sleep(2 * $tries); goto SYwPS; ws_Ci: if ($tries > 4) { $completeImage = 'stop'; } goto RiOSc; SYwPS: $inputs['model_ai'] = 'text-davinci-003'; goto iTCvF; iTCvF: $tries++; goto ws_Ci; RiOSc: } } while (is_string($completeImage) && $completeImage == 'restart'); goto ROt2r; mCOhD: } private function mettre_a_jour_status_post($wpg_postId, $status) { if ($wpg_postId != 0) { $post_id_update = wp_update_post(array('ID' => $wpg_postId, 'post_status' => $status), true); if (!is_wp_error($post_id_update)) { } } } public function save_image($imageurl, $titre_article) { goto IAHhi; SLk9B: if (isset($result)) { $response = $result; } else { $response = false; } goto R9R5k; IAHhi: global $wpdb; goto k2i2M; lzR2x: if (!function_exists('download_url')) { include_once ABSPATH . 'wp-admin/includes/file.php'; } goto nmQ9t; GvG_r: if (!function_exists('wp_generate_attachment_metadata')) { include_once ABSPATH . 'wp-admin/includes/image.php'; } goto lzR2x; k2i2M: $seoai_image_attachment_url = ''; goto GvG_r; nmQ9t: if (!function_exists('media_handle_sideload')) { include_once ABSPATH . 'wp-admin/includes/media.php'; } goto g3MN7; R9R5k: return $response; goto N_iJO; g3MN7: try { goto PlwAf; zbI5m: $uniq_name = sanitize_title($titre_article) . '-' . time(); goto L535L; tZ8N6: $checkExist = $wpdb->get_row("SELECT * FROM {$wpdb->get_blog_prefix()}postmeta WHERE meta_value LIKE '%/{$filename}'"); goto tz6aK; L535L: $filename = sanitize_file_name($uniq_name . '.' . $imagetype); goto tZ8N6; YFj30: $imagetype = end($array); goto zbI5m; PlwAf: $array = explode('/', getimagesize($imageurl)['mime']); goto YFj30; tz6aK: if ($checkExist) { $result['img_url'] = wp_get_attachment_url($checkExist->post_id); $result['attachment_id'] = $checkExist->post_id; } else { goto rm4Tz; TKCHw: $update_attachement = update_post_meta($attachment_id, '_wp_attachment_image_alt', $titre_article); goto l51_e; Qg3tS: $tmp = $this->compressImage($tmp, $tmp, 65); goto G_ngx; u2jcG: @unlink($tmp); goto YHSqT; G_ngx: $args = array('name' => $filename, 'tmp_name' => $tmp); goto RAIok; S3SSK: if (is_wp_error($tmp)) { return false; } goto Qg3tS; RAIok: $attachment_id = media_handle_sideload($args, 0, '', array('post_title' => $titre_article, 'post_content' => $titre_article, 'post_excerpt' => $titre_article)); goto TKCHw; rm4Tz: $tmp = download_url($imageurl, 30); goto S3SSK; l51_e: if ($update_attachement !== false) { goto vubM2; pYh12: $result['img_url'] = $seoai_image_attachment_url; goto qXfSC; eZVzy: $attach_data = wp_generate_attachment_metadata($attachment_id, $fullsizepath); goto OUXbI; HT2y4: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : ' . json_encode($result)); goto h7Ft3; OUXbI: wp_update_attachment_metadata($attachment_id, $attach_data); goto i_QuE; qXfSC: $result['attachment_id'] = $attachment_id; goto HT2y4; i_QuE: $seoai_image_attachment_url = wp_get_attachment_url($attachment_id); goto pYh12; vubM2: $imagenew = get_post($attachment_id); goto iWlYa; iWlYa: $fullsizepath = get_attached_file($imagenew->ID); goto eZVzy; h7Ft3: } goto u2jcG; YHSqT: } goto yEepK; yEepK: } catch (\Exception $exception) { } goto SLk9B; N_iJO: } public function maj_quota() { goto rgxRl; Cnn0H: $result = $this->send_remote($data, MAJ_QUOTA_LICENCE); goto PDMhG; rgxRl: $data = array(); goto Cnn0H; PDMhG: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' - Vita : Quota licence mihena'); goto GhUAq; GhUAq: } public function run_moteur() { goto IsVlr; ixVSi: $nb_apk = count($liste_api); goto IsCBd; hpqwt: if ($nb_progress < $limit) { $this->generer_tous(); } else { } goto YvhF8; A5oq6: $table_list = $wpdb->get_blog_prefix() . 'tbl_apikey_liste'; goto SUPIW; IsVlr: global $wpdb; goto UitPJ; SSxrY: $nb_progress = $this->get_ligne_progress(); goto jjaJe; VA53l: if ($apk['apkId'] == -1) { exit; } goto SSxrY; jjaJe: if ($nb_progress === false) { exit; } goto K8gIS; IsCBd: if ($nb_apk >= 5) { $limit = 5; } elseif ($nb_apk > 2 and $nb_apk < 5) { $limit = $nb_apk; } goto hpqwt; K8gIS: $limit = 2; goto A5oq6; UitPJ: $apk = $this->setApkId(); goto VA53l; SUPIW: $liste_api = $wpdb->get_results("SELECT * FROM {$table_list} WHERE api_key_status='OK'", ARRAY_A); goto ixVSi; YvhF8: } public function generer_tous() { $ligne_a_traiter = $this->get_ligne_a_traiter(); if (!empty($ligne_a_traiter)) { switch (trim($ligne_a_traiter->post_title)) { case 'generate_by_kw': $this->process_step_one_bulk($ligne_a_traiter); break; case 'rewrite_by_scrap': $this->process_step_one_bulk($ligne_a_traiter); break; case 'generate_product_cat': $this->process_generate_product_cat($ligne_a_traiter); break; case 'generate_product': $this->process_generate_product($ligne_a_traiter); break; default: goto v5ZyK; fryzR: break; goto OU3Vy; v5ZyK: $filename_zen = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'zen-' . $post_id . '.json'; goto FqD_i; FqD_i: @unlink($filename_zen); goto JL5QI; BR3BN: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : error = pas bon title'); goto bIaEi; afDAK: $this->mettre_a_jour_status_post($ligne_a_traiter->ID, 'failed'); goto BR3BN; JL5QI: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $id_post_ligne . '.json'; goto lmfRA; bIaEi: exit; goto fryzR; lmfRA: @unlink($filename_source); goto afDAK; OU3Vy: } } else { } } private function continue_bulk($ligne_a_traiter) { exit; } private function process_generate_product($ligne_a_traiter) { goto P6s4p; nMy1q: usleep(1500); goto wYg2i; eRiHU: $sous_titre_json = $this->write_json($json_filename, json_encode($product_outline)); goto jK5Cc; iSosZ: $inputs['type_generer'] = 'product_outline'; goto DFYM7; jK5Cc: for ($i = 1; $i <= count($product_outline); $i++) { $inputs = array('type_generer' => 'product_paragraphe', 'mot_cle' => $mot_cle, 'postID' => $id_post_ligne, 'img' => 0, 'pos' => $i, 'h2' => $product_outline[$i], 'sections' => $product_outline, 'total_content' => count($product_outline), 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); $this->cron_gen_paragraphe($inputs); if ($i % 5 == 0) { sleep(5); } else { usleep(1500); } } goto FunV2; IsnC_: $this->write_json($json_inputs_filename, json_encode($inputs)); goto od2rv; r8p4M: $json_filename = 'source-' . $id_post_ligne; goto eRiHU; tFspJ: $inputs = array('type_generer' => 'product_intro', 'mot_cle' => $mot_cle, 'postID' => $id_post_ligne, 'img' => 0, 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); goto rVlga; DFYM7: $product_outline = $this->generate_text($inputs)['product_outline']; goto lyYvq; v2sYV: $inputs['type_generer'] = 'product_list'; goto pFGAx; rVlga: $product_intro = $this->generate_text($inputs)['product_intro']; goto gWkSR; UO02P: $this->mettre_a_jour_status_post($id_post_ligne, 'progress'); goto E8lF_; hRBRw: $filename_zen = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'zen-' . $id_post_ligne . '.json'; goto vhaqZ; B8iEv: usleep(1500); goto RHhPy; E8lF_: update_post_meta($id_post_ligne, 'wpg_bulk_start_time', current_time('timestamp')); goto tFspJ; P6s4p: $id_post_ligne = $ligne_a_traiter->ID; goto hRBRw; brPZO: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $id_post_ligne . '.json'; goto DjloB; rbIY0: $post_array = array('ID' => $id_post_ligne, 'post_name' => sanitize_title($mot_cle), 'post_excerpt' => $fiche_content, 'meta_input' => $metaInput); goto jQ4gn; lyYvq: $fiche_content = $product_intro . "\n---\n" . $product_list . "\n---\n" . $product_summary; goto rbIY0; DjloB: @unlink($filename_source); goto FZjnU; FunV2: $json_inputs_filename = 'inputs-' . $id_post_ligne; goto IsnC_; FZjnU: if ($ligne_a_traiter->post_content != '') { goto fWUMe; lUxoS: $langue_output = $data_content->langue_output; goto Zaznc; Zaznc: $prix_moyen = $data_content->prix_moyen; goto UirCe; dNwht: $langue_source = $data_content->langue_source; goto lUxoS; L_us_: $cat_creation = intval($data_content->category); goto NCFV1; fWUMe: $data_content = json_decode($ligne_a_traiter->post_content); goto L_us_; NCFV1: $custom_prompt = $data_content->custom_prompt; goto dNwht; UirCe: } else { exit; } goto JwbBM; GBmVE: $seo = $this->wpg_seo_plugin_activated(array('metatitle' => $mot_cle . ' - ' . get_bloginfo('name'), 'metadesc' => $product_meta_desc)); goto A3A76; Xebe4: usleep(1500); goto iSosZ; vhaqZ: @unlink($filename_zen); goto brPZO; pFGAx: $product_list = $this->generate_text($inputs)['product_list']; goto nMy1q; jQ4gn: $post_id_update = wp_update_post($post_array, true); goto ExS6d; YdvN2: $product_summary = $this->generate_text($inputs)['product_summary']; goto B8iEv; JwbBM: $type_generer = $ligne_a_traiter->post_title; goto D8fwq; D8fwq: $mot_cle = get_post_meta($id_post_ligne, 'wpg_keyword_post', true); goto UO02P; RHhPy: $inputs['type_generer'] = 'product_meta_desc'; goto ZJTzj; A3A76: $metaInput = array($seo['metatitle']['name'] => $seo['metatitle']['value'], $seo['metadesc']['name'] => $seo['metadesc']['value']); goto Xebe4; gWkSR: usleep(1500); goto v2sYV; ExS6d: $product_outline = array_combine(range(1, count($product_outline)), $product_outline); goto r8p4M; wYg2i: $inputs['type_generer'] = 'product_summary'; goto YdvN2; ZJTzj: $product_meta_desc = $this->generate_text($inputs)['product_meta_desc']; goto GBmVE; od2rv: } private function process_generate_product_cat($ligne_a_traiter) { goto q18mC; WEZMX: $json_filename = 'source-' . $id_post_ligne; goto sn4Ge; yXnKo: $filename_zen = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'zen-' . $id_post_ligne . '.json'; goto ygD2T; aXPkl: $sommaire_categorie = array_combine(range(1, count($sommaire_categorie)), $sommaire_categorie); goto WEZMX; C3EFJ: $json_inputs_filename = 'inputs-' . $id_post_ligne; goto QDSmu; IGwxM: @unlink($filename_source); goto GoctG; Jv6Lu: usleep(1500); goto aXPkl; yuci7: $inputs = array('type_generer' => 'collection_outline', 'mot_cle' => $mot_cle, 'postID' => $id_post_ligne, 'img' => 0, 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); goto P2Xx9; sn4Ge: $sous_titre_json = $this->write_json($json_filename, json_encode($sommaire_categorie)); goto U2MKt; QDSmu: $this->write_json($json_inputs_filename, json_encode($inputs)); goto rp1vx; kAaWW: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $id_post_ligne . '.json'; goto IGwxM; a_ZHk: $this->mettre_a_jour_status_post($id_post_ligne, 'progress'); goto BqeEu; ng42U: $type_generer = $ligne_a_traiter->post_title; goto g4HOK; g4HOK: $mot_cle = get_post_meta($id_post_ligne, 'wpg_keyword_post', true); goto a_ZHk; GoctG: if ($ligne_a_traiter->post_content != '') { goto StseY; h5OX8: $prix_moyen = $data_content->prix_moyen; goto BCWHC; StseY: $data_content = json_decode($ligne_a_traiter->post_content); goto LiLtz; LiLtz: $cat_creation = intval($data_content->category); goto r26zY; KRbDc: $langue_output = $data_content->langue_output; goto h5OX8; r26zY: $custom_prompt = $data_content->custom_prompt; goto oHib_; oHib_: $langue_source = $data_content->langue_source; goto KRbDc; BCWHC: } else { exit; } goto ng42U; q18mC: $id_post_ligne = $ligne_a_traiter->ID; goto yXnKo; U2MKt: for ($i = 1; $i <= count($sommaire_categorie); $i++) { $inputs = array('type_generer' => 'collection_paragraphe', 'mot_cle' => $mot_cle, 'postID' => $id_post_ligne, 'img' => 0, 'pos' => $i, 'h2' => $sommaire_categorie[$i], 'sections' => $sommaire_categorie, 'total_content' => count($sommaire_categorie), 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); $this->cron_gen_paragraphe($inputs); if ($i % 5 == 0) { sleep(5); } else { usleep(1500); } } goto C3EFJ; ygD2T: @unlink($filename_zen); goto kAaWW; P2Xx9: $sommaire_categorie = $this->generate_text($inputs)['collection_outline']; goto Jv6Lu; BqeEu: update_post_meta($id_post_ligne, 'wpg_bulk_start_time', current_time('timestamp')); goto yuci7; rp1vx: } private function cron_gen_paragraphe($inputs) { goto j3StO; l3MfU: $response = wp_remote_post($url, $args); goto LCwEy; j3StO: $args = array('timeout' => 0.01, 'blocking' => false, 'cookies' => $_COOKIE, 'headers' => array('Cache-Control' => 'no-cache'), 'body' => array('action' => 'wpg_bulk_paragraphe', 'nonce' => wp_create_nonce('wpg_bulk_paragraphe'), 'inputs' => $inputs), 'sslverify' => apply_filters('https_local_ssl_verify', false)); goto VmDt1; VmDt1: $url = admin_url('admin-ajax.php'); goto l3MfU; LCwEy: } public function process_step_one_bulk($ligne_a_traiter) { goto V0OBD; dlQ9F: $filename_zen = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'zen-' . $id_post_ligne . '.json'; goto P4Dj4; R1HJa: wp_send_json(array('status' => 'success', 'postId' => $id_post_ligne)); goto Pfy0u; vF9pE: $post_status = $ligne_a_traiter->post_password; goto dnkqw; dnkqw: $type_generer = $ligne_a_traiter->post_title; goto DUfmi; P4Dj4: @unlink($filename_zen); goto FwIwz; oD0Ct: if ($ligne_a_traiter->post_content != '') { goto Z532K; Z532K: $data_content = json_decode($ligne_a_traiter->post_content); goto dfimQ; SceVd: $cat_creation = intval($data_content->category); goto qwBh9; omArz: $langue_output = $data_content->langue_output; goto Z_7An; Z_7An: $type_titre = $data_content->wpg_typeTitle; goto iLVY7; lGGPr: $langue_source = $data_content->langue_source; goto omArz; qwBh9: $custom_prompt = $data_content->custom_prompt; goto lGGPr; dfimQ: $type_creation = $data_content->type_creation; goto SceVd; iLVY7: } else { exit; } goto vF9pE; TJ_XB: if (file_exists($filename_source)) { $this->continue_bulk($ligne_a_traiter); } else { goto IlfRs; vJdIe: switch ($this->{$api_param}->wpg_type_slug) { case 'h1': $post_slug = sanitize_title($titre_a_traiter); break; case 'metatitle': $post_slug = sanitize_title($this->metatitle); break; default: goto fkowb; BEGTl: $generateur_slug = $this->generate_text($inputs); goto FdBUz; FdBUz: $post_slug = $generateur_slug['slugify']; goto GkbtJ; fkowb: $inputs['type_generer'] = 'slugify'; goto BEGTl; GkbtJ: break; goto xDvwP; xDvwP: } goto v1MHV; ny3dK: usleep(1500); goto rDJto; FK0j3: if (is_wp_error($post_id_update)) { goto QK8fb; LEVNw: wp_send_json(array('status' => 'error', 'postId' => $id_post_ligne)); goto rLREy; Z9GFG: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : error update post 1 = ' . $post_id_update->get_error_message()); goto LEVNw; rLREy: wp_die(); goto tD8KF; QK8fb: $this->mettre_a_jour_status_post($id_post_ligne, 'pending'); goto Z9GFG; tD8KF: } else { if (isset($all_imgs) and isset($all_imgs['img_featured']) and !empty($all_imgs['img_featured'])) { goto WEyZP; gunJ0: if ($saved_image_featured !== false) { set_post_thumbnail($post_id_update, $saved_image_featured['attachment_id']); } goto zY2KZ; WEyZP: $img_title = sanitize_title($this->metatitle); goto zKE0r; zKE0r: $saved_image_featured = $this->save_image($all_imgs['img_featured'], $img_title); goto gunJ0; zY2KZ: } if ($type_generer == 'generate_by_kw') { goto AzdVa; MDQRf: $json_inputs_filename = 'inputs-' . $id_post_ligne; goto pdYTZ; D6kS7: usleep(1500); goto bCpVQ; AzdVa: $inputs['type_generer'] = 'sous-titre'; goto auACY; NHYYJ: $sous_titre_json = $this->write_json($json_filename, json_encode($h2_list)); goto zfNlp; NmSYE: $generateur_sous_titre = $this->generate_text($inputs); goto ELgVg; zfNlp: for ($i = 1; $i <= count($h2_list); $i++) { $dernier = count($h2_list); switch ($i) { case 2: $h2_pos = 'first'; break; case $dernier: $h2_pos = 'last'; break; default: $h2_pos = $i - 1; break; } $inputs = array('type_generer' => 'paragraphe', 'mot_cle' => $mot_cle, 'h1' => $titre_a_traiter, 'postID' => $id_post_ligne, 'h2' => $h2_list[$i], 'who_is_me' => $who_is_me, 'h2_pos' => $h2_pos, 'img' => 0, 'pos' => $i, 'sections' => $sous_titres, 'total_content' => count($h2_list), 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); $this->cron_gen_paragraphe($inputs); if ($i % 5 == 0) { sleep(5); } else { usleep(1500); } } goto MDQRf; oNVEc: $inputs['who_is_me'] = $this->who_is_me; goto NmSYE; ELgVg: $sous_titres = $generateur_sous_titre['sous-titre']; goto D6kS7; Y31hQ: $h2_list[1] = 'intro'; goto A2tgl; bCpVQ: $h2_list = array(); goto Y31hQ; A2tgl: for ($i = 0; $i < count($sous_titres); $i++) { $h2_list[$i + 2] = $sous_titres[$i]; } goto a1M2U; a1M2U: $json_filename = 'source-' . $id_post_ligne; goto NHYYJ; auACY: $inputs['img'] = 0; goto oNVEc; pdYTZ: $this->write_json($json_inputs_filename, json_encode($inputs)); goto vl0Sb; vl0Sb: } else { goto kbvXn; MHvtZ: $json_filename = 'source-' . $id_post_ligne; goto E_o0U; E_o0U: $content_json = $this->write_json($json_filename, json_encode($content)); goto slvUV; gton7: $json_inputs_filename = 'inputs-' . $id_post_ligne; goto dP3kX; slvUV: for ($i = 1; $i <= count($content); $i++) { $valeur = $content[$i]; $inputs = array('type_generer' => 'rewrite', 'mot_cle' => $mot_cle, 'h1' => $titre_a_traiter, 'postID' => $id_post_ligne, 'content' => $valeur, 'who_is_me' => $who_is_me, 'img' => 0, 'pos' => $i, 'total_content' => count($content), 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); $this->cron_gen_paragraphe($inputs); if ($i % 5 == 0) { sleep(5); } else { usleep(1500); } } goto gton7; MA8fT: $content = array_combine(range(1, count($content)), $content); goto MHvtZ; kbvXn: $content = $content_url['message']['content']; goto MA8fT; dP3kX: $this->write_json($json_inputs_filename, json_encode($inputs)); goto GNXUK; GNXUK: } } goto TdJB7; fZoUu: $inputs['who_is_me'] = $who_is_me; goto aCogY; v1MHV: usleep(1500); goto D9lJR; ReU2L: $inputs['h1'] = $titre_a_traiter; goto gYUUW; m0Kbp: $this->metatitle = $generateur_metatitle['metatitle']; goto ZhAaG; gYUUW: $generateur_metatitle = $this->generate_text($inputs); goto m0Kbp; bqNl8: $post_array = array('ID' => $id_post_ligne, 'post_title' => trim($titre_a_traiter, '"'), 'post_name' => sanitize_title($post_slug), 'meta_input' => $metaInput); goto KEpHV; HP1js: $who_is_me = $this->generate_text($inputs)['who_is_me']; goto EqYAg; Ijf8x: $seo = $this->wpg_seo_plugin_activated(array('metatitle' => $this->metatitle, 'metadesc' => $this->metadescription)); goto suEHO; ZhAaG: $inputs['metatitle'] = $this->metatitle; goto onNRO; IlfRs: $inputs = array('type_generer' => 'who_is_me', 'mot_cle' => $mot_cle, 'postID' => $id_post_ligne, 'img' => 0, 'custom_prompt' => $custom_prompt, 'langue_source' => $langue_source, 'langue_output' => $langue_output); goto HP1js; D9lJR: $inputs['type_generer'] = 'metadescription'; goto mV6rb; aCogY: $h1_titre = $mot_cle; goto GrXtk; GrXtk: if ($type_titre == 0 or $langue_source != $langue_output) { $h1_titre = $this->generate_text($inputs)['h1']; } goto l2ACv; rDJto: $inputs['type_generer'] = 'metatitle'; goto ReU2L; onNRO: usleep(1500); goto vJdIe; Hzrhb: if ($this->api_param->tbl_add_featured_img == 1) { goto uM22b; VBwOZ: $inputs['img_prompt'] = $prompt_img; goto LPBYD; V4_XV: usleep(1500); goto NE2rM; RzupK: $inputs['who_is_me'] = $who_is_me_designer; goto tvjQv; vnEbz: usleep(1500); goto q5zGD; uM22b: $inputs['type_generer'] = 'who_is_me_designer'; goto Dmoli; jBNN2: if ($resultat['error'] == '') { $all_imgs['img_featured'] = $resultat['url_images'][0]; } goto V4_XV; UdyOB: usleep(1500); goto Y9uwH; ae0nU: $prompt_img = $gen_img_prompt['image_prompt']; goto vnEbz; ET9cx: $who_is_me_designer = $who_is_me_designer['who_is_me_designer']; goto UdyOB; Y9uwH: $inputs['type_generer'] = 'image_prompt'; goto RzupK; Dmoli: $inputs['who_is_me'] = ''; goto ggSyK; q5zGD: $inputs['type_generer'] = 'image'; goto OYj1s; OYj1s: $inputs['nb_img_gen'] = 1; goto VBwOZ; ggSyK: $who_is_me_designer = $this->generate_text($inputs); goto ET9cx; tvjQv: $gen_img_prompt = $this->generate_text($inputs); goto ae0nU; LPBYD: $inputs['img'] = 1; goto ofoKh; ofoKh: $resultat = $this->generer_images($inputs); goto jBNN2; NE2rM: } goto Ijf8x; EqYAg: $this->who_is_me = $who_is_me; goto WHYBy; jDL3r: $this->metadescription = $generateur_metadesc['metadescription']; goto Dg6Gu; l2ACv: $titre_a_traiter = $h1_titre; goto ny3dK; suEHO: $metaInput = array($seo['metatitle']['name'] => $seo['metatitle']['value'], $seo['metadesc']['name'] => $seo['metadesc']['value']); goto bqNl8; hNHf8: $post_id_update = wp_update_post($post_array, true); goto FK0j3; mV6rb: $generateur_metadesc = $this->generate_text($inputs); goto jDL3r; Dg6Gu: usleep(1500); goto Hzrhb; jizzj: $inputs['type_generer'] = 'h1'; goto fZoUu; KEpHV: if ($type_creation == 'post') { $post_array = array_merge($post_array, array('post_category' => array($cat_creation))); } goto hNHf8; WHYBy: usleep(1500); goto jizzj; TdJB7: } goto R1HJa; Q2nDK: update_post_meta($id_post_ligne, 'wpg_bulk_start_time', current_time('timestamp')); goto II4je; l1k_M: @unlink($filename_source); goto oD0Ct; FwIwz: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $id_post_ligne . '.json'; goto l1k_M; V0OBD: $id_post_ligne = $ligne_a_traiter->ID; goto dlQ9F; B1WyH: $this->mettre_a_jour_status_post($id_post_ligne, 'progress'); goto Q2nDK; DUfmi: if ($type_generer == 'generate_by_kw') { $mot_cle = get_post_meta($id_post_ligne, 'wpg_keyword_post', true); } else { goto GoHom; QIjk4: $content_url = $this->send_remote($data, GET_SCRAPPED_CONTENT); goto vXbxS; QSNoT: $data = array('url' => $url, 'postID' => $id_post_ligne); goto QIjk4; GoHom: $url = get_post_meta($id_post_ligne, 'wpg_keyword_post', true); goto QSNoT; vXbxS: if ($content_url === false) { goto VASP2; P_6hm: exit; goto q77e1; VASP2: $this->mettre_a_jour_status_post($id_post_ligne, 'failed'); goto mR8_6; mR8_6: $this->write_error('Date : ' . date('Y-m-d h:i:s') . ' : error = scrap pas good'); goto P_6hm; q77e1: } else { $mot_cle = $content_url['message']['title']; } goto Yh9zG; Yh9zG: } goto B1WyH; II4je: $filename_source = WPGENERATOR_PLUGIN_DIR . '/admin/bulkfiles/' . 'source-' . $id_post_ligne . '.json'; goto TJ_XB; Pfy0u: wp_die(); goto gWN9x; gWN9x: } public function wpg_seo_plugin_activated($seo) { if ($seo == 'check') { goto CD2ho; vgJZ1: $seo_plugin = array('wordpress-seo/wp-seo.php', 'seo-by-rank-math/rank-math.php', 'wp-seopress/seopress.php', 'all-in-one-seo-pack/all_in_one_seo_pack.php', 'autodescription/autodescription.php'); goto nZ_mF; Vm2Z4: return false; goto Ae6YK; CD2ho: if (!function_exists('is_plugin_active')) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } goto vgJZ1; nZ_mF: foreach ($seo_plugin as $plg) { if (is_plugin_active($plg)) { return true; break; } } goto Vm2Z4; Ae6YK: } else { goto tElN2; YVRfv: if (is_plugin_active('wordpress-seo/wp-seo.php')) { goto pQfIW; Vy0HN: $wpg_seo['metatitle']['value'] .= ' %%page%% %%sep%% %%sitename%%'; goto vSWSK; pQfIW: $wpg_seo['metatitle']['name'] = '_yoast_wpseo_title'; goto gGODF; gGODF: $wpg_seo['metadesc']['name'] = '_yoast_wpseo_metadesc'; goto Vy0HN; vSWSK: } elseif (is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) { $wpg_seo['metatitle']['name'] = '_aioseo_title'; $wpg_seo['metadesc']['name'] = '_aioseo_description'; } elseif (is_plugin_active('seo-by-rank-math/rank-math.php')) { goto a62rO; wqmqa: $wpg_seo['metatitle']['value'] .= ' - %title% %sep% %sitename%'; goto Fr6dX; a62rO: $wpg_seo['metatitle']['name'] = 'rank_math_title'; goto wqmqa; Fr6dX: $wpg_seo['metadesc']['name'] = 'rank_math_description'; goto oHSQI; oHSQI: } elseif (is_plugin_active('wp-seopress/seopress.php')) { $wpg_seo['metatitle']['name'] = '_seopress_titles_title'; $wpg_seo['metadesc']['name'] = '_seopress_titles_desc'; } elseif (is_plugin_active('autodescription/autodescription.php')) { $wpg_seo['metatitle']['name'] = '_genesis_title'; $wpg_seo['metadesc']['name'] = '_genesis_description'; } goto IbCj_; tElN2: $wpg_seo['metatitle']['name'] = '_wpg_seo_metatitle'; goto XaBM6; IbCj_: return $wpg_seo; goto tUzMG; I70bd: $wpg_seo['metadesc']['name'] = '_wpg_seo_metadesc'; goto q4CqS; XaBM6: $wpg_seo['metatitle']['value'] = $seo['metatitle']; goto I70bd; q4CqS: $wpg_seo['metadesc']['value'] = $seo['metadesc']; goto YVRfv; tUzMG: } } private function compressImage($source, $destination, $quality) { goto ZwQqU; ZwQqU: $imgInfo = getimagesize($source); goto B0Fcx; B0Fcx: $mime = $imgInfo['mime']; goto uA921; QXo7x: return $destination; goto XNa6N; WIklg: imagejpeg($image, $destination, $quality); goto QXo7x; uA921: switch ($mime) { case 'image/jpeg': $image = imagecreatefromjpeg($source); break; case 'image/png': $image = imagecreatefrompng($source); break; case 'image/gif': $image = imagecreatefromgif($source); break; default: $image = imagecreatefromjpeg($source); } goto WIklg; XNa6N: } } } if (!function_exists('wpg_moteur')) { function wpg_moteur() { WPG_Moteur::get_instance(); } }