actualmanx
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [Montezuma] Fixes for PHP 8+chat gpt worked better then copilot what i did was ask please fix the code for php 8.3 then i paste in either the section of code or the whole code from the one file and it fixes it. i did however have an issue with the one i just fixed the thumb.php has been a nightmare i kept breaking it in the end chat gpt only changed the starting code and it took all the undefined error and null arrays out of it. ill be using chat gpt more and more now
Forum: Themes and Templates
In reply to: [Montezuma] Fixes for PHP 8+ok I’m back again with version 2 of
wp-content/themes/montezuma/includes/thumb.php
<?php if (!function_exists('bfa_delete_thumb_transient')) : function bfa_delete_thumb_transient($post_id) { delete_transient('bfa_thumb_transient'); } endif; add_action('save_post', 'bfa_delete_thumb_transient'); if (!function_exists('bfa_thumb')) : function bfa_thumb($width, $height, $crop = false, $before = '', $after = '', $link = 'permalink') { global $post, $upload_dir; $bfa_thumb_transient = get_transient('bfa_thumb_transient') ?: array(); // Initialize the array if not set if (!is_writable($upload_dir['basedir'])) { echo "WP Upload Directory not writable! Check file and directory permissions"; return; } // Unique thumb per size & post $id = get_the_ID() . '_' . $width . '_' . $height . '_' . ($crop === false ? '0' : '1'); $this_thumb = isset($bfa_thumb_transient[$id]) ? $bfa_thumb_transient[$id] : false; if ($this_thumb === false) { $this_thumb = ''; $hasthumb = false; $hassrc = false; $has_thumbnail = false; if ('' != ($thumb = get_post_thumbnail_id())) $hasthumb = true; elseif (false !== ($thumb = bfa_get_first_attachment_id())) $hasthumb = true; elseif (false !== ($thumb = bfa_get_first_unattached_gallery_img_id())) $hasthumb = true; // if local image not added with WP uploader but added as manual HTML link elseif (false !== ($thumb = bfa_get_first_img_src())) $hassrc = true; if ($hasthumb === true) { $thumbimage = bfa_vt_resize($thumb, '', $width, $height, $crop); $has_thumbnail = true; } elseif ($hassrc === true) { $thumbimage = bfa_vt_resize('', $thumb, $width, $height, $crop); $has_thumbnail = true; } if ($has_thumbnail === true) { $this_thumb .= '<img src="' . $thumbimage['url'] . '" width="' . $thumbimage['width'] . '" height="' . $thumbimage['height'] . '" alt="' . $post->post_title . '"/>'; } $bfa_thumb_transient[$id] = $this_thumb; set_transient('bfa_thumb_transient', $bfa_thumb_transient, 3600); } if (trim($this_thumb) != '' && $this_thumb != false) { if ($link == 'permalink') $this_thumb = '<a href="' . get_permalink($post->ID) . '">' . $this_thumb . '</a>'; echo $before . $this_thumb . $after; } } endif; // Rest of your functions remain unchanged if (!function_exists('bfa_get_first_attachment_id')) : function bfa_get_first_attachment_id() { global $post; $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID); $attachments = get_posts($args); if ($attachments) return $attachments[0]->ID; return false; } endif; // For galleries with images not attached to the current post: [gallery ids="xxx,xxx,xxx,xxx,xxx,xxx,xxx"] if (!function_exists('bfa_get_first_unattached_gallery_img_id')) : function bfa_get_first_unattached_gallery_img_id($args = array()) { global $post; preg_match_all('|<gallery \s*ids\s*=\s*"\s*(.*?)\s*,|i', $post->post_content, $matches); foreach ($matches[1] as $match) { if (isset($match)) return $match; } return false; } endif; if (!function_exists('bfa_get_first_img_src')) : function bfa_get_first_img_src($args = array()) { global $post; $site_url = site_url(); preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post->post_content, $matches); foreach ($matches[1] as $match) { if (isset($match) && strpos($match, $site_url) !== false) return $match; } return false; } endif; if (!function_exists('bfa_vt_resize')) : function bfa_vt_resize($attach_id = null, $img_url = null, $width, $height, $crop = false) { // Based on: vt_resize - Resize images dynamically using WP built-in functions - Victor Teixeira if ($attach_id) { // is an attachment, we have the ID $image_src = wp_get_attachment_image_src($attach_id, 'full'); $file_path = get_attached_file($attach_id); } elseif ($img_url) { // not an attachment, use image URL $file_path = parse_url($img_url); $file_path = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT'] . $file_path['path']); $orig_size = getimagesize($file_path); $image_src[0] = $img_url; $image_src[1] = $orig_size[0]; $image_src[2] = $orig_size[1]; } $file_info = pathinfo($file_path); $extension = '.' . $file_info['extension']; $no_ext_path = $file_info['dirname'] . '/' . $file_info['filename']; // image path without the extension #$cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . $extension; $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . '-' . ($crop === false ? '0' : '1') . $extension; if ($image_src[1] > $width || $image_src[2] > $height) { // if file size larger than target size. // the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match) if (file_exists($cropped_img_path)) { $cropped_img_url = str_replace(basename($image_src[0]), basename($cropped_img_path), $image_src[0]); $vt_image = array( 'url' => $cropped_img_url, 'width' => $width, 'height' => $height, #'final_image' => $final_image, 'image_url' => $img_url ); return $vt_image; } // $crop = false if ($crop === false) { $proportional_size = wp_constrain_dimensions($image_src[1], $image_src[2], $width, $height); // calculate the size proportionally #$resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . $extension; $resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . '-' . ($crop === false ? '0' : '1') . $extension; if (file_exists($resized_img_path)) { // checking if the file already exists $resized_img_url = str_replace(basename($image_src[0]), basename($resized_img_path), $image_src[0]); $vt_image = array( 'url' => $resized_img_url, 'width' => $proportional_size[0], 'height' => $proportional_size[1], #'final_image' => $final_image, 'image_url' => $img_url ); return $vt_image; } } // no cache files - let's finally resize it $image = wp_get_image_editor($file_path); // wp_get_image_editor since WP 3.5 if (!is_wp_error($image)) { $image->resize($width, $height, $crop); $image->set_quality(30); $final_image = $image->save($cropped_img_path); $img_url = str_replace(basename($image_src[0]), basename($final_image['path']), $image_src[0]); /* Sample output: final_image= Array ( [path] => C:\UniServer_5.3.10\www\wordpress351/wp-content/uploads/2012/11/AmazingFlash_size1.png [file] => AmazingFlash_size1.png [width] => 440 [height] => 260 [mime-type] => image/png ) */ // resized output $vt_image = array( 'url' => $img_url, 'width' => $final_image['width'], 'height' => $final_image['height'], 'final_image' => $final_image, 'image_url' => $img_url ); return $vt_image; } } // default output - without resizing $vt_image = array( 'url' => $image_src[0], 'width' => $image_src[1], 'height' => $image_src[2], #'final_image' => $final_image, 'image_url' => $img_url ); return $vt_image; } endif;Forum: Themes and Templates
In reply to: [Montezuma] Fixes for PHP 8+ok so i broke something but has now been fixed update Version 2
wp-content/themes/montezuma/includes/parse_php.php
<?php function bfa_parse_php_callback(array $matches): string { $function_name = $matches[1]; $parameter_string = $matches[2]; $whitelist = bfa_get_whitelist(); /* * Check for "echo " in 'function_name' part and remove it * echo function_name( ... ) */ $echo = FALSE; if (strpos($function_name, 'echo ') === 0) { $echo = TRUE; // Remove 'echo ' (first 5 letters) from the beginning of the string $function_name = str_replace(substr($function_name, 0, 5), '', $function_name); } // Allow only whitelisted functions: if (!in_array($function_name, array_keys($whitelist))) return ''; // $need_loop = array( 'bfa_comments_popup_link', 'comments_popup_link', 'the_content' ); $need_loop = array('the_author', 'the_author_meta', 'the_author_posts_link', 'the_content', 'the_post_thumbnail', 'the_date', 'the_excerpt' ); // functions that needs the loop // the following line changed by Patch 113-02 // if (have_posts()) if (!in_the_loop() && in_array($function_name, $need_loop)) { /* global $query_string; $posts = query_posts($query_string); */ if ((is_singular() || is_page()) && have_posts()) the_post(); } // No parameter -> parameter type doesn't matter if ($parameter_string == '') { ob_start(); if ($echo == TRUE) echo $function_name(); else $function_name(); return ob_get_clean(); } /* * Array style parameters: * function_name(array('this'=>'that','this'=>3,'this'=>true)); */ elseif ($whitelist[$function_name]['type'] == 'array') { $param_array = str_getcsv($parameter_string, ',', "'\"", "\\"); ob_start(); if ($echo === TRUE) echo $function_name($param_array); else $function_name($param_array); return ob_get_clean(); } /* * URL-query style parameters: * function_name( 'this=that&this=that&this=that' ); */ elseif ($whitelist[$function_name]['type'] == 'queryarray') { ob_start(); if ($echo === TRUE) echo $function_name($parameter_string); else $function_name($parameter_string); return ob_get_clean(); } /* * PHP function-style parameters: * function_name( 'param', 'param', '', TRUE, 1, 'param' ); */ elseif ($whitelist[$function_name]['type'] == 'function') { $args = str_getcsv($parameter_string, ',', "'\"", "\\"); ob_start(); if ($echo === TRUE) { echo call_user_func_array($function_name, $args); } else { call_user_func_array($function_name, $args); } return ob_get_clean(); } /* * Single PHP style parameter, or none at all: * function_name(); * function_name('param'); */ elseif ($whitelist[$function_name]['type'] == 'single' || $whitelist[$function_name]['type'] == 'function') { ob_start(); if ($echo === TRUE) echo call_user_func($function_name, trim($parameter_string, "'")); else call_user_func($function_name, trim($parameter_string, "'")); return ob_get_clean(); } return ''; } function bfa_parse_php_string(array $matches): string { $php_string = $matches[1]; $php_string = str_replace(array("\r", "\n", "\t"), "", $php_string); // Since 1.2.0: $php_string = str_replace(", ", ",", $php_string); // Replace translation texts that are paramaters first // __('afsfsfs "nnhjj" peter\'s ', 'montezuma') // __("afsfsfs \"nnhjj\" peter's ", 'montezuma') $php_string = preg_replace_callback( '/__\(\s*[\'|"](.*?)[\'|"]\s*,\s*\'montezuma\'\s*\)/', function($matches) { return translate(stripslashes($matches[1]), "montezuma"); }, $php_string ); // $matches[1] is the (.*) from above. We have a php code string without the // opening and closing PHP tags, and no spaces left/right // match 'echo function_name( parameters )' or 'function_name( parameters )' // \s* = 0 or more spaces // (echo [a-z_]+[a-z\d_]+|[a-z_]+[a-z\d_]*) = min 1 character, 'echo func_name' or 'func_name' // 'func_name' can start with a-z or _, second character optional, can be a-z, _ or \d = number // \s* = 0 or more spaces // \( = opening bracket ( - literally // \s* = 0 or more spaces // (?:array\s*\()? = ?: = don't capture. ()? = optional // content: an optional 'array' followed by 0 or more spaces and an opening bracket ( return preg_replace_callback( '/\s*(echo [a-zA-Z_]+[a-zA-Z\d_]+|[a-zA-Z_]+[a-zA-Z\d_]*)\s*\(\s*(?:array\s*\()?\s*(.*?)\s*(?:\))?\s*\)\s*/', 'bfa_parse_php_callback', $php_string ); } function bfa_parse_php(string $text): string { $text = preg_replace_callback( '/\<\?php \s*(.*?)\s*(?:;)?\s*\?\>/s', // s = multiline \s* = 0 or more spaces 'bfa_parse_php_string', $text ); return $text; } // parse potentially eval'able code for illegal function calls function bd_parse($str) { // allowed functions: $allowedCalls = explode( ',', 'explode,implode,date,time,round,trunc,rand,ceil,floor,srand,' . 'strtolower,strtoupper,substr,stristr,strpos,print,print_r' ); // check if there are any illegal calls $parseErrors = array(); $tokens = token_get_all($str); $vcall = ''; foreach ($tokens as $token) { if (is_array($token)) { $id = $token[0]; switch ($id) { case(T_VARIABLE): $vcall .= 'v'; break; case(T_CONSTANT_ENCAPSED_STRING): $vcall .= 'e'; break; case(T_STRING): $vcall .= 's'; case(T_REQUIRE_ONCE): case(T_REQUIRE): case(T_NEW): case(T_RETURN): case(T_BREAK): case(T_CATCH): case(T_CLONE): case(T_EXIT): case(T_PRINT): case(T_GLOBAL): case(T_ECHO): case(T_INCLUDE_ONCE): case(T_INCLUDE): case(T_EVAL): case(T_FUNCTION): case(T_GOTO): case(T_USE): case(T_DIR): if (array_search($token[1], $allowedCalls) === false) $parseErrors[] = 'illegal call: ' . $token[1]; } } else $vcall .= $token; } // check for dynamic functions if (stristr($vcall, 'v(') != '') $parseErrors[] = array('illegal dynamic function call'); return $parseErrors; }Forum: Reviews
In reply to: [Filedownload] Very PleasedThank you for the reply i should have replied back i figured it out. im very pleased with the mod so far.
Forum: Plugins
In reply to: [MP3-jPlayer] Songs don't play in Android browseri have the sidebar player and it plays my live stream from a icecast2 server in mp3 on my android (galaxy s2 ) without flash update to the latest version of mp3-jplayer