noexcal Posted February 24, 2008 Share Posted February 24, 2008 Alright on my site people can post "widgets" I want to search these inputs for certain urls. Right now it takes all embed codes and does this <embed src="blah.swf"> turns to <embed enableJSURL="false" enableHREF="false" saveEmbedTags="true" allowScriptAccess="never" allownetworking="internal" src="blah.swf"> What I want to do, is have a white list. the white list will look something like 'youtube.com' 'myflashfetish.com' and I want the regex to check the src="blah.swf' so if the regex saw <embed src="youtube.com?v=3242"> or <embed src="myflashfetish.com/somethingstupid.swf"> it would ignore it. but if it saw anything else it would do the replacing. Link to comment https://forums.phpfreaks.com/topic/92690-embed-urls-search-and-replace/ Share on other sites More sharing options...
ucffool Posted February 24, 2008 Share Posted February 24, 2008 You could write the regex with a PHP variable called $whitelist, that is stored in your database. Basically, taking entries in the database, processing the mysql output into an array, then impoding the array into $whitelist with the | as the delimiter. DB: id - site 1 - youtube 2 - break $whitelist_array = array(); $query = "SELECT site FROM whitelist"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)): $whitelist[] = $row['site']; endwhile; $whitelist = implode('|',$whitelist_array); if (eregi("($whitelist)", $user_input_trimmed)){ // allow it } And yes, in the above example, I could have used mysql_fetch_result to be more efficient, just made a choice. Link to comment https://forums.phpfreaks.com/topic/92690-embed-urls-search-and-replace/#findComment-475286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.