Remove the PHP 5.3 deprecated split function.

This commit is contained in:
Loic d'Anterroches 2009-09-24 20:40:22 +02:00
parent 157819195b
commit 838645463d
15 changed files with 23 additions and 23 deletions

View File

@ -187,10 +187,10 @@ class IDF_Diff
*/ */
public static function getChunk($line) public static function getChunk($line)
{ {
$elts = split(' ', $line); $elts = explode(' ', $line);
$res = array(); $res = array();
for ($i=1;$i<3;$i++) { for ($i=1;$i<3;$i++) {
$res[] = split(',', trim(substr($elts[$i], 1))); $res[] = explode(',', trim(substr($elts[$i], 1)));
} }
return $res; return $res;
} }

View File

@ -95,7 +95,7 @@ class IDF_Form_PasswordInputKey extends Pluf_Form
return false; return false;
} }
$cr = new Pluf_Crypt(md5(Pluf::f('secret_key'))); $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
$f = split(':', $cr->decrypt($encrypted), 3); $f = explode(':', $cr->decrypt($encrypted), 3);
if (count($f) != 3) { if (count($f) != 3) {
return false; return false;
} }

View File

@ -91,6 +91,6 @@ class IDF_Form_RegisterInputKey extends Pluf_Form
return false; return false;
} }
$cr = new Pluf_Crypt(md5(Pluf::f('secret_key'))); $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
return split(':', $cr->decrypt($encrypted), 2); return explode(':', $cr->decrypt($encrypted), 2);
} }
} }

View File

@ -63,7 +63,7 @@ class IDF_Form_UserChangeEmail extends Pluf_Form
throw new Pluf_Form_Invalid(__('The validation key is not valid. Please copy/paste it from your confirmation email.')); throw new Pluf_Form_Invalid(__('The validation key is not valid. Please copy/paste it from your confirmation email.'));
} }
$cr = new Pluf_Crypt(md5(Pluf::f('secret_key'))); $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
return split(':', $cr->decrypt($encrypted), 3); return explode(':', $cr->decrypt($encrypted), 3);
} }

View File

@ -230,7 +230,7 @@ class IDF_Precondition
return true; // no match in the hash, anonymous return true; // no match in the hash, anonymous
} }
$cr = new Pluf_Crypt(md5(Pluf::f('secret_key'))); $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
list($userid, $projectid) = split(':', $cr->decrypt($encrypted), 2); list($userid, $projectid) = explode(':', $cr->decrypt($encrypted), 2);
if ($projectid != $request->project->id) { if ($projectid != $request->project->id) {
return true; // anonymous return true; // anonymous
} }

View File

@ -210,9 +210,9 @@ class IDF_Project extends Pluf_Model
$conf = $this->getConf(); $conf = $this->getConf();
$tags = array(); $tags = array();
foreach (preg_split("/\015\012|\015|\012/", $conf->getVal($cfg_key, $default), -1, PREG_SPLIT_NO_EMPTY) as $s) { foreach (preg_split("/\015\012|\015|\012/", $conf->getVal($cfg_key, $default), -1, PREG_SPLIT_NO_EMPTY) as $s) {
$_s = split('=', $s, 2); $_s = explode('=', $s, 2);
$v = trim($_s[0]); $v = trim($_s[0]);
$_v = split(':', $v, 2); $_v = explode(':', $v, 2);
if (count($_v) > 1) { if (count($_v) > 1) {
$class = trim($_v[0]); $class = trim($_v[0]);
$name = trim($_v[1]); $name = trim($_v[1]);

View File

@ -84,7 +84,7 @@ class IDF_Scm_Cache_Git extends Pluf_Model
$sql = new Pluf_SQL('project=%s AND githash IN ('.implode(', ', $hashes).')', $sql = new Pluf_SQL('project=%s AND githash IN ('.implode(', ', $hashes).')',
array($this->_project->id)); array($this->_project->id));
foreach (Pluf::factory(__CLASS__)->getList(array('filter' => $sql->gen())) as $blob) { foreach (Pluf::factory(__CLASS__)->getList(array('filter' => $sql->gen())) as $blob) {
$tmp = split(chr(31), $blob->content, 3); $tmp = explode(chr(31), $blob->content, 3);
$res[$blob->githash] = (object) array( $res[$blob->githash] = (object) array(
'hash' => $blob->githash, 'hash' => $blob->githash,

View File

@ -45,7 +45,7 @@ class IDF_Scm_Git extends IDF_Scm
{ {
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD ' $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD '
.escapeshellarg($this->repo); .escapeshellarg($this->repo);
$out = split(' ', shell_exec($cmd), 2); $out = explode(' ', shell_exec($cmd), 2);
return (int) $out[0]*1024; return (int) $out[0]*1024;
} }
@ -671,10 +671,10 @@ class IDF_Scm_Git extends IDF_Scm
if (false === $data) { if (false === $data) {
return $res; return $res;
} }
$data = split(chr(30), $data); $data = explode(chr(30), $data);
foreach ($data as $rec) { foreach ($data as $rec) {
if (isset($hashes[substr($rec, 0, 40)])) { if (isset($hashes[substr($rec, 0, 40)])) {
$tmp = split(chr(31), substr($rec, 40), 3); $tmp = explode(chr(31), substr($rec, 40), 3);
$res[substr($rec, 0, 40)] = $res[substr($rec, 0, 40)] =
(object) array('hash' => substr($rec, 0, 40), (object) array('hash' => substr($rec, 0, 40),
'date' => $tmp[0], 'date' => $tmp[0],

View File

@ -37,7 +37,7 @@ class IDF_Scm_Mercurial extends IDF_Scm
{ {
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD ' $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD '
.escapeshellarg($this->repo); .escapeshellarg($this->repo);
$out = split(' ', shell_exec($cmd), 2); $out = explode(' ', shell_exec($cmd), 2);
return (int) $out[0]*1024; return (int) $out[0]*1024;
} }

View File

@ -58,7 +58,7 @@ class IDF_Scm_Svn extends IDF_Scm
} }
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD ' $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD '
.escapeshellarg(substr($this->repo, 7)); .escapeshellarg(substr($this->repo, 7));
$out = split(' ', shell_exec($cmd), 2); $out = explode(' ', shell_exec($cmd), 2);
return (int) $out[0]*1024; return (int) $out[0]*1024;
} }
@ -435,7 +435,7 @@ class IDF_Scm_Svn extends IDF_Scm
$log = array(); $log = array();
$log['author'] = (string) $entry->author; $log['author'] = (string) $entry->author;
$log['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $entry->date)); $log['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $entry->date));
$split = split("[\n\r]", (string) $entry->msg, 2); $split = explode("[\n\r]", (string) $entry->msg, 2);
$log['title'] = $split[0]; $log['title'] = $split[0];
$log['commit'] = (string) $entry['revision']; $log['commit'] = (string) $entry['revision'];
$log['full_message'] = (isset($split[1])) ? trim($split[1]) : ''; $log['full_message'] = (isset($split[1])) ? trim($split[1]) : '';

View File

@ -321,11 +321,11 @@ function IDF_Views_Admin_getForgeSize()
} }
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -sk ' $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -sk '
.escapeshellarg(Pluf::f('upload_path')); .escapeshellarg(Pluf::f('upload_path'));
$out = split(' ', shell_exec($cmd), 2); $out = explode(' ', shell_exec($cmd), 2);
$res['downloads'] = $out[0]*1024; $res['downloads'] = $out[0]*1024;
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -sk ' $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -sk '
.escapeshellarg(Pluf::f('upload_issue_path')); .escapeshellarg(Pluf::f('upload_issue_path'));
$out = split(' ', shell_exec($cmd), 2); $out = explode(' ', shell_exec($cmd), 2);
$res['attachments'] = $out[0]*1024; $res['attachments'] = $out[0]*1024;
$res['database'] = IDF_Views_Admin_getForgeDbSize(); $res['database'] = IDF_Views_Admin_getForgeDbSize();
$res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments'] + $res['database']; $res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments'] + $res['database'];

View File

@ -231,7 +231,7 @@ class IDF_Views_Download
foreach ($st as $s) { foreach ($st as $s) {
$v = ''; $v = '';
$d = ''; $d = '';
$_s = split('=', $s, 2); $_s = explode('=', $s, 2);
if (count($_s) > 1) { if (count($_s) > 1) {
$v = trim($_s[0]); $v = trim($_s[0]);
$d = trim($_s[1]); $d = trim($_s[1]);

View File

@ -563,7 +563,7 @@ class IDF_Views_Issue
foreach ($st as $s) { foreach ($st as $s) {
$v = ''; $v = '';
$d = ''; $d = '';
$_s = split('=', $s, 2); $_s = explode('=', $s, 2);
if (count($_s) > 1) { if (count($_s) > 1) {
$v = trim($_s[0]); $v = trim($_s[0]);
$d = trim($_s[1]); $d = trim($_s[1]);

View File

@ -226,7 +226,7 @@ class IDF_Views_Source
$cache->set($key, $res); $cache->set($key, $res);
} }
// try to find the previous level if it exists. // try to find the previous level if it exists.
$prev = split('/', $request_file); $prev = explode('/', $request_file);
$l = array_pop($prev); $l = array_pop($prev);
$previous = substr($request_file, 0, -strlen($l.' ')); $previous = substr($request_file, 0, -strlen($l.' '));
$scmConf = $request->conf->getVal('scm', 'git'); $scmConf = $request->conf->getVal('scm', 'git');
@ -250,7 +250,7 @@ class IDF_Views_Source
public static function makeBreadCrumb($project, $commit, $file, $sep='/') public static function makeBreadCrumb($project, $commit, $file, $sep='/')
{ {
$elts = split('/', $file); $elts = explode('/', $file);
$out = array(); $out = array();
$stack = ''; $stack = '';
$i = 0; $i = 0;
@ -346,7 +346,7 @@ class IDF_Views_Source
$cobject = $scm->getCommit($commit); $cobject = $scm->getCommit($commit);
$in_branches = $scm->inBranches($commit, $request_file); $in_branches = $scm->inBranches($commit, $request_file);
// try to find the previous level if it exists. // try to find the previous level if it exists.
$prev = split('/', $request_file); $prev = explode('/', $request_file);
$l = array_pop($prev); $l = array_pop($prev);
$previous = substr($request_file, 0, -strlen($l.' ')); $previous = substr($request_file, 0, -strlen($l.' '));
$scmConf = $request->conf->getVal('scm', 'git'); $scmConf = $request->conf->getVal('scm', 'git');

View File

@ -397,7 +397,7 @@ class IDF_Views_Wiki
foreach ($st as $s) { foreach ($st as $s) {
$v = ''; $v = '';
$d = ''; $d = '';
$_s = split('=', $s, 2); $_s = explode('=', $s, 2);
if (count($_s) > 1) { if (count($_s) > 1) {
$v = trim($_s[0]); $v = trim($_s[0]);
$d = trim($_s[1]); $d = trim($_s[1]);