Jump to content

phreak3r

Members
  • Posts

    110
  • Joined

  • Last visited

Recent Profile Visitors

1,473 profile views

phreak3r's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

1

Community Answers

  1. @requinix I'm going to use as many tags as I need to. When I figure out a way to not have to use more than one I will eliminate one of the two. I didn't know inline event handlers were already outdated, I don't follow the corporation or industry standards. I guess I'll just figure it out. Thanks for the response though.
  2. I am trying to delete some videos. The videos are echo'd out individually with their own 'delete' input. The input value takes the id of the video, I didn't know of any other work around for that. I'd like to delete the video that corresponds with the button pressed, if that makes sense. Anyways, I would like to delete the video where the video id is equal to the video id of the input or the value of the input pressed. I am positive the way I am carrying this out is not correct, as I am thrown an 'index undefined error'. Here is the disgusting code at hand. Recommendations are appreciated, but please try and keep answers in line with the relevant information given. Thank You. <?php error_reporting(-1); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require('dbcon/dbcon.php'); include('header.php'); include('user.php'); $channel_id = $_SESSION['channel_id']; $query = $pdo->prepare("SELECT * FROM videos001 WHERE uploader = :channel_id"); $query->bindValue('channel_id', $_SESSION['channel_id']); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $title = $row['video_title']; $video_path = $row['video_path']; $video_id = $row['video_id']; /* - get videos of user - display videos out onto page */ ?> <html> <body> <div class="content"> <form method="post"> <h3><?php echo $title; ?></h3> <input type="button" name="delete" id="delete" value="<?php echo $video_id;?>" onclick="deleteVideo()"> </form> </div> </body> </html> <?php } function removeVideoFromFilesystem(PDO $pdo, $video_path, $video_id) { //chdir($video_path); //unlink($video_id . ".mp3"); $query = $pdo->prepare("DELETE from videos001 where video_id = :video_id"); $query->bindValue(':video_id', $_POST['delete']); $query->execute(); } if (isset($_POST['call_func'])) { removeVideoFromFileSystem($pdo, $video_path, $_POST['delete']); } ?> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> function deleteVideo() { $.ajax({ url: 'dashboard.php', type: 'post', data: {"call_func":"1"}, success: function(response) { console.log(response); } }); } </script> </head> <body><?php print_r($_POST['delete']); ?></body> </html>
  3. I ended up copying the function from a StackOverflow answer. I am not familiar with some of the operations used in this function, but I will make an attempt to re-write it.
  4. @gw1500se When you upload a video to YouTube it tells you 'uploaded x seconds ago' 'uploaded x minutes ago'. I am trying to implement that feature to display the elapsed time, since each file upload if that makes sense.
  5. I wrote a function that grabs the elapsed time of a recently uploaded video. However, the time does not seem to increment. For example, if I upload a video, the time will display as '1 second'. However, if I continuously refresh the page, the time does not increment or increase. Any way to fix this? I figured I'd have to put it in some kind of loop (I do call the function in another class). function getElapsedTime($time) { $time = time() - $time; // get time since video upload date $time = ($time < 1) ? 1 : $time; $tokens = array( 31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second' ); foreach ($tokens as $unit => $text) { if ($time < $unit) continue; $numberOfUnits = floor($time / $unit); return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : ''); } }
  6. An example? Please and thank you!
  7. Sarcastic and cynical. Mmmm...my favorite flavor! What is the difference between my canned messages and using an array to 'save' generated messages? I am the kind of person that needs things further simplified sometimes.
  8. So it is not the same as my array holding defined error messages? I might have an idea of what you mean, but for the most part I do not. How would this help? In my mind, PHP is a language where you are simply manipulating arrays, that's all. At least that is how I interpret it.
  9. mac_gyver, that worked, I am still getting an error, but at least there isn't any of the null business.
  10. The Loaded Configuration File is /etc/php/7.2/apache2/php.ini. Both master and local are 8M. I modified the drb@z10n:/etc/php/7.2/cli path. ?
  11. ginerjm, I think the form is valid. I will scour the Internet for some similar problems.
  12. Yes, it does. I made a simple mistake and added a semicolon after the variable. For example : echo $a; "<br>";
  13. Okay, well I tried using "." but that did not really seem to work. Thank you for your contribution. I know many of my previous posts may display the behavior "IT'S BROKEN! HELP!", but I am genuinely trying to understand this all.
  14. Apparently there is nothing in the array. Array ( ) And why is a comma used instead of a period in reference to the echo "<pre>",print_r($_POST, true),"</pre>"; line?
  15. If you really want to see the whole code, here it goes. I could do with some better erm...organization/structure? It is such a big script, so I tried to refrain from including it. <?php include('header.php'); require('dbcon/dbcon.php'); include('functions.php'); isLoggedIn(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Error declaration $error = ["Your file is too big!", "There was an error uploading your file!", "Cannot upload file of this type!", "Empty fields!"]; // Process POST variables $videoTitle = $_POST['video_title']; $videoDesc = $_POST['textarea-videoDesc']; // Process session variable $username = $_SESSION['username']; // file upload stuff... $file = $_FILES['videoFile']; $fileName = $file['name']; $fileTmpName = $file['tmp_name']; $fileSize = $file['size']; $fileError = $file['error']; $fileType = $file['type']; $fileExt = explode('.', $fileName); $fileActualExt = strtolower(end($fileExt)); $allowed = array('mp4', 'mov', 'mkv'); if (in_array($fileActualExt, $allowed)) { if ($fileError === 0) { if ($fileSize < 2000000) { $fileNameNew = $username . "." . $fileActualExt; $fileDestination = "channel/" . $username . "/videos/" . $fileNameNew; move_uploaded_file($fileTmpName, $fileDestination); } else { echo $error[0]; } } else { echo $error[1]; } } else if (!$allowed) { echo $error[2]; } //////////////////////////////////////////////////////////////////// $thumbnailImageFile = $_FILES['thumbnailImage']; $thumbnailImageName = $_FILES['thumbnailImage']['name']; $thumbnailImageTmpName = $_FILES['thumbnailImage']['tmp_name']; $thumbnailImageSize = $_FILES['thumbnailImage']['size']; $thumbnailImageError = $_FILES['thumbnailImage']['error']; $thumbnailImageType = $_FILES['thumbnailImage']['type']; $thumbnailImageExt = explode('.', $thumbnailImageName); $thumbnailImageActualExt = strtolower(end($thumbnailImageExt)); $allowedThumbnailFileExts = array('png', 'jpg', 'jpeg'); if (in_array($thumbnailImageActualExt, $allowedThumbnailFileExts)) { if ($thumbnailImageError === 0) { if ($thumbnailImageSize < 200000000) { $thumbnailImageNameNew = $username . "thumbnailImage" . uniqid('', true). "." . $thumbnailImageActualExt; $thumbnailImageDestination = 'uploads/thumbnails/' . $thumbnailImageNameNew; move_uploaded_file($thumbnailImageTmpName, $thumbnailImageDestination); } else { echo $error[0]; } } else { echo $error[1]; } } else if (!$allowed) { echo $error[2]; } if (isset($file) && $fileSize != 0 /*&& $thumbnailImageSize != 0*/ && !empty($videoTitle)) { $sql = $pdo->prepare("INSERT into videos001 (uploader, video, thumbnail, video_title, video_desc) VALUES (:username, :fileDestination, :thumbnailImageDestination, :videoTitle, :videoDesc)"); $sql->bindValue(':username', $username); $sql->bindValue(':fileDestination', $fileDestination); $sql->bindValue(':thumbnailImageDestination', $thumbnailImageDestination); $sql->bindValue(':videoTitle', $videoTitle); $sql->bindValue(':videoDesc', $videoDesc); $sql->execute(); header('Location: /soapbox/upload.php?success'); } else { echo $error[3]; var_dump($file, $videoTitle, $videoDesc); } } // end of if server method... // TODO: if there's no thumbnail, do not upload video, let user know to put in a thumbnail ?> <!DOCTYPE html> <html> <head> <title>soapbox - upload</title> </head> <body> <form action="upload.php" method="POST" enctype="multipart/form-data" multiple><br> <p>Video File:</p><input type="file" name="videoFile" id="fileToUpload"><br> <p>Thumbnail Image File: </p><input type="file" name="thumbnailImage"><br> <p>Video Title: </p><input type="text" name="video_title" id="videoTitle" placeholder="Video title"><br> <p>Video Description</p><textarea name="textarea-videoDesc" placeholder="Video description..." rows="7" style="resize: none;"></textarea><br> <br><input type="submit" name="uploadBtn" value="Upload"> </form> </body> </html>
×
×
  • 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.