$current_name) { $available_id .= '\''.$current_id.'\', '; $available_names .= '\''.addslashes($current_name).'\', '; } // Remove the last comma $regex = '/(.+), $/'; $available_id = preg_replace($regex, '$1', $available_id); $available_names = preg_replace($regex, '$1', $available_names); // Locales array $array = array( 'LOCALES_AVAILABLE_ID' => $available_id, 'LOCALES_AVAILABLE_NAMES' => $available_names ); // Apply it! foreach($array as $array_key => $array_value) { $string = preg_replace('/(var '.$array_key.'(( )?=( )?)\[)(\];)/', '$1'.$array_value.'$5', $string); } return $string; } // The function to set the good configuration to a JS file function setConfiguration($string, $hash, $locale, $version, $max_upload) { // Special BOSH URL if BOSH proxy enabled if(BOSHProxy()) { $bosh_special = staticLocation().'server/bosh.php'; } else { $bosh_special = HOST_BOSH; } // Configuration array $array = array( // xml:lang 'XML_LANG' => $locale, // Jappix parameters 'JAPPIX_STATIC' => staticLocation(), 'JAPPIX_VERSION' => $version, 'JAPPIX_MAX_FILE_SIZE' => $max_upload, 'JAPPIX_MAX_UPLOAD' => formatBytes($max_upload), 'JAPPIX_MINI_CSS' => getFiles($hash, '', 'css', 'mini.xml', ''), // Main configuration 'SERVICE_NAME' => SERVICE_NAME, 'SERVICE_DESC' => SERVICE_DESC, 'OWNER_NAME' => OWNER_NAME, 'OWNER_WEBSITE' => OWNER_WEBSITE, 'LEGAL' => LEGAL, 'JAPPIX_RESOURCE' => JAPPIX_RESOURCE, 'LOCK_HOST' => LOCK_HOST, 'ANONYMOUS' => ANONYMOUS, 'REGISTRATION' => REGISTRATION, 'MANAGER_LINK' => MANAGER_LINK, 'GROUPCHATS_JOIN' => GROUPCHATS_JOIN, 'GROUPCHATS_SUGGEST' => GROUPCHATS_SUGGEST, 'ENCRYPTION' => ENCRYPTION, 'HTTPS_STORAGE' => HTTPS_STORAGE, 'HTTPS_FORCE' => HTTPS_FORCE, 'COMPRESSION' => COMPRESSION, 'ADS_ENABLE' => ADS_ENABLE, 'GADS_CLIENT' => GADS_CLIENT, 'GADS_SLOT' => GADS_SLOT, 'MULTI_FILES' => MULTI_FILES, 'DEVELOPER' => DEVELOPER, 'REGISTER_API' => REGISTER_API, // Hosts configuration 'HOST_MAIN' => HOST_MAIN, 'HOST_MUC' => HOST_MUC, 'HOST_PUBSUB' => HOST_PUBSUB, 'HOST_VJUD' => HOST_VJUD, 'HOST_ANONYMOUS' => HOST_ANONYMOUS, 'HOST_STUN' => HOST_STUN, 'HOST_TURN' => HOST_TURN, 'HOST_TURN_USERNAME' => HOST_TURN_USERNAME, 'HOST_TURN_PASSWORD' => HOST_TURN_PASSWORD, 'HOST_BOSH' => $bosh_special, 'HOST_BOSH_MAIN' => HOST_BOSH_MAIN, 'HOST_BOSH_MINI' => HOST_BOSH_MINI, 'HOST_WEBSOCKET' => HOST_WEBSOCKET, 'HOST_STATIC' => HOST_STATIC, 'HOST_UPLOAD' => HOST_UPLOAD ); // Apply it! foreach($array as $array_key => $array_value) { $string = preg_replace('/var '.$array_key.'(( )?=( )?)null;/', 'var '.$array_key.'$1\''.addslashes($array_value).'\';', $string); } return $string; } // The function to set the logos function setLogos($string, $files) { // Jappix Desktop home logo? if(in_array('home.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/desktop_home.png')) { $string .= '#home .left .logo { background-image: url(../store/logos/desktop_home.png) !important; background-position: center center !important; }'; } // Jappix Desktop app logo? if(in_array('tools.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/desktop_app.png')) { $string .= '#top-content .tools-logo { background-image: url(../store/logos/desktop_app.png) !important; background-position: center center !important; }'; } // Jappix Mobile logo? if(in_array('mobile.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/mobile.png')) { $string .= '.header div { background-image: url(../store/logos/mobile.png) !important; background-position: center center !important; }'; } // Jappix Mini logo? if(in_array('mini.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/mini.png')) { $string .= '#jappix_mini div.jm_actions a.jm_logo { background-image: url(../store/logos/mini.png) !important; background-position: center center !important; }'; } return $string; } // The function to set the background function setBackground($string) { // Get the default values $array = defaultBackground(); // Read the background configuration $xml = readXML('conf', 'background'); if($xml) { $read = new SimpleXMLElement($xml); foreach($read->children() as $child) { $current_child = (string)$child; // Any value? if($current_child) $array[$child->getName()] = $current_child; } } $css = ''; // Generate the CSS code switch($array['type']) { // Image case 'image': $css .= "\n".' background-image: url(../store/backgrounds/'.urlencode($array['image_file']).'); background-repeat: '.$array['image_repeat'].'; background-position: '.$array['image_horizontal'].' '.$array['image_vertical'].'; background-color: '.$array['image_color'].';' ; // Add CSS code to adapt the image? if($array['image_adapt'] == 'on') $css .= ' background-attachment: fixed; background-size: cover; -moz-background-size: cover; -webkit-background-size: cover;'; $css .= "\n"; break; // Color case 'color': $css .= "\n".' background-color: '.$array['color_color'].';'."\n"; break; // Default: use the filtering regex default: $css .= '$3'; break; } // Apply the replacement! return preg_replace('/(\.body-images( )?\{)([^\{\}]+)(\})/i', '$1'.$css.'$4', $string); } ?>