Dodaję moduł do witryny przez PA i mi takie coś wyświetla się:
A to zawartość strony modules.php
Plik klimas_function.php
Proszę o pomoc co to może być za błąd i jak go rozwiązać ?
Warning: Invalid argument supplied for foreach() in C:\WebServ\httpd\system\admin\modules.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at C:\WebServ\httpd\system\admin\modules.php:21) in C:\WebServ\httpd\system\klimas_functions.php on line 50[/b]
A to zawartość strony modules.php
Kod:
<?php
include('../../config.php');
include(KLIMAS_ROOT . '/system/admin/klimas_header.php');
$adminmenu = array(
LANG_011 => 'modules.php'
);
/*
* Installing a module
*/
if(isset($_GET['install']))
{
$include = $_GET['install'];
include(KLIMAS_ROOT . '/modul/' . $include . '/info.php');
if(!empty($install))
{
foreach($install as $query)
{
$db -> db_query($query);
}
}
if(!empty($blocks))
{
foreach($blocks as $block)
{
$blockcontent = addslashes(get_contents(KLIMAS_ROOT . '/modul/' . $include . '/blocks/' . $block['content']));
$db -> db_query("INSERT INTO " . DB_PREFIX . "blocks (title, content, type, system, position, visible, owner) VALUES (
'" . $block['title'] . "',
'" . $blockcontent . "',
'" . $block['type'] . "',
'" . $block['system'] . "',
'" . $block['position'] . "',
'" . $block['visible'] . "',
'" . $include . "'
)");
}
}
$db -> db_query("INSERT INTO " . DB_PREFIX . "modules (date, folder, name, hasadmin, hasfront) VALUES (
'" . date('Y-m-d') . "',
'" . $module['folder'] . "',
'" . $module['name'] . "',
'" . $module['hasadmin'] . "',
'" . $module['hasfront'] . "'
)");
redirect_with_message('msg', 'LANG_076');
}
/*
* Uninstalling a module
*/
if(isset($_GET['uninstall']))
{
$include = $_GET['uninstall'];
include(KLIMAS_ROOT . '/modul/' . $include . '/info.php');
if(!empty($uninstall))
{
foreach($uninstall as $query)
{
$db -> db_query($query);
}
}
if(!empty($blocks))
{
foreach($blocks as $block)
{
$db -> db_query("DELETE FROM " . DB_PREFIX . "blocks WHERE owner = '" . $include . "'");
}
}
$db -> db_query("DELETE FROM " . DB_PREFIX . "modules WHERE folder = '" . $module['folder'] . "' LIMIT 1");
redirect_with_message('msg', 'LANG_077');
}
$installed = $db -> db_query("SELECT * FROM " . DB_PREFIX . "modules ORDER BY date ASC");
$installed = $db -> db_result();
foreach($installed as $key)
{
$array[] = $key['folder'];
}
$allmodules = scan_modules();
include(KLIMAS_ROOT . '/system/admin/klimas_head.php');
?>
<h3><?php print LANG_021; ?></h3>
<table width="100%">
<tr>
<th><?php print LANG_022; ?></th>
<th width="80"><?php print LANG_025; ?></th>
<th width="80"><?php print LANG_023; ?></th>
<th width="80"><?php print LANG_024; ?></th>
<th width="80"></th>
</tr>
<?php
if(!empty($array))
{
foreach($allmodules as $single)
{
if(in_array($single, $array))
{
include(KLIMAS_ROOT . '/modul/' . $single . '/info.php');
?>
<tr>
<td><?php print $module['name']; ?></td>
<td><?php print $module['license']; ?></td>
<td><?php print $module['version']; ?></td>
<td><?php print $module['author']; ?></td>
<td align="center">[url="#" onclick="confirm_box('<?php print LANG_124; ?>', '?uninstall=<?php print $module['folder']; ?>');"]">[img]../img/uninstall.png[/img]" />[/url]</td>
</tr>
<?php
}
}
}
?>
</table>
<h3><?php print LANG_026; ?></h3>
<table width="100%">
<tr>
<th><?php print LANG_022; ?></th>
<th width="80"><?php print LANG_025; ?></th>
<th width="80"><?php print LANG_023; ?></th>
<th width="80"><?php print LANG_024; ?></th>
<th width="80"></th>
</tr>
<?php
if(!empty($allmodules))
{
foreach($allmodules as $single)
{
if(!@in_array($single, $array))
{
include(KLIMAS_ROOT . '/modul/' . $single . '/info.php');
?>
<tr>
<td><?php print $module['name']; ?></td>
<td><?php print $module['license']; ?></td>
<td><?php print $module['version']; ?></td>
<td><?php print $module['author']; ?></td>
<td align="center">[url="#" onclick="confirm_box('<?php print LANG_125; ?>', '?install=<?php print $single; ?>');"]">[img]../img/install.png[/img]" />[/url]</td>
</tr>
<?php
}
}
}
?>
</table>
<?php
include(KLIMAS_ROOT . '/system/admin/klimas_foot.php');
?>
Plik klimas_function.php
Kod:
<?php
function scan_modules()
{
$dir = KLIMAS_ROOT . '/modul/';
$dh = opendir($dir);
$files = array();
while(false !== ($filename = readdir($dh)))
{
if($filename != "." && $filename != "..") {
$files[] = $filename;
}
}
sort($files);
return $files;
}
function convert_bytes($number)
{
$len = strlen($number);
if($len < 4)
{
return sprintf("%d b", $number);
}
if($len >= 4 && $len <=6)
{
return sprintf("%0.2f KB", $number/1024);
}
if($len >= 7 && $len <=9)
{
return sprintf("%0.2f MB", $number/1024/1024);
}
return sprintf("%0.2f GB", $number/1024/1024/1024);
}
function redirect_with_message($type, $message, $place = '0')
{
if($place == '0')
{
$file = basename($_SERVER['SCRIPT_FILENAME']);
}
else
{
$file = $place;
}
header('Location: ' . $file . '?' . $type . '=' . $message);
die();
}
function get_contents($file)
{
$str = fopen($file, 'rb');
$contents = fread($str, filesize($file));
fclose($str);
return $contents;
}
function filenameCleanup($str)
{
$str = preg_replace('/\ /', '_', $str);
$str = preg_replace('/[^a-zA-Z_\.]/', '', $str);
$str = strtolower($str);
return $str;
}
function debug($str)
{
print '<pre style="background-color: grey">';
print_r($str);
print '</pre>';
}
function mysql_is_table($tbl)
{
$tables = array();
$q = @mysql_query("SHOW TABLES");
while ($r = @mysql_fetch_array($q)) { $tables[] = $r[0]; }
@mysql_free_result($q);
if (in_array($tbl, $tables)) { return TRUE; }
else { return FALSE; }
}
function file_extension($strFileName)
{
return strtolower(substr(strrchr($strFileName, '.'), 1));
}
function table_name($str)
{
$str = DB_PREFIX . $str;
return $str;
}
?>