Hi Matt,
you are right. I just only pointed out no-good statements.
I had prepared my moodle/lib/componentlib.class.php, then my system got possible to download selected language pack. But, It's not perfect;
Download selected language pack: OK
Delete selected language pack : OK
Update all language pack : NG
Maybe, there are some bugs yet.
----- if you want, let's try to apply following modification for your system.
Blue : originalRed : Modification (adding)(1) Line 273
$zipfile= $CFG->dataroot.'/temp/'.$this->zipfilename;// if ($contents = file_get_contents($source)) {if ($contents = $this->proxy_file_get_contents($source)) { (2) Line 460
$availablecomponents = array();
if ($availablecomponents = $this->proxy_url($source)) {
/* if ($fp = fopen($source, 'r')) {/// Read from URL, each line will be one component
while(!feof ($fp)) {
$availablecomponents[] = split(',', fgets($fp,1024));
}
fclose($fp);
*/(3) Line 516
function get_extra_md5_field() {return $this->extramd5info;
} //returns an array of languages, or false if can not read from source
//uses a socket if proxy is set as a config variable
function proxy_url($url) {
global $CFG;
if ($CFG->proxyhost && $CFG->proxyport) {
$proxy_fp = fsockopen($CFG->proxyhost, $CFG->proxyport);if (!$proxy_fp) {return false; //failed
}
fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
$i = 0;
while(!feof($proxy_fp)) {
$string = fgets($proxy_fp, 1024);
if ($i > 11) { //12 lines of info skipped
$availablelangs[] = split(',', $string);
}
$i++;
}
fclose($proxy_fp);
} else { //proxy not in use
if ($fp = fopen($url, 'r')){ /// attempt to get the list from Moodle.org.
while(!feof ($fp)) {
$availablelangs[] = split(',', fgets($fp,1024));
}
} else { /// fopen failed, return false.
return false;
}
}
return $availablelangs;
}
// based on proxy_url() modified by T.Shiraifunction proxy_file_get_contents($url) {
global $CFG;
if ($CFG->proxyhost && $CFG->proxyport) {
$proxy_fp = fsockopen($CFG->proxyhost, $CFG->proxyport);
if (!$proxy_fp) {
return false; //failed
}
fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
$i = 0;
$contents = "";
while(!feof($proxy_fp)) {
if ($i <= 11) fgets($proxy_fp, 1024); else {
$contents .= fread($proxy_fp, 8192);
}
$i++;
}
fclose($proxy_fp);
} else { //proxy not in use
if (!$contents = file_get_contents($url)) return false;
}
return $contents;
}
} /// End of component_installer class-----------------
Following statement does not need to modiy in Line 393
if ($temp = file_get_contents($source)) {
Now, I retry to update language pack automatically, it's finished successfully. Oh!