PHP - : : How To Format Loads Of Words
Hi there,
I have a HUGE list of inappropriate words in plain text, but the thing is, I want to use these bad words in an array. But I can't just copy and paste the bad words into the array, as each bad word needs to have two apostraphes aside one another. E.g the array should be: Code: [Select] $bad_words = array('badword1','badword2','badword3'); but my text document just has: badword1 badword2 badword3 How do I format the bad words to have apostraphes aside each other? I don't want to manually go through each word. Thanks Similar TutorialsI know it is an "if" statement, but I am struggling with a simple issue. I want to format specific words, like a keyword. (ex: <b>Open</p>, if that word is contained in my ".$data['status']." field of the database ".$db_prefix."fieldstatus. Code: [Select] $sql = dbquery( "SELECT * FROM ".$db_prefix."fieldstatus ORDER BY fieldstatus_id ASC" ); if (iADMIN) echo "<center><a href='".MODS."fieldstatus_panel/fieldstatus_admin.php'>".$locale['imp135']."</a><br><br></center>"; if (dbrows($sql)) { $i = 0; echo "<table width='100%' cellpadding='0' cellspacing='1'>\n"; while ($data = dbarray($sql)) { echo "<tr><td valign='top'><font size='1' color='#db3026'><b>".$data['fields']."</b> is </font><font size='1'>".$data['status']."</font></td></tr><tr> </tr>\n"; } echo "</table>\n"; } else { echo "<center><br>\n".$locale['imp141']."<br><br>\n</center>\n"; } Any suggestions would be greatly appreciated.
Hello All, function convertTimeFormat($time12Hour) { // Initialized required variable to an empty string. $time24Hour = ""; // Used explode() function to break the string into an array and stored its value in $Split variable. $Split = explode(":",$time12Hour); // print_r(explode (":", $time12Hour)); => Array ( [0] => 09 [1] => 50 [2] => 08AM ) // Retrieved only "hour" from the array and stored in $Hour variable. $Hour = $Split[0]; $Split[2] = substr($Split[2],0,2); // Used stripos() function to find the position of the first occurrence of a string inside another string. if($Hour == '12' && strpos($time12Hour,"AM")!== FALSE) { // Code here } elseif(strpos($time12Hour,"PM")!== FALSE && $Hour != "12") { // code here } return $time24Hour; } $time12Hour = "09:50:08AM"; $result = convertTimeFormat($time12Hour); print_r($result); /* Input : "09:50:08AM"; Output : "21:50:08PM"; */
Hi all, I am currently making a website that has e-custom functions and a back end for the client. I want them to be able to upload images - but they need to be transparent. I do not want to leave this in the hands of the client, so I am looking at ways of using the GD library to make the change I got no issue with the png/gif type for upload/resize function since this type already transparent background but my major problems is how to deal with jpeg/jpg image type which is their background was not a transparent...so is it possible I can change/ convert to png/gif type upon successful of uploading image...so the new final image will be png/gif type with transparent background...is it doable...I am not even sure it is possible...? Thanks for any help.. Heya guys The other day i got the error: [28-Jan-2011 12:07:40] PHP Warning: POST Content-Length of 16970062 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 Basically this means my server provider doesn't allow the total $_POST data on one page to be above 8MB, and being on shared hosting i cannot fix this So, whats the best way to get around this? Ajax? Options and code samples please I think this will help a lot of people as i haven't seen many answers after lots of research on the web. Thanks Danny. This is my code [Page where user uploads files -Edit-Page.php] <?php session_start(); if ($_SESSION['adminlogin'] == 1){ //Run } else { header('Location: Log-In.php'); exit; } $url = $_POST['url']; ?> <!DOCTYPE HTML> <html lang="en-GB"> <head> <meta charset="utf-8"> <!--Search Engine Meta Tags--> <meta name="author" content="Worldwide Lighthouses"> <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel"> <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships"> <!--Stylesheets/Javascript--> <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)"> <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)"> <!--Mobile Browser Support--> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <!--IE Support--> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]--> <meta name="application-name" content="Worldwide Lighthouses"> <meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> <meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> <meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> <meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> <meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> <meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico"> <title>Edit Page | Worldwide Lighthouses</title> <script> <!-- function fixForm(select) { var inputCount = parseInt(select); var newHTML = ''; for(i=1; i<=inputCount; i++) { newHTML += '<label>Thumbnail '+i+' | Size: 200px x 430px | Format: PNG</label>\n'+ '<input type="file" name="thumbnail'+i+'" size="100" accept="image/x-png" class="File">\n'+ '<label>Accompanying Large Image | Size : Large | Format: PNG</label>\n'+ '<input type="file" name="large'+i+'" size="100000000" accept="image/x-png" class="File"><br><br>\n' ; if(i < inputCount) { newHTML += '<br>\n\n'; } else { newHTML += '\n\n'; } } document.getElementById('formInputs').innerHTML=newHTML; } //--> function setVisibility(id, visibility) { document.getElementById(id).style.display = visibility; } </script> <style> input:focus, textarea:focus { background:#9CDCCB; } form#Page { width:80%; margin-top:10px; margin-bottom:10px; margin-left:auto; margin-right:auto; background-colour: rgb(33, 33, 33); /* The Fallback */ background: rgba(33, 33, 33, 0.8); border-radius:10px; padding:20px; } label { display:block; width:100%; color:#FFF; } .TitleInput { width:660px; } .info { width:260px; height:80px; } .url { width:660px; } #IntroParagraph{ width:660px; height:120px; } #MainParagraph{ width:660px; height:240px; } .File { width:660px; } #loading { position: fixed; top: 25%; left: 25%; width: 50%; height: 50%; background:url(../../layout-resources/article-background.jpg); border:3px #333 solid; border-radius:10px; text-align:center; color:#1D5A4B; display:none; } #loadinginfo { position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; } </style> </head> <body> <div id="loading"><div id="loadinginfo"><img src="upload.gif" width="128" height="15" alt="Uploading"><br><h1>Uploading images...</h1><p>Please Wait, this could take a while.</p></div></div> <header> <h1 id="WWLH">Worldwide Lighthouses</h1> <form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box"> <input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off"> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> </header> <nav> <ul id="Nav"> <li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li> <li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li> <li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li> <li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li> <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li> <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li> <li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li> </ul> </nav> <?php if ($_SESSION['adminlogin']==1) { echo '<div id="logout"> <div style="float:left; width:30%; text-align:left;!important"> <a href="Log-In-Accept-Deny.php">Back to Admin Home</a> </div> <div style="float:right; width:70%;"> <a href="Logout.php">Log Out of Admin</a> <p style="font-size:10px;">Always Sign Out when Finished!</p> </div></div>';} ?> <article> <h1 class="Title">Enter Page Information</h1> <div class="Textbox"> <form action="Preview-and-Confirm-Page-Changes.php" enctype="multipart/form-data" method="post" id="Page"> <input type="hidden" value="<?php echo $url ?>" name="url"> <label>Type of Page</label> <br> <input type="radio" name="typeofpage" value="englandtrinityhouse" checked> English - Trinity House <br> <input type="radio" name="typeofpage" value="englandprivate"> English - Privately Owned <br> <input type="radio" name="typeofpage" value="welshtrinityhouse"> Welsh - Trinity House <br> <input type="radio" name="typeofpage" value="welshprivate"> Welsh - Privately Owned <br> <input type="radio" name="typeofpage" value="northernlighthouseboard"> Scottish - Northern Lighthouse Board <br> <input type="radio" name="typeofpage" value="scottishprivate"> Scottish - Privately Owned <br> <input type="radio" name="typeofpage" value="channelislandstrinityhouse"> Channel Islands - Trinity House <br> <input type="radio" name="typeofpage" value="channelislandsprivate"> Channel Islands - Privately Owned <br> <input type="radio" name="typeofpage" value="francelb"> French - Lighthouse Board <br> <input type="radio" name="typeofpage" value="franceprivate"> French - Privately Owned <br> <input type="radio" name="typeofpage" value="switzerland"> Switzerland <br> <input type="radio" name="typeofpage" value="norway"> Norway <br> <input type="radio" name="typeofpage" value="lightshiptrinityhouse"> Lightship - Trinity House <br> <input type="radio" name="typeofpage" value="lightshipprivate"> Lightship - Private <br> <br> <label>Folder Name (Usually title of page with hyphens eg. Beachy-Head) Just provide the last section</label> <input type="text" name="foldername"> <label>Title of Page<br>(eg.Beachy Head Lighthouse. Dont Include | Worldwide Lighthouses, this is automatically added)</label><input type="text" placeholder="Title of Page" name="title" class="TitleInput"><br><br> <input type="hidden" name="MAX_FILE_SIZE" value="100000000000000000000000000000" /> <label>Main Page Image | Size: 170x170px Format:PNG</label><input type="file" name="mainpageimage" size="100" accept="image/x-png" class="File"><br><br> <h2>Information</h2> <label>Date Established:</label><input type="text" placeholder="Date Established" name="established" required="true" class="TitleInput"><br> <label>Current Lighthouse Built:</label><input type="text" placeholder="Date Current Lighthouse Established" name="currentlighthousebuilt" required="true" class="TitleInput"><br> <label>Height (In Metres, Will automatically convert to show feet and metres on same page)</label><input type="number" placeholder="Heigtht in metres" name="height" required="true" class="TitleInput"><br> <label>Date Automated:</label><input type="text" placeholder="Date Automated" name="automated" required="true" class="TitleInput"><br> <label>Date Electrified:</label><input type="text" placeholder="Date Electrified" name="electrified" required="true" class="TitleInput"><br> <label>Range (In Nautical Miles):</label><input type="number" placeholder="Range in Nautical Miles" name="range" required="true" class="TitleInput"><br> <label>Operator:</label><input type="text" placeholder="Operator" name="operator" required="true" class="TitleInput"><br><br> <h2>Media</h2> <label>Link to Video Page: (if none leave blank)</label><input type="url" name="video"> <label>Link to Audio Page: (if none leave blank)</label><input type="url" name="audio"> <h2>Write up</h2> <label>Paragraph:</label><textarea id="MainParagraph" name="paragraph"></textarea> <h2>Thumbnails</h2> <label> Number of Thumbnails </label> <select name="numberofthumbnails" onChange="fixForm(this.options[selectedIndex].text);"> <option value="0">0</option> <option value="2">2</option> <option value="4">4</option> <option value="6">6</option> <option value="8">8</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="16">16</option> <option value="18">18</option> <option value="20">20</option> <option value="22">22</option> <option value="24">24</option> </select> <br><br> <span id="formInputs"> </span> <input type="submit" value="Preview Page" onClick="setVisibility('loading', 'block');"> </form> <?php if ($_SESSION['adminlogin'] == 1){ echo "<br>Logged in on server side."; }?> </div> </article> <footer> <ul> <li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li> <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li> <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li> <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li> <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li> <li><a href="#Top">Back to top</a></li> </ul> <br> <br> &#169; Worldwide Lighthouses <?php echo date("Y"); ?> </footer> </body> Code: [Select] <!-- The Input Form --> <form action="changemail_script.php" method="POST" > <input type="text" name="new_email" /> <input type="submit" name="submit_new_email" value="Submit" /> </form> When I have it as above, and I click submit, then the form loads the script itself and since the database connection variables are included into the header it will not work anymore. Any ideas why it does that? Should rather just include the script file and simply leave the action field empty, or do you have a better suggestion? Let's say I'm requesting a 5 megabyte data file with cURL. I want to echo it for the user as it gets downloaded with cURL. Is there any way to do this? I'm also just using cURL as an example, it could be file_get_contents(), or something else as well. Thanks! Hi All. I have been really struggling with this for a while! When a URL loads I wish to load with parameters entered & those parameters entered on a page but cannot get my head round it. Any help will be much appretiated... So when a user navigates to www.test.com/page.php I wish to to actually pull back www.test.com/page.php?term=&submit=Go Any help will be really really appretiated. Hello,
I've made a function that contains the html header (<head>). When I call that function in a other file, with the header file included, it puts the header function in the body. So all the meta tags are in the body, instead of the head.
Would it be possible to load this all in the head?
The head function does contain the html and head tags. However, without them, it still doesn't want to go to the head.
I've been trying to do this for a while and can't understand why I'm getting a 503 Error. I'm making a download center which counts the downloads of each file, and the only thing I can't get to work is the actual downloading of the file. It took a while for me to realize I was having an issue as my code works perfectly on my home server.
Here is my current code:
function download_file_to_user($target_file, $filename) { Hey guys, need some help real quick. I'm using this walkthrough over at css-tricks, some might be familiar with it by now? Anyway, I've followed the instructions exactly. It's supposed to display a simple form that you fill out and submit, which then updates the MYSQL database. However, whenever i load display.php in my browser, all i get is a blank page, and there are no notifications or errors to be in seen in the console. Any help is greatly appreciated. Thanks! Here's my code: SimpleCMS.zip 3.7KB 0 downloads display.php <!DOCTYPE html> <html lang="en"> PHP 2.11.10 I have a php page that loads. It takes about 4-5 seconds because I am constructing a select/combo box with 2400 records. While the whole page is loading I would like to make the cursor an hourglass while the cursor is over the PHP page, so the user cannot click on anything until the page is done loading. During production I expect 10,000 records in this combo box so disabling user input while the page is loading becomes more important. How do I do that? : : NEW Problem I want to replace bad words which someone has inputted into my HTML textarea, with something like [CENSORED]. Here's what I've got so far: note: $review is the posted textarea name. Code: [Select] $words_text = 'badwords.txt'; $bad_words = file($words_text); $good_words = str_ireplace($bad_words,'[CENSORED]',$review); echo $good_words; The thing is, if I type bad words in the textarea, I still get bad words when I echo $good_words. I don't know why I'm getting this, any ideas Hello dear friends, I've an idea so let us say we have paragraph with bad words Code: [Select] $para = "Hello shit oh shit what the hell this is shit day"; Now let say we create textarea Code: [Select] <textarea id="badword" name="badword"> </textarea> and let us say we have database table as following Code: [Select] CREATE TABLE `banned` ( `id` varchar(50) NOT NULL default '', `badwords` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; consider we have connetion and can update mysql table badwords 1- now how we can enter word per line in this textarea example we entered in this textarea per line shit hell die death then by click on submit it stored in an database table 'banned' as INSERT INTO `banned` VALUES ('1', 'shit,hell,die,death'); 2- if we called `badwords` from table 'banned' how then can put 'shit,hell,die,death' into array so we can exclude it from $para can someone please help me in this , how to store textarea per line as sperated words in database table and how then call it back as array to exclude it form our paragraph Or it there any other simple way doing the same thank you Hi there, I'm making an online clothing store for the brick and mortar shop we have and would like the customer to be able to refine their search by size, colour etc. The size options will be XS, S, M etc etc where XS is 0, S is 1 and so on. So when they select XS it will add ?size=0 to the URL, if they select XS and S it will be ?size=0;1 What I need to know is how to make some PHP code which can recognise the ; is a break and know that both sizes are selected. Hope that makes sense and thanks in advance Hi, having a really strange problem, i have a form like this: <form method='post' action='addcart.php'> echo $name //prints both parts of name separated by space <input type='hidden' value='$name' name='na' and then in the addcart.php echo $_POST['na'] //only prints first half of name So for example, if $name was "Product One" when i print the value in first script it prints Product One fine but when i print in the other script it only prints "Product". This then leads onto only half the name being copied into a database. I'm sure this was working fine before, not sure what the problem here is... I would like to get all words from a site in a array. I found this great thing: http://simplehtmldom.sourceforge.net/ however it makes use of: file_get_contents which gives me: Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in And my hosting doesn't allow a change for that, they tell me to use curl. With curl i get this: Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in It's caused by this line: curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); But setting it to 0 cause then instead of getting the word from the page i want i get the following words in a array: 302 Moved The Document has moved here What can i do now? hi, now i have something like this: $pizza = "piece1 piece2 piece3 piece4"; $one_word = explode(" ", $pizza); but i want to get 2 words together, like that: $two_words[0]='piece1 piece2'; $two_words[1]='piece3 piece4'; $two_words[2]='piece2 piece3'; $two_words[3]='piece1 piece4'; if it's impossible with explode, then it's fine if you use some other function, i don't care as long as it works. thank you, tastro I'm pretty sure the problem is starring me in the face, but I can't seem to locate it. function filter($string) { //swear words pulled from bannedwordlist.com $f = fopen('../badwords.txt', 'r'); $bad_words = fread($f, filesize('../badwords.txt')); $bad_words = explode('\n', $bad_words); $input = strtolower($string); foreach($bad_words as $value) { $string = str_replace($value, '****', $input); } return $string; } UPDATED CODE function filter($string) { //swear words pulled from bannedwordlist.com $f = fopen('../badwords.txt', 'r'); $bad_words = fread($f, filesize('../badwords.txt')); $bad_words = explode('\n', $bad_words); $input = strtolower($string); $string = str_replace($bad_words, '****', $input); return $string; } I've already echoed out $value in the foreeach loop, and it does correctly retrieve the bad words and put them into an array. My only problem is, the returned string is still in strtolower() form, and the words aren't censored. :/ I'm trying to pull in data using a particular word from a mysql db (it's like a search facility). But this code only picks if the db has got the exact same word. E.g. if fincom = "DALLS" it pulls the data only when "searchwords" has DALLS. It ignores if "searchwords" has BARBIE DALLS. How can I fix this. I need to pick all records which contains the search word 'fincom' anywhere in searchwords. Hope this makes scene. $SomeVar = $_POST['fincom']; $query = "SELECT * FROM news_home WHERE searchwords = '".$SomeVar."' ORDER BY timestamp DESC"; $results = mysql_query($query); hi folks, i have a variable in which some common words are stored and another variable in which a sentence is stored. I want to remove the common words from the sentence> Is there any way of doing this in PHP? Code: [Select] <?php $common_words = "to, this, all, the, from"; $sentence = "I want to remove all the common words from this sentence"; ?>the final output should be: "I remove common words sentence." |