Current location: Hot Scripts Forums » Programming Languages » PHP » its driving me crazy

its driving me crazy

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-07-09, 11:21 AM
Wanasa Wanasa is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
its driving me crazy

hi everyone ,
this problem is driving me crazy i've spent 4 hours and still didn't know the cause, the problem is the visited counter add to although the Mysql query is +1 only i've even tried to printed to check and it do +1 bu the counter get it 2....

here is the page to see what am talking about :
Exploring File - P.V.Share Demo

do refresh and see the visited: in the file details.


here is the page code :
PHP Code:
<?php

/* HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH *\
--------------------------------------------------------------------------------
#                            #
#    P.V. SHARE v1.0                    #
#    System Copy Type : FULL COPY            #
#    P.V. SHARE COMPANY - www.pvshare.com        #
#    Last Modify : 01/04/09                #
#    -----------------------------------------------------------    #
#    FILE CONTENT :                    #
#    using this file the the visitors can play the files on the    #
#    the system.                    #
#                            #
---------------------------------------------------------------------------------
\* HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH */



# including the configuration files and all needed functions files
require_once("includes/config.php");


# SET THE GOLBALES FOR THE SYSTEM
# ------------------------------------------------------

# the defualt variables for the templates in the system
global $vars;

# the settings from the config.php file
global $setting;

# the language file array
global $lang;

# ------------------------------------------------------


# SET THE DEFAULT VARIABLES FOR THIS FILE
# ------------------------------------------------------

# page title
$vars['PAGETITLE'] = $lang['viewfile_pagetitle'];

# ------------------------------------------------------

# build the style header
echo buildPage($vars'header');


if(!
session_is_registered("loggedin") && !session_is_registered("userid") && (getSetting("allowvisitors") < 1)) {

    echo 
loginform($nickname);

} else {

    if(
$_COOKIE['pvshare_userID'])
        
$userid $_COOKIE['pvshare_userID'];

    if(
$_GET['fileid']) {
    
    
            if(!
$_POST['operation']) {
                
# update the view number
                
$updateQuery "UPDATE `files` SET `visited` = visited+1 WHERE `id` = "$_GET['fileid'];
                echo 
$updateQuery;
                
$updateResult mysql_query($updateQuery);
                    
                if(!
$updateResult)
                    
reportError("script index :: viewfile.php :: Error 106"mysql_error(), $updateQuery);
            }
            
        
# get the file details and check by type if the file should be treated as video, sound or image
        
$query "SELECT * FROM `files` WHERE `id` = '"$_GET['fileid'] ."'";
        
$result mysql_query($query);
        
        if(!
$result)
            
reportError("script index :: viewfile.php :: Error 104"mysql_error(), $query);

        if(
mysql_num_rows($result) > 0) {

            
$file mysql_fetch_object($result);

            
$filevars['ID'] = $file->id;
            
$filevars['USERID'] = $file->userid;
            
$filevars['FILENAME'] = $file->filename;
            
$filevars['FILENN'] = $file->filenn;
            
$filevars['DESCRIPTION'] = $file->description;
            
$filevars['EXTENTION'] = $file->extention;
            
$filevars['DOWNLOADED'] = $file->downloaded;
            
$filevars['VISITED'] = $file->visited;
            
$filevars['SIZE'] = $file->size;
            
$filevars['DATE'] = $file->date;

            
$filevars['FILEURL'] = getSetting('filesdirectory') ."/"getnickname($filevars['USERID']) ."___"$filevars['FILENAME'];

        
            
# build the file details template
            
$viewfiletemp['FILEDETAIL'] = buildPage($filevars'filedetail');
            
            
# choose how to treat the file. To add another file type tp treat as video, sound or image
            # just add || ($file->extention == "EXAMPLE") to the condition where to treat the file as            
            
$treatas "other";

            if(
getSetting('playVideo')) {
                if((
$file->extention == "mov") || ($file->extention == "wmv") || ($file->extention == "avi")) {
                    
$treatas "video";
                    
$filevars['WIDTH'] = getSetting('videoWidth');
                }
            }
            if(
getSetting('playSound')) {
                if((
$file->extention == "wav") || ($file->extention == "mp3")) {
                    
$treatas "sound";
                    
$filevars['WIDTH'] = getSetting('soundFormWidth');
                }
            }
            if(
getSetting('playSound')) {
                if((
$file->extention == "rm") || ($file->extention == "ram")) {
                    
$treatas "realplayersound";
                    
$filevars['WIDTH'] = getSetting('soundFormWidth');
                }
            }
            if(
getSetting('viewImages')) {
                if((
$file->extention == "jpg") || ($file->extention == "jpeg") || ($file->extention == "gif") || ($file->extention == "png") || ($file->extention == "jpeg")) {
                    
$treatas "image";
                    list(
$width,$height) = getimagesize($filevars['FILEURL']);
                    if(
$width getSetting('imagesWidth'))
                        
$filevars['WIDTH'] = $width;
                    else
                        
$filevars['WIDTH'] = getSetting('imagesWidth');
                }
            }

            
# start treating the file
            
if($treatas == "video") {

                
$viewfiletemp['VIEWFILE'] = buildPage($filevars'videomediaplayer');

            }
            elseif(
$treatas == "sound") {

                
$viewfiletemp['VIEWFILE'] = buildPage($filevars'soundmediaplayer');

            }
            elseif(
$treatas == "realplayersound") {

                
$viewfiletemp['VIEWFILE'] = buildPage($filevars'realplayercode');

            }
            elseif(
$treatas == "image") {


                
# Capture the original size of the uploaded image
                
list($width,$height) = getimagesize($filevars['FILEURL']);

                
# For our purposes, I have resized the image to be
                # 600 pixels wide, and maintain the original aspect
                # ratio. This prevents the image from being "stretched"
                # or "squashed". If you prefer some max width other than
                # 600, simply change the $newwidth variable
                
$filevars['HIEGHT'] = ($height/$width)*$filevars['WIDTH'];

                
$viewfiletemp['VIEWFILE'] = buildPage($filevars'imageviewer');

            }
            elseif(
$treatas == "other") {

                
$viewfiletemp['VIEWFILE'] = $lang['viewfile_unsupportedextinsion'];

            }


            
# build the download template
            
$downloadvars['NICKNAME'] = getnickname($filevars['USERID']);
            
$downloadvars['FILENAME'] = $filevars['FILENAME'];
            
$viewfiletemp['DOWNLOADFILE'] = buildPage($downloadvars'gotodownloadfile');


            
# check if there any comments need to be added
            
if($_POST['operation'] == "addComment" && addslashes(strip_tags($_POST['comment'])) != "") {


                
# check comments status
                
$commentstatus groupcommentmoderated(usergroupfromuserid($userid));


                
# do the add comment function
                
$query "INSERT INTO `comments` (`id` , `userid`, `fileid`, `comment`, `date`, `positivevote`, `negativevote`, `status`) VALUES
                            (NULL, '"
$userid ."', '"$filevars['ID'] ."', '"addslashes(strip_tags($_POST['comment'])) ."', '"$date ."', '0', '0', '"$commentstatus ."')";
                
$result mysql_query($query);
                
                if(!
$result)
                    
reportError("script index :: viewfile.php :: Error 108"mysql_error(), addslashes($query));

                if(
$result) {

                    
$dm['TITLE'] = $lang['usercp_passwordupdatedtitle'];
                    
$dm['MESSAGE'] = $lang['viewfile_commentadded'];

                    echo 
buildPage($dm'donemessage');

                } else {

                    
$em['TITLE'] = $lang['viewfile_commentmessagetitle'];
                    
$em['MESSAGE'] = $lang['viewfile_commenterror'];

                    echo 
buildPage($em'errormessage');

                }

            }



            
$query "SELECT * FROM `comments` WHERE `fileid` = '"$filevars['ID'] ."' AND `status` = 1";
            
$result mysql_query($query);
            
            if(!
$result)
                
reportError("script index :: viewfile.php :: Error 110"mysql_error(), addslashes($query));

            for(
$i=0$i mysql_num_rows($result); $i++) {

                
$comment mysql_fetch_object($result);

                
$commentvars['ID'] = $comment->id;
                
$commentvars['USERID'] = $comment->userid;
                
$commentvars['FILEID'] = $comment->fileid;
                
$commentvars['COMMENT'] = stripslashes(nl2br($comment->comment));
                
$commentvars['DATE'] = $comment->date;
                
$commentvars['POSITIVEVOTE'] = $comment->positivevote;
                
$commentvars['NEGATIVEVOTE'] = $comment->negativevote;
                
$commentvars['SIGNATURE'] = usersignaturefromuserid($commentvars['USERID']);


                
# SET THE USER NAME
                
$nickname getnickname($commentvars['USERID']);
                
$commentvars['NICKNAME'] = "<a href='member.php?nickname="$nickname ."' target='_self'>"$nickname ."</a>";


                
# show the file comments
                
$viewfiletemp['FILECOMMENT'] .= buildPage($commentvars,'filecomments');
            }

            if(
mysql_num_rows($result) == 0) {
                
$viewfiletemp['FILECOMMENT'] = "";
            }

            
# check if the user is allowed to add comment
            # using his / her group id to get the group details
            # if so show the post comment form
            
if(grouppostcomment(usergroupfromuserid($userid))) {

                
$viewfiletemp['FILECOMMENTFORM'] = buildPage($filevars,'filecommentform');

            } else {
            
                
$viewfiletemp['FILECOMMENTFORM'] = "";
            
            }

            echo 
buildPage($viewfiletemp'viewfilepage');
            
            

        } else {

            
# wrong file selected no such file exist
            # error message title
            # error message content
            
echo buildPage($filevars,'errormessage');

        }


    } else {

        
# NO file selected message
        # error message title
        # error message content
        
echo buildPage($filevars,'errormessage');

    }

}

# build the style footer
echo buildPage($vars'footer');


?>
PLEASE HELP am going nuts here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Going crazy over Contact form creation! Please Help! roig12 HTML/XHTML/XML 7 06-15-09 03:22 AM
simple css driving me nuts bitstomper CSS 3 05-25-07 11:28 PM
Crazy bug - going back in time kailash HotScripts Site Bug Reports 3 06-15-05 02:05 PM
FORM VALIDATION - CHECKBOXES: Driving me crazy!!! seala ASP 2 09-24-03 05:26 AM


All times are GMT -5. The time now is 06:46 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.