Eli kyseessä deittisofta jossa kuvien kommenttien, blogien kommenttien ja viestien järjestys menee minusta hölmösti, vanhin kirjoitus jää alimmaiseksi ja uusin tulee aina ylimmäksi.
Kysyin softan myyjältä Jenkkilästä tukea mutta eivät anna sen enempää tietoa kuin PHP fiilun mistä ton voi muuttaa.
Mä en tajua mitään noista PHP jutuista niin voisko joku auttaa tän lähettämäni filen kanssa ja muuttaa tohon kommenttien järjestyksen silleen että vanhin jää ylimmäksi ja uudet putoo aina sen alle.
En saanut laitettua liitteenä, joten:
Koodi: Valitse kaikki
<?php
/*
=====================================================
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2011 VLD Interactive
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
=====================================================
*/
//------------------------------------------------
// Includes
//------------------------------------------------
if ( isset($_GET['hp']) && $_GET['hp'] ) {
if ( isset($_GET['a']) && trim($_GET['a']) == 'delete' )
{
delete_comment();
}
else
{
fetch_object_comments();
}
}
function fetch_object_comments($return = 0, $type = '', $member_id = 0, $content_id = 0, $page = 1)
{
global $DB, $LANG, $SESSION, $PREFS, $TEMPLATE;
//------------------------------------------------
// Get passed in values
//------------------------------------------------
if ( !$return ) {
$type = isset($_POST['type']) && in_array($_POST['type'], array('blog','picture','video','event','news','page')) ? trim($_POST['type']) : '';
$content_id = isset($_POST['content_id']) && is_numeric($_POST['content_id']) ? intval($_POST['content_id']) : '';
$member_id = isset($_POST['member_id']) && is_numeric($_POST['member_id']) ? intval($_POST['member_id']) : '';
$page = isset($_POST['page']) && is_numeric($_POST['page']) ? intval($_POST['page']) : 0;
if ( !$type || !$content_id || !$page ) exit;
}
else {
if ( !$type || !$content_id || !$page ) return;
}
//------------------------------------------------
// Set table name
//------------------------------------------------
if ( $type == 'news' ) {
$table = $type;
$report = $type;
}
else {
$table = $type.'s';
$report = $type;
}
//------------------------------------------------
// Set column name
//------------------------------------------------
if ( $type == 'blog' ) {
$column = 'entry_id';
}
else {
$column = $type.'_id';
}
$comments_obj = array();
//------------------------------------------------
// Get comments
//------------------------------------------------
$result = $DB->query("SELECT c.*, m.*
FROM " . DB_PREFIX . $table . "_comments as c, " . DB_PREFIX . "members as m
WHERE c.$column='$content_id' AND c.poster_id=m.member_id
ORDER BY c.postdate DESC
LIMIT " . (($page - 1) * $PREFS->conf[$table . '_comments_per_page']) . ", " . $PREFS->conf[$table . '_comments_per_page']);
//------------------------------------------------
// Check if resultset contains any rows
//------------------------------------------------
if ($DB->num_rows($result))
{
$i = 0;
$nopic = 1;
//------------------------------------------------
// Fetch resultset
//------------------------------------------------
while($obj = $DB->fetch_array($result, MYSQL_ASSOC))
{
$comments_obj[$i] = &$SESSION->parse_data($obj, array(
'member_id' => 'poster_id',
'basic_rows' => 1,
)
);
$comments_obj[$i]['comment_id'] = $obj['comment_id'];
$comments_obj[$i]['comment_poster_id'] = $obj['poster_id'];
$comments_obj[$i]['comment_body'] = nl2br(htmlentities2utf8($obj['body'], ($PREFS->conf['enable_bbcode'] && $PREFS->conf['bbcode_comments'])));
$comments_obj[$i]['comment_post_date'] = get_date($obj['postdate'], "human");
//------------------------------------------------
// Check if user can delete comment
//------------------------------------------------
if ($SESSION->auth && $type != 'news' && $type != 'page')
{
if ( ($SESSION->conf['member_id'] == $member_id ) && $SESSION->conf['can_delete_own_' . $table . '_comments'])
{
$comments_obj[$i]['comment_delete_link'] = '<a href="javascript:void(0);" onclick="javascript:delete_comment(\'' . $LANG['core']['delete_comment?'] . '\',\'owner\',\'' . $type . '\',\'' . $member_id . '\',\'' . $content_id . '\',\'' . $obj['comment_id'] . '\')" >' . $LANG['core']['delete_comment'] . '</a>';
}
elseif ($SESSION->conf['member_id'] == $obj['poster_id'] && $SESSION->conf['can_delete_own_' . $table . '_comments'])
{
$comments_obj[$i]['comment_delete_link'] = '<a href="javascript:void(0);" onclick="javascript:delete_comment(\'' . $LANG['core']['delete_comment?'] . '\',\'poster\',\'' . $type . '\',\'' . $member_id . '\',\'' . $content_id . '\',\'' . $obj['comment_id'] . '\')" >' . $LANG['core']['delete_comment'] . '</a>';
}
elseif ($SESSION->conf['can_delete_all_' . $table . '_comments'])
{
$comments_obj[$i]['comment_delete_link'] = '<a href="javascript:void(0);" onclick="javascript:delete_comment(\'' . $LANG['core']['delete_comment?'] . '\',\'admin\',\'' . $type . '\',\'' . $member_id . '\',\'' . $content_id . '\',\'' . $obj['comment_id'] . '\')" >' . $LANG['core']['delete_comment'] . '</a>';
}
}
else
{
$comments_obj[$i]['comment_delete_link'] = '';
}
$i++;
}
//------------------------------------------------
// Clean up
//------------------------------------------------
unset($obj);
}
//------------------------------------------------
// Clean up
//------------------------------------------------
unset($result);
//------------------------------------------------
// Parse variables
//------------------------------------------------
$TEMPLATE->assign("comment_type", $report . '_comments');
$comment_reports = isset($PREFS->conf['enable_' . $report . '_comments_reports']) ? $PREFS->conf['enable_' . $report . '_comments_reports'] : 0;
$TEMPLATE->assign("comment_type_reports_enabled", $comment_reports);
//------------------------------------------------
// Total comments
//------------------------------------------------
$result = $DB->query("SELECT totalcomments FROM " . DB_PREFIX . $table . " WHERE $column='$content_id' LIMIT 1");
//------------------------------------------------
// Check if resultset contains any rows
//------------------------------------------------
if ($DB->num_rows($result))
{
//------------------------------------------------
// Fetch resultset
//------------------------------------------------
$obj = $DB->fetch_object($result);
$totalcomments = $obj->totalcomments;
//------------------------------------------------
// Clean up
//------------------------------------------------
unset($obj);
}
//------------------------------------------------
// Clean up
//------------------------------------------------
unset($result);
//------------------------------------------------
// Total pages
//------------------------------------------------
$totalpages = ceil($totalcomments / $PREFS->conf[$table . '_comments_per_page']);
//------------------------------------------------
// Page links
//------------------------------------------------
$link_url = "javascript:get_comments_page('$type','$member_id','$content_id','%page%');return false;";
$page_links = create_page_links($page, $PREFS->conf[$table . '_comments_per_page'], $totalcomments, $link_url);
//------------------------------------------------
// Assign fields
//------------------------------------------------
$TEMPLATE->assign("block_comments", $comments_obj);
$TEMPLATE->assign("member_id", $member_id);
$TEMPLATE->assign("total_pages", $totalpages);
$TEMPLATE->assign("page_links", $page_links);
$output = $return ? $TEMPLATE->output('block.public_comments.tpl') : $TEMPLATE->result('block.public_comments.tpl');
if ( !$return ) {
echo ("ok|" . $output);
exit;
}
else {
return $output;
}
}
// End Function
function delete_comment()
{
global $DB, $LANG, $SESSION, $PREFS;
//------------------------------------------------
// Check if user has access to this module
//------------------------------------------------
if (!$SESSION->auth)
{
die ("error|". $LANG['core']['not_loggedin']);
}
//------------------------------------------------
// Get passed in values
//------------------------------------------------
$user_type = isset($_POST['u_type']) && in_array($_POST['u_type'],array('owner','poster','admin')) ? trim($_POST['u_type']) : '';
$content_type = isset($_POST['c_type']) && in_array($_POST['c_type'],array('event','picture','video','blog')) ? trim($_POST['c_type']) : '';
$member_id = isset($_POST['member_id']) && is_numeric($_POST['member_id']) ? intval($_POST['member_id']) : 0;
$content_id = isset($_POST['content_id']) && is_numeric($_POST['content_id']) ? intval($_POST['content_id']) : 0;
$comment_id = isset($_POST['comment_id']) && is_numeric($_POST['comment_id']) ? intval($_POST['comment_id']) : 0;
if (!$user_type || !$content_type || !$member_id || !$content_id || !$comment_id)
{
die ("error|" . $LANG['core']['invalid_action']);
}
$column = ($content_type == "blog") ? "entry" : $content_type;
if($user_type == 'owner')
{
//------------------------------------------------
// Check permissions
//------------------------------------------------
if (!$SESSION->conf['can_delete_own_' . $content_type . 's_comments'])
{
die ("error|" . $LANG['core']['no_action']);
}
//------------------------------------------------
// Delete the values
//------------------------------------------------
$DB->query("DELETE FROM " . DB_PREFIX . $content_type . "s_comments WHERE member_id='" . $SESSION->conf['member_id'] . "' AND " . $column . "_id='$content_id' AND comment_id='$comment_id' LIMIT 1");
//------------------------------------------------
// Update stats
//------------------------------------------------
if ($DB->affected_rows() == 1)
{
$DB->query("UPDATE " . DB_PREFIX . $content_type . "s SET totalcomments=totalcomments-1 WHERE member_id='" . $SESSION->conf['member_id'] . "' AND " . $column . "_id='$content_id' LIMIT 1");
}
else
{
die ("error|" . $LANG['core']['invalid_action'] . 'member_id:' . $SESSION->conf['member_id'] . ', content_id:' . $content_id);
}
}
elseif ($user_type == 'poster')
{
//------------------------------------------------
// Check permissions
//------------------------------------------------
if (!$SESSION->conf['can_delete_own_' . $content_type . 's_comments'])
{
die ("error|" . $LANG['core']['no_action']);
}
//------------------------------------------------
// Delete the values
//------------------------------------------------
$DB->query("DELETE FROM " . DB_PREFIX . $content_type . "s_comments WHERE poster_id='" . $SESSION->conf['member_id'] . "' AND " . $column . "_id='$content_id' AND comment_id='$comment_id' LIMIT 1");
//------------------------------------------------
// Update stats
//------------------------------------------------
if ($DB->affected_rows() == 1)
{
$DB->query("UPDATE " . DB_PREFIX . $content_type . "s SET totalcomments=totalcomments-1 WHERE member_id='" . $member_id . "' AND " . $column . "_id='$content_id' LIMIT 1");
}
else
{
die ("error|" . $LANG['core']['invalid_action']);
}
}
else
{
//------------------------------------------------
// Check permissions
//------------------------------------------------
if (!$SESSION->conf['can_delete_all_' . $content_type . 's_comments'])
{
die ("error|" . $LANG['core']['no_action']);
}
//------------------------------------------------
// Delete the values
//------------------------------------------------
$DB->query("DELETE FROM " . DB_PREFIX . $content_type . "s_comments WHERE member_id='" . $member_id . "' AND " . $column . "_id='$content_id' AND comment_id='$comment_id' LIMIT 1");
//------------------------------------------------
// Update stats
//------------------------------------------------
if ($DB->affected_rows() == 1)
{
$DB->query("UPDATE " . DB_PREFIX . $content_type . "s SET totalcomments=totalcomments-1 WHERE member_id='" . $member_id . "' AND " . $column . "_id='$content_id' LIMIT 1");
}
else
{
die ("error|" . $LANG['core']['invalid_action']);
}
}
//------------------------------------------------
// Set message and disappear
//------------------------------------------------
die ("ok|" . $LANG['core']['deleted_comment']);
}
// End Function
?>