Jump to content

bschultz

Members
  • Content Count

    454
  • Joined

  • Last visited

Everything posted by bschultz

  1. I got it working...left the dollar sign out of the function call getplayer('qb1'); and then an if / elseif statement inside the function: if ($position == 'qb1') { $new_position = $qb1; } elseif ($position == 'qb2') { $new_position = $qb2; } Thanks....
  2. I've tried that...the echo of the sql shows the name is blank
  3. I have a php file with a bunch of variables declared. I now need a function to put data on a separate page that pulls variables from the required page. So, on the required page, I have a variable set like this: $qb1 = "John Doe"; The function on the new script is called like this: getplayer($qb1); I've tried this without the dollar sign in the function like this: getplayer(qb1); and then adding the $dollar sign in the rest of the function code...but it never populates the sql query correctly. I'm guessing this is a case for variable variables or something similar, but I don't know how to get the variable value from the required page. Any ideas? Thanks. Here's the code: <?php function getplayer($position) { // start function //$new_position = "$" . $position; $new_position = $position; $file = "their.php"; require "$file"; //echo $qb1; this displays the name John Doe...as $qb1 is declared in the required file $db_select_their = "bschultz_their"; $servername = "localhost"; $username = "user"; $password = "pass"; $dbname = "db_name"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM (select number as position_number, name as position_name, pronunciation as position_pronunciation, pos as position_pos, height as position_height, weight as position_weight, year as position_year, city as position_city, state as position_state, notes as position_notes FROM $db_select_their WHERE name = '$new_position') as position"; //$sql = "SELECT * FROM bschultz_their WHERE name = $new_position"; echo $sql; //exit; /* this displays this text... SELECT * FROM (select number as position_number, name as position_name, pronunciation as position_pronunciation, pos as position_pos, height as position_height, weight as position_weight, year as position_year, city as position_city, state as position_state, notes as position_notes FROM bschultz_their WHERE name = '') as position The name is empty */ $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "#: " . $position_number . " - Name: " . $position_name . ""; } } else { echo "0 results"; } } // end function getplayer("${$qb1}"); $conn->close(); ?>
  4. I'm replacing Wordpress with my own content management system. Wordpress is just too bloated for my liking. The url's for the mp3's are embedded into the stories. Our final Beaver Fever Friday of the year was yesterday. What a show. It's always nice to get to know these seniors over their careers. Here are the interviews if you missed them: Christa Benson - Track <a href="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/ChristaBenson.mp3">Christa Benson - Track</a><br /><br /> Cody Cook - MGolf <a href="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/CodyCook.mp3">Cody Cook - MGolf</a><br /><br /> There is NO VARIABLE in the database content. Here's what I need the code to look like Our final Beaver Fever Friday of the year was yesterday. What a show. It's always nice to get to know these seniors over their careers. Here are the interviews if you missed them: Christa Benson - Track<audio controls> <source src="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/ChristaBenson.mp3" type="audio/mpeg"> </audio> <br /><br /> Cody Cook - MGolf <audio controls> <source src="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/CodyCook.mp3" type="audio/mpeg"> </audio> <br /><br />
  5. I'm finally moving away from Wordpress. I've used a couple of different mp3 players in the past, and I need to figure out how to replace a link to an mp3 file or just some text with xxx.mp3 with an html5 audio player. The one plugin I used replaced all links with a player button...another plugin I used you only needed to have .mp3 at the end, and it would replace the text with a button player. I have a VERY hard time wrapping my head around regex. How can I accomplish these two scenarios with 1 regex? <a href=http://domain.com/soundfile1.mp3>Some File</a> and http://domain.com/soundfile1.mp3 Are both in the old Wordpress database. The plugin has a button to press to play the file. Both need to be replaced with this: <audio controls> <source src="http://domain.com/soundfile1.mp3" type="audio/mpeg"/> </audio>
  6. Here's the function... function media_shooter_date ($show, $date_of_directory) // show is daily or weekend...date of directory is the date to expect from the media shooter directory { $todays_dow = date('l'); // Sunday, Monday...etc if ($show == "daily" && $todays_dow == "Sunday") { $media_shooter_date_diff = "+1 day"; } if ($show == "daily" && $todays_dow == "Monday") { $media_shooter_date_diff = "+0 day"; } if ($show == "daily" && $todays_dow == "Tuesday") { $media_shooter_date_diff = "-1 day"; } if ($show == "daily" && $todays_dow == "Wednesday") { $media_shooter_date_diff = "-2 days"; } if ($show == "daily" && $todays_dow == "Thursday") { $media_shooter_date_diff = "-3 days"; } if ($show == "daily" && $todays_dow == "Friday") { $media_shooter_date_diff = "-4 days"; } if ($show == "daily" && $todays_dow == "Saturday") { $media_shooter_date_diff = "-5 days"; } if ($show == "Saturday" && $todays_dow == "Sunday") { $media_shooter_date_diff = "+6 days"; } if ($show == "Saturday" && $todays_dow == "Monday") { $media_shooter_date_diff = "+5 days"; } if ($show == "Saturday" && $todays_dow == "Tuesday") { $media_shooter_date_diff = "+4 days"; } if ($show == "Saturday" && $todays_dow == "Wednesday") { $media_shooter_date_diff = "+3 days"; } if ($show == "Saturday" && $todays_dow == "Thursday") { $media_shooter_date_diff = "+2 days"; } if ($show == "Saturday" && $todays_dow == "Friday") { $media_shooter_date_diff = "+1 day"; } if ($show == "Saturday" && $todays_dow == "Saturday") { $media_shooter_date_diff = "+0 day"; } if ($show == "Sunday" && $todays_dow == "Sunday") { $media_shooter_date_diff = "+0 day"; } if ($show == "Sunday" && $todays_dow == "Monday") { $media_shooter_date_diff = "+6 days"; } if ($show == "Sunday" && $todays_dow == "Tuesday") { $media_shooter_date_diff = "+5 days"; } if ($show == "Sunday" && $todays_dow == "Wednesday") { $media_shooter_date_diff = "+4 days"; } if ($show == "Sunday" && $todays_dow == "Thursday") { $media_shooter_date_diff = "+3 days"; } if ($show == "Sunday" && $todays_dow == "Friday") { $media_shooter_date_diff = "+2 day"; } if ($show == "Sunday" && $todays_dow == "Saturday") { $media_shooter_date_diff = "+1 day"; } return date('m.d.y', strtotime("$media_shooter_date_diff")). "\n"; }
  7. I have confirmed the date is correct... Here's the code: $this_show_date = media_shooter_date ("Saturday", "Saturday"); echo "This show date = $this_show_date\n"; /* // This is the old code...that does NOT check for the date $dir = "/showdownloads/MediaShooter/MediaShooterDrop/*Years\ of\ Hits*"; foreach(glob($dir) as $file) { $files = glob("$file/*.*"); foreach($files as $audio){ $file_to_go = str_replace($file,"",$audio); copy($audio, '/showdownloads/25Years/' . $file_to_go); } } */ $path = "/showdownloads/MediaShooter/MediaShooterDrop/"; $dir = new DirectoryIterator("/showdownloads/MediaShooter/MediaShooterDrop/"); foreach ($dir as $fileinfo) { //echo "$fileinfo\n"; if ($fileinfo->isDir() && !$fileinfo->isDot()) { if (stripos($fileinfo->getFilename(), "Years of Hits") !== false && stripos($fileinfo->getFilename(), "{$this_show_date}") !== false && stripos($fileinfo->getFilename(), 'revised') !== false) { $final_directory = $fileinfo->getFilename(); } elseif (stripos($fileinfo->getFilename(), "Years of Hits") !== false && stripos($fileinfo->getFilename(), "{$this_show_date}") !== false && stripos($fileinfo->getFilename(), 'revised') === false) { $final_directory = $fileinfo->getFilename(); } } } echo $final_directory; exit; $files = glob("/showdownloads/MediaShooter/MediaShooterDrop/$final_directory/*.*"); foreach($files as $audio){ $file_to_go = str_replace($file,"",$audio); copy($audio, '/showdownloads/25Years/' . $file_to_go); }
  8. Changing the code to replace strpos with stripos still didn't match anything.
  9. I'm trying to loop through a directory for subdirectory names. If a subdirectory matches needle and haystack...loop through that directory and proceed. Here's the code $this_show_date = media_shooter_date ("Saturday", "Saturday"); $path = "/showdownloads/MediaShooter/MediaShooterDrop/"; $dir = new DirectoryIterator("/showdownloads/MediaShooter/MediaShooterDrop/"); foreach ($dir as $fileinfo) { echo "$fileinfo\n"; if ($fileinfo->isDir() && !$fileinfo->isDot()) { if (strpos($fileinfo->getFilename(), "Years of Hits") !== false && strpos($fileinfo->getFilename(), "{$this_show_date}") !== false && strpos($fileinfo->getFilename(), 'revised') !== false) { $final_directory = $fileinfo->getFilename(); // does this match ALL of the following: Years of Hits, the date returned from $this_show_date AND contains the word REVISED } elseif (strpos($fileinfo->getFilename(), "Years of Hits") !== false && strpos($fileinfo->getFilename(), "{$this_show_date}") !== false && strpos($fileinfo->getFilename(), 'revised') !== true) { $final_directory = $fileinfo->getFilename(); // does this match ALL of the following: Years of Hits, the date returned from $this_show_date AND DOES NOTcontain the word REVISED } } } echo $final_directory; exit; // once $final_directory is set, the code will proceed By echoing the $filename, I get this: This should match 25 Years of Hits SATURDAY 1 07.21.18 1 for WMIS-FM only and 25 Years of Hits SATURDAY WITH REVISED HOUR 2 SEGMENT 1 07.21.18 1 for WMIS-FM only...but doesn't. Any ideas why? Thanks!
  10. Barand, Many thanks...I would NEVER come up with that. Very much appreciated!
  11. The more I think of this...that logic won't work either. What if a special show runs for 6 hours? That would never fall between start and end of any one show. That would fall somewhere between Show #1 and Show #3 Not going to lie...this is far and away above anything I've ever written before.
  12. OK...so I read up on multidimentional arrays. I'd say this is headed in the right direction...but how do I work the logic for if special starts BEFORE the PREVIOUS regular? $regular = array( array( "title" => "Regular #1", "start" => "2018-04-02 12:00:00", "end" => "2018-04-02 15:00:00" ), array( "title" => "Regular #2", "start" => "2018-04-02 15:00:00", "end" => "2018-04-02 18:00:00" ), ); $specialty = array( array( "title" => "Special #1", "start" => "2018-04-02 18:00:00", "end" => "2018-04-02 19:00:00" ), ); foreach ( $regular as $show ) { foreach ( $specialty as $special ) { if (strtotime($special['start']) > strtotime($show['start']) && strtotime($special['start']) < strtotime($show['end'])) { echo "$special[title] falls between start end end of $show[title]\n"; } } // end regular as show } // end specialty as special
  13. Finally had some time to work on this...I'm getting an undefined offset error. Am I even going in the right direction? Print_r shows me the two results...so the offset should work. $regular_starts = array("Regular Show #1" => '2018-04-02 12:00:00', "Regular Show #2" => '2018-04-02 15:00:00'); $regular_ends = array("Regular Show #1" => '2018-04-02 15:00:00', "Regular Show #2" => '2018-04-02 18:00:00'); print_r($regular_starts); $special_starts = array("Special Show #1" => '2018-04-02 14:00:00'); $special_ends = array("Special Show #1" => '2018-04-02 17:00:00'); $r = 0; // regular $s = 0; // special $how_many_shows = count($regular_starts); while ($r <= $how_many_shows) { foreach ($regular_ends as $regular) { foreach ($special_starts as $special) { if ($special <= $regular) { echo "Show " . $special_starts[$s] . "starts BEFORE the end of the " . $regular_starts[$r] . "...a change needs to be made\n"; } $s++; } $r++; } } // end while
  14. The end times ARE in the database...but for the regular shows NORMAL end time. If there is a special show on that particular day, the start or end times will vary from the NORMAL time that's in the database. I haven't written any code...since I don't even know where I should start manipulating the times
  15. I work at a radio station. I have all of our shows in a database for displaying on the websites. We have regular scheduled shows...and then we have some specialty shows that air at ransom times. I have the list of regular shows that gets pulled into the database each night for the next day. After it pulls the regular shows in, it pulls the list of speciality shows (in a different table) in for the next day. Here's how it looks: Regular Show #1 is on 12pm - 3pm Specialty Show #1 is on 2pm - 5pm Regular Show #3 is on 3pm - 6pm I need it to read: Regular Show #1 is on 12pm - 2pm Specialty Show #1 is on 2pm - 5pm Regular Show #3 is on 5pm - 6pm All of the fields are datetime. I'm sure I could put all the start and end times into two arrays, compare the two to see if a start time is BEFORE the PREVIOUS shows endtime. If I did that, I'm having a hard time wrapping my head around the logic to back up one spot in the array, change the end time to be the same as the start time of the specialty show, and then find the start time of the next regular show...and change it to the end time of the specialty show. Is there an better way to do this? If not...how would I manage the logic of stepping thru the arrays? Thanks!
  16. I've finally had some time to work on this again. I've succesfully read the html into curl, and put the correct values into a string. Now, I need to put the string into an array with key => value. How can I turn this string... "LCL-Show02-2018-March23.mp3" => "4950301", "LCL-Show02-2018-March22.mp3" => "4950302" Into an array with where... $array_name['LCL-Show02-2018-March23.mp3'] will return 4950301 Thanks!
  17. I got to thinking...I hadn't looked at the whole source code of that file. The transfer_identifier is in the java script...as are the file id's for the whole page <script type="text/javascript">var transferData={"metadata":"","job_ticket_id":0,"who":"D_286577002_2640591309","transport":"TCP/IP Secure","host_addr":"192.223.7.72","host_port":"443","job_id":"","who_plus":"3153325650217078101","ssl_params":"Auto%2dGenerated+by+MassTransit%0a2%0a","force_forward_or_service":"","transfer_identifier":"2c9759cb130043816cf53c8621ee9b42","hideDownloadAllButton":"","totalFileSizeToSend":84265681,"totalFileSizeSent":5817819453,"tableStyle":0};var downloadFileList=[{"file_path":"","file_name":"Wk 03-12 topics.txt","file_status":"100","file_id":4941409},{"file_path":"","file_name":"LCL-Show02-2018-March12.mp3","file_status":"100","file_id":4941410},{"file_path":"","file_name":"LCL-Show02-2018-March15.mp3","file_status":"100","file_id":4941412},{"file_path":"","file_name":"LCL-Show02-2018-March16.mp3","file_status":"100","file_id":4941413},{"file_path":"","file_name":"LCL-Show01-2018-March13.mp3","file_status":"100","file_id":4941414},{"file_path":"","file_name":"LCL-Show01-2018-March16.mp3","file_status":"100","file_id":4941415},{"file_path":"","file_name":"LCL-Show01-2018-March12.mp3","file_status":"100","file_id":4941416},{"file_path":"","file_name":"LCL-Show02-2018-March12.mp3","file_status":"100","file_id":4941417},{"file_path":"","file_name":"LCL-Show02-2018-March13.mp3","file_status":"100","file_id":4941418},{"file_path":"","file_name":"LCL-Show02-2018-March15.mp3","file_status":"100","file_id":4941419},{"file_path":"","file_name":"LCL-Show01-2018-March15.mp3","file_status":"100","file_id":4941420},{"file_path":"","file_name":"LCL-Show02-2018-March16.mp3","file_status":"100","file_id":4941421},{"file_path":"","file_name":"LCL-Show02-2018-March14.mp3","file_status":"100","file_id":4941423},{"file_path":"","file_name":"LCL-Show01-2018-March16.mp3","file_status":"100","file_id":4941424},{"file_path":"","file_name":"LCL-Show01-2018-March13.mp3","file_status":"100","file_id":4941425},{"file_path":"","file_name":"LCL-Show02-2018-March14.mp3","file_status":"100","file_id":4941427},{"file_path":"","file_name":"LCL-Show01-2018-March14.mp3","file_status":"100","file_id":4941428},{"file_path":"","file_name":"LCL-Show02-2018-March13.mp3","file_status":"100","file_id":4941429},{"file_path":"","file_name":"LCL-Show01-2018-March12.mp3","file_status":"100","file_id":4941942},{"file_path":"","file_name":"LCL-Show01-2018-March15.mp3","file_status":"100","file_id":4941943},{"file_path":"","file_name":"LCL-Show01-2018-March09.mp3","file_status":"100","file_id":4941944},{"file_path":"","file_name":"LCL-Show01-2018-March14.mp3","file_status":"100","file_id":4941947},{"file_path":"","file_name":"LCL-Show02-2018-March09.mp3","file_status":"100","file_id":4941948}];$j(document).ready(function(){$G.transferLackey.handleOnReady(transferData,downloadFileList,5902085134);});</script> So, I'm thinking that I'll have to scrape the page to get this info...then pass the cookie via curl, and download the files. I think I have a plan. I'll report back.
  18. I have some files that I need to download for work. They are from a password protected web directory. Once I log in, I'm shown an HTML table with dates and files. Next to each file name is a checkbox. If a checkbox is checked, a DOWNLOAD SELECTED button is shown. Using the debugging features of Firefox, I see that the download is handled by these three urls: This form is POST, with the following params: https://domain.com/index.php?action=FileTransfer.download_selected_http selectedFiles 4941422 transfer_identifier 48b47cfda429980c8c41b50cb17774c8 useCompression true This form is GET https://domain.com/index.php?action=FileTransfer.get_http_status_messages&id=48b47cfda429980c8c41b50cb17774c8&_=1520995394437 and finally This form is GET https://domain.com/index.php?action=FileTransfer.get_http_status_messages&id=48b47cfda429980c8c41b50cb17774c8&_=1520995395434 If I need to scrape the html, here's the corresponding code in the html <tr id="4941422" class="DownloadFileList odd "> <td class="select aligncenter"><input type="checkbox" id="4941422" class="3363384" value="4941422" name="downloadFile" onClick="$G.transferLackey.updateDownloadControls();" /></td> <td >LCL-Show01-2018-March14.mp3</td> <td class="wrap_anywhere"></td> <td class="aligncenter">PMT1DSM</td> <td class="aligncenter">2018-03-08 06:00:05 PM</td> <td class="alignright">3285</td> <td class="UploadFileList-remove" wrap="nowrap"> <a href="#" onclick="$G.transferLackey.DeleteFileById(4941422, 'LCL-Show01-2018-March14.mp3', 3363384, 1);"><div class="removeIcon"></div></a> </td> </tr> And finally, here's the output of cliget addon for Firefox curl --header 'Host: domain.com' --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' --header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --header 'Accept-Language: en-US,en;q=0.5' --referer 'https://domain.com/index.php?action=FileTransfer.download_frame' --header 'Content-Type: application/x-www-form-urlencoded' --cookie 'PHPSESSID=abjnhmkq8034jg1f0lpnj90354; cookies_enabled=1; plugvercheck=0' --header 'Upgrade-Insecure-Requests: 1' --request POST --data-urlencode 'useCompression=true' --data-urlencode 'selectedFiles=4941941' --data-urlencode 'transfer_identifier=cee18c977b984073ae4f414e13fb654c' 'https://masstransit.meredith.com/index.php?action=FileTransfer.download_selected_http' --output 'mtdownload5539_2018.03.14_03.01.zip' Some of the params match the html code...many do not. What's my best method of trying to automate the downloads of these files? Or, is there a way to find an absolute download path / url of a file when a download script is used by the host website?
  19. I got it... echo "<table border= '1'>"; $html = str_get_html($_POST['stats']); $html->find("table"); foreach($html->find('tr') as $row) { echo "<tr>"; foreach ($row->find('td') as $content) { echo "<td>"; echo $content->plaintext; echo "</td>"; } echo "</tr>"; } echo "</table>";
  20. I have an application where a user copies and pastes into a form textbox some information from another site (which I don't control). This info is ALWAYS in html table form...but is horribly mangled with css and other info that the application doesn’t need. So, I thought to run the pasted data through simple_html_dom to get me just the contents of the table...and put it into a new table that's free of other formatting and such. Here's the code... $html = str_get_html($_POST['stats']); $html->find("table"); foreach($html->find('tr') as $row) { // start foreach table row echo "<tr>"; foreach ($row->find('td')->plaintext as $content) { echo "<td>$content</td>"; } echo "</tr>"; } If I echo the contents of $_POST['stats'], I get the full css'd table. Running through the 2 foreach statements...I get nothing echoed. Any ideas where I've gone wrong? Thanks!
  21. That class will work....thank you!
  22. 30 files in this directory
  23. All files are 128k constant. id3 tags are empty. That's how they're downloaded. I read that -k would force KB...but without it, $showsize was off from what right clicking the directory showed me for file size. Would it be better to get size of all files instead of directory size? Does du take into account the size of all files individually, or just the combined disk space used?
×
×
  • 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.