| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 3 |
global $wpchatbot_pro_professional_init,$wpchatbot_pro_master_init; |
| 4 |
if((isset($wpchatbot_pro_master_init) && $wpchatbot_pro_master_init->is_valid()) || (isset($wpchatbot_pro_professional_init) && $wpchatbot_pro_professional_init->is_valid()) || (function_exists('get_openaiaddon_valid_license') && get_openaiaddon_valid_license())){ |
| 5 |
?> |
| 6 |
<div class="row"> |
| 7 |
<div class="col-md-12"> |
| 8 |
<div class="alert alert-danger my-4"> |
| 9 |
<?php esc_html_e( 'This feature is still experimental and development is ongoing because of the difficulties in cleaning up the multitudes of tags added by page builders','chatbot' ); ?> |
| 10 |
</div> |
| 11 |
<form class="file_form my-4"> |
| 12 |
<div id="wp-chatbot-post-converter"> |
| 13 |
<ul class="checkbox-list"> |
| 14 |
<?php |
| 15 |
$get_cpt_args = array( |
| 16 |
'public' => true, |
| 17 |
); |
| 18 |
$post_types = get_post_types( $get_cpt_args, 'object' ); |
| 19 |
foreach ($post_types as $post_type) { |
| 20 |
if($post_type->name != "attachment"){ |
| 21 |
?> |
| 22 |
<div class="form-check form-check-inline"> |
| 23 |
<input |
| 24 |
id="wp_chatbot_data_converter_<?php echo esc_attr( $post_type->name ); ?>" |
| 25 |
type="checkbox" |
| 26 |
name="wp_chatbot_data_converter_list[]" |
| 27 |
value="<?php echo esc_attr( $post_type->name ); ?>" > |
| 28 |
<label class="form-check-label" for="wp_chatbot_data_converter_<?php echo esc_attr( $post_type->name ); ?>"> <?php echo esc_attr( $post_type->name ); ?></label> |
| 29 |
</div> |
| 30 |
<?php |
| 31 |
} |
| 32 |
} |
| 33 |
?> |
| 34 |
</ul> |
| 35 |
</div> |
| 36 |
<a class="btn btn-default qcld_convert_data"><?php esc_html_e( 'Convert Data', 'chatbot' ); ?></a> |
| 37 |
</form> |
| 38 |
<h3><?php esc_html_e( 'Conversions Files', 'chatbot' ); ?></h3> |
| 39 |
|
| 40 |
<?php |
| 41 |
|
| 42 |
global $wpdb; |
| 43 |
|
| 44 |
$qcld_openai_files_page = isset($_GET['wpage']) && !empty($_GET['wpage']) ? sanitize_text_field(wp_unslash($_GET['wpage'])) : 1; |
| 45 |
|
| 46 |
$qcld_openai_files_per_page = 20; |
| 47 |
|
| 48 |
$qcld_openai_files_offset = ( $qcld_openai_files_page * $qcld_openai_files_per_page ) - $qcld_openai_files_per_page; |
| 49 |
|
| 50 |
$qcld_openai_files_count_sql = $wpdb->prepare("SELECT COUNT(*) FROM ".$wpdb->posts." f WHERE f.post_type='qcldopenai_convert' AND f.post_status='publish'"); //DB: Nothing to pass as PREPARED STATEMENTS ARGUMENT // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 51 |
|
| 52 |
$qcld_openai_files_sql = $wpdb->prepare("SELECT f.* FROM ".$wpdb->posts." f WHERE f.post_type='qcldopenai_convert' AND f.post_status='publish' ORDER BY f.post_date DESC LIMIT %d, %d", $qcld_openai_files_offset, $qcld_openai_files_per_page); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 53 |
|
| 54 |
$qcld_openai_files = $wpdb->get_results( $qcld_openai_files_sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 55 |
|
| 56 |
$qcld_openai_files_total = $wpdb->get_var( $qcld_openai_files_count_sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 57 |
|
| 58 |
?> |
| 59 |
|
| 60 |
<div class="table-responsive"> |
| 61 |
<table class="table table-striped table-bordered qcld_convert_datatable"> |
| 62 |
<thead><tr><td><?php esc_html_e( 'Filename','chatbot');?></td><td><?php esc_html_e( 'Fine tune with','chatbot');?></td><td><?php esc_html_e( 'Date of creation','chatbot');?></td><td><?php esc_html_e( 'Size','chatbot');?></td><td> <?php esc_html_e( 'Action','chatbot');?></td></tr></thead> |
| 63 |
<tbody id="post_conversion_files"> |
| 64 |
<?php |
| 65 |
if($qcld_openai_files && is_array($qcld_openai_files) && count($qcld_openai_files)): |
| 66 |
foreach($qcld_openai_files as $qcld_openai_file): |
| 67 |
$file = wp_upload_dir()['basedir'].'/qcldopenai_site_training/'.$qcld_openai_file->post_title; |
| 68 |
if(file_exists($file)): |
| 69 |
$type = explode('_',$qcld_openai_file->post_title); |
| 70 |
$type = (sizeof($type) == 2) ? 'GPT3.5' : 'Davinci, ADA etc.'; |
| 71 |
?> |
| 72 |
<tr> |
| 73 |
<td><?php echo esc_html($qcld_openai_file->post_title);?></td> |
| 74 |
<td><?php echo esc_html($type);?></td> |
| 75 |
<td><?php echo esc_html( gmdate( 'd.m.Y H:i', strtotime( $qcld_openai_file->post_date ) ) );?></td> |
| 76 |
<td><?php echo esc_html( gmdate( 'd.m.Y H:i', strtotime( $qcld_openai_file->post_modified ) ) );?></td> |
| 77 |
<td><?php echo esc_html( size_format(filesize($file)) );?></td> |
| 78 |
<td> |
| 79 |
<a class="button button-small" href="<?php echo esc_url( wp_upload_dir()['baseurl'].'/qcldopenai_site_training/'.esc_html($qcld_openai_file->post_title) )?>" download><?php esc_html_e( 'Download', 'chatbot' ); ?></a> |
| 80 |
<a class="button button-small qcld_delete_training_file" data-file="<?php echo esc_url( wp_upload_dir()['basedir'].'/qcldopenai_site_training/'.esc_html($qcld_openai_file->post_title) )?>" ><?php esc_html_e('Delete', 'chatbot'); ?></a> |
| 81 |
<button class="button button-small qcld_convert_upload" data-lines="<?php echo count(file($file))?>" data-file="<?php echo esc_html($qcld_openai_file->post_title)?>"><?php esc_html_e('Upload As FT Model', 'chatbot'); ?></button> |
| 82 |
</td> |
| 83 |
</tr> |
| 84 |
<?php |
| 85 |
endif; |
| 86 |
endforeach; |
| 87 |
endif; |
| 88 |
?> |
| 89 |
</tbody> |
| 90 |
</table> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
<?php |
| 95 |
} else { ?> |
| 96 |
<div class="row my-4"> |
| 97 |
<div class="col-md-12"> |
| 98 |
<?php esc_html_e('Fine tuning and training is available with the ', 'chatbot');?> |
| 99 |
<a href="https://www.wpbot.pro/pricing/"><?php esc_html_e('WPBot Pro Professional', 'chatbot'); ?></a> |
| 100 |
<?php esc_html_e(' and ', 'chatbot'); ?> |
| 101 |
<a href="https://www.wpbot.pro/pricing/"><?php esc_html_e('Master', 'chatbot'); ?></a> |
| 102 |
<?php esc_html_e('Licenses', 'chatbot'); ?> |
| 103 |
|
| 104 |
</div> |
| 105 |
</div> |
| 106 |
<?php } ?> |
| 107 |
|
| 108 |
|