Headline
CVE-2023-5646: Diff [2980494:2981113] for chatbot/trunk – WordPress Plugin Repository
The AI ChatBot for WordPress is vulnerable to Directory Traversal in version 4.9.2 via the qcld_openai_upload_pagetraining_file function. This allows subscriber-level attackers to append “<?php” to any existing file on the server resulting in potential DoS when appended to critical files such as wp-config.php. This vulnerability is the same as CVE-2023-5241, but was reintroduced in version 4.9.2.
165 public function openai_ft_model_create(){ 166 $file_id = sanitize_text_field($_POST[‘file_id’]); 167 $ft_suffix = sanitize_text_field($_POST[‘ft_suffix’]); 168 $ft_engines = sanitize_text_field($_POST[‘ft_engines’]); 169 $rel = $this->openai_finetune_create($file_id,$ft_suffix,$ft_engines); 170 // print_r(wp_send_json([$rel]));wp_die(); 171 echo wp_send_json([$rel]); 172 wp_die(); 173 } 174 public function qcld_openai_file_dowload(){ 175 176 // -H “Authorization: Bearer $OPENAI_API_KEY” > results.csv 177 178 $file_id = sanitize_text_field($_POST[‘file_id’]); 179 $url = 'https://api.openai.com/v1/files/’.$file_id; 180 $url1 = 'https://api.openai.com/v1/files/’.$file_id. '/content’; 181 $apt_key = "Authorization: Bearer ". get_option(‘open_ai_api_key’); 182 $headers = array( 183 "Content-Type: application/json", 184 $apt_key, 185 ); 186 $headers1 = array( 187 "Content-Type: file.jsonl", 188 $apt_key, 189 ); 190 $curl = curl_init(); 191 curl_setopt($curl, CURLOPT_URL, $url); 192 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 193 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 194 $result = json_decode(curl_exec($curl)); 195 curl_close($curl); 196 $ch = curl_init(); 197 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 198 curl_setopt($ch, CURLOPT_URL, $url1); 199 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 200 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘GET’); 201 //curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 202 $res = curl_exec($ch); 203 if (curl_errno($ch)) { 204 echo ‘Error:’ . curl_error($ch); 205 } 206 curl_close($ch); 207 if(!empty($result)){ 208 $response[‘status’] = 'success’; 209 $response[‘fileinfo’] = $result; 210 $response[‘filedata’] = $res; 211 212 } 213 echo wp_send_json([$response]); 214 wp_die(); 215 216 } 153
270 public function qcld_openai_post_data_converter_count() 271 { 272 global $wpdb; 273 $qcldopenai_result = array(‘status’ => ‘error’); 274 if(isset($_POST[‘data’]) && is_array($_POST[‘data’])){ 275 $types = Self::qcld_sanitize_text_or_array_field($_POST[‘data’]); 276 $sql = "SELECT COUNT(*) FROM “.$wpdb->posts.” WHERE post_status=’publish’ AND post_type IN (‘".implode("’,’",$types)."’)"; 277 $qcldopenai_result[‘count’] = $wpdb->get_var($sql); 278 $qcldopenai_result[‘status’] = 'success’; 279 $qcldopenai_result[‘types’] = $types; 280 } 281 else $qcldopenai_result[‘msg’] = 'Please select least one data to convert’; 282 283 $this->qcld_openai_post_data_converter($qcldopenai_result); 284 $this->qcld_openai_post_data_converter_gpt3($qcldopenai_result); 285 } 286 287 public function qcld_openai_post_data_converter($result) 288 { 289 $qcldopenai_result = array(‘status’ => ‘error’,’msg’ => ‘Something went wrong’); 290 global $wpdb; 291 if( 292 isset($result[‘types’]) 293 && is_array($result[‘types’]) 294 ){ 295 $types = Self::qcld_sanitize_text_or_array_field($result[‘types’]); 296 297 $qcldopenai_total = sanitize_text_field($_POST[‘total’]); 298 $qcldopenai_per_page = sanitize_text_field($_POST[‘per_page’]); 299 $qcldopenai_page = isset($_POST[‘page’]) && !empty($_POST[‘page’]) ? sanitize_text_field($_POST[‘page’]) : 1; 300 if(isset($_POST[‘file’]) && !empty($_POST[‘file’])){ 301 $qcldopenai_file = sanitize_text_field($_POST[‘file’]); 302 }else{ 303 $qcldopenai_file = md5(time()).’.jsonl’; 304 } 305 if(isset($_POST[‘id’]) && !empty($_POST[‘id’])){ 306 $qcldopenai_convert_id = sanitize_text_field($_POST[‘id’]); 307 }else{ 308 $qcldopenai_convert_id = wp_insert_post(array( 309 ‘post_title’ => $qcldopenai_file, 310 ‘post_type’ => 'qcldopenai_convert’, 311 ‘post_status’ => ‘publish’ 312 )); 313 } try { 314 $upload = wp_upload_dir(); 315 $upload_dir = $upload[‘basedir’] . ‘/’ . 'qcldopenai_site_training’; 316 $permissions = 0755; 317 $oldmask = umask(0); 318 if (!is_dir($upload_dir)){ 319 mkdir($upload_dir, $permissions); 320 $umask = umask($oldmask); 321 $chmod = chmod($upload_dir, $permissions); 322 } 323 $gcdirpath = WP_CONTENT_DIR.’/qcldopenai_site_training’; 324 $qcldopenai_json_file = fopen(wp_upload_dir()[‘basedir’] .’/qcldopenai_site_training/’.basename($qcldopenai_file), “w”); 325 $qcldopenai_content = ‘’; 326 $sql = "SELECT post_title, post_content FROM “.$wpdb->posts.” WHERE post_status=’publish’ AND post_type IN (‘".implode("’,’",$types)."’) ORDER BY post_date"; 327 $qcldopenai_data = $wpdb->get_results($sql); 328 if($qcldopenai_data && is_array($qcldopenai_data) && count($qcldopenai_data)){ 329 foreach($qcldopenai_data as $item){ 330 $tag_less_content = wp_strip_all_tags($item->post_content); 331 $vc_tag_less = preg_replace("/\[(\/*)?vc_(.*?)\]/", '’, $tag_less_content); 332 $clean_html_body = preg_replace('/\xc2\xa0/’, '’, $vc_tag_less); 333 $completion_string = str_replace(array(“\n","\r","\t",” "), ' ', $clean_html_body); 334 $completion_string = wp_trim_words( $completion_string,500); 335 336 $tag_less_title = wp_strip_all_tags($item->post_title); 337 $clean_html_title = preg_replace('/\xc2\xa0/’, '’, $tag_less_title); 338 $title_string = str_replace(array(“\n","\r","\t",” "), ' ‘, $clean_html_title); 339 $title_string = wp_trim_words( $title_string,50); 340 $data = array( 341 “prompt” => $title_string.’ ->’, 342 “completion” => $completion_string 343 ); 344 fwrite($qcldopenai_json_file, json_encode($data) . PHP_EOL); 345 } 346 } 347 fclose($qcldopenai_json_file); 348 $qcldopenai_result[‘file’] = $qcldopenai_file; 349 $qcldopenai_result[‘id’] = $qcldopenai_convert_id; 350 $qcldopenai_result[‘status’] = 'success’; 351 } catch (\Exception $exception){ 352 $qcldopenai_result[‘msg’] = $exception->getMessage(); 353 } 354 } 355 else $qcldopenai_result[‘msg’] = 'Please select least one data to convert’; 356 // wp_send_json($qcldopenai_result); 357 } 358 public function qcld_openai_post_data_converter_gpt3($result) 359 { 360 $qcldopenai_result = array(‘status’ => ‘error’,’msg’ => ‘Something went wrong’); 361 global $wpdb; 362 if( 363 isset($result[‘types’]) 364 && is_array($result[‘types’]) 365 ){ 366 $types = Self::qcld_sanitize_text_or_array_field($result[‘types’]); 367 368 $qcldopenai_total = sanitize_text_field($_POST[‘total’]); 369 $qcldopenai_per_page = sanitize_text_field($_POST[‘per_page’]); 370 $qcldopenai_page = isset($_POST[‘page’]) && !empty($_POST[‘page’]) ? sanitize_text_field($_POST[‘page’]) : 1; 371 if(isset($_POST[‘file’]) && !empty($_POST[‘file’])){ 372 $qcldopenai_file = sanitize_text_field($_POST[‘file’]); 373 }else{ 374 $qcldopenai_file = md5(time()).’_gpt3.5.jsonl’; 375 } 376 if(isset($_POST[‘id’]) && !empty($_POST[‘id’])){ 377 $qcldopenai_convert_id = sanitize_text_field($_POST[‘id’]); 378 }else{ 379 $qcldopenai_convert_id = wp_insert_post(array( 380 ‘post_title’ => $qcldopenai_file, 381 ‘post_type’ => 'qcldopenai_convert’, 382 ‘post_status’ => ‘publish’ 383 )); 384 } try { 385 $upload = wp_upload_dir(); 386 $upload_dir = $upload[‘basedir’] . ‘/’ . 'qcldopenai_site_training’; 387 $permissions = 0755; 388 $oldmask = umask(0); 389 if (!is_dir($upload_dir)){ 390 mkdir($upload_dir, $permissions); 391 $umask = umask($oldmask); 392 $chmod = chmod($upload_dir, $permissions); 393 } 394 $gcdirpath = WP_CONTENT_DIR.’/qcldopenai_site_training’; 395 $qcldopenai_json_file = fopen(wp_upload_dir()[‘basedir’] .’/qcldopenai_site_training/’.basename($qcldopenai_file), “w”); 396 $qcldopenai_content = ‘’; 397 $sql = "SELECT post_title, post_content FROM “.$wpdb->posts.” WHERE post_status=’publish’ AND post_type IN (‘".implode("’,’",$types)."’) ORDER BY post_date"; 398 $qcldopenai_data = $wpdb->get_results($sql); 399 if($qcldopenai_data && is_array($qcldopenai_data) && count($qcldopenai_data)){ 400 foreach($qcldopenai_data as $item){ 401 402 $tag_less_content = wp_strip_all_tags($item->post_content); 403 $vc_tag_less = preg_replace("/\[(\/*)?vc_(.*?)\]/", '’, $tag_less_content); 404 $clean_html_body = preg_replace('/\xc2\xa0/’, '’, $vc_tag_less); 405 $completion_string = str_replace(array(“\n","\r","\t",” "), ' ', $clean_html_body); 406 $completion_string = wp_trim_words( $completion_string,500); 407 408 $tag_less_title = wp_strip_all_tags($item->post_title); 409 $clean_html_title = preg_replace('/\xc2\xa0/’, '’, $tag_less_title); 410 $title_string = str_replace(array(“\n","\r","\t",” "), ' ', $clean_html_title); 411 $title_string = wp_trim_words( $title_string,50); 412 $data = new stdClass(); 413 $system = [ "role"=> "system", "content"=> “You are an assistant that occasionally misspells words”]; 414 $user = ["role"=> "user", $title_string=> “Tell me a story.” ]; 415 416 $assistant = ["role"=> "assistant", "content"=> $completion_string ]; 417 $data->messages = array( $system ,$user, $assistant); 418 fwrite($qcldopenai_json_file, json_encode($data) . PHP_EOL); 419 } 420 } 421 fclose($qcldopenai_json_file); 422 $qcldopenai_result[‘file’] = $qcldopenai_file; 423 $qcldopenai_result[‘id’] = $qcldopenai_convert_id; 424 $qcldopenai_result[‘status’] = 'success’; 425 } catch (\Exception $exception){ 426 $qcldopenai_result[‘msg’] = $exception->getMessage(); 427 } 428 } 429 else $qcldopenai_result[‘msg’] = 'Please select least one data to convert’; 430 wp_send_json($qcldopenai_result); 431 } 432 433 public function openai_ft_model_delete(){ 434 $ft_id = sanitize_text_field($_POST[‘ft_id’]); 435 $url = ‘https://api.openai.com/v1/models/’ . $ft_id; 436 $apt_key = "Authorization: Bearer ". get_option(‘open_ai_api_key’); 437 $curl = curl_init(); 438 $headers = array( 439 "Content-Type: multipart/form-data", 440 $apt_key, 441 ); 442 curl_setopt($curl, CURLOPT_URL, $url); 443 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 444 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, ‘DELETE’); 445 curl_setopt($curl, CURLOPT_POST, true); 446 $res = json_decode(curl_exec ($curl)); 447 curl_close ($curl); 448 echo wp_send_json([$rel]); 449 wp_die(); 450 451 } 452 public function qcld_openai_upload_pagetraining_file(){ 453 454 if( 455 isset($_POST[‘filename’]) 456 && !empty($_POST[‘filename’]) 457 ){ 458 $filename = sanitize_text_field($_POST[‘filename’]); 459 $line = isset($_POST[‘line’]) && !empty($_POST[‘line’]) ? sanitize_text_field($_POST[‘line’]) : 0; 460 $file = wp_upload_dir()[‘basedir’].’/qcldopenai_site_training/’.$filename; 461 if(file_exists($file)){ 462 $qcld_openai_lines = file($file); 463 $fileo = '@’. wp_upload_dir()[‘basedir’].’/qcldopenai_site_training/’.$filename; 464 $split_file = wp_upload_dir()[‘basedir’].’/qcldopenai_site_training/’.$filename; 465 $qcld_openai_json_file = fopen($split_file, “a”); 466 $qcld_openai_content = '’; 467 for($i = $line; $i <= count($qcld_openai_lines);$i++){ 468 if($i == count($qcld_openai_lines)){ 469 $qcld_openai_content .= $qcld_openai_lines[$i]; 470 $qcld_openai_result[‘next’] = 'DONE’; 471 } 472 else{ 473 if(mb_strlen($qcld_openai_content, ‘8bit’) > $this->wpaicg_max_file_size){ 474 $qcld_openai_result[‘next’] = $i+1; 475 break; 476 } 477 else{ 478 $qcld_openai_content .= $qcld_openai_lines[$i]; 479 } 480 } 481 } 482 fwrite($qcld_openai_json_file,$qcld_openai_content); 483 fclose($qcld_openai_json_file); 484 $url = 'https://api.openai.com/v1/files’; 485 $apt_key = "Authorization: Bearer ". get_option(‘open_ai_api_key’); 486 $curl = curl_init($url); 487 $c_file = curl_file_create($split_file, mime_content_type($split_file),basename($split_file)); 488 $data = array( 489 ‘purpose’ => 'fine-tune’, 490 ‘file’ => $c_file, 491 ); 492 curl_setopt($curl, CURLOPT_URL, $url); 493 curl_setopt($curl, CURLOPT_POST, true); 494 $headers = array( 495 "Content-Type: multipart/form-data", 496 $apt_key, 497 ); 498 $init = curl_init(); 499 curl_setopt($init, CURLOPT_URL,$url); 500 curl_setopt($init, CURLOPT_HTTPHEADER, $headers); 501 curl_setopt($init, CURLOPT_POSTFIELDS, $data); 502 curl_setopt($init, CURLOPT_RETURNTRANSFER, true); 503 $res = json_decode(curl_exec ($init)); 504 505 curl_close ($init); 506 if(!empty($res->error)){ 507 $response[‘status’] = 'error’; 508 $response[‘message’] = $res->error->message; 509 } 510 511 if(!empty($res->status)){ 512 $response[‘status’] = 'success’; 513 $response[‘message’] = ‘Successfully Created file’ . $res->id ; 514 515 } 516 echo wp_send_json([$response]); 517 wp_die(); 518 } else { 519 if(!empty($res->status)){ 520 $response[‘status’] = 'error’; 521 $response[‘message’] = 'The file has been removed from wp-uploads’; 522 } 523 } 524 } 525 } 526 207
754 public function openai_finetune_list(){ 755 756 $apt_key = "Authorization: Bearer ". get_option(‘open_ai_api_key’); 757 $headers = array( 758 "Content-Type: application/json", 759 $apt_key, 760 ); 761 $curl_ft = curl_init(); 762 $url = "https://api.openai.com/v1/fine-tunes"; 763 curl_setopt($curl_ft, CURLOPT_URL, $url); 764 curl_setopt($curl_ft, CURLOPT_HTTPHEADER, $headers); 765 curl_setopt($curl_ft, CURLOPT_RETURNTRANSFER, true); 766 $result = json_decode(curl_exec($curl_ft)); 767 $ft_arry = []; 768 foreach($result->data as $value ){ 769 if(($value->training_files[0]->status != ‘deleted’) && ($value->result_files[0]->status != ‘deleted’) ){ 770 $ft_arry[] = [$value->fine_tuned_model,$value->status,$value->training_files[0]->filename,$value->training_files[0]->id]; 771 } 772 } 773 curl_close($curl_ft); 774 wp_send_json( $ft_arry); 775 wp_die(); 776 777 778 } 779 public function openai_finetune_gpt3_list(){ 780 781 $apt_key = "Authorization: Bearer ". get_option(‘open_ai_api_key’); 782 $headers = array( 783 "Content-Type: application/json", 784 $apt_key, 785 ); 786 $curl_ft = curl_init(); 787 $url = "https://api.openai.com/v1/fine_tuning/jobs"; 788 curl_setopt($curl_ft, CURLOPT_URL, $url); 789 curl_setopt($curl_ft, CURLOPT_HTTPHEADER, $headers); 790 curl_setopt($curl_ft, CURLOPT_RETURNTRANSFER, true); 791 $result = json_decode(curl_exec($curl_ft)); 792 793 $ft_arry = []; 794 foreach($result->data as $value ){ 795 if(($value->status != ‘failed’)){ 796 $ft_arry[] = [$value->fine_tuned_model,$value->status,$value->training_file,$value->training_file]; 797 } 798 } 799 curl_close($curl_ft); 800 wp_send_json( $ft_arry); 801 wp_die(); 802 803 804 } 281
1244 public function openai_keyword_suggestion_content(){ 1245 1246 $OPENAI_API_KEY = get_option(‘open_ai_api_key’); 1247 $ai_engines = get_option(‘openai_engines’); 1248 $max_token = get_option(‘openai_max_tokens’); 1249 $temperature = get_option(‘openai_temperature’); 1250 $ppenalty = get_option(‘presence_penalty’); 1251 $fpenalty = get_option(‘frequency_penalty’); 1252 1253 $qcld_article_text = isset($_POST[‘keyword’]) ? sanitize_text_field( $_POST[‘keyword’] ) : '’; 1254 $keyword_number = isset( $_POST[‘keyword_number’] ) ? sanitize_text_field( $_POST[‘keyword_number’] ) : '’; 1255 $qcld_article_language = isset($_POST[‘qcld_article_language’]) ? sanitize_text_field( $_POST[‘qcld_article_language’] ) : '’; 1256 $qcld_article_number_of_heading = isset($_POST[‘qcld_article_number_of_heading’]) ? sanitize_text_field( $_POST[‘qcld_article_number_of_heading’] ) : '’; 1257 $qcld_article_heading_tag = isset($_POST[‘qcld_article_heading_tag’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_tag’] ) : '’; 1258 $qcld_article_heading_style = isset($_POST[‘qcld_article_heading_style’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_style’] ) : '’; 1259 $qcld_article_heading_tone = isset($_POST[‘qcld_article_heading_tone’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_tone’] ) : '’; 1260 $qcld_article_heading_img = isset($_POST[‘qcld_article_heading_img’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_img’] ) : '’; 1261 $qcld_article_heading_tagline = isset($_POST[‘qcld_article_heading_tagline’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_tagline’] ) : '’; 1262 $qcld_article_heading_intro = isset($_POST[‘qcld_article_heading_intro’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_intro’] ) : '’; 1263 $qcld_article_heading_conclusion = isset($_POST[‘qcld_article_heading_conclusion’]) ? sanitize_text_field( $_POST[‘qcld_article_heading_conclusion’] ) : '’; 1264 $qcld_article_label_anchor_text = isset($_POST[‘qcld_article_label_anchor_text’]) ? sanitize_text_field( $_POST[‘qcld_article_label_anchor_text’] ) : '’; 1265 $qcld_article_target_url = isset($_POST[‘qcld_article_target_url’]) ? sanitize_text_field( $_POST[‘qcld_article_target_url’] ) : '’; 1266 $qcld_article_target_label_cta = isset($_POST[‘qcld_article_target_label_cta’]) ? sanitize_text_field( $_POST[‘qcld_article_target_label_cta’] ) : '’; 1267 $qcld_article_cta_pos = isset($_POST[‘qcld_article_cta_pos’]) ? sanitize_text_field( $_POST[‘qcld_article_cta_pos’] ) : '’; 1268 $qcld_article_label_keywords = isset($_POST[‘qcld_article_label_keywords’]) ? sanitize_text_field( $_POST[‘qcld_article_label_keywords’] ) : '’; 1269 $qcld_article_label_word_to_avoid = isset($_POST[‘qcld_article_label_word_to_avoid’]) ? sanitize_text_field( $_POST[‘qcld_article_label_word_to_avoid’] ) : '’; 1270 $qcld_article_label_keywords_bold = isset($_POST[‘qcld_article_label_keywords_bold’]) ? intval( $_POST[‘qcld_article_label_keywords_bold’] ) : '’; 1271 $qcld_article_heading_faq = isset($_POST[‘qcld_article_heading_faq’]) ? intval( $_POST[‘qcld_article_heading_faq’] ) : '’; 1272 1273 $img_size = isset($_POST[‘qcld_article_img_size’]) ? sanitize_text_field( $_POST[‘qcld_article_img_size’] ) : '’; 1274 //$img_size = "512x512"; 1275 1276 if ( empty($qcld_article_language) ) { 1277 $qcld_article_language = "en"; 1278 } 1279 // if number of heading is not set, set it to 5 1280 if ( empty($qcld_article_number_of_heading) ) { 1281 $qcld_article_number_of_heading = 5; 1282 } 1283 // if writing style is not set, set it to descriptive 1284 if ( empty($qcld_article_heading_style) ) { 1285 $qcld_article_heading_style = "infor"; 1286 } 1287 // if writing tone is not set, set it to assertive 1288 if ( empty($qcld_article_heading_tone) ) { 1289 $qcld_article_heading_tone = "formal"; 1290 } 1291 // if heading tag is not set, set it to h2 1292 if ( empty($qcld_article_heading_tag) ) { 1293 $qcld_article_heading_tag = "h2"; 1294 } 1295 1296 $writing_style = apply_filters('qcld_seo_openai_filter_for_style’, $qcld_article_heading_style, $qcld_article_language ); 1297 $tone_text = apply_filters('qcld_seo_openai_filter_for_tone’, $qcld_article_heading_tone, $qcld_article_language ); 1298 1299 if ( $qcld_article_language == “en” ) { 1300 1301 1302 if ( $qcld_article_number_of_heading == 1 ) { 1303 $prompt_text = " blog topic about "; 1304 } else { 1305 $prompt_text = " blog topics about "; 1306 } 1307 1308 $intro_text = "Write an introduction about "; 1309 $conclusion_text = "Write a conclusion about "; 1310 $tagline_text = "Write a tagline about "; 1311 $introduction = "Introduction"; 1312 $conclusion = "Conclusion"; 1313 $faq_text = strval( $qcld_article_number_of_heading ) . " questions and answers about " . $qcld_article_text . "."; 1314 $faq_heading = "Q&A"; 1315 $style_text = "Writing style: " . $writing_style . "."; 1316 1317 if ( empty($qcld_article_label_keywords) ) { 1318 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1319 } else { 1320 $keyword_text = ". Keywords: " . $qcld_article_label_keywords . "."; 1321 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1322 } 1323 1324 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1325 1326 if ( !empty($qcld_article_label_word_to_avoid) ) { 1327 $avoid_text = " Exclude following keywords: " . $qcld_article_label_word_to_avoid . "."; 1328 $myprompt = $myprompt . $avoid_text; 1329 } 1330 1331 $myintro = $intro_text . $qcld_article_text; 1332 $myconclusion = $conclusion_text . $qcld_article_text; 1333 $mytagline = $tagline_text . $qcld_article_text; 1334 $mycta = "Write a Call to action about: " . $qcld_article_text . " and create a href tag link to: " . $qcld_article_target_label_cta . "."; 1335 1336 } else if ( $qcld_article_language == “de” ) { 1337 $prompt_text = " blog-Themen über "; 1338 $intro_text = "Schreiben Sie eine Einführung über "; 1339 $conclusion_text = "Schreiben Sie ein Fazit über "; 1340 $tagline_text = "Schreiben Sie eine Tagline über "; 1341 $introduction = "Einführung"; 1342 $conclusion = "Fazit"; 1343 $faq_text = strval( $qcld_article_number_of_heading ) . " Fragen und Antworten über " . $qcld_article_text . "."; 1344 $faq_heading = "Fragen und Antworten"; 1345 $style_text = "Schreibstil: " . $writing_style . "."; 1346 1347 if ( empty($qcld_article_label_keywords) ) { 1348 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1349 } else { 1350 $keyword_text = ". Schlüsselwörter: " . $qcld_article_label_keywords . "."; 1351 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1352 } 1353 1354 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1355 1356 if ( !empty($qcld_article_label_word_to_avoid) ) { 1357 $avoid_text = " Ausschließen folgende Schlüsselwörter: " . $qcld_article_label_word_to_avoid . "."; 1358 $myprompt = $myprompt . $avoid_text; 1359 } 1360 1361 $myintro = $intro_text . $qcld_article_text; 1362 $myconclusion = $conclusion_text . $qcld_article_text; 1363 $mytagline = $tagline_text . $qcld_article_text; 1364 $mycta = "Schreiben Sie eine Call to action über: " . $qcld_article_text . " und erstellen Sie einen href-Tag-Link zu: " . $qcld_article_target_label_cta . "."; 1365 } else if ( $qcld_article_language == “fr” ) { 1366 $prompt_text = " sujets de blog sur "; 1367 $intro_text = "Écrivez une introduction sur "; 1368 $conclusion_text = "Écrivez une conclusion sur "; 1369 $tagline_text = "Rédigez un slogan sur "; 1370 $introduction = "Introduction"; 1371 $conclusion = "Conclusion"; 1372 $faq_text = strval( $qcld_article_number_of_heading ) . " questions et réponses sur " . $qcld_article_text . "."; 1373 $faq_heading = "Questions et réponses"; 1374 $style_text = "Style d’écriture: " . $writing_style . "."; 1375 1376 if ( empty($qcld_article_label_keywords) ) { 1377 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1378 } else { 1379 $keyword_text = ". Mots clés: " . $qcld_article_label_keywords . "."; 1380 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1381 } 1382 1383 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1384 1385 if ( !empty($qcld_article_label_word_to_avoid) ) { 1386 $avoid_text = " Exclure les mots-clés suivants: " . $qcld_article_label_word_to_avoid . "."; 1387 $myprompt = $myprompt . $avoid_text; 1388 } 1389 1390 $myintro = $intro_text . $qcld_article_text; 1391 $myconclusion = $conclusion_text . $qcld_article_text; 1392 $mytagline = $tagline_text . $qcld_article_text; 1393 $mycta = "Écrivez un appel à l’action sur: " . $qcld_article_text . " et créez un lien href tag vers: " . $qcld_article_target_label_cta . "."; 1394 1395 } else if ( $qcld_article_language == “es” ) { 1396 $prompt_text = " temas de blog sobre "; 1397 $intro_text = "Escribe una introducción sobre "; 1398 $conclusion_text = "Escribe una conclusión sobre "; 1399 $tagline_text = "Escribe una eslogan sobre "; 1400 $introduction = "Introducción"; 1401 $conclusion = "Conclusión"; 1402 $faq_text = strval( $qcld_article_number_of_heading ) . " preguntas y respuestas sobre " . $qcld_article_text . "."; 1403 $faq_heading = "Preguntas y respuestas"; 1404 $style_text = "Estilo de escritura: " . $writing_style . "."; 1405 1406 if ( empty($qcld_article_label_keywords) ) { 1407 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1408 } else { 1409 $keyword_text = ". Palabras clave: " . $qcld_article_label_keywords . "."; 1410 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1411 } 1412 1413 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1414 1415 if ( !empty($qcld_article_label_word_to_avoid) ) { 1416 $avoid_text = " Excluir las siguientes palabras clave: " . $qcld_article_label_word_to_avoid . "."; 1417 $myprompt = $myprompt . $avoid_text; 1418 } 1419 1420 $myintro = $intro_text . $qcld_article_text; 1421 $myconclusion = $conclusion_text . $qcld_article_text; 1422 $mytagline = $tagline_text . $qcld_article_text; 1423 $mycta = "Escribe una llamada a la acción sobre: " . $qcld_article_text . " y cree un enlace de etiqueta html <a href> para: " . $qcld_article_target_label_cta . "."; 1424 1425 } else if ( $qcld_article_language == “it” ) { 1426 $prompt_text = " argomenti di blog su "; 1427 $intro_text = "Scrivi un’introduzione su "; 1428 $conclusion_text = "Scrivi una conclusione su "; 1429 $tagline_text = "Scrivi un slogan su "; 1430 $introduction = "Introduzione"; 1431 $conclusion = "Conclusione"; 1432 $faq_text = strval( $qcld_article_number_of_heading ) . " domande e risposte su " . $qcld_article_text . "."; 1433 $faq_heading = "Domande e risposte"; 1434 $style_text = "Stile di scrittura: " . $writing_style . "."; 1435 1436 if ( empty($qcld_article_label_keywords) ) { 1437 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1438 } else { 1439 $keyword_text = ". Parole chiave: " . $qcld_article_label_keywords . "."; 1440 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1441 } 1442 1443 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1444 1445 if ( !empty($qcld_article_label_word_to_avoid) ) { 1446 $avoid_text = " Escludere le seguenti parole chiave: " . $qcld_article_label_word_to_avoid . "."; 1447 $myprompt = $myprompt . $avoid_text; 1448 } 1449 1450 $myintro = $intro_text . $qcld_article_text; 1451 $myconclusion = $conclusion_text . $qcld_article_text; 1452 $mytagline = $tagline_text . $qcld_article_text; 1453 $mycta = "Scrivi un call to action su: " . $qcld_article_text . " e crea un href tag link a: " . $qcld_article_target_label_cta . "."; 1454 1455 } else if ( $qcld_article_language == “pt” ) { 1456 $prompt_text = " tópicos de blog sobre "; 1457 $intro_text = "Escreva uma introdução sobre "; 1458 $conclusion_text = "Escreva uma conclusão sobre "; 1459 $tagline_text = "Escreva um slogan sobre "; 1460 $introduction = "Introdução"; 1461 $conclusion = "Conclusão"; 1462 $faq_text = strval( $qcld_article_number_of_heading ) . " perguntas e respostas sobre " . $qcld_article_text . "."; 1463 $faq_heading = "Perguntas e respostas"; 1464 $style_text = "Estilo de escrita: " . $writing_style . "."; 1465 1466 if ( empty($qcld_article_label_keywords) ) { 1467 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1468 } else { 1469 $keyword_text = ". Palavras-chave: " . $qcld_article_label_keywords . "."; 1470 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1471 } 1472 1473 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1474 1475 if ( !empty($qcld_article_label_word_to_avoid) ) { 1476 $avoid_text = " Excluir as seguintes palavras-chave: " . $qcld_article_label_word_to_avoid . "."; 1477 $myprompt = $myprompt . $avoid_text; 1478 } 1479 1480 $myintro = $intro_text . $qcld_article_text; 1481 $myconclusion = $conclusion_text . $qcld_article_text; 1482 $mytagline = $tagline_text . $qcld_article_text; 1483 $mycta = "Escreva um call to action sobre: " . $qcld_article_text . " e crie um href tag link para: " . $qcld_article_target_label_cta . "."; 1484 1485 } else if ( $qcld_article_language == “nl” ) { 1486 $prompt_text = " blogonderwerpen over "; 1487 $intro_text = "Schrijf een inleiding over "; 1488 $conclusion_text = "Schrijf een conclusie over "; 1489 $tagline_text = "Schrijf een slogan over "; 1490 $introduction = "Inleiding"; 1491 $conclusion = "Conclusie"; 1492 $faq_text = strval( $qcld_article_number_of_heading ) . " vragen en antwoorden over " . $qcld_article_text . "."; 1493 $faq_heading = "Vragen en antwoorden"; 1494 $style_text = "Schrijfstijl: " . $writing_style . "."; 1495 1496 if ( empty($qcld_article_label_keywords) ) { 1497 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1498 } else { 1499 $keyword_text = ". Trefwoorden: " . $qcld_article_label_keywords . "."; 1500 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1501 } 1502 1503 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1504 1505 if ( !empty($qcld_article_label_word_to_avoid) ) { 1506 $avoid_text = " Sluit de volgende trefwoorden uit: " . $qcld_article_label_word_to_avoid . "."; 1507 $myprompt = $myprompt . $avoid_text; 1508 } 1509 1510 $myintro = $intro_text . $qcld_article_text; 1511 $myconclusion = $conclusion_text . $qcld_article_text; 1512 $mytagline = $tagline_text . $qcld_article_text; 1513 $mycta = "Schrijf een call to action over: " . $qcld_article_text . " en maak een href tag link naar: " . $qcld_article_target_label_cta . "."; 1514 1515 } else if ( $qcld_article_language == “ru” ) { 1516 $prompt_text = "Перечислите "; 1517 $prompt_last = " идей блога о "; 1518 $intro_text = "Напишите введение о "; 1519 $conclusion_text = "Напишите заключение о "; 1520 $tagline_text = "Напишите слоган о "; 1521 $introduction = "Введение"; 1522 $conclusion = "Заключение"; 1523 $faq_text = strval( $qcld_article_number_of_heading ) . " вопросов и ответов о " . $qcld_article_text . "."; 1524 $faq_heading = "Вопросы и ответы"; 1525 $style_text = "Стиль написания: " . $writing_style . "."; 1526 1527 if ( empty($qcld_article_label_keywords) ) { 1528 $myprompt = $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $qcld_article_text . "."; 1529 } else { 1530 $keyword_text = ". Ключевые слова: " . $qcld_article_label_keywords . "."; 1531 $myprompt = $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $qcld_article_text . $keyword_text; 1532 } 1533 1534 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1535 1536 if ( !empty($qcld_article_label_word_to_avoid) ) { 1537 $avoid_text = " Исключите следующие ключевые слова: " . $qcld_article_label_word_to_avoid . "."; 1538 $myprompt = $myprompt . $avoid_text; 1539 } 1540 1541 $myintro = $intro_text . $qcld_article_text; 1542 $myconclusion = $conclusion_text . $qcld_article_text; 1543 $mytagline = $tagline_text . $qcld_article_text; 1544 $mycta = "Напишите call to action о: " . $qcld_article_text . " и сделайте href tag link на: " . $qcld_article_target_label_cta . "."; 1545 1546 } else if ( $qcld_article_language == “ja” ) { 1547 $prompt_text = " に関するブログのアイデアを "; 1548 $prompt_last = " つ挙げてください"; 1549 $intro_text = " について紹介文を書く"; 1550 $conclusion_text = " についての結論を書く"; 1551 $tagline_text = " についてのスローガンを書く"; 1552 $introduction = "序章"; 1553 $conclusion = "結論"; 1554 $faq_text = $qcld_article_text . " に関する " . strval( $qcld_article_number_of_heading ) . " の質問と回答."; 1555 $faq_heading = "よくある質問"; 1556 $style_text = "書き方: " . $writing_style . "."; 1557 1558 if ( empty($qcld_article_label_keywords) ) { 1559 $myprompt = $qcld_article_text . $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . "."; 1560 } else { 1561 $keyword_text = ". キーワード: " . $qcld_article_label_keywords . "."; 1562 $myprompt = $qcld_article_text . $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $keyword_text; 1563 } 1564 1565 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1566 1567 if ( !empty($qcld_article_label_word_to_avoid) ) { 1568 $avoid_text = " 次のキーワードを除外します。 " . $qcld_article_label_word_to_avoid . "."; 1569 $myprompt = $myprompt . $avoid_text; 1570 } 1571 1572 $myintro = $qcld_article_text . $intro_text; 1573 $myconclusion = $qcld_article_text . $conclusion_text; 1574 $mytagline = $qcld_article_text . $tagline_text; 1575 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1576 $mycta = $qcld_article_text . " についてのコール・トゥ・アクションを書き、hrefタグリンクを作成します。 " . $qcld_article_target_label_cta . "."; 1577 1578 } else if ( $qcld_article_language == “zh” ) { 1579 $prompt_text = " 关于 "; 1580 $of_text = " 的 "; 1581 $piece_text = " 个博客创意"; 1582 $intro_text = "写一篇关于 "; 1583 $intro_last = " 的介绍"; 1584 $conclusion_text = "写一篇关于 "; 1585 // write a tagline about 1586 $tagline_text = "写一个标语关于 "; 1587 $conclusion_last = " 的结论"; 1588 $introduction = "介绍"; 1589 $conclusion = "结论"; 1590 $faq_text = $qcld_article_text . " 的 " . strval( $qcld_article_number_of_heading ) . " 个问题和答案."; 1591 $faq_heading = "常见问题"; 1592 $style_text = "写作风格: " . $writing_style . "."; 1593 1594 if ( empty($qcld_article_label_keywords) ) { 1595 $myprompt = $prompt_text . $qcld_article_text . $of_text . strval( $qcld_article_number_of_heading ) . $piece_text . "."; 1596 } else { 1597 $keyword_text = ". 关键字: " . $qcld_article_label_keywords . “."; 1598 $myprompt = $prompt_text . $qcld_article_text . $of_text . strval( $qcld_article_number_of_heading ) . $piece_text . $keyword_text; 1599 } 1600 1601 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1602 1603 if ( !empty($qcld_article_label_word_to_avoid) ) { 1604 $avoid_text = " 排除以下关键字:” . $qcld_article_label_word_to_avoid . "."; 1605 $myprompt = $myprompt . $avoid_text; 1606 } 1607 1608 $myintro = $intro_text . $qcld_article_text . $intro_last; 1609 $myconclusion = $conclusion_text . $qcld_article_text . $conclusion_last; 1610 $mytagline = $tagline_text . $qcld_article_text; 1611 // 写一个关于 123 的号召性用语并创建一个 <a href> html 标签链接到: 1612 $mycta = "写一个关于 " . $qcld_article_text . " 的号召性用语并创建一个 <a href> html 标签链接到: " . $qcld_article_target_label_cta . "."; 1613 1614 } else if ( $qcld_article_language == “ko” ) { 1615 $prompt_text = " 다음과 관련된 "; 1616 $prompt_last = "가지 블로그 아이디어: "; 1617 $intro_text = "블로그 토픽에 대한 소개를 작성하십시오 "; 1618 $conclusion_text = "블로그 토픽에 대한 결론을 작성하십시오 "; 1619 $introduction = "소개"; 1620 $conclusion = "결론"; 1621 $faq_text = $qcld_article_text . "에 대한 " . strval( $qcld_article_number_of_heading ) . "개의 질문과 답변."; 1622 $faq_heading = "자주 묻는 질문"; 1623 // write a tagline about 1624 $tagline_text = "에 대한 태그라인 작성 "; 1625 $style_text = "작성 스타일: " . $writing_style . "."; 1626 1627 if ( empty($qcld_article_label_keywords) ) { 1628 $myprompt = $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $qcld_article_text . "."; 1629 } else { 1630 $keyword_text = ". 키워드: " . $qcld_article_label_keywords . "."; 1631 $myprompt = $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $qcld_article_text . $keyword_text; 1632 } 1633 1634 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1635 1636 if ( !empty($qcld_article_label_word_to_avoid) ) { 1637 $avoid_text = " 다음 키워드를 제외하십시오. " . $qcld_article_label_word_to_avoid . "."; 1638 $myprompt = $myprompt . $avoid_text; 1639 } 1640 1641 $myintro = $intro_text . $qcld_article_text; 1642 $myconclusion = $conclusion_text . $qcld_article_text; 1643 $mytagline = $qcld_article_text . $tagline_text; 1644 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1645 $mycta = $qcld_article_text . "에 대한 호출 행동을 작성하고 href 태그 링크를 만듭니다. " . $qcld_article_target_label_cta . "."; 1646 1647 } else if ( $qcld_article_language == “id” ) { 1648 $prompt_text = " topik blog tentang "; 1649 $intro_text = "Tulis pengantar tentang "; 1650 $conclusion_text = "Tulis kesimpulan tentang "; 1651 $introduction = "Pengantar"; 1652 $conclusion = "Kesimpulan"; 1653 $faq_text = strval( $qcld_article_number_of_heading ) . " pertanyaan dan jawaban tentang " . $qcld_article_text . "."; 1654 $faq_heading = "Pertanyaan dan jawaban"; 1655 // write a tagline about 1656 $tagline_text = "Tulis tagline tentang "; 1657 $style_text = "Gaya penulisan: " . $writing_style . "."; 1658 1659 if ( empty($qcld_article_label_keywords) ) { 1660 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1661 } else { 1662 $keyword_text = ". Kata kunci: " . $qcld_article_label_keywords . "."; 1663 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1664 } 1665 1666 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1667 1668 if ( !empty($qcld_article_label_word_to_avoid) ) { 1669 $avoid_text = " Hindari kata kunci berikut: " . $qcld_article_label_word_to_avoid . "."; 1670 $myprompt = $myprompt . $avoid_text; 1671 } 1672 1673 $myintro = $intro_text . $qcld_article_text; 1674 $myconclusion = $conclusion_text . $qcld_article_text; 1675 $mytagline = $tagline_text . $qcld_article_text; 1676 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1677 $mycta = "Tulis panggilan tindakan tentang " . $qcld_article_text . " dan buat tautan tag href ke: " . $qcld_article_target_label_cta . "."; 1678 1679 } else if ( $qcld_article_language == “tr” ) { 1680 $prompt_text = " hakkında "; 1681 $prompt_last = " blog başlığı listele."; 1682 $intro_text = " ile ilgili bir giriş yazısı yaz."; 1683 $conclusion_text = " ile ilgili bir sonuç yazısı yaz."; 1684 $introduction = "Giriş"; 1685 $conclusion = "Sonuç"; 1686 $faq_text = $qcld_article_text . " hakkında " . strval( $qcld_article_number_of_heading ) . " soru ve cevap."; 1687 $faq_heading = "SSS"; 1688 // write a tagline about 1689 $tagline_text = " ile ilgili bir slogan yaz."; 1690 $style_text = "Yazı stili: " . $writing_style . "."; 1691 1692 if ( empty($qcld_article_label_keywords) ) { 1693 $myprompt = $qcld_article_text . $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . "."; 1694 } else { 1695 $keyword_text = ". Anahtar kelimeler: " . $qcld_article_label_keywords . "."; 1696 $myprompt = $qcld_article_text . $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $keyword_text; 1697 } 1698 1699 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1700 1701 if ( !empty($qcld_article_label_word_to_avoid) ) { 1702 $avoid_text = " Bu anahtar kelimeleri kullanma: " . $qcld_article_label_word_to_avoid . "."; 1703 $myprompt = $myprompt . $avoid_text; 1704 } 1705 1706 $myintro = $qcld_article_text . $intro_text; 1707 $myconclusion = $qcld_article_text . $conclusion_text; 1708 $mytagline = $qcld_article_text . $tagline_text; 1709 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1710 $mycta = $qcld_article_text . " hakkında bir çağrıyı harekete geçir ve bir href etiketi bağlantısı oluştur: " . $qcld_article_target_label_cta . "."; 1711 1712 } else if ( $qcld_article_language == “hi” ) { 1713 $prompt_text = " के बारे में "; 1714 $prompt_last = " ब्लॉग विषय सूचीबद्ध करें."; 1715 $intro_text = "का परिचय लिखिए "; 1716 $conclusion_text = "के बारे में निष्कर्ष लिखिए "; 1717 $introduction = "प्रस्तावना"; 1718 $conclusion = "निष्कर्ष"; 1719 $faq_text = $qcld_article_text . " के बारे में " . strval( $qcld_article_number_of_heading ) . " प्रश्न और उत्तर."; 1720 $faq_heading = "सामान्य प्रश्न"; 1721 // write a tagline about 1722 $tagline_text = " के बारे में एक नारा लिखिए"; 1723 $style_text = "लेखन शैली: " . $writing_style . "."; 1724 1725 if ( empty($qcld_article_label_keywords) ) { 1726 $myprompt = $qcld_article_text . $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . "."; 1727 } else { 1728 $keyword_text = ". कीवर्ड: " . $qcld_article_label_keywords . "."; 1729 $myprompt = $qcld_article_text . $prompt_text . strval( $qcld_article_number_of_heading ) . $prompt_last . $keyword_text; 1730 } 1731 1732 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1733 1734 if ( !empty($qcld_article_label_word_to_avoid) ) { 1735 $avoid_text = " निम्नलिखित खोजशब्दों को बाहर करें: " . $qcld_article_label_word_to_avoid . "."; 1736 $myprompt = $myprompt . $avoid_text; 1737 } 1738 1739 $myintro = $intro_text . $qcld_article_text; 1740 $myconclusion = $conclusion_text . $qcld_article_text; 1741 $mytagline = $qcld_article_text . $tagline_text; 1742 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1743 $mycta = $qcld_article_text . " के बारे में कोई कॉल एक्शन लिखें और एक href टैग लिंक बनाएं: " . $qcld_article_target_label_cta . "."; 1744 1745 } else if ( $qcld_article_language == “pl” ) { 1746 $prompt_text = " tematów blogów o "; 1747 $intro_text = "Napisz wprowadzenie o "; 1748 $conclusion_text = "Napisz konkluzja o "; 1749 $introduction = "Wstęp"; 1750 $conclusion = "Konkluzja"; 1751 $faq_text = "Napisz " . strval( $qcld_article_number_of_heading ) . " pytania i odpowiedzi o " . $qcld_article_text . "."; 1752 $faq_heading = "Pytania i odpowiedzi"; 1753 // write a tagline about 1754 $tagline_text = "Napisz slogan o "; 1755 $style_text = "Styl pisania: " . $writing_style . "."; 1756 1757 if ( empty($qcld_article_label_keywords) ) { 1758 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1759 } else { 1760 $keyword_text = ". Słowa kluczowe:: " . $qcld_article_label_keywords . "."; 1761 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text . "."; 1762 } 1763 1764 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1765 1766 if ( !empty($qcld_article_label_word_to_avoid) ) { 1767 $avoid_text = " Wyklucz następujące słowa kluczowe: " . $qcld_article_label_word_to_avoid . "."; 1768 $myprompt = $myprompt . $avoid_text; 1769 } 1770 1771 $myintro = $intro_text . $qcld_article_text; 1772 $myconclusion = $conclusion_text . $qcld_article_text; 1773 $mytagline = $tagline_text . $qcld_article_text; 1774 $mycta = "Napisz wezwanie do działania dotyczące " . $qcld_article_text . " i utwórz link tagu HTML <a href> do: " . $qcld_article_target_label_cta . "."; 1775 1776 } else if ( $qcld_article_language == “uk” ) { 1777 $prompt_text = " теми блогів про "; 1778 $intro_text = "Напишіть вступ про "; 1779 $conclusion_text = "Напишіть висновок про "; 1780 $introduction = "Вступ"; 1781 $conclusion = "Висновок"; 1782 $faq_text = "Напишіть " . strval( $qcld_article_number_of_heading ) . " питання та відповіді про " . $qcld_article_text . "."; 1783 $faq_heading = "Питання та відповіді"; 1784 // write a tagline about 1785 $tagline_text = "Напишіть слоган про "; 1786 $style_text = "Стиль письма: " . $writing_style . "."; 1787 1788 if ( empty($qcld_article_label_keywords) ) { 1789 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1790 } else { 1791 $keyword_text = ". Ключові слова: " . $qcld_article_label_keywords . "."; 1792 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1793 } 1794 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1795 1796 if ( !empty($qcld_article_label_word_to_avoid) ) { 1797 $avoid_text = " Виключіть такі ключові слова: " . $qcld_article_label_word_to_avoid . "."; 1798 $myprompt = $myprompt . $avoid_text; 1799 } 1800 $myintro = $intro_text . $qcld_article_text; 1801 $myconclusion = $conclusion_text . $qcld_article_text; 1802 $mytagline = $tagline_text . $qcld_article_text; 1803 // Напишіть заклик до дії про Google і створіть посилання на тег html <a href> для: 1804 $mycta = "Напишіть заклик до дії про " . $qcld_article_text . " і створіть посилання на тег html <a href> для: " . $qcld_article_target_label_cta . "."; 1805 1806 } else if ( $qcld_article_language == “ar” ) { 1807 $prompt_text = " موضوعات المدونات على "; 1808 $intro_text = "اكتب مقدمة عن: "; 1809 $conclusion_text = "اكتب استنتاجًا عن: "; 1810 $introduction = "مقدمة"; 1811 $conclusion = "استنتاج"; 1812 $faq_text = "اكتب " . strval( $qcld_article_number_of_heading ) . " أسئلة وأجوبة عن " . $qcld_article_text . "."; 1813 $faq_heading = "الأسئلة الشائعة"; 1814 // write a tagline about اكتب شعارًا عن 1815 $tagline_text = " اكتب شعارًا عن "; 1816 $style_text = "نمط الكتابة: " . $writing_style . "."; 1817 1818 if ( empty($qcld_article_label_keywords) ) { 1819 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1820 } else { 1821 $keyword_text = ". الكلمات الدالة: " . $qcld_article_label_keywords . "."; 1822 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1823 } 1824 1825 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1826 1827 if ( !empty($qcld_article_label_word_to_avoid) ) { 1828 $avoid_text = " تجنب الكلمات التالية: " . $qcld_article_label_word_to_avoid . "."; 1829 $myprompt = $myprompt . $avoid_text; 1830 } 1831 1832 $myintro = $intro_text . $qcld_article_text; 1833 $myconclusion = $conclusion_text . $qcld_article_text; 1834 $mytagline = $qcld_article_text . $tagline_text; 1835 $mycta = "اكتب عبارة تحث المستخدم على اتخاذ إجراء بشأن " . $qcld_article_text . " وأنشئ <a href> رابط وسم html من أجل: " . $qcld_article_target_label_cta . "."; 1836 1837 } else if ( $qcld_article_language == “ro” ) { 1838 $prompt_text = " subiecte de blog despre "; 1839 $intro_text = "Scrieți o introducere despre "; 1840 $conclusion_text = "Scrieți o concluzie despre "; 1841 $introduction = "Introducere"; 1842 $conclusion = "Concluzie"; 1843 $faq_text = "Scrieți " . strval( $qcld_article_number_of_heading ) . " întrebări și răspunsuri despre " . $qcld_article_text . "."; 1844 $faq_heading = "Întrebări și răspunsuri"; 1845 // write a tagline about 1846 $tagline_text = "Scrieți un slogan despre "; 1847 $style_text = "Stilul de scriere: " . $writing_style . "."; 1848 1849 if ( empty($qcld_article_label_keywords) ) { 1850 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1851 } else { 1852 $keyword_text = ". Cuvinte cheie: " . $qcld_article_label_keywords . "."; 1853 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1854 } 1855 1856 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1857 1858 if ( !empty($qcld_article_label_word_to_avoid) ) { 1859 $avoid_text = " Evitați cuvintele: " . $qcld_article_label_word_to_avoid . "."; 1860 $myprompt = $myprompt . $avoid_text; 1861 } 1862 1863 $myintro = $intro_text . $qcld_article_text; 1864 $myconclusion = $conclusion_text . $qcld_article_text; 1865 $mytagline = $tagline_text . $qcld_article_text; 1866 // Scrieți un îndemn despre Google și creați o etichetă html <a href> link către: 1867 $mycta = "Scrieți un îndemn despre " . $qcld_article_text . " și creați o etichetă html <a href> link către: " . $qcld_article_target_label_cta . "."; 1868 1869 } else if ( $qcld_article_language == “hu” ) { 1870 // Írj 5 blogtémát a Google-ról 1871 $prompt_text = " blog témákat a következő témában: "; 1872 $intro_text = "Írj bevezetést "; 1873 $conclusion_text = "Írj következtetést "; 1874 $introduction = "Bevezetés"; 1875 $conclusion = "Következtetés"; 1876 $faq_text = "Írj " . strval( $qcld_article_number_of_heading ) . " kérdést és választ a következő témában: " . $qcld_article_text . "."; 1877 $faq_heading = "GYIK"; 1878 // write a tagline about 1879 $tagline_text = "Írj egy tagline-t "; 1880 $style_text = "Írásmód: " . $writing_style . "."; 1881 1882 if ( empty($qcld_article_label_keywords) ) { 1883 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1884 } else { 1885 $keyword_text = ". Kulcsszavak: " . $qcld_article_label_keywords . "."; 1886 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1887 } 1888 1889 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1890 1891 if ( !empty($qcld_article_label_word_to_avoid) ) { 1892 $avoid_text = " Kerülje a következő szavakat: " . $qcld_article_label_word_to_avoid . "."; 1893 $myprompt = $myprompt . $avoid_text; 1894 } 1895 1896 $myintro = $intro_text . $qcld_article_text; 1897 $myconclusion = $conclusion_text . $qcld_article_text; 1898 $mytagline = $tagline_text . $qcld_article_text; 1899 // Írjon cselekvésre ösztönzést a 123-ról, és hozzon létre egy <a href> html címke hivatkozást: 1900 $mycta = "Írjon cselekvésre ösztönzést a " . $qcld_article_text . "-rol, témában, és hozzon létre egy <a href> html címke hivatkozást: " . $qcld_article_target_label_cta . "."; 1901 1902 } else if ( $qcld_article_language == “cs” ) { 1903 $prompt_text = " blog témata o "; 1904 $intro_text = "Napi úvodní zprávy o "; 1905 $conclusion_text = "Napi závěrečná zpráva o "; 1906 $introduction = "Úvodní zpráva"; 1907 $conclusion = "Závěrečná zpráva"; 1908 $faq_text = "Napi " . strval( $qcld_article_number_of_heading ) . " otázky a odpovědi o " . $qcld_article_text . "."; 1909 $faq_heading = "Často kladené otázky"; 1910 // write a tagline about 1911 $tagline_text = "Napi tagline o "; 1912 $style_text = "Styl psaní: " . $writing_style . "."; 1913 if ( empty($qcld_article_label_keywords) ) { 1914 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1915 } else { 1916 $keyword_text = ". Klíčová slova: " . $qcld_article_label_keywords . "."; 1917 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1918 } 1919 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1920 if ( !empty($qcld_article_label_word_to_avoid) ) { 1921 $avoid_text = " Vyhněte se slovům: " . $qcld_article_label_word_to_avoid . "."; 1922 $myprompt = $myprompt . $avoid_text; 1923 } 1924 $myintro = $intro_text . $qcld_article_text; 1925 $myconclusion = $conclusion_text . $qcld_article_text; 1926 $mytagline = $tagline_text . $qcld_article_text; 1927 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1928 $mycta = "Napi hovor k akci o " . $qcld_article_text . " a vytvořte href tag link na: " . $qcld_article_target_label_cta . "."; 1929 1930 } else if ( $qcld_article_language == “el” ) { 1931 $prompt_text = " θέματα ιστολογίου για "; 1932 $intro_text = "Γράψτε μια εισαγωγή για "; 1933 $conclusion_text = "Γράψτε μια συμπέραση για "; 1934 $introduction = "Εισαγωγή"; 1935 $conclusion = "Συμπέραση"; 1936 $faq_text = "Γράψτε " . strval( $qcld_article_number_of_heading ) . " ερωτήσεις και απαντήσεις για " . $qcld_article_text . "."; 1937 $faq_heading = "Συχνές ερωτήσεις"; 1938 // write a tagline about 1939 $tagline_text = "Γράψτε μια tagline για "; 1940 $style_text = "Στυλ συγγραφής: " . $writing_style . "."; 1941 1942 if ( empty($qcld_article_label_keywords) ) { 1943 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1944 } else { 1945 $keyword_text = ". Λέξεις-κλειδιά: " . $qcld_article_label_keywords . "."; 1946 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1947 } 1948 1949 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1950 1951 if ( !empty($qcld_article_label_word_to_avoid) ) { 1952 $avoid_text = " Αποφύγετε τις εξής λέξεις: " . $qcld_article_label_word_to_avoid . "."; 1953 $myprompt = $myprompt . $avoid_text; 1954 } 1955 1956 $myintro = $intro_text . $qcld_article_text; 1957 $myconclusion = $conclusion_text . $qcld_article_text; 1958 $mytagline = $tagline_text . $qcld_article_text; 1959 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1960 $mycta = "Γράψτε μια κλήση σε ενέργεια για " . $qcld_article_text . " και δημιουργήστε έναν σύνδεσμο href tag στο: " . $qcld_article_target_label_cta . "."; 1961 1962 } else if ( $qcld_article_language == “bg” ) { 1963 $prompt_text = " блог теми за "; 1964 $intro_text = "Напишете въведение за "; 1965 $conclusion_text = "Напишете заключение за "; 1966 $introduction = "Въведение"; 1967 $conclusion = "Заключение"; 1968 $faq_text = "Напишете " . strval( $qcld_article_number_of_heading ) . " въпроси и отговори за " . $qcld_article_text . "."; 1969 $faq_heading = "Често задавани въпроси"; 1970 // write a tagline about 1971 $tagline_text = "Напишете tagline за "; 1972 $style_text = "Стил на писане: " . $writing_style . "."; 1973 1974 if ( empty($qcld_article_label_keywords) ) { 1975 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 1976 } else { 1977 $keyword_text = ". Ключови думи: " . $qcld_article_label_keywords . "."; 1978 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 1979 } 1980 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 1981 if ( !empty($qcld_article_label_word_to_avoid) ) { 1982 $avoid_text = " Избягвайте думите: " . $qcld_article_label_word_to_avoid . "."; 1983 $myprompt = $myprompt . $avoid_text; 1984 } 1985 1986 $myintro = $intro_text . $qcld_article_text; 1987 $myconclusion = $conclusion_text . $qcld_article_text; 1988 $mytagline = $tagline_text . $qcld_article_text; 1989 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 1990 $mycta = "Напишете действие за " . $qcld_article_text . " и създайте връзка href tag към: " . $qcld_article_target_label_cta . "."; 1991 1992 } else if ( $qcld_article_language == “sv” ) { 1993 $prompt_text = " bloggämnen om "; 1994 $intro_text = "Skriv en introduktion om "; 1995 $conclusion_text = "Skriv en slutsats om "; 1996 $introduction = "Introduktion"; 1997 $conclusion = "Slutsats"; 1998 $faq_text = "Skriv " . strval( $qcld_article_number_of_heading ) . " frågor och svar om " . $qcld_article_text . "."; 1999 $faq_heading = "FAQ"; 2000 // write a tagline about 2001 $tagline_text = "Skriv en tagline om "; 2002 $style_text = "Skrivstil: " . $writing_style . "."; 2003 2004 if ( empty($qcld_article_label_keywords) ) { 2005 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 2006 } else { 2007 $keyword_text = ". Nyckelord: " . $qcld_article_label_keywords . "."; 2008 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 2009 } 2010 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 2011 if ( !empty($qcld_article_label_word_to_avoid) ) { 2012 $avoid_text = " Undvik ord: " . $qcld_article_label_word_to_avoid . "."; 2013 $myprompt = $myprompt . $avoid_text; 2014 } 2015 2016 $myintro = $intro_text . $qcld_article_text; 2017 $myconclusion = $conclusion_text . $qcld_article_text; 2018 $mytagline = $tagline_text . $qcld_article_text; 2019 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 2020 $mycta = "Skriv ett åtgärdsförslag om " . $qcld_article_text . " och skapa en href tag-länk till: " . $qcld_article_target_label_cta . "."; 2021 2022 } else { 2023 $prompt_text = " blog topics about "; 2024 $intro_text = "Write an introduction about "; 2025 $conclusion_text = "Write a conclusion about "; 2026 $introduction = "Introduction"; 2027 $conclusion = "Conclusion"; 2028 $faq_text = "Write " . strval( $qcld_article_number_of_heading ) . " questions and answers about " . $qcld_article_text . "."; 2029 $faq_heading = "Q&A"; 2030 // write a tagline about 2031 $tagline_text = "Write a tagline about "; 2032 $style_text = "Writing style: " . $writing_style . "."; 2033 2034 if ( empty($qcld_article_label_keywords) ) { 2035 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . "."; 2036 } else { 2037 $keyword_text = ". Keywords: " . $qcld_article_label_keywords . "."; 2038 $myprompt = strval( $qcld_article_number_of_heading ) . $prompt_text . $qcld_article_text . $keyword_text; 2039 } 2040 // if $qcld_article_label_word_to_avoid is not empty, add it to the prompt 2041 if ( !empty($qcld_article_label_word_to_avoid) ) { 2042 $avoid_text = " Exclude the following keywords: " . $qcld_article_label_word_to_avoid . "."; 2043 $myprompt = $myprompt . $avoid_text; 2044 } 2045 $myintro = $intro_text . $qcld_article_text; 2046 $myconclusion = $conclusion_text . $qcld_article_text; 2047 $mytagline = $tagline_text . $qcld_article_text; 2048 // Write a call to action about $qcld_article_text and create a href tag link to: $qcld_article_target_label_cta. 2049 $mycta = "Write a call to action about " . $qcld_article_text . " and create a href tag link to: " . $qcld_article_target_label_cta . "."; 2050 2051 } 2052 2053 $result_data = '’; 2054 if(!empty($qcld_article_text)){ 2055 $request_body = [ 2056 “prompt” => $myprompt, 2057 “model” => $ai_engines, 2058 “max_tokens” => (int)$max_token, 2059 “temperature” => (float)$temperature, 2060 “presence_penalty” => (float)$ppenalty, 2061 “frequency_penalty” => (float)$fpenalty, 2062 “top_p” => 1, 2063 “best_of” => 1, 2064 ]; 2065 2066 $data = json_encode($request_body); 2067 $url = "https://api.openai.com/v1/completions"; 2068 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2069 2070 $curl = curl_init($url); 2071 curl_setopt($curl, CURLOPT_URL, $url); 2072 curl_setopt($curl, CURLOPT_POST, true); 2073 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2074 $headers = array( 2075 "Content-Type: application/json", 2076 $apt_key , 2077 ); 2078 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2079 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2080 $result = curl_exec($curl); 2081 curl_close($curl); 2082 // $results = json_decode($result); 2083 // $result_data = isset( $results->choices[0]->text ) ? trim( $results->choices[0]->text ) : '’; 2084 $complete = json_decode( $result ); 2085 // we need to catch the error here 2086 if ( isset( $complete->error ) ) { 2087 $complete = $complete->error->message; 2088 // exit 2089 echo esc_html( $complete ) ; 2090 exit; 2091 } else { 2092 $complete = $complete->choices[0]->text; 2093 } 2094 // trim the text 2095 $complete = trim( $complete ); 2096 $mylist = array(); 2097 $mylist = preg_split( "/\r\n|\n|\r/", $complete ); 2098 // delete 1. 2. 3. etc from beginning of the line 2099 $mylist = preg_replace( '/^\\d+\\.\\s/’, '’, $mylist ); 2100 $allresults = ""; 2101 $qcld_article_heading_tag = sanitize_text_field( $_REQUEST[“qcld_article_heading_tag”] ); 2102 foreach ( $mylist as $key => $value ) { 2103 $withstyle = $value . '. ' . $style_text . ', ' . $tone_text . '.’; 2104 // if avoid is not empty add it to the prompt 2105 if ( !empty(${$wpai_words_to_avoid}) ) { 2106 $withstyle = $value . '. ' . $style_text . ', ' . $tone_text . ', ' . $avoid_text . '.’; 2107 } 2108 2109 $request_body = [ 2110 “prompt” => $myprompt, 2111 “model” => $ai_engines, 2112 “max_tokens” => (int)$max_token, 2113 “temperature” => (float)$temperature, 2114 “presence_penalty” => (float)$ppenalty, 2115 “frequency_penalty” => (float)$fpenalty, 2116 “top_p” => 1, 2117 “best_of” => 1, 2118 ]; 2119 $data = json_encode($request_body); 2120 $url = "https://api.openai.com/v1/completions"; 2121 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2122 2123 $curl = curl_init($url); 2124 curl_setopt($curl, CURLOPT_URL, $url); 2125 curl_setopt($curl, CURLOPT_POST, true); 2126 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2127 $headers = array( 2128 "Content-Type: application/json", 2129 $apt_key , 2130 ); 2131 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2132 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2133 $result = curl_exec($curl); 2134 curl_close($curl); 2135 2136 $complete = json_decode( $result ); 2137 $complete = isset($complete->choices[0]->text) ? $complete->choices[0]->text : '’; 2138 // trim the text 2139 $complete = trim( $complete ); 2140 $value = str_replace( '\\/’, '’, $value ); 2141 $value = str_replace( '\\’, ‘’, $value ); 2142 // trim value 2143 $value = trim( $value ); 2144 // we will add h tag if the user wants to 2145 2146 if ( $qcld_article_heading_tag == “h1” ) { 2147 $result = “\n"."<h1>” . $value . “</h1>” ."\n". $complete; 2148 } elseif ( $qcld_article_heading_tag == “h2” ) { 2149 $result = “\n"."<h2>” . $value . “</h2>” ."\n". $complete; 2150 } elseif ( $qcld_article_heading_tag == “h3” ) { 2151 $result = “\n"."<h3>” . $value . “</h3>” ."\n". $complete; 2152 } elseif ( $qcld_article_heading_tag == “h4” ) { 2153 $result = “\n"."<h4>” . $value . “</h4>” ."\n". $complete; 2154 } elseif ( $qcld_article_heading_tag == “h5” ) { 2155 $result = “\n"."<h5>” . $value . “</h5>” ."\n". $complete; 2156 } elseif ( $qcld_article_heading_tag == “h6” ) { 2157 $result = “\n"."<h6>” . $value . “</h6>” ."\n". $complete; 2158 } else { 2159 $result = “\n"."<h2>” . $value . “</h2>” ."\n". $complete; 2160 } 2161 2162 $allresults = $allresults . $result; 2163 } 2164 2165 2166 2167 2168 if ( $qcld_article_heading_intro == “1” ) { 2169 // we need to catch the error here 2170 $request_body = [ 2171 “prompt” => $myintro, 2172 “model” => $ai_engines, 2173 “max_tokens” => (int)$max_token, 2174 “temperature” => (float)$temperature, 2175 “presence_penalty” => (float)$ppenalty, 2176 “frequency_penalty” => (float)$fpenalty, 2177 “top_p” => 1, 2178 “best_of” => 1, 2179 ]; 2180 $data = json_encode($request_body); 2181 $url = "https://api.openai.com/v1/completions"; 2182 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2183 2184 $curl = curl_init($url); 2185 curl_setopt($curl, CURLOPT_URL, $url); 2186 curl_setopt($curl, CURLOPT_POST, true); 2187 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2188 $headers = array( 2189 "Content-Type: application/json", 2190 $apt_key , 2191 ); 2192 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2193 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2194 $result = curl_exec($curl); 2195 curl_close($curl); 2196 2197 $completeintro = json_decode( $result ); 2198 2199 if ( isset( $completeintro->error ) ) { 2200 $completeintro = $completeintro->error->message; 2201 // exit 2202 echo esc_html( $completeintro ) ; 2203 exit; 2204 } else { 2205 $completeintro = $completeintro->choices[0]->text; 2206 // trim the text 2207 $completeintro = trim( $completeintro ); 2208 // add <h1>Introuction</h1> to the beginning of the text 2209 $completeintro = “\n"."<h1>” . $introduction . “</h1>” ."\n". $completeintro; 2210 // add intro to the beginning of the text 2211 $allresults = $completeintro . $allresults; 2212 } 2213 2214 } 2215 2216 // if wpai_add_faq is checked then call api with faq prompt 2217 2218 if ( $qcld_article_heading_faq == “1” ) { 2219 // we need to catch the error here 2220 $request_body = [ 2221 “prompt” => $faq_text, 2222 “model” => $ai_engines, 2223 “max_tokens” => (int)$max_token, 2224 “temperature” => (float)$temperature, 2225 “presence_penalty” => (float)$ppenalty, 2226 “frequency_penalty” => (float)$fpenalty, 2227 “top_p” => 1, 2228 “best_of” => 1, 2229 ]; 2230 $data = json_encode($request_body); 2231 $url = "https://api.openai.com/v1/completions"; 2232 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2233 2234 $curl = curl_init($url); 2235 curl_setopt($curl, CURLOPT_URL, $url); 2236 curl_setopt($curl, CURLOPT_POST, true); 2237 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2238 $headers = array( 2239 "Content-Type: application/json", 2240 $apt_key , 2241 ); 2242 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2243 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2244 $result = curl_exec($curl); 2245 curl_close($curl); 2246 2247 $completefaq = json_decode( $result ); 2248 2249 if ( isset( $completefaq->error ) ) { 2250 $completefaq = $completefaq->error->message; 2251 // exit 2252 echo esc_html( $completefaq ) ; 2253 exit; 2254 } else { 2255 $completefaq = $completefaq->choices[0]->text; 2256 // trim the text 2257 $completefaq = trim( $completefaq ); 2258 // add <h1>FAQ</h1> to the beginning of the text 2259 $completefaq = “\n"."<h2>” . $faq_heading . “</h2>” ."\n". $completefaq; 2260 // add intro to the beginning of the text 2261 $allresults = $allresults . $completefaq; 2262 } 2263 2264 } 2265 2266 //if myconclusion is not empty,calls the openai api 2267 2268 if ( $qcld_article_heading_conclusion == “1” ) { 2269 2270 // we need to catch the error here 2271 $request_body = [ 2272 “prompt” => $myconclusion, 2273 “model” => $ai_engines, 2274 “max_tokens” => (int)$max_token, 2275 “temperature” => (float)$temperature, 2276 “presence_penalty” => (float)$ppenalty, 2277 “frequency_penalty” => (float)$fpenalty, 2278 “top_p” => 1, 2279 “best_of” => 1, 2280 ]; 2281 $data = json_encode($request_body); 2282 $url = "https://api.openai.com/v1/completions"; 2283 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2284 2285 $curl = curl_init($url); 2286 curl_setopt($curl, CURLOPT_URL, $url); 2287 curl_setopt($curl, CURLOPT_POST, true); 2288 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2289 $headers = array( 2290 "Content-Type: application/json", 2291 $apt_key , 2292 ); 2293 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2294 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2295 $result = curl_exec($curl); 2296 curl_close($curl); 2297 2298 $completeconclusion = json_decode( $result ); 2299 2300 if ( isset( $completeconclusion->error ) ) { 2301 $completeconclusion = $completeconclusion->error->message; 2302 // exit 2303 echo esc_html( $completeconclusion ) ; 2304 exit; 2305 } else { 2306 $completeconclusion = $completeconclusion->choices[0]->text; 2307 // trim the text 2308 $completeconclusion = trim( $completeconclusion ); 2309 // add <h1>Conclusion</h1> to the beginning of the text 2310 $completeconclusion = “\n"."<h1>” . $conclusion . “</h1>” ."\n". $completeconclusion; 2311 // add intro to the beginning of the text 2312 $allresults = $allresults . $completeconclusion; 2313 } 2314 2315 } 2316 2317 // qcld_article_heading_tagline is checked then call the openai api 2318 2319 if ( $qcld_article_heading_tagline == “1” ) { 2320 // we need to catch the error here 2321 $request_body = [ 2322 “prompt” => $mytagline, 2323 “model” => $ai_engines, 2324 “max_tokens” => (int)$max_token, 2325 “temperature” => (float)$temperature, 2326 “presence_penalty” => (float)$ppenalty, 2327 “frequency_penalty” => (float)$fpenalty, 2328 “top_p” => 1, 2329 “best_of” => 1, 2330 ]; 2331 $data = json_encode($request_body); 2332 $url = "https://api.openai.com/v1/completions"; 2333 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2334 2335 $curl = curl_init($url); 2336 curl_setopt($curl, CURLOPT_URL, $url); 2337 curl_setopt($curl, CURLOPT_POST, true); 2338 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2339 $headers = array( 2340 "Content-Type: application/json", 2341 $apt_key , 2342 ); 2343 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2344 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2345 $result = curl_exec($curl); 2346 curl_close($curl); 2347 2348 $completetagline = json_decode( $result ); 2349 2350 if ( isset( $completetagline->error ) ) { 2351 $completetagline = $completetagline->error->message; 2352 // exit 2353 echo esc_html( $completetagline ) ; 2354 exit; 2355 } else { 2356 $completetagline = $completetagline->choices[0]->text; 2357 // trim the text 2358 $completetagline = trim( $completetagline ); 2359 // add <p> to the beginning of the text 2360 $completetagline = “\n"."<p>” . $completetagline . "</p>"."\n"; 2361 // add intro to the beginning of the text 2362 $allresults = $completetagline . $allresults; 2363 } 2364 2365 } 2366 2367 // if qcld_article_label_keywords_bold is checked then then find all keywords and bold them. keywords are separated by comma 2368 if ( $qcld_article_label_keywords_bold == “1” ) { 2369 // check to see at least one keyword is entered 2370 2371 if ( $qcld_article_label_keywords != “” ) { 2372 // split keywords by comma if there are more than one but if there is only one then it will not split 2373 2374 if ( strpos( $qcld_article_label_keywords, ‘,’ ) !== false ) { 2375 $keywords = explode( “,", $qcld_article_label_keywords ); 2376 } else { 2377 $keywords = array( $qcld_article_label_keywords ); 2378 } 2379 2380 // loop through keywords and bold them 2381 foreach ( $keywords as $keyword ) { 2382 $keyword = trim( $keyword ); 2383 // replace keyword with bold keyword but make sure exact match is found. for example if the keyword is “the” then it should not replace “there” with “there"… capital dont matter 2384 $allresults = preg_replace( ‘/\\b’ . $keyword . '\\b/’, ‘<strong>’ . $keyword . '</strong>’, $allresults ); 2385 } 2386 } 2387 2388 } 2389 // if qcld_article_target_url and qcld_article_label_anchor_text is not empty then find qcld_article_label_anchor_text in the text and create a link using qcld_article_target_url 2390 if ( $qcld_article_target_url != “” && $qcld_article_label_anchor_text != “” ) { 2391 // create a link if anchor text found… rules: 1. only for first occurance 2. exact match 3. case insensitive 4. if anchor text found inside any h1,h2,h3,h4,h5,h6, a then skip it. 5. use anchor text to create link dont replace it with existing text 2392 $allresults = preg_replace( 2393 '/(?<!<h[1-6]><a href=”)(?<!<a href=”)(?<!<h[1-6]>)(?<!<h[1-6]><strong>)(?<!<strong>)(?<!<h[1-6]><em>)(?<!<em>)(?<!<h[1-6]><strong><em>)(?<!<strong><em>)(?<!<h[1-6]><em><strong>)(?<!<em><strong>)\\b’ . $qcld_article_label_anchor_text . ‘\\b(?![^<]*<\\/a>)(?![^<]*<\\/h[1-6]>)(?![^<]*<\\/strong>)(?![^<]*<\\/em>)(?![^<]*<\\/strong><\\/em>)(?![^<]*<\\/em><\\/strong>)/i’, 2394 ‘<a href="’ . $qcld_article_target_url . ‘">’ . $qcld_article_label_anchor_text . ‘</a>’, 2395 $allresults, 2396 1 2397 ); 2398 } 2399 // if qcld_article_target_label_cta is not empty then call api to get cta text and create a link using qcld_article_target_label_cta 2400 2401 if ( $qcld_article_target_label_cta != “” ) { 2402 // call api to get cta text 2403 $request_body = [ 2404 “prompt” => $mycta, 2405 “model” => $ai_engines, 2406 “max_tokens” => (int)$max_token, 2407 “temperature” => (float)$temperature, 2408 “presence_penalty” => (float)$ppenalty, 2409 “frequency_penalty” => (float)$fpenalty, 2410 “top_p” => 1, 2411 “best_of” => 1, 2412 ]; 2413 $data = json_encode($request_body); 2414 $url = "https://api.openai.com/v1/completions"; 2415 $apt_key = "Authorization: Bearer ". $OPENAI_API_KEY; 2416 2417 $curl = curl_init($url); 2418 curl_setopt($curl, CURLOPT_URL, $url); 2419 curl_setopt($curl, CURLOPT_POST, true); 2420 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2421 $headers = array( 2422 "Content-Type: application/json", 2423 $apt_key , 2424 ); 2425 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2426 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2427 $result = curl_exec($curl); 2428 curl_close($curl); 2429 2430 // we need to catch the error here 2431 $completecta = json_decode( $result ); 2432 2433 if ( isset( $completecta->error ) ) { 2434 $completecta = $completecta->error->message; 2435 // exit 2436 echo esc_html( $completecta ) ; 2437 exit; 2438 } else { 2439 $completecta = $completecta->choices[0]->text; 2440 // trim the text 2441 $completecta = trim( $completecta ); 2442 // add <p> to the beginning of the text 2443 $completecta = “<p>” . $completecta . “</p>"."\n"; 2444 2445 if ( $wpai_cta_pos == “beg” ) { 2446 $allresults = preg_replace( 2447 ‘/(<h[1-6]>)/’, 2448 $completecta . ' $1’, 2449 $allresults, 2450 1 2451 ); 2452 } else { 2453 $allresults = $allresults . $completecta; 2454 } 2455 2456 } 2457 2458 } 2459 2460 // if add image is checked then we should send api request to get image 2461 if ( $qcld_article_heading_img == “1” ) { 2462 $request_body = [ 2463 “prompt” => $qcld_article_text, 2464 “n” => 1, 2465 “size” => $img_size, 2466 “response_format” => "url", 2467 ]; 2468 $data = json_encode($request_body); 2469 $url = "https://api.openai.com/v1/images/generations"; 2470 $apt_key = "Authorization: Bearer “. $OPENAI_API_KEY; 2471 $curl = curl_init($url); 2472 curl_setopt($curl, CURLOPT_URL, $url); 2473 curl_setopt($curl, CURLOPT_POST, true); 2474 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 2475 $headers = array( 2476 “Content-Type: application/json", 2477 $apt_key , 2478 ); 2479 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 2480 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 2481 $result = curl_exec($curl); 2482 curl_close($curl); 2483 2484 // we need to catch the error here 2485 $imgresult = json_decode( $result ); 2486 2487 2488 $imgresult = $imgresult->data[0]->url; 2489 2490 2491 $array = explode('/’, getimagesize($imgresult)[‘mime’]); 2492 $imagetype = end($array); 2493 $uniq_name = md5($imgresult); 2494 $filename = $uniq_name . ‘.’ . $imagetype; 2495 2496 $uploaddir = wp_upload_dir(); 2497 $target_file_name = $uploaddir[‘path’] . ‘/’ . $filename; 2498 2499 $contents = file_get_contents( $imgresult ); 2500 $savefile = fopen($target_file_name, ‘w’); 2501 fwrite($savefile, $contents); 2502 fclose($savefile); 2503 2504 /* add the image title */ 2505 $image_title = ucwords( $uniq_name ); 2506 2507 $qcld_seo_openai_images_attribution = 'gpt openai’; 2508 2509 /* add the caption */ 2510 $attachment_caption = '’; 2511 if (! isset($qcld_seo_openai_images_attribution[‘attribution’]) | isset($qcld_seo_openai_images_attribution[‘attribution’]) == ‘true’) 2512 $attachment_caption = ‘<a href="’ . esc_url( $imgresult ) . '” target="_blank” rel="noopener">’ . esc_attr( $filename ) . '</a>’; 2513 unset($imgresult); 2514 /* insert the attachment */ 2515 $wp_filetype = wp_check_filetype(basename($target_file_name), null); 2516 $attachment = array( 2517 ‘guid’ => $uploaddir[‘url’] . ‘/’ . basename($target_file_name), 2518 ‘post_mime_type’ => $wp_filetype[‘type’], 2519 ‘post_title’ => $image_title, 2520 ‘post_status’ => ‘inherit’ 2521 ); 2522 $post_id = isset($_REQUEST[‘post_id’]) ? absint($_REQUEST[‘post_id’]): ‘’; 2523 $attach_id = wp_insert_attachment($attachment, $target_file_name, $post_id); 2524 if ($attach_id == 0) 2525 die(‘Error: File attachment error’); 2526 $attach_data = wp_generate_attachment_metadata($attach_id, $target_file_name); 2527 $result = wp_update_attachment_metadata($attach_id, $attach_data); 2528 $image_data = array(); 2529 $image_data[‘ID’] = $attach_id; 2530 $image_data[‘post_excerpt’] = $attachment_caption; 2531 wp_update_post($image_data); 2532 $parsed = wp_get_attachment_image_src( $attach_id, ‘medium’ )[0]; 2533 if(!empty($parsed)){ 2534 $attach_id = $parsed; 2535 } 2536 $imgresult = “\n"."<img src=’” . $attach_id . "’ alt=’” . $qcld_article_text . "’ />"."\n"; 2537 // get half of qcld_article_number_of_heading and insert image in the middle 2538 $half = intval( $qcld_article_number_of_heading ) / 2; 2539 $half = round( $half ); 2540 $half = $half - 1; 2541 // use qcld_article_heading_tag to add heading tag to image 2542 $allresults = explode( “</” . $qcld_article_heading_tag . “>", $allresults ); 2543 $allresults[$half] = $allresults[$half] . $imgresult; 2544 $allresults = implode( “</” . $qcld_article_heading_tag . “>", $allresults ); 2545 wp_send_json( [ ‘status’ => 'success’, ‘keywords’ => $allresults ] ); 2546 wp_die(); 2547 } else { 2548 wp_send_json( [ ‘status’ => 'success’, ‘keywords’ => $allresults ] ); 2549 wp_die(); 2550 } 2551 } 2552 wp_send_json( [ ‘status’ => 'success’, ‘keywords’ => $result_data ] ); 2553 wp_die(); 2554 2555 } 2556 2557 public function qcld_seo_image_generate_url_functions() { 2558 2559 $qcld_seo_result = array( 2560 ‘status’ => 'error’, 2561 ‘msg’ => esc_html(‘Something went wrong’), 2562 ); 2563 2564 /* Download and upload the chosen image */ 2565 if (isset($_POST[‘qcld_seo_openai_images_upload’])) { 2566 // “pluggable.php” is required for wp_verify_nonce() and other upload related helpers 2567 if (!function_exists(‘wp_verify_nonce’)) 2568 require_once(ABSPATH . ‘wp-includes/pluggable.php’); 2569 if(!function_exists(‘wp_generate_attachment_metadata’)){ 2570 include_once( ABSPATH . ‘wp-admin/includes/image.php’ ); 2571 } 2572 if(!function_exists(‘download_url’)){ 2573 include_once( ABSPATH . ‘wp-admin/includes/file.php’ ); 2574 } 2575 if(!function_exists(‘media_handle_sideload’)){ 2576 include_once( ABSPATH . ‘wp-admin/includes/media.php’ ); 2577 } 2578 2579 $post_id = isset($_REQUEST[‘post_id’]) ? absint($_REQUEST[‘post_id’]): '’; 2580 $imageurl = isset($_POST[‘image_url’]) ? sanitize_url( $_POST[‘image_url’] ) : '’; 2581 $image_user = isset($_POST[‘image_user’]) ? sanitize_url( $_POST[‘image_user’] ) : '’; 2582 $image_src_page = isset($_POST[‘image_src_page’]) ? esc_url( $_POST[‘image_src_page’] ) : '’; 2583 $qcld_seo_openai_images_attribution = 'gpt openai’; 2584 2585 $array = explode('/’, getimagesize($imageurl)[‘mime’]); 2586 $imagetype = end($array); 2587 $uniq_name = md5($imageurl); 2588 $filename = $uniq_name . ‘.’ . $imagetype; 2589 2590 $uploaddir = wp_upload_dir(); 2591 $target_file_name = $uploaddir[‘path’] . ‘/’ . $filename; 2592 2593 $contents = file_get_contents( $imageurl ); 2594 $savefile = fopen($target_file_name, ‘w’); 2595 fwrite($savefile, $contents); 2596 fclose($savefile); 2597 unset($imageurl); 2598 2599 /* add the image title */ 2600 $image_title = ucwords( $uniq_name ); 2601 2602 /* add the caption */ 2603 $attachment_caption = '’; 2604 if (! isset($qcld_seo_openai_images_attribution[‘attribution’]) | isset($qcld_seo_openai_images_attribution[‘attribution’]) == ‘true’) 2605 $attachment_caption = ‘<a href="’ . esc_url( $image_src_page ) . '” target="_blank” rel="noopener">’ . esc_attr( $image_user ) . '</a>’; 2606 2607 /* insert the attachment */ 2608 $wp_filetype = wp_check_filetype(basename($target_file_name), null); 2609 $attachment = array( 2610 ‘guid’ => $uploaddir[‘url’] . ‘/’ . basename($target_file_name), 2611 ‘post_mime_type’ => $wp_filetype[‘type’], 2612 ‘post_title’ => $image_title, 2613 ‘post_status’ => ‘inherit’ 2614 ); 2615 2616 $attach_id = wp_insert_attachment($attachment, $target_file_name, $post_id); 2617 if ($attach_id == 0) 2618 die(‘Error: File attachment error’); 2619 2620 $attach_data = wp_generate_attachment_metadata($attach_id, $target_file_name); 2621 $result = wp_update_attachment_metadata($attach_id, $attach_data); 2622 2623 $image_data = array(); 2624 $image_data[‘ID’] = $attach_id; 2625 $image_data[‘post_excerpt’] = $attachment_caption; 2626 wp_update_post($image_data); 2627 2628 // $parsed = wp_get_attachment_image_src( $attach_id, ‘medium’ )[0]; 2629 2630 /*if(!empty($parsed)){ 2631 $attach_id = $parsed; 2632 }*/ 2633 2634 $size = 'large’; 2635 $attachment_id = $attach_id; 2636 2637 list( $url, $width, $height ) = wp_get_attachment_image_src( $attachment_id, $size ); 2638 $qcld_seo_result[‘status’] = 'success’; 2639 $html = esc_html(‘Image Successfully Added to Media Library’); 2640 2641 wp_send_json_success( compact( 'attachment_id’, 'url’, 'width’, 'height’, 'size’, ‘html’ ) ); 2642 exit; 2643 2644 2645 2646 2647 } 2648 2649 wp_send_json( $qcld_seo_result ); 2650 exit; 2651 2652 2653 } 721