0

I've tried and it doesn't seem to work. Any help would be greatly appreciated.

CODE:

foreach (glob('mov/Alene*.mov') as $filename){ 
    $theData = file_get_contents($filename) or die("Unable to retrieve file data");
}

$string = $theData;
$titles = explode("\n", $string);

function getInfo($string){
    $Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX'];
    $split = preg_split("/\"(.+)\"/", $string, 0, PREG_SPLIT_DELIM_CAPTURE);
    if(count($split) == 3){ 
        preg_match("/(".implode("|", $Ratings).")\s/", $split[0], $matches);
        $rating = $matches[0];
        return ["title" => $split[1], "rating" => $rating];
    }
    return false;
}




$infolist = array();
foreach($titles as $title){
    $info = getInfo($title);
    if($info !== false){
    $infolist[] = $info;
    }
}

usort($infolist, "infosort");

function infosort($lhs,$rhs) {
  return strcmp($lhs['rating'], $rhs['rating']);
}

foreach ($infolist as $info) {
        echo "<div style ='margin-bottom: 3px; text-align: center;
          font:13px Verdana,tahoma,sans-serif;color:green;'> 
           {$info["title"]} : {$info["rating"]}</div>";
}


//------------------LOGO---------------------//

echo "<div style='text-align:center; margin-top: 20px;'><img src='imgs/shclogo.png'
alt='Logo' width='200' height='133'/></div>";

//-------------------------------------------//
?>

I've tried adding:

if($info["rating"]!=="XXX")//foreach $infolist as $info... 

I've also tried adding that in the source where preg_match is but that didn't work either. It all still displays the "XXX" titles.

I just need to figure out how to ignore the XXX titles and display everything else.

The output originally looks like this...

(HD) Safe House : R
(HD) Wanderlust : R
(HD) Machine Gun Preacher : R
(HD) Silent House : R
(HD) Seeking Justice : R
Adult title 1 : XXX
Adult title 2 : XXX
Adult title 3 : XXX
Adult title 4 : XXX

There are many more XXX titles, but I can't display them all. Any help and you'd be my life saver.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ValleyDigital
  • 1,460
  • 4
  • 21
  • 37
  • @UltimateProgrammer_BR Given that this appears to be a script for generating a list of pay-per-view titles available to hotel guests, or something of that general nature, I'm going to assume those titles don't signify quite what they appear to. – Aaron Miller Jun 10 '13 at 17:57
  • lol... you guys are crazy. – ValleyDigital Jun 10 '13 at 17:58
  • @AaronMiller: I'am not sure of this. – Casimir et Hippolyte Jun 10 '13 at 17:59
  • @CasimiretHippolyte Neither am I. But I'm here to provide programming support, not to engage in vigilantism. – Aaron Miller Jun 10 '13 at 18:01
  • @CasimiretHippolyte That said, I'd be tempted to take a quick poke at Google to see what I could find out about those titles, save that I'm at work right now, and regardless of whether our shared suspicion is justified, whatever search results those titles would elicit would be all but guaranteed to buy me a very unpleasant conversation with HR. – Aaron Miller Jun 10 '13 at 18:02
  • @DeveloperLooper That the word 'young', in the titles of the XXX-rated videos in your list, makes them look vaguely like child pornography. As I've said, I find it highly unlikely this is in fact the case, because your code makes it look like these titles are (potentially) being served to hotel guests, and it seems improbable in the extreme that any halfway sensible business would so jeopardize itself. Still, not a bad idea to edit out the filenames as I see you have just done, although even more thorough bowdlerization (i.e., ratings A-D, excluding D) might have been advisable as well. – Aaron Miller Jun 10 '13 at 18:14
  • @AaronMiller Oh, I see. Yes you are absolutely correct. Nothing illegal going on. Thank you for your help as well. – ValleyDigital Jun 10 '13 at 18:16

1 Answers1

0

After foreach ($infolist as $info) {, add:

if ($info['rating'] == 'XXX') { continue; };

This will skip over the XXX-rated titles before attempting to output anything for them, which should have the effect you desire.

Aaron Miller
  • 3,692
  • 1
  • 19
  • 26
  • that did not work either... It still lists all xxx titles even with that code added as you suggested... :/ – ValleyDigital Jun 10 '13 at 18:02
  • Perhaps you need to trim spaces from the rating values, or something like that? If the `rating` member of `$info` contains exactly `XXX`, then the provided code should work. – Aaron Miller Jun 10 '13 at 18:05
  • You might also try `if (preg_match('/XXX/', $info['rating'])) { continue; };` – Aaron Miller Jun 10 '13 at 18:05