comparison contrib/web/php-admin/htdocs/edit.php @ 767:4be42e1ca045

Simplify file-reading code in php-admin (Franky Van Liedekerke)
author Ben Schmidt
date Thu, 21 Oct 2010 09:30:39 +1100
parents dbb144f085a5
children fc5892d87716
comparison
equal deleted inserted replaced
766:75fb7729c6e8 767:4be42e1ca045
51 global $tpl, $topdir, $list; 51 global $tpl, $topdir, $list;
52 52
53 $file = $topdir."/".$list."/control/".$name; 53 $file = $topdir."/".$list."/control/".$name;
54 $value = ""; 54 $value = "";
55 55
56 if(!is_file($file)) 56 if(is_file($file)) {
57 $lines = array("");
58 else
59 $lines = file($file); 57 $lines = file($file);
60 58 $value = $lines[0];
61 $value = $lines[0]; 59 }
62 60
63 $tpl->assign(array("NAME" => htmlentities($name), 61 $tpl->assign(array("NAME" => htmlentities($name),
64 "NICENAME" => htmlentities($nicename), 62 "NICENAME" => htmlentities($nicename),
65 "TEXT" => htmlentities($text), 63 "TEXT" => htmlentities($text),
66 "VALUE" => htmlentities($value))); 64 "VALUE" => htmlentities($value)));
73 global $tpl, $topdir, $list; 71 global $tpl, $topdir, $list;
74 72
75 $file = "$topdir/$list/control/$name"; 73 $file = "$topdir/$list/control/$name";
76 $value = ""; 74 $value = "";
77 75
78 if(!is_file($file)) 76 if(is_file($file))
79 $lines = array(); 77 $value = file_get_contents($file);
80 else
81 $lines = file($file);
82
83 foreach ($lines as $line)
84 {
85 $value .= $line;
86 }
87 78
88 $tpl->assign(array("NAME" => htmlentities($name), 79 $tpl->assign(array("NAME" => htmlentities($name),
89 "NICENAME" => htmlentities($nicename), 80 "NICENAME" => htmlentities($nicename),
90 "TEXT" => htmlentities($text), 81 "TEXT" => htmlentities($text),
91 "VALUE" => htmlentities($value))); 82 "VALUE" => htmlentities($value)));