Jump to content

Recommended Posts

Hi guys,

at the moment i am working on a multilanguage mod for my website.

everything works fine, but one big problem is there:

it seems like since i wrote this mod, i have some memoryleaks on my server.

could you please have a look on the script, maybe someone out there will find the error.

 

Thanks a lot!

 

The language files:

de.php

<?php

// function
define("year_ago","jahr her");
define("years_ago","jahre her");
define("month_ago","monat her");
define("months_ago","monate her");
define("day_ago","tag her");
define("days_ago","tage her");
define("hour_ago","stunde her");
define("hours_ago","stunden her");
define("minute_ago","minute her");
define("minutes_ago","minuten her");
define("second_ago","sekunde her");
define("seconds_ago","sekunden her");
...and so on...

 

en.php

<?php

// function
define("year_ago","year ago");
define("years_ago","years ago");
define("month_ago","month ago");
define("months_ago","months ago");
define("day_ago","day ago");
define("days_ago","days ago");
define("hour_ago","hour ago");
define("hours_ago","hours ago");
define("minute_ago","minute ago");
define("minutes_ago","minutes ago");
define("second_ago","second ago");
define("seconds_ago","seconds ago");
...and so on...

 

now the function.php, which is included in EVERY file on the page.

 

<?php
function find_language()
{
define('$lng', '');
define('$msg', '');
if(isset($_COOKIE['lng']))
{
	$lng= $_COOKIE['lng'];
	$komplett = "cp_config/$lng/$lng.php";
	require($komplett);
	switch ($lng)
	{
		case "en":
		if($_SESSION[uID] == "")
			{
				$msg = "Oops, you aren't a member. video-links are replaced with text ads.<br /> please register to see a complete adfree page";
		}
		break;

		case "de":
		if($_SESSION[uID] == "")
			{
				$msg = "Uups, du bist kein mitglied, deshalb wurden einige links mit werbung ersetzt.<br /> um eine komplett werbefreie seite zu sehen musst du dich registrieren";
	}
		break;   
	}
}
else
{
	$lng=substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
	switch ($lng)
	{
	case "en":
	if($_SESSION[uID] == "")
	{
		$msg = "Oops, you aren't a member. video-links are replaced with text ads.<br /> please register to see a complete adfree page";
	}
	$lng= "en";
	$komplett = "cp_config/$lng/$lng.php";
	require($komplett);
	$t = time()+3600*24*360;
	SetCookie("lng",$lng,$t);
	break;

	case "de":
	if($_SESSION[uID] == "")
	{ 
		$msg = "Uups, du bist kein mitglied, deshalb wurden einige links mit werbung ersetzt.<br /> um eine komplett werbefreie seite zu sehen musst du dich registrieren";
	}
	$lng= "de";
	$komplett = "cp_config/$lng/$lng.php";
	require($komplett);
	$t = time()+3600*24*360;
	SetCookie("lng",$lng,$t);
	break;
	   
	default:
	$msg = "Hi, at the moment we don't have a translation for your language. Are you interested to do this job?? Just mail to 'crownadmin@gmail.com' or 'admin@crownporn.com'! Be a part of Crownporn.com! Thanks man!";
	$lng= "en";
	$komplett = "cp_config/$lng/$lng.php";
	require($komplett);
	$t = time()+3600*24*360;
	SetCookie("lng",$lng,$t);
}
}
$lang = array();
$lang[msg] = $msg ;
$lang[lng] = $lng ;
return $lang;
}
if (isset($_COOKIE['lng'])) {
$lng= $_COOKIE['lng'];
$komplett = "cp_config/$lng/$lng.php";
	require_once($komplett);
}
else
{
$tmp=find_language();
$msg=$tmp[msg];
$lng=$tmp[lng];
}

 

and last but not least i have a lng.php where the user can set the language manually:

<?php
$lng=($_GET['lng']);
$t = time()+3600*24*360;
SetCookie("lng",$lng,$t);
$ref = $_SERVER["HTTP_REFERER"];
header("Location: $ref");
?>

 

 

can someone find the error?

i hope so.

 

it would be great, if someone could help me out!

 

Best Greatings!

Link to comment
https://forums.phpfreaks.com/topic/73073-memoryleak-in-multilingual-site/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.