Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: 1 [2]   Go Down

Author Topic: Fatal error: Out of memory  (Read 8220 times)

0 Members and 1 Guest are viewing this topic.

copperminepro

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
Re: Fatal error: Out of memory
« Reply #20 on: February 25, 2008, 12:28:27 pm »

Get a better host which will allocate more memory to you..


the 4 posts above me were classic
Logged

Sukebe

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Fatal error: Out of memory
« Reply #21 on: March 12, 2008, 08:42:52 pm »

Great! Buy more memory for shared host or switch to better host.  ;D

If you don't want to follow such a nice advice, try this hack:

1. Create file "advanced_get_lang_var.php":
Code: [Select]
<?php

/**
 * advanced_get_lang_var()
 *
 * A better way to return a variable from the language file
 *
 * @param string $file Path to lang file.
 * @param string $var_name Language variable name
 * @return
 **/
function advanced_get_lang_var($file$var_name)
{
    static 
$loaded_files// static var for loaded lang variables

    // Load lang file just once, not for every function call.
    
if (empty($loaded_files[$file])) {
        
// read file code
        
$file_contents file_get_contents($file);
        
// find names of all lang vars
        
if (preg_match_all('/\$(\w+)\s*=/is'$file_contents$matches)) {
            
// include lang file to load all the lang vars
            
include($file);
            
$loaded_files[$file] = array();

            
// and store them in static variable
            
foreach($matches[1] as $match) {
                
$loaded_files[$file][$match] = $$match;
            }
        }
    }

    return 
$loaded_files[$file][$var_name];
}


?>

2. Put this file into "include" directory.
3. Edit functions.inc.php: find cpg_get_default_lang_var() function and rewrite it a bit. Change
Code: [Select]
        include('lang/'.$language.'.php');
        return $$language_var_name;

for
Code: [Select]
        include_once('advanced_get_lang_var.php');
        return advanced_get_lang_var('lang/'.$language.'.php', $language_var_name);

That's all.

Don't forget to restore this hack next time when you upgrade you CPG.
Logged
Pages: 1 [2]   Go Up
 

Page created in 0.014 seconds with 19 queries.