Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About chrisyroid

  • Rank
  1. After endless google searches I came up with a solution which includes a bit of your last few posts. I changed my Tampermonkey script to count the account tables and send that to my PHP. "&accountsnumber=" + accountsCount Then I modified my PHP to accept that value and used that number to figure out how many entries should be written to my html file. $accountnumber = $_POST['accountsnumber']; $str = '<strong>Updated last: ' . $_POST['date'] . '</strong><br /><br />'; for ($i = 0; $i < $accountnumber; $i++) { $identer = $i + 1; $str.= '<strong>Account ' . $identer . '</strong><br />(' . $_POST['accountname' . $identer] . ')' . '<br />CREDITS<br />' . $_POST['credits' . $identer] . '<br />-<br />'; } file_put_contents("content.html", rtrim($str, '<br />-<br />')); Thank you so much for all your help.
  2. Putting this in my php file writes "..." to my html file. $contents = $mystring . "..."; $n = 1; $accounts = array(); foreach ($_POST["accounts"] as $account) { $accounts[] = "<strong>Account {$n}</strong><br>({$account['name']})<br>CREDITS<br>{$account['credits']}"; } $contents .= implode("<br>-<br>", $accounts); file_put_contents("content.html", $contents); This is what I get now if I use var_dump$(_POST) Object {readyState: 4, responseText: "↵array(2) {↵ ["date"]=>↵ string(58) "Sun Dec 27 … ["credits"]=>↵ string(2) "72"↵ }↵ }↵}↵", status: 200, statusText: "OK"}abort: ( statusText )always: ()complete: ()done: ()error: ()fail: ()getAllResponseHeaders: ()getResponseHeader: ( key )overrideMimeType: ( type )pipe: ( /* fnDone, fnFail, fnProgress */ )progress: ()promise: ( obj )readyState: 4responseText: "↵array(2) {↵ ["date"]=>↵ string(58) "Sun Dec 27 2015 18:35:23 GMT-0700 (Mountain Standard Time)"↵ ["data"]=>↵ array(6) {↵ [0]=>↵ array(2) {↵ ["name"]=>↵ string(28) "****@gmail.com"↵ ["credits"]=>↵ string(3) "110"↵ }↵ [1]=>↵ array(2) {↵ ["name"]=>↵ string(33) "****@gmail.com"↵ ["credits"]=>↵ string(3) "110"↵ }↵ [2]=>↵ array(2) {↵ ["name"]=>↵ string(23) "****@gmail.com"↵ ["credits"]=>↵ string(3) "536"↵ }↵ [3]=>↵ array(2) {↵ ["name"]=>↵ string(32) "****@outlook.com"↵ ["credits"]=>↵ string(3) "333"↵ }↵ [4]=>↵ array(2) {↵ ["name"]=>↵ string(19) "****@gmail.com"↵ ["credits"]=>↵ string(3) "188"↵ }↵ [5]=>↵ array(2) {↵ ["name"]=>↵ string(20) "****@gmail.com"↵ ["credits"]=>↵ string(2) "72"↵ }↵ }↵}↵"setRequestHeader: ( name, value )state: ()status: 200statusCode: ( map )statusText: "OK"success: ()then: ( /* fnDone, fnFail, fnProgress */ )__proto__: Object
  3. I think I know where to change accounts[n] But I can't figure out where to change data[n][credits] And how do I use the above changed code to write to an html file?
  4. I don't quite understand what is supposed to be going on here. Also I just realized that I don't need "$mystring" don't know why that was still in there...
  5. I'm trying to shorten this piece of my code into a loop. I've tried to get the $param_name using: $_POST as $param_name => $param_val But that just gets me the last entry and not the whole thing. Here's the code I'm trying to shorten: file_put_contents( "content.html", $mystring . "<strong> Updated last: " . $_POST['date'] . "</strong><br><br>" . //Please add more entries depending on how many accounts you have configured "<strong>Account 1</strong><br>(" . $_POST['accountname1'] . ")" . "<br>CREDITS<br>" . $_POST['credits1'] . "<br>-<br>" . "<strong>Account 2</strong><br>(" . $_POST['accountname2'] . ")" . "<br>CREDITS<br>" . $_POST['credits2'] . "<br>-<br>" . "<strong>Account 3</strong><br>(" . $_POST['accountname3'] . ")" . "<br>CREDITS<br>" . $_POST['credits3'] . "<br>-<br>" . "<strong>Account 4</strong><br>(" . $_POST['accountname4'] . ")" . "<br>CREDITS<br>" . $_POST['credits4'] . "<br>-<br>" . "<strong>Account 5</strong><br>(" . $_POST['accountname5'] . ")" . "<br>CREDITS<br>" . $_POST['credits5'] . "<br>-<br>" . "<strong>Account 6</strong><br>(" . $_POST['accountname6'] . ")" . "<br>CREDITS<br>" . $_POST['credits6']); Also here's the Javascript code I'm posting with: function bprs() { { var rowCount = $('#accountsTable tr').length; var accountsCount = rowCount -1; var accounts = []; for (var n = 1; n <= accountsCount; n++) { accounts[n] = { name: $('#accountName' + n).text(), credits: $('#credits' + n).text() }; } var date = new Date(); var data = "date=" + date + accounts.reduce(function (prev, account, n) { return prev + "&accountname" + n + "=" + account.name + "&credits" + n + "=" + account.credits; }, ''); I'd like my php page to generate the html code based on how many entries are in the post data. I know I'm close, I just don't know how to loop data like this properly.
  6. At this point I don't know where to start. I usually learn by getting examples and breaking them down on my own and learning as I go along.
  7. Could you give me an example of how such a SQL database would work?
  8. It's not from a database unfortunately. It's hand written and coded into each page. I planed to have php generate them via some kind of template or text file since I HATE working with SQL. I guess if I don't have a choice I'd do it that way but I have only minimal understanding of how that would all work.
  9. The file and folder listing works good but I'm having a problem with the query string. When I click on: "myfile.mkv" the url changes to: "http://localhost/test.php?dir=&file=myfile.mkv" and the page refreshes instead of opening up the file. Same goes for the directories. Also I might not have made it clear in my last post. I also want an easier way to show another page for each file containing a thumbnail and short description. This is how it goes. Main Directory --> Videos ---->TV Show -------->Episode.mkv <-- Links to php file. ---------->Episode.mkv.php <-- Page containing description and thumbnail. When user clicks "play" episode plays. This is what I have coded in "Episode.mkv.php" <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Episode 1</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <link href="../../../Styles/style.css" rel="stylesheet" type="text/css" media="all"/> </head> <body class="single"> <div class="wrap"> <header> <div class="logo"> <a href="index.html"> <img src="Thumbnails/ep1_snap.png" style="border: max-width: 320px; max-height: 240px;" /></a> </div> </header> <div class="content"> <article> <section class="head"> <h3>Description</h3> </section> <section> <center><b>Episode title</b></center> <br> Episode description goes here. <br><br> Original air date: September 13, 1986 <br><br> <nav class="vertical menu"> <center><a href="../Season 1/episode.mkv">Play Episode</a></center> </nav> <br> <a href="../Season 1/">Back to main menu</a> </section> </article> </body> </html>
  10. Hi. I am trying to create a simple video file server. I finished the skeleton of it but when it came to creating the multitude of pages I realized that there could be an easier way to do it. I started out basically getting the folder names in the server then printing them on the page. <?php $dirs = glob("*", GLOB_ONLYDIR); echo '<ul>'; foreach($dirs as $dir) { $forbidden_folders = array("not4u", "ignore", Styles); $filename = str_replace($forbidden_folders, '', $dir); if (!empty($filename)) { echo '<li><a href="'.$dir.'">'.$dir.'</a></li>'; } } echo '</ul>' ?> Then I created in each of the folders with files a php file with this code: <?php function date_sort_desc($a, $b) { preg_match('/\w+ \d{4}/', $a, $matches_a); preg_match('/\w+ \d{4}/', $b, $matches_b); $timestamp_a = strtotime($matches_a[0]); $timestamp_b = strtotime($matches_b[0]); if ($timestamp_a == $timestamp_b) return 0; return $timestamp_a < $timestamp_b; } $files = array(); $dir = opendir('.'); while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..") and ($file != "index.php")) { $files[] = $file; } } natsort($files); $i = 0; foreach($files as $file) { $i++; $string = str_replace("TV Show Name S1 E$i - ", '' , $file); echo '<div><a href="../Discriptions/'.$file.'.php">'.basename($string, '.m4v').'</a></div><br>'; } ?> This opens up a php file with the same file name as the file to be played containing the episode's thumbnail and description. That file then contains a link pointing back to the real file. The problem here is that I'd have to make a new php file for every file in my collection. I'm wondering if there's somehow a way to simplify all of this.
  • 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.