GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Assistance... How Do I Do This Please? (https://gfy.com/showthread.php?t=1085524)

Webmaster Advertising 10-16-2012 09:23 AM

PHP Assistance... How Do I Do This Please?
 
Lets say i have an index.php file and 2 lists of words for example;

List One:

Red
Blue
Green
Yellow

List Two:

Cats
Dogs
Birds
Fish

How would i go about dynamically changing the content to automagically insert combinations of both lists in specific areas of the index.php page so it changes like below:

This page is about selling Red Fish
This page is about selling Blue Fish
This page is about selling Green Fish
This page is about selling Yellow Fish

Or;

This page is about selling Red Dogs
This page is about selling Blue Dogs
This page is about selling Green Dogs
This page is about selling Yellow Dogs

Using all combinations of words in list 1 as the primary word and list 2 as the secondary word?

Would it be something like this...

Code:

<?php
 if ($_GET['list1'])
if ($_GET['list2'])
 {echo htmlentities($_GET['list1']);}
{echo htmlentities($_GET['list2']);}
 else
 {echo ucwords("Colored Animals");}
 ?>

So i could link:

domain.com/?list1&list2

Does that make sense to any of you who are technically inclined?

Basically, i want to generate a list of URL to throw in a site map and have the page dynamically show whatever 'phrase' based on list1 and list2 the url contains.

helterskelter808 10-16-2012 09:36 AM

Quote:

Originally Posted by Webmaster Advertising (Post 19255392)
Basically, i want to generate a list of URL to throw in a site map and have the page dynamically show whatever 'phrase' based on list1 and list2 the url contains.

Then you don't need a list. All you need to do is display whatever values are in the request on the page. Something like:

Code:

<?php

$color = $_GET['color'];
$animal = $_GET['animal'];

echo 'This page is about '.$color.' '.$animal;

?>

Would produce:

This page is about Red Dogs

When you visited:

yoursite.com/?color=Red&animal=Dogs

Edit: Obviously you'd need to perform sanitization to protect against malicious requests.

helterskelter808 10-16-2012 10:03 AM

http://christophercummings.com/image...rekTTWT8-a.jpg

KillerK 10-16-2012 10:05 AM

I normally do it as

$colors = array("Red","Blue","Green","Yellow");
$pets = array("Cat","Dog","Bird","Fish");

$color = $colors[array_rand($colors)];
$pet = $pets[array_rand($pets)];

print "The Color of the " . $pet . " is " . $color . "!";

ProG 10-16-2012 10:11 AM

I think you guys missed the "Using all combinations" part

Code:

// URL http://www.domain.com/?colors[]=Red&colors[]=Blue&colors[]=Green&colors[]=Yellow&animals[]=Fish&animals[]=Dogs

parse_str($_SERVER['QUERY_STRING'], $values);
foreach($values['animals'] as $animal) {
        foreach($values['colors'] as $color) {
                echo "This page is about selling " . $color . " " . $animal . PHP_EOL;
        }
}


helterskelter808 10-16-2012 10:19 AM

Okay, LIMIT 1. But something's still not quite right...

http://dvdmedia.ign.com/dvd/image/gremlins2_03.jpg

(I hope the OP appreciates the effort being put in here.)

Webmaster Advertising 10-16-2012 10:24 AM

Quote:

Originally Posted by helterskelter808 (Post 19255407)
Then you don't need a list. All you need to do is display whatever values are in the request on the page. Something like:

Code:

<?php

$color = $_GET['color'];
$animal = $_GET['animal'];

echo 'This page is about '.$color.' '.$animal;

?>

Would produce:

This page is about Red Dogs

When you visited:

yoursite.com/?color=Red&animal=Dogs

Edit: Obviously you'd need to perform sanitization to protect against malicious requests.

Ah okay (on not needing a list for the actual colors and animals).

Id still need a list of combinations ?color=Red&Animal=Dogs though to include in the sitemap.xml file though.

As far as the sanitization goes, do you know if its possible to have 'exclusion words' in the code you posted above or would that be something different?

Thanks everyone for their assistance (and the funny pics :thumbsup)

Webmaster Advertising 10-16-2012 10:26 AM

Quote:

Originally Posted by helterskelter808 (Post 19255514)
Okay, LIMIT 1. But something's still not quite right...

http://dvdmedia.ign.com/dvd/image/gremlins2_03.jpg

(I hope the OP appreciates the effort being put in here.)

What happens if you add &echo=H2O to the code that produced that?

sarettah 10-16-2012 02:01 PM

Quote:

Originally Posted by Webmaster Advertising (Post 19255534)
What happens if you add &echo=H2O to the code that produced that?


$gremlin_parts=explode(" ",$gremlin);

helterskelter808 10-16-2012 04:28 PM

Quote:

Originally Posted by Webmaster Advertising (Post 19255532)
Ah okay (on not needing a list for the actual colors and animals).

Id still need a list of combinations ?color=Red&Animal=Dogs though to include in the sitemap.xml file though.

As far as the sanitization goes, do you know if its possible to have 'exclusion words' in the code you posted above or would that be something different?

Thanks everyone for their assistance (and the funny pics :thumbsup)

Sorry, I didn't see the part about the sitemap when I replied. Not sure what you mean by exclusion words. If you mean words you don't want in the request, if there's a specific list of words you'll accept, just check against those, and if the word isn't one of them, reject it. Or, if there's an unknown number or type of 'word' you'll accept, reject the word based on regular expressions. Like, reject anything that's not ascii letters of 3-12 characters or whatever.

amateurcanada 10-16-2012 09:05 PM

<? echo "hello world"; ?>


All times are GMT -7. The time now is 02:25 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123