<?php
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."pateikti_daina.php";
require_once INCLUDES."download_system/function.php";
$result = dbquery("SELECT * FROM ".$db_prefix."download_cats");
global $userdata;
$message = "";
$download_user = $userdata['user_name'];
if (dbrows($result) != 0) {
if (isset($_POST['save_download'])) {
$download_title = stripinput($_POST['download_title']);
$download_url = stripinput($_POST['download_url']);
$download_cat = $_POST['download_cat'];
$result = dbquery("INSERT INTO ".$db_prefix."downloads (download_title, download_url, download_cat, download_user, download_datestamp, download_count, download_status) VALUES ('$download_title', '$download_url', '$download_cat', '$download_user', '".time()."', '0', '3')");
redirect("pateikta");
}
$download_title = "";
$download_url = "";
$download_license = "";
$formaction = FUSION_SELF;
if(!isset($_GET['status'])) {
opentable($locale['MD001']);
$editlist = ""; $sel = "";
$result2 = dbquery("SELECT * FROM ".$db_prefix."download_cats ORDER BY download_cat_name");
if (dbrows($result2) != 0) {
while ($data2 = dbarray($result2)) {
$editlist .= "<option value='".$data2['download_cat_id']."'$sel>".$data2['download_cat_name']."</option>\n";
}
}
echo "<form name='inputform' method='post' action='$formaction'>
<table align='center' cellpadding='0' cellspacing='0' width='460'>
<tr>
<td width='80' class='tbl'>".$locale['MD002']."</td>
<td class='tbl'><input type='text' name='download_title' value='$download_title' class='textbox' style='width:380px;'></td>
</tr>
<tr>
<td class='tbl'></td>
<td class='tbl'><span class='small2'>".$locale['MD015']."</span></td>
</tr>
<tr>
<td width='80' class='tbl'>".$locale['MD003']."</td>
<td class='tbl'><input type='text' name='download_url' value='$download_url' class='textbox' style='width:380px;'></td>
</tr>
<tr>
<td class='tbl'></td>
<td class='tbl'><span class='small2'>".$locale['MD016']."</span></td>
</tr>
<tr>
<td width='80' class='tbl'>".$locale['MD004']."</td>
<td class='tbl'><select name='download_cat' class='textbox'>
$editlist</select></td>
</tr>
";
echo "<tr>
<td align='center' colspan='2' class='tbl'>";
echo "<input type='submit' name='save_download' value='".$locale['MD005']."' class='button'></td>
</tr>
</table>
</form>\n";
closetable();
} elseif(isset($_GET['status']) && $_GET['status'] = 'pateikta') {
opentable($locale['MD006']);
echo $locale['MD006'];
closetable();
}
tablebreak();
opentable($locale['MD007']);
echo "<table align='center' cellpadding='0' cellspacing='0' width='400'>\n";
$result = dbquery("SELECT * FROM ".$db_prefix."download_cats ORDER BY download_cat_name");
if (dbrows($result) != 0) {
echo "<tr>
<td class='tbl2'>".$locale['MD009']."</td>
<td align='right' class='tbl2'>".$locale['MD010']."</td>
</tr>
<tr>
<td colspan='2' height='1'></td>
</tr>\n";
while ($data = dbarray($result)) {
if (!isset($download_cat_id)) $download_cat_id = "";
if ($data['download_cat_id'] == $download_cat_id) { $p_img = "off"; $div = ""; } else { $p_img = "on"; $div = "style='display:none'"; }
echo "<tr>
<td class='tbl2'>".$data['download_cat_name']."</td>
<td class='tbl2' align='right'><img onclick=\"javascript:flipBox('".$data['download_cat_id']."')\" src='".THEME."images/panel_".$p_img.".gif' name='b_".$data['download_cat_id']."' alt=''></td>
</tr>\n";
$result2 = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_cat='".$data['download_cat_id']."' AND download_user = '".$userdata['user_id']."' ORDER BY download_title");
if (dbrows($result2) != 0) {
echo "<tr>
<td colspan='2'>
<div id='box_".$data['download_cat_id']."'".$div.">
<table cellpadding='0' cellspacing='0' width='100%'>\n";
while ($data2 = dbarray($result2)) {
if (!strstr($data2['download_url'],"http://") && !strstr($data2['download_url'],"../")) {
$download_url = seom($data2['download_id']);
} else {
$download_url = seom($data2['download_id']);
}
echo "<tr>\n<td class='tbl'><a href='$download_url' target='_blank'>".$data2['download_title']."</a></td>
<td align='right' width='100' class='tbl'>";
echo "<a href='".$settings['siteurl']."groti.php?play_id=".$data2['download_id']."' onclick=\"OpenPopup(this.href); return false\">".$locale['MD011']."</a><br /></td>
</tr>\n";
}
echo "</table>
</div>
</td>
</tr>\n";
} else {
echo "<tr>
<td colspan='2'>
<div id='box_".$data['download_cat_id']."' style='display:none'>
<table cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td class='tbl'>".$locale['MD012']."</td>
</tr>
</table>
</div>
</td>
</tr>\n";
}
}
echo "</table>\n";
} else {
echo "<tr>
<td align='center'><br>
".$locale['MD013']."<br><br></td>
</tr>
</table>\n";
}
closetable();
} else {
opentable($locale['MD007']);
echo "<center>".$locale['MD014']."<br></center>\n";
closetable();
}
if (isset($_GET['status']) && !isset($message)) {
if ($_GET['status'] == "sn") {
$message .= $locale['MD006'];
}
}
if ($message != "") { echo "<div id='close-message'><div class='admin-message'>".$message."</div></div>\n"; }
echo "</td>\n";
require_once THEMES."templates/footer.php";
?>