Jump to content

Chrisj

Members
  • Posts

    551
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Chrisj

  1. Thanks for your replies.

    When I add your "standard HTML img element" 

    <?php
    $file = '/home/me/www/images/' . $row['filename'];
    if(file_exists($file)) {
     $file = $row['filename'];
    } else {
     $file = 'default.jpg';
    }
     echo '<img src="http://mysite.com/images/' . $file . '" alt="No image" />';
     ?>
    

    I see this part of that code on the page   '; ?>

    Help please.

  2. I'm using a templated PHP script where the (video) Upload Form info (title, description, etc.) is displayed (after the upload) on a page below the video.
     
    I added a basic image-uploader to the Form, and some code that, via the Form, adds the 'user_id' to the beginning of the file name, for example, people.png uploaded (by user 9) becomes the new file name: 9people.png, which gets uploaded into the /upload/ folder, and stores that new file name into a db table called 'videos', into a column named 'thumbnail'. 
     
    I'm looking for guidance with making a successful hyperlink(to the image) appear where the Upload Form info is displayed.
     

    This is the results.php page code that corresponds with the html page (inner_results.htm):

    <?php
    include_once ('classes/config.php');
    include_once ('classes/sessions.php');
    include_once ('classes/functions.inc.php');
     $page_title        = $site_name;
     $submitted         = $_POST['submitted'];
    $which_one         = mysql_real_escape_string($_GET['load']);
    $limit         = 20;
     $keyword = $_SESSION['searched'];
     // this is per each template from config.inc.php advanced config settings
    $page_display_small_width    = $config['general_medium_thumb_width']; // 80
     $member_credits = get_member_credits($user_id);
     if ($user_id != "") {
     $inner_template1     = "themes/$user_theme/templates/inner_results.htm";
     }else{
     $show_login        = 1;
    $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm";
    }
     // FUNCTIONS
     function getUsername($id) {
     $sql1 = "SELECT * FROM member_profile WHERE $query1 = mysql_query($sql1) or DIE(mysql_error());
    $result = mysql_fetch_array($query1);
     return $result['user_name'];
    }
    function getVidTitle($id) {
    $sql1 = "SELECT * FROM videos WHERE indexer = $id";
    $query1 = mysql_query($sql1) or DIE(mysql_error());
    $result = mysql_fetch_array($query1);
     return $result['title'];
    }
    ?>
    Can you make a suggestion, or give me an idea, as to what I might add to results.php (and inner_results.php) in order to display a successful hyperlink to the image that was uploaded with the video? 
    Any help will be appreciated.
     
  3. I'm using a templated PHP script and have successfully added a link (to an image) 
    to an html page there  (inner_play.htm) 
    <a href="http://www.--.com/upload/[var.thumbnail]"><?php echo $newfilename?>Click Link</a>
    

    and this (into the play.php file):

    $thumbnail = $result['thumbnail'];
    

    and this

    $thumbnail = $_SESSION['$newfilename'];
    
    So, I added it to another page (search_results.htm) without success.
     
    I've tried a few different places, (in search.php file), to add:
    $thumbnail = $result['thumbnail'];
    $thumbnail = $_SESSION['$newfilename'];
    but the link doesn't work from search_results.htm page
    Maybe you can simply tell me where those lines should work best in search.php, or any other insight.
    Any help will be appreciated. - see Search.php file attached

    search.php

  4. Trying again:

    <?php
    
    
    include_once ('classes/config.php');
    include_once ('classes/sessions.php');
    include 'uploader_conlib.php';
    
    $config['notification_error'] = $lang_error;
    
    $page_title = $lang_upload_video;
    
    
    if ($_SESSION['user_id'] == "") {
    	header("Location: " . "$base_url/login.php");
    	die();
    }
    
    $load_javascript	= 1;
    $ahah			= 1;
    $thickbox = 1;
    
    ///////////////////////////////////////////////////////////////////////////////////////
    // ADDED SPAMMER UPLOAD TRACKING LOGING
    //
    
    $member_uploading		= $_SESSION['user_name'];
    $tracking_log_file	= 'logs/uploader_log.txt';
    $admin_email		= $config['admin_notify_email'];
    $user_ip			= mysql_escape_string($_SERVER['REMOTE_ADDR']);
    $referer			= mysql_real_escape_string($_SERVER['HTTP_REFERER']);
    
    if ( $referer == '' ) die_spammer_alerts();
    if ( !ereg ($_SERVER['SERVER_NAME'], $referer) ) die_spammer_alerts();
    
    ///////////////////////////////////////////////////////////////////////////////////////
    
    //echo $debugmodex;
    
    //get channel data, create "select" form fields to load into form
    $sql			= "SELECT channel_id, channel_name FROM channels";
    $result1 		= @mysql_query($sql);
    $count_cats 	= @mysql_num_rows($result1);
    $fields_all 	= '';
    $sub_fields_all	= '';
    $show_fields	= '';
    
    $fields_all .= '<option value="99999">Select One</option>';
    
    while ($result = @mysql_fetch_array($result1)) {
        	$fields_all .= '<option value="'.$result['channel_id'].'">'.$result['channel_name'].'</option>';
    }
    
    $sub_cat_choice = (int) mysql_real_escape_string( $_GET['sub_cat'] );
    
    if ( $sub_cat_choice ) {
    
    	if ( $sub_cat_choice == '99999' ) {
    
    		$sub_fields_all  .= '<select class="image_form" style="width:160px;" size="1" name="sub_cat">';
    		$sub_fields_all  .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
    		$sub_fields_all .= '</select> ('.$lang_select.')';
    		echo $sub_fields_all;
    		die();
    
    	} else {
    
    		$sql2			= "SELECT * from sub_channels WHERE parent_channel_id = $sub_cat_choice";
          	$query		= @mysql_query($sql2);
    		$sub_fields_all  .= '<select class="image_form" style="width:160px;" size="1" name="sub_cat">';
    
          	while ($result2 = @mysql_fetch_array($query)) {
        			$count_subs		= @mysql_num_rows($query);
        			$sub_fields_all  .= '<option value="'.$result2['sub_channel_id'].'">'.$result2['sub_channel_name'].'</option>';
         		}
    
         		if ( $count_subs == '' ) {
         			$sub_fields_all  .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
    		}
    
         		$sub_fields_all .= '</select> ('.$lang_select.')';
    
         		echo $sub_fields_all;
    	     	die();
    	}
    }
    
    // grab values from form if any
    $form_submitted		= $_POST['form_submitted'];
    $title 			= $_POST['title'];
    $description 		= $_POST['description'];
    $tags 			= $_POST['tags'];
    $thumbnail    = $_POST['thumbnail'];
    $location_recorded	= $_POST['location_recorded'];
    $allow_comments 		= $_POST['allow_comments'];
    $allow_embedding 		= $_POST['allow_embedding'];
    $public_private 		= $_POST['public_private'];
    $channel 			= $_POST['channel'];
    $sub_cat			= $_POST['sub_cat'];
    $procede 			= true;
    
    ///////////////////////////////////////
    /////////////////////////////////////////
    
    $allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    //  ADD CHECK FOR VALID FILE
    if (!in_array($extension,$allowedExts))
    {
    echo ("Error - Invalid File Name");
    //exit();  // or do whatever else you want here
    }
    $length = 20;
    $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"];
    //
    $thumbnail = $newfilename;
    //
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    //
    $sql = "INSERT INTO videos ( filename ) VALUES( '$thumbnail' )";
    //
    mysql_query($sql);
    $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    
    ///////////////////////////////////////
    /////////////////////////////////////////
    
    $row = mysql_query("SELECT channel_name FROM channels WHERE channel_id = '$channel'");
    
    while( $result = mysql_fetch_assoc($row) ) $channel_name = $result['channel_name'];
    
    // validate form
    if ($form_submitted == 'yes') {
    
    	if ($_SESSION['user_id'] == '') die();
    	$post_vid_upload_token	= mysql_real_escape_string( $_POST['vid_upload_token'] );
    
    	if ( $post_vid_upload_token != $_SESSION['vid_upload_token'] ) die();
    
    	foreach ($_POST as $key => $value) {
          	if ($key == 'title' || $key == 'description' || $key == 'tags' || $key == '$channel') {
                	if (!isset($value) || ($value == '')) {
                    		$display_key	= @str_replace('_', ' ', $key);
                    		$error_message	= $config['notification_error'];
                    		$blk_notification = 1;
                    		$error_message 	= $error_message . " - " . $display_key . "  - $lang_required ";
                    		$procede 		= false;
                	}
            	}
        	}
    
        	if ( $channel == '99999' ) {
    
        		$error_message	= $config['notification_error'];
         		$blk_notification = 1;
         		$error_message 	= $error_message . " - $lang_select_channel";
        		$procede 		= false;
        	}
    } else {
    
    	$procede = false;
    }
    
    // display page with form error
    if ($procede == false && $form_submitted == 'yes') {
    	$template 		= "themes/$user_theme/templates/main_1.htm";
        	$inner_template1 	= "themes/$user_theme/templates/inner_upload_video_form.htm";
        	$TBS 			= new clsTinyButStrong;
        	$TBS->NoErr 	= true;
        	$TBS->LoadTemplate("$template");
        	$TBS->Render 	= TBS_OUTPUT;
        	$TBS->Show();
    	@mysql_close();
        	die();
    }
    
    // disply clean page
    if (!isset($form_submitted) || ($form_submitted == "")) {
    	$template 		= "themes/$user_theme/templates/main_1.htm";
        	$inner_template1 	= "themes/$user_theme/templates/inner_upload_video_form.htm";
        	$TBS 			= new clsTinyButStrong;
        	$TBS->NoErr 	= true;
        	$TBS->LoadTemplate("$template");
        	$TBS->Render 	= TBS_OUTPUT;
        	$TBS->Show();
        	@mysql_close();
        	die();
    }
    
    if ($procede == true && $form_submitted == 'yes') {
        if ($_SESSION['user_id'] == "") die();
    
        //=================================START OF UPLOAD=================================
        $THIS_VERSION = '2.0';
        if (isset($_GET['cmd']) && $_GET['cmd'] == 'about') {
            kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER VERSION =  <b>" .
                $UBER_VERSION . "</b><br>UU_FILE_UPLOAD = <b>" . $THIS_VERSION . "<b><br>\n");
        }
        $tmp_sid = md5(uniqid(mt_rand(), true));
        ///////////////////////////////////////////////////////////////////////
        // This is where you might set your config file eg.                  //
        // if($_SESSION['user'] == "tom"){ $config_file = 'uu_tom_config'; } //
        ///////////////////////////////////////////////////////////////////////
        $config_file = $default_config_file;
        $path_to_upload_script .= '?tmp_sid=' . $tmp_sid;
        $path_to_ini_status_script .= '?tmp_sid=' . $tmp_sid;
    
        if ($MULTI_CONFIGS_ENABLED) {
            $path_to_upload_script .= "&config_file=$config_file";
            $path_to_ini_status_script .= "&config_file=$config_file";
        }
    
        //allow form to be refilled on error
        foreach($_POST as $key=>$value) {
             $$key = $value;
        }
    
        $template = "themes/$user_theme/templates/main_1.htm";
        $inner_template1 = "themes/$user_theme/templates/inner_upload_video.htm";
        $TBS = new clsTinyButStrong;
        $TBS->NoErr = true;// no more error message displayed.
        $TBS->LoadTemplate("$template");
        $TBS->Render = TBS_OUTPUT;
        $TBS->Show();
    
        @mysql_close();
        die();
        //===============================================================END OF UPLOADER================================================================
    }
    
    function die_spammer_alerts() {
    
    global $member_uploading, $user_ip, $admin_email, $site_name;
    
    	$subject	= 'Possible Video Spamming !!';
    
    	$message	= "The following member uploaded a possible spam video: => " . $member_uploading . "\n\n" . "The IP used: " . $user_ip . "\n";
    
    	$to		= $admin_email;
          $from 	= $site_name;
    
          mail($to, $subject, $message, "From: $from");
    
          // if config auto ban spammer is true - enter user name and ip to ban table
          /*
          include_once ('classes/config.php');
          $sql		= "DELETE FROM videos WHERE video_id = '$raw_video'";
          $query	= @mysql_query($sql);
          */
    
          write_log($message);
    }
    
    function write_log($message) {
    	global $tracking_log_file;
    
    	if (@file_exists($tracking_log_file)) {
        		$fo = @fopen($tracking_log_file, 'a');
            	@fwrite($fo, $message);
            	@fclose($fo);
    
        	} else {
          	$fo = @fopen($tracking_log_file, 'w');
            	@fwrite($fo, $message);
            	@fclose($fo);
        	}
    exit();
    }
    
    
    ?>
    
  5. Thanks ginerjm for that. Much appreciated. Very helpful.

     

    Another question, please; Currently, the user id populates the Thumbnail field, of the Upload Form, upon the Form page opening.

    And after Submit, the (uploaded) file name is added to the user_id, in that field. 

     

    How can I change it so the user_id doesn't populate the Thumbnail field upon opening the Form page, but is added to the (uploaded) file name,

    after Submit?

     

    Any help will be appreciated

  6. Can you please tell me what each of these lines of code means?

    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    $length = 20;
    $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"];
    $thumbnail = $newfilename . "." . $extension;
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    $sql = "INSERT INTO videos ( filename ) VALUES( $thumbnail )";
    mysql_query($sql);
    $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    $description = $description . " \n " . $newfilename;
    
  7. In an Upload Form that I'm using, it has this line:

    $newfilename = $SESSION['userid'].$_FILES["file"]["name"];
    

    I need to "store the newfilename in a session variable" (in another php file)

    and use the session variable in this link, instead of newfilename:

    <a href="upload/<?php echo $newfilename?>"><?php echo $newfilename?></a>

    So, would this be correct?

    $newfilename = $_SESSION['newfilename'].$_FILES["newfilename"];
    
  8. This change now gets the image uploaded, however this code takes me to the next page.

    I'd like to figure out how to stay on the same page after upload. Any help will be appreciated.

    <form enctype="multipart/form-data" action="" method="POST">
    <input type="file" name="file" id="file">
    <input class="upload-input" type="hidden" name="form_submitted" value="yes" />
    <input type="submit" value="submit" />
    </form>
    
  9. I don't know why this image upload code isn't uploading the image file to the uploads/ folder.

    Any help will be appreciated.

    	$allowedExts = array("gif", "jpeg", "jpg", "png");
    	$temp = explode(".", $_FILES["file"]["name"]);
    	$extension = strtolower( end($temp) );
    	if (  $_FILES["file"]["size"] < 2000000
    	&& in_array($extension, $allowedExts) )
    	{
    	if ($_FILES["file"]["error"]!= 0)
    	{
    	echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    	} else {
    	$length = 20;
    	$randomString = substr(str_shuffle(md5(time())),0,$length);
    	$newfilename = $randomString . "." . $extension;
    	move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
    	$file_location = '<a href="http://www.--.com/upload/' . $newfilename . '">http://www.--.com/upload/' . $newfilename . '</a>';
    	}
    	} else {
    	echo "Invalid upload file";
    	}
    
    <form enctype="multipart/form-data" action="uploader.php">
    <input type="file" name="file" id="file">
    <input type="submit" name="submitted" value="Submit">
    </form>
    
  10. Thanks for that, however this code (below) doesn't successfully display the path of the chosen file, on the html page, like so:

    ../upload/test.png
    Any help/improvements will be appreciated.

    <html>
     <head>
      <title>PHP Test</title>
     </head>
      <body>
     <?php
     if ($form_submitted == 'yes') {
     $allowedExts = array("gif", "jpeg", "jpg", "png");
     $temp = explode(".", $_FILES["file"]["name"]);
     $extension = strtolower( end($temp) );
     $newfilename = md5($_FILES['tmp']['name'] . time()) . '.' . $extension;
     if (  $_FILES["file"]["size"] < 200000
           && in_array($extension, $allowedExts) )
     {
         if ($_FILES["file"]["error"]!= 0)
         {
             echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
         } else {
             $length = 20;
             move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
             $file_location = '<a href="http://www.--.com/upload/' . $newfilename . '">' . $newfilename . '</a>';
         }
     } else {
       echo "Invalid upload file";
     }
     $description = $description . "\n http://www.--.com/upload/" . $newfilename;
     }
    ?>
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file">
    </body>
    </html>
    
  11. I need help making the uploaded image file name, that's chosen to be uploaded, be displayed on the html page with the path /upload/ added to the beginning of the displayed file name like so:
    ../upload/test.png
    Any help/improvements will be appreciated.

    <html>
     <head>
      <title>PHP Test</title>
     </head>
      <body>
     <?php
     if ($form_submitted == 'yes') {
     $allowedExts = array("gif", "jpeg", "jpg", "png");
     $temp = explode(".", $_FILES["file"]["name"]);
     $extension = strtolower( end($temp) );
     if (  $_FILES["file"]["size"] < 200000
           && in_array($extension, $allowedExts) )
     {
         if ($_FILES["file"]["error"]!= 0)
         {
             echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
         } else {
             $length = 20;
             move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
             $file_location = '<a href="http://../upload/' . $newfilename . '">' . $newfilename . '</a>';
         }
     } else {
       echo "Invalid upload file";
     }
    ?>
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file">
    </body>
    </html>
    
  12. I've added this code (below) to a file called uploader.php (attached).

     

    When I simply open the corresponding html page, I see "Invalid upload file" in the top left corner of the page. When I remove this code from uploader.php the "Invalid upload file" disappears. Any ideas on how to resolve this will be appreciated.

    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) ); // in case user named file ".JPG" etc.!!!
    
    if (  $_FILES["file"]["size"] < 200000 
          && in_array($extension, $allowedExts) )
    {
        if ($_FILES["file"]["error"] > 0) 
        {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
        } else {
            $length = 20;
            $randomString = substr(str_shuffle(md5(time())),0,$length);
            $newfilename = $randomString . "." . $extension;
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename);
          
           $file_location = '<a href="http://www.-----.com/upload/' . $newfilename . '">' . $newfilename . '</a>';
        }
    } else {
      echo "Invalid upload file";
    }
    $description = $description . " \n " . $newfilename;
    
  13. thanks for your reply.

    I plugged in your code that you "switched around a little" and after logging in I was re-directed to the /myaccount.php page.

    Although i appreciate your help, that isn't what i was hoping for.

     

    The code that shows in my initial post, logs-in successfully (from the home page) and then shows the sub-menu things on the home page.

    (But it also shows the log-in Form still on the homepage). I'd like to stay on the home page (with the sub menu stuff)and not be re-directed (but just have the log-in form disappear after succeeding). 

     

    Any additional help will be appreciated.

  14. When I asked how to make this Log In Form disappear once it performs it's function:

    <form action="../login.php" method="post" accept-charset="UTF-8" class="middletext"
    onsubmit="javascript:this.style.display='none';">
    <p>
    <input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER     USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if     (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" >
    <input type="text" size="20" name="password_login" id="password_login" value="ENTER     PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if     (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" >
    <input type="hidden" name="cookie_time" value="10080" />
    <img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit"   style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
    <input type="hidden" name="submitted" value="yes" />
    <input type="hidden" name="remember_me" value="remember_me" />
    </p>
    </form>
    </div>
    <!--Begin Sub-Navigation. This only appears when a user is logged in.-->
    <div class="container1">
    <div class="menu1">
    <div class="sub-nav"><a href="../index.php"></a> <img     src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /><a    href="../members/[var.user_name]"> my account</a><img src="../themes/default/images/arrow-    red.jpg" style="vertical-align:middle" alt="" />
    <a href="../credits.php">[var.lang_my_credits]: [var.member_credits]</font></a><img     src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle"><a     href="../logout.php">[var.login_out]</a>
    <!--[onload;block=div;when [var.loggedin]=1;comm]-->
    </div>
    

    I was given this line of code:

    if($_SESSION['loggedin'] == true){ //dont show form } else { //show form }
    

    But I don't know how/where to integrate it into the Form.

    Any help will be appreciated.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.