Jump to content

Parsing error in PHP


Guest anon
 Share

Recommended Posts

I am trying to add our own version of easy urpmi for this board. It works fine on my PC but fails on the server. Blank page and error in logs reads "error unexpected $ on line 240" which is the end of the file. Tried several edits but it still fails :wall:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Easy Urpmi</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="urpmiweb.css" type="text/css">
</head>
<body>
<center><h1>MandrakeUsers Easy urpmi config for Mandrake-Linux</h1></center>
<p>This tool will give you the right command to type in order to setup urpmi.</p>
<?php
$list_mdkver='';
$list_location='';
if (!$user['mdkver']) $user['mdkver']=$default_version;
if (!$user['arch']) $user['arch']=$default_arch;
parse_line(readfiles());

if ($motdf=@fopen('mirror.list/motd.txt','r')) {
 ?><p class="motd"><?
 while ($line=fgets($motdf,1024)) {
       echo $line."<br>";
       }
 ?></p><?
       fclose($motdf);
}
if ($globinfo[':lastchange']['date']) { ?><p><b>Last update of mirror list:</b> <?=htmlentities($globinfo[':lastchange']['date'])?></p><? }
?>
<p>Please follow steps 1 to 3 :</p>
<?php

?>
<h2>1) Select your system and architecture:</h2>
<form action="<?=$PHP_SELF?>#second" method="POST">
<p>Mandrake <b>version</b>:
<select name="user[mdkver]" onChange="this.form.action='<?=$PHP_SELF?>';this.form.submit()">
<?php
krsort($list_mdkver);
reset($list_mdkver);
foreach (array_keys($list_mdkver) as $key)
{
?>
<option name="<?=$key?>"<?=($user['mdkver']==$key)?' selected':''?>><?=$key?></option>
<?php
}
?>
</select>
and <b>architecture</b>:
<select name="user[arch]" onChange="this.form.action='<?=$PHP_SELF?>';this.form.submit()">
<?php
ksort($list_arch);
reset($list_arch);
foreach (array_keys($list_arch) as $key)
{
?>
<option name="<?=$key?>"<?=($user['arch']==$key)?' selected':''?>><?=$key?></option>
<?php
}
?>
</select>
<input type="submit" value="send">
</p>
<p>
<!--<input type="checkbox" name="is_sure" value=1<?=isset($is_sure)?' checked':''?> onClick="this.form.action='<?=$PHP_SELF?>';this.form.submit()"> Show non base distro sources-->
<? if (isset($globinfo[':is_sure'])) {?><input type="checkbox" name="minor" value=1<?=isset($minor)?' checked':''?> onClick="this.form.action='<?=$PHP_SELF?>';this.form.submit()"> Show specific sources too<?}?>
</p>
</form>
<p>A '*' will restrict the selection to sources that can be applied to all.<br />
<b>Cooker</b> is a devel (cutting-edge, unstable), don't use it unless you're sure of what you are doing.</p>
<a name="second"><h2>2) Select a mirror for each source you want</h2></a>
<!--<p>Package source <b>main</b> provides the core of Mandrake Linux (official CDROM contents), and source <b>updates</b> provides the official security and bug fix updates
- only these two have Mandrake's offical support !</p>-->
<!--<p><b>plf</b> provides packages for the Mandrake distribution which do not come from MandrakeSoft, see <a href="http://plf.zarb.org">the PLF page</a>.</p>-->
A few <b>plf</b> packages need <b>contrib</b>, therefore you should add <b>contrib</b> if you add <b>plf</b>.</p>
<p>Restrict your selection to sources you really need, since sources may cause conflicts.</p>
<?php
if (is_array($list)) {
?>
<form action="<?=$PHP_SELF?>#third" name="f2" method="POST">
<input type="hidden" name="user[mdkver]" value="<?=$user['mdkver']?>">
<input type="hidden" name="user[arch]" value="<?=$user['arch']?>">

<?php
if (isset($is_sure)) { ?><input type="hidden" name="is_sure" value="1"><? }
if (isset($minor)) { ?><input type="hidden" name="minor" value="1"><? }

reset($list);
while (list($key,$val)=each($list))
 {
 if (isset($globinfo[':minor'][$key]) && (!isset($minor))) continue;
 (isset($globinfo[':group'][$key])) ? $group[$globinfo[':group'][$key]][$key]=$val : $group_noname[$key]=$val;
 }

if (is_array($group))
{
 ksort($group);
 reset($group);
 while (list($group_name,$l)=each($group))
 {
 ?><h3><?=$group_name?>:</h3><?
 while (list($key,$val)=each($l))
	 {
	 show_media_source($key,$val);
	 }
 }
}
if (is_array($group_noname))
 {
 ksort($group_noname);
 reset($group_noname);
 ?><h3>Other sources:</h3><?
 while (list($key,$val)=each($group_noname))
	 {
	 show_media_source($key,$val);
	 }
 }

?>
Prefix to be added to each media name (optional): <input name="prefix" value="<?=$prefix?>"> <input type="submit" value="send">
</form>
<a name="third"><h2>3) Type this in a console as root</h2></a>
<p class="console">
<?php
reset($list);
while (list($key,$val)=each($list))
 {
 if ($val[$mirror[$key]] && $selection[$key])
	 {
	 echo htmlentities("urpmi.addmedia ".$globinfo[':urpmiopt'][$key]." $prefix$key ".$val[$mirror[$key]]['url'])."<br>\n";
	 }
 }
?>
 </p>
<p>If you get an error, please check this mirror is accessible, and not over connection limit.</p>
<?php
}
else
{
?>
<p><b>Please select your type of architecture first, example i586</b></p>
<?php
}
?>
<hr align="left" width="25%">
<font size="-1">
If you know a mirror that is not on this list, contact Anon at MUB and I will add it.<br>
<br>
Thanks to Sebastien Ducoulombier (sebd), Pascal Terjan (pterjan) and Yves Mettier for their help.<br>
This software is under GPL<br>
<a href="http://nanardon.homelinux.org/urpmi.setup/">Original site</a><br>
<pre>Id: urpmiweb.php,v 1.14 2003/03/07 20:25:21 nanardon Exp</pre>
</font>
<center><a href="http://www.mandrakeusers.org/index.php?act=idx">
<img src= "http://www.mandrakeusers.org/Skin/logo.png" alt="logo" border="0" /></a></center>
</body>
</html>

Link to comment
Share on other sites

whats this function on line 16?

parse_line(readfiles());

 

parse_line is that one of your own functions if so wheres the definition and or the include file statement also readfile is a php function but not readfiles.

 

looks like you have custom php functions with no includes to the functions definition file.

Link to comment
Share on other sites

I only posted the lower have of the file, as thats the bit that causing the errors.

The first section loks like this

<?php
include('urpmiweb.inc');
if (file_exists("mirror.list/urpmiweb.conf")) include("mirror.list/urpmiweb.conf");
function parse_line($liste_line)
{
global $list_arch, $list_mdkver, $list_location, $user, $list, $mach;
if (!is_array($liste_line)) return;
foreach($liste_line as $val)
 {
 $list_arch[$val['arch']]=1;
 $list_mdkver[$val['mdkver']]=1;
 switch ($val['arch'])
	 {
	 case '*':
	 case 'noarch':
	 case $user['arch']:
	 break;
	 default:
	 $val['url']='';
	 }
 switch ($val['mdkver'])
	 {
	 case '*':
	 case $user['mdkver']:
	 break;
	 default:
	 $val['url']='';
	 }

	 if ($val['url']) $list[$val['name']][$val['mach']]=$val;
 }
}

function show_media_source($key,$val)
{
global $globinfo;
global $selection;
global $mirror;
//global $minor;
//if (!isset($globinfo[':is_sure'][$key]) && !isset($is_sure)) continue;
//if (isset($globinfo[':minor'][$key]) && (!isset($minor))) return;
?>
<p>Source <b><?=$key?></b>:
<?php
if ($globinfo[':source'][$key])
 {
 echo $globinfo[':source'][$key];
 }
if ($globinfo[':s_url'][$key])
 {
 ?><br>Take a look to <a href="<?=$globinfo[':s_url'][$key]?>"><?=htmlentities($globinfo[':s_url'][$key])?></a><?
 }
if (!$globinfo[':is_sure'][$key]) {
 ?><!--<br><font color="red">This source is not part of the Mandrake base distribution</font>--><?
 }
?>
<br>
<input type="checkbox" name="selection[<?=$key?>]"<?=isset($selection[$key])?' checked':''?>>
<select name="mirror[<?=$key?>]" onchange="document.f2.elements['selection[<?=$key?>]'].checked=true;">
<?php
$optionl=array();
reset($val);
while (list($key2,$val2)=each($val))
 {
 $optionl[$val2['location'].' ('.$key2.')']=$key2;
 }
ksort($optionl);
reset($optionl);
while (list($key2,$val2)=each($optionl))
 {
 ?>
 <option value="<?=$val2?>"<?=($mirror[$key]==$val2)?' selected':''?>><?=$key2?></option>
 <?php
 }
?>
</select>
</p>
<?php
}
?>

Link to comment
Share on other sites

Do you just want to rewrite easy urpmi from scratch? I could probably code a DB-backed version in an hour or so (with an admin section for editing). It would certainly be nicer than reading from a flatfile if you want to change things.

 

I am a web developer professionally, so I would love to write this as a contribution back to the community, if you would use it.

Link to comment
Share on other sites

Do you just want to rewrite easy urpmi from scratch? I could probably code a DB-backed version in an hour or so (with an admin section for editing). It would certainly be nicer than reading from a flatfile if you want to change things.

 

I am a web developer professionally, so I would love to write this as a contribution back to the community, if you would use it.

Sounds a great idea ! The main easy urpmi site is often over loaded or down, which is why i thought putting a version up on this boads server would not only help them, but its good for this board also.

Thanks very much, look forward to seeing it. B) :thumbs:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...