Viewing file: index.php (11.85 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/********************************************************************************
- MemHT Portal -
Copyright (C) 2007-2008 by Miltenovik Manojlo
http://www.memht.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your opinion) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/> (GPLv2)
or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA02110-1301, USA.
********************************************************************************/
if (!defined("_LOAD_PAGE_")) {
die("<table style='padding: 2px; border: 1px solid #999; background-color: #EEE; font-family: Verdana; font-size: 10px;' align='center'><tr><td><b>Error:</b> This file cannot be opened directly!</td></tr></table>");
}
if (isset($_GET['op'])) { $op = inCode($_GET['op']); } else { $op = ""; }
if (isset($_GET['id'])) { $id = intval($_GET['id']); } else { $id = 0; }
if (isset($_GET['ok'])) { $ok = inCode($_GET['ok']); } else { $ok = false; }
if (isset($_POST['title'])) { $title = inCode($_POST['title']); } else { $title = ""; }
if (isset($_POST['description'])) { $description = inCode($_POST['description']); } else { $description = ""; }
if (isset($_POST['videoid'])) { $videoid = inCode($_POST['videoid']); } else { $videoid = ""; }
if (isset($_POST['width'])) { $width = intval($_POST['width']); } else { $width = 0; }
if (isset($_POST['height'])) { $height = intval($_POST['height']); } else { $height = 0; }
if (isset($_POST['tags'])) { $tags = inCode($_POST['tags']); } else { $tags = ""; }
if (isset($_POST['enabled'])) { $enabled = intval($_POST['enabled']); } else { $enabled = 0; }
if (isset($_GET['pg'])) { $pg = inCode($_GET['pg']); } else { $pg = 1; }
$ofsppg = 30; //Items per page
$ofsbgn = ($pg*$ofsppg)-$ofsppg;
function main($ofsbgn,$ofsppg,$pg) {
global $dblink,$siteConfig;
$n = 0;
echo "<table width='100%' align='center' cellspacing='1' cellpadding='0' class='std_nicetable'>";
echo "<thead>\n";
echo "<tr><td width='35%'>"._TITLE_."<td width='40%'>"._TAGS_."</td></td><td width='15%'>"._AUTHOR_."</td><td width='10%' align='center'>"._DATE_."</td><td width='1%'> </td></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
if ($result = $dblink->get_list("SELECT id,title,author,enabled,DATE_FORMAT(date, '".$siteConfig['timestamp']."') as date FROM memht_youtube_videos ORDER BY id DESC LIMIT $ofsbgn,$ofsppg")) {
foreach ($result as $row) {
$id = intval($row['id']);
$title = outCode($row['title']);
$author = outCode($row['author']);
$date = $row['date'];
$enabled = intval($row['enabled']);
$off = ($enabled!="1") ? "<img src='images/off.gif' title='"._OFF_."'>" : "" ;
$class = (($n++%2)!=0) ? "hlight" : "clean" ;
echo "<tr><td class='$class'><a href='index.php?page=youtube&op=show&id=$id' title='$title'><b>$title</b></a><td class='$class' id='info'>";
if ($result = $dblink->get_list("SELECT tag FROM memht_youtube_tags WHERE cid=$id ORDER BY tag")) {
foreach ($result as $row) {
echo "<span style='padding: 0 4px;'><a href=\"index.php?page=youtube&op=related&tag=".$row['tag']."\" title=\"".$row['tag']."\" target='_blank'>".$row['tag']."</a></span>";
}
}
echo "</td><td class='$class' nowrap>$author</td><td class='$class' align='center' nowrap>$date</td><td class='$class' nowrap><a href='admin.php?page=youtube&op=edit&id=$id' title='"._MODIFY_."'><img src='images/edit.gif' border='0'></a> <a href='admin.php?page=youtube&op=delete&id=$id' title='"._DELETE_."'><img src='images/delete.gif' border='0'></a> $off</td></tr>\n";
}
} else {
echo "<tr><td align='center' id='errorText' colspan='4' class='clean'><b>"._EMPTY_."</b></td></tr>";
}
echo "</tbody>\n";
echo "</table>";
//Pages
include_once("inc/class/paginationSystem.class.php");
$ps = new paginationSystem();
$ps->items = $ofsppg;
$ps->actpg = $pg;
$ps->query = "SELECT id FROM memht_youtube_videos";
$ps->url = "admin.php?page=youtube&pg={{N}}";
$ps->show();
}
function add($title,$description,$videoid,$width,$height,$tags,$enabled,$ok=false) {
global $dblink,$admin,$tzNOW;
if (!$ok) {
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=youtube&op=add&ok=true'>";
echo "<tr><td width='25%'><b>"._TITLE_."</b></td><td><input type='text' name='title' size='40' maxlength='255'></td></tr>\n";
echo "<tr><td valign='top'><b>"._DESCRIPTION_."</b></td><td>";
textarea("description","100%","200px",1,"fulladmin");
echo "</td></tr>\n";
echo "<tr><td><b>Video ID</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=[http://www.youtube.com/watch?v=<b style='color:#F00;'>8ctKH9GCbRg</b>]\"></td><td><input type='text' name='videoid' size='20' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._DIMX_."</b></td><td><input type='text' name='width' size='10' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._DIMY_."</b></td><td><input type='text' name='height' size='10' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._TAGS_."</b></td><td><input type='text' name='tags' size='40' maxlength='255'> <span id='info'>("._SEPARATEDBYCOMMAS_.")</span></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._ADD_."'></td></tr>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($title=="") { $save = false; $msg = _TITLE_." "._FIELD_." "._REQUIRED_; }
if ($videoid=="") { $save = false; $msg = "Video ID "._FIELD_." "._REQUIRED_; }
if ($save) {
$dblink->query("INSERT INTO memht_youtube_videos (id,title,description,date,videoid,width,height,author,enabled)
VALUES (null,'$title','$description',$tzNOW,'$videoid','$width','$height','$admin','$enabled')");
if ($tags!="") {
$row = $dblink->get_row("SELECT id FROM memht_youtube_videos ORDER BY id DESC LIMIT 1");
$lastid = intval($row['id']);
$tags = explode(",",$tags);
foreach ($tags as $tag) {
$dblink->query("INSERT INTO memht_youtube_tags (tag,cid) VALUES ('".inCode(trim($tag))."','$lastid')");
}
}
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=youtube'>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";
}
}
}
function edit($id,$title,$description,$videoid,$width,$height,$tags,$enabled,$ok=false) {
global $dblink;
if (!$ok) {
$row = $dblink->get_row("SELECT * FROM memht_youtube_videos WHERE id=$id");
$title = outCode($row['title']);
$description = outCode($row['description']);
$videoid = outCode($row['videoid']);
$width = intval($row['width']);
$height = intval($row['height']);
$author = outCode($row['author']);
$enabled = intval($row['enabled']);
if ($result = $dblink->get_list("SELECT tag FROM memht_youtube_tags WHERE cid=$id")) {
$tags = array();
foreach ($result as $row) {
$tags[] = outCode($row['tag']);
}
$tags = implode(",",$tags);
} else {
$tags = "";
}
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=youtube&op=edit&id=$id&ok=true'>";
echo "<tr><td width='25%'><b>"._TITLE_."</b></td><td><input type='text' name='title' value=\"$title\" size='40' maxlength='255'></td></tr>\n";
echo "<tr><td valign='top'><b>"._DESCRIPTION_."</b></td><td>";
textarea("description","100%","200px",1,"fulladmin",$description);
echo "</td></tr>\n";
echo "<tr><td><b>Video ID</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=[http://www.youtube.com/watch?v=<b style='color:#F00;'>8ctKH9GCbRg</b>]\"></td><td><input type='text' name='videoid' value=\"$videoid\" size='20' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._DIMX_."</b></td><td><input type='text' name='width' value=\"$width\" size='10' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._DIMY_."</b></td><td><input type='text' name='height' value=\"$height\" size='10' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._TAGS_."</b></td><td><input type='text' name='tags' value=\"$tags\" size='40' maxlength='255'> <span id='info'>("._SEPARATEDBYCOMMAS_.")</span></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
if ($enabled==1) {
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
} else {
echo "<option value='1'>"._YES_."</option>\n";
echo "<option value='0' selected>"._NO_."</option>\n";
}
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._MODIFY_."'></td></tr>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($title=="") { $save = false; $msg = _TITLE_." "._FIELD_." "._REQUIRED_; }
if ($videoid=="") { $save = false; $msg = "Video ID "._FIELD_." "._REQUIRED_; }
if ($save) {
$dblink->query("UPDATE memht_youtube_videos SET title='$title',description='$description',videoid='$videoid',width='$width',height='$height',enabled='$enabled' WHERE id=$id");
if ($tags!="") {
$dblink->query("DELETE FROM memht_youtube_tags WHERE cid=$id");
$tags = explode(",",$tags);
foreach ($tags as $tag) {
$dblink->query("INSERT INTO memht_youtube_tags (tag,cid) VALUES ('".inCode(trim($tag))."','$id')");
}
}
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=youtube'>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";
}
}
}
function delete($id,$ok=false) {
global $dblink;
$id = intval($id);
if ($ok) {
$dblink->query("DELETE FROM memht_youtube_videos WHERE id=$id");
$dblink->query("DELETE FROM memht_comments WHERE whr=20 AND wid=$id");
$dblink->query("DELETE FROM memht_ratings WHERE whr=20 AND wid=$id");
$dblink->query("DELETE FROM memht_youtube_tags WHERE cid=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=youtube'>";
} else {
echo "<div align='center'><b>"._SUREDELETE_."</b><br><a href='admin.php?page=youtube&op=delete&id=$id&ok=true' title='"._YES_."'>"._YES_."</a> - <a href='admin.php?page=youtube' title='"._NO_."'>"._NO_."</a></div>";
}
}
require_once("admin/inc/inc_header.php");
admin_page_title($page);
openTable();
echo "<div align='center' class='box'>";
echo "<a href='admin.php?page=youtube' title='"._LIST_."'><img src='admin/icons/messages.png' border='0' title='"._LIST_."' align='top'> "._LIST_."</a>";
echo " - <a href='admin.php?page=youtube&op=add' title='"._ADD_."'><img src='admin/icons/add.png' border='0' title='"._ADD_."' align='top'> "._ADD_."</a>";
echo "</div>";
closeTable();
openTable();
switch($op) {
case "add":
add($title,$description,$videoid,$width,$height,$tags,$enabled,$ok);
break;
case "edit":
edit($id,$title,$description,$videoid,$width,$height,$tags,$enabled,$ok);
break;
case "delete":
delete($id,$ok);
break;
default:
main($ofsbgn,$ofsppg,$pg);
break;
}
closeTable();
require_once("admin/inc/inc_footer.php");
?>
|