Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. The answers were already written in the previous posts, but here is the code using PFMaBiSmAd's method <style type="text/css"> span.highlight {font-weight:bold;} </style> <h2><b>Definition of <?php echo "$word";?></b></h2> </td> </tr> <tr> <td cellpadding="5"> <?php echo preg_replace("/\b($word)\b/i",'<span class="highlight">\1</span>',$definition); ?> </center></br></br>
  2. Yup, that's a good way too PFMaBiSmAd A while back I made 2 different functions for a multi-word,multi-color highlighter demo and code In use at my random urls example
  3. a fast visit to here and look at the examples would better help to understand arrays http://php.net/manual/en/language.types.array.php when you place array(), that creates an array, to display an array it must loop the results, it looped them the first time in your while loop. If your goal is to make a new array, sort them or display elsewhere, then use $big_image[] = '<span><img src="https://alaskapac.centertix.net/UPLImage/' . $image . '" alt="' . $EventName. '" title="' . $EventName . '" id="wows'. $i .'" /></span>'."\n"; $nav_image[] = '<a href="#wows' . $i2 . '" title="'.$EventName.'"><img src="https://alaskapac.centertix.net/UPLImage/' . $image . '" alt="' . $EventName. '" />'.$i.'</a>'."\n"; then outside your while loop must do a foreach to get each array result echo '<div id="wowslider-container1">'."\n".'<div class="ws_images">'."\n"; foreach($big_image as $b_image){ echo $b_image; } echo '</div><div class="ws_bullets"><div>'."\n"; foreach($nav_image as $n_image){ echo $n_image; } echo '</div></div>'."\n".'</div>'; you could play around with your styles and dividers
  4. There's always an issue with case when replacing, they can replace any match it finds, but sadly would then replace with whatever case your search word was. Here is my solution. <?php function boldWord($word,$text){ $word = strtolower($word); $ucf_word = ucfirst($word); $uc_word = strtoupper($word); return str_replace(array($word,$ucf_word,$uc_word), array("<b>$word</b>","<b>$ucf_word</b>","<b>$uc_word</b>"), $text); } $text = "Let's replace car in the text, Car and CAR also replaces."; echo boldWord("car",$text); ?> Results: Let's replace car in the text, Car and CAR also replaces. If you don't care about the case, a simple str_ireplace would do. $text = "Let's replace car in the text, Car and CAR also replaces."; $word = "car"; echo str_ireplace($word, "<b>$word</b>", $text); or preg_match $text = "Let's replace car in the text, Car and CAR also replaces."; $word = "car"; $pattern = "/$word/i"; $replace = "<b>$word</b>"; echo preg_replace($pattern, $replace, $text); Results for both: Let's replace car in the text, car and car also replaces.
  5. There seems to be items missing from that tutorial. Don't foget to have a folder named upload in the same directory as this script is, or change your target path. pretty sure I added the essentials to this, also included a timestamp to the front of the file name so you don't have duplicate named files. <html> <body> <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> <?php if(isset($_POST['submit']) && !empty($_FILES["file"]["name"])) { $timestamp = time(); $target = "upload/"; $target = $target . basename($_FILES['uploaded']['name']) ; $ok=1; $allowed_types = array("image/gif","image/jpeg","image/pjpeg","image/png","image/bmp"); $allowed_extensions = array("gif","png","jpg","bmp"); if ($_FILES['file']['size'] > 350000) { $max_size = round(350000 / 1024); echo "Your file is too large. Maximum $max_size Kb is allowed. <br>"; $ok=0; } if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; $ok=0; } else { $path_parts = pathinfo(strtolower($_FILES["file"]["name"])); if(in_array($_FILES["file"]["type"],$allowed_types) && in_array($path_parts["extension"],$allowed_extensions)){ $filename = $timestamp."-".$_FILES["file"]["name"]; echo "Name: " . $filename . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; $path_parts = pathinfo($_FILES["file"]["name"]); echo "Extension: " . $path_parts["extension"] . "<br />"; echo "Size: " . round($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Stored in: " . $_FILES["file"]["tmp_name"]. " <br />"; } else { echo "Type " . $_FILES["file"]["type"] . " with extension " . $path_parts["extension"] . " not allowed <br />"; $ok=0; } } if($ok == 1){ @move_uploaded_file($_FILES["file"]["tmp_name"], $target . $filename); $file_location = $target . $filename; if(file_exists($file_location)){ echo "Uploaded to <a href='$file_location'>$filename</a> <br />"; } else { echo "There was a problem saving the file. <br />"; } } } else { echo "Select your file to upload."; } ?> You can use the file types with if/else or a switch statement and display a resized image if was an image, a link if was a file, an embed if audio or video, etc.... I just made it a hyperlink for simplicity.
  6. Well I'm not sure what that code does from https://github.com/hswong3i, but since are in the php forum, here's a way to do it. I tend to favor parse_url() , although are other methods. <?php //$url = "http://localhost/sandbox/token.php?grant_type=authorization_code&client_id=0123456789ab&client_secret=secrettest&code=3b186c90256fc572027a5eb7fb2e51f8&redirect_uri=/"; $url_path = end(explode("/",parse_url($url, PHP_URL_PATH))); echo $url_path."<br />"; $url_query = parse_url($url, PHP_URL_QUERY); echo $url_query."<br />"; if(preg_match("/&/",$url_query)){ $parameters = explode("&",$url_query); } else { $parameters[] = $url_query; } foreach($parameters as $parameter){ $value = explode("=",$parameter); echo "Request: " . $value[0] . " Value: " . $value[1] . "<br />"; } ?> Results would be: token.php grant_type=authorization_code&client_id=0123456789ab&client_secret=secrettest&code=3b186c90256fc572027a5eb7fb2e51f8&redirect_uri=/ Request: grant_type Value: authorization_code Request: client_id Value: 0123456789ab Request: client_secret Value: secrettest Request: code Value: 3b186c90256fc572027a5eb7fb2e51f8 Request: redirect_uri Value: /
  7. Some changes to the previous code, also added checking for extensions within the allowed mime types. <html> <body> <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> <?php if(isset($_POST['submit']) && !empty($_FILES["file"]["name"])) { $allowed_types = array("image/gif","image/jpeg","image/pjpeg","image/png","image/bmp"); $allowed_extensions = array("gif","png","jpg","bmp"); if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { $path_parts = pathinfo(strtolower($_FILES["file"]["name"])); if(in_array($_FILES["file"]["type"],$allowed_types) && in_array($path_parts["extension"],$allowed_extensions)){ echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; $path_parts = pathinfo($_FILES["file"]["name"]); echo "Extension: " . $path_parts["extension"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } else { echo "Type " . $_FILES["file"]["type"] . " with extension " . $path_parts["extension"] . " not allowed"; } } } else { echo "Select your file to upload."; } ?>
  8. Try something like this, add any allowed mime types in the allowed array. I also see the wrong type quotes in your code, try using an editor that does not convert quotes, notepad2 works great. The proper double quote is ", not “ or ” <html> <body> <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> <?php if(isset($_POST['submit']) && !empty($_POST['submit'])) { $allowed_array = array("image/gif","image/jpeg","image/pjpeg","image/png","image/bmp"); if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { if(in_array($_FILES["file"]["type"],$allowed_array)){ echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } else { echo $_FILES["file"]["type"] . " not allowed"; } } } else { echo "Select your file to upload."; } ?>
  9. Don't pretend to be google, be your browser, people know you are not google by the ip. Here is a few different methods, if need a different user-agent string, look them up for curl: curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'); in htaccess: php_value user_agent Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 within a php script: ini_set('user_agent', 'Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'); for file_get_contents you use the ini_set() above
  10. Checking and saving against their ip on every page load seems wasteful to me. Only reason I could see for saving their ip would be for banning purposes, which you could just ban them by username if that's the case. And if wanted to ban ip's, should use htaccess instead.
  11. something similar to this, you must change to your values I included the reference links for you to read It would be best to auto_increment the values http://dev.mysql.com/doc/refman/5.6/en/example-auto-increment.html here's a sample auto_increment create CREATE TABLE users ( id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, fname VARCHAR(255) ) if needed additional can modify the create or alter it later ALTER TABLE users ADD lname VARCHAR(250) <?php //a comma separated list $text_list = "john,mary,ken,mark"; //explode() http://php.net/manual/en/function.explode.php $text_array = explode(",", $text_list); //can also make the list as an array, will not need to explode it //$text_array = array("john","mary","ken","mark"); //create a mysql connection http://php.net/manual/en/function.mysql-connect.php $con = mysql_connect("localhost","mysql admin name","mysql password");//change to your admin credentials if (!$con) { die('Could not connect: ' . mysql_error()); } /*connect to database*/ mysql_select_db("database name", $con);//change your database name //foreach loop http://php.net/manual/en/control-structures.foreach.php //within the foreach an insert or create statement http://dev.mysql.com/doc/refman/5.6/en/insert.html foreach($text_array as $text){ mysql_query("INSERT INTO users (fname) VALUES ('$text')"); echo $text . " added <br />"; } //close the mysql connection mysql_close($con); ?> If it's really large lists, you can also use load data infile
  12. I'm sure can use a do-while loop Lower the number by 1 , or use the decrement operator , until get some results
  13. It would be best to download at least the trial version of Flash8 and make the changes required. If you did save it to work in FlashMX, it could lose any functionality that the newer Flash8 provides. You can only save Flash 8 FLAs to one prior version, which is Flash MX 2004, by doing a File | Save As Then would have to repeat the same process to make it from Flash MX 2004 to Flash MX
  14. Most developers have niches or are more skilled at certain aspects of websites, such as design, plugins, custom coding, management, optimization, different frameworks,etc... Learning everything about wordpress would for sure be a daunting task. Be aware it's constantly changing code, which may benefit you in some way, but must keep up with them in what you develop. Familiarize yourself with different popular cms's out there and concentrate on your current abilities to integrate them. I guess you should first make yourself a site, show off some of your work, and try to get the ball rolling. Lastly, I know money is important, but if the girl requires you to have money, she's not the one for you. There are plenty out there just seeking love and companionship.
  15. I tried phpcake a very long time ago, I found the tutorials to be not that hard to understand. Try following the tutorials at the left here, or try this blog tutorial. http://book.cakephp.org/view/1528/Blog Once you get the Model-View-Controller methods down, you will find it easier as you do more with it. You can have a dynamic site with no static pages using procedural or object oriented php without a framework such as cakephp,zend. Use of include() for files,pages or templates along with css style, dynamic content to display based on different php code. You can make this as simple or as difficult depending on your skill level and future goals. You may also want to look into using a template engine such as smarty
  16. <table border="1" ALIGN="center"> <tr> <td>Filters<p><a href="?cat=filter1">•Filter1</a><br>• Filter2<br>•Filter3</td> <td><table cellspacing="3" cellpadding="3"> <?php error_reporting(E_ALL); include ("includes/db_config.php"); mysql_connect($db_hostname,$db_username,$db_password); @mysql_select_db($db_database) or die( "Unable to select database"); if(isset($_GET['cat']) && !empty($_GET['cat'])){ $escape_cat = mysql_real_escape_string($_GET['cat']); $query="SELECT * FROM `shaun` WHERE `cat` ='".$escape_cat."'"; }else{ $query="SELECT * FROM `shaun`"; } $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product if($pro_name != "" && $pro_name != null) echo "<td><a href=\"detalis.php?id=$id\"><img src=\"/project/thum/$thumbnail\" alt=\"$thumbnail\" height=\"150\" width=\"150\" /><br>$pro_name<br></a>$short_details $cat</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0){ for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>';} ?></table></td> </tr> </table> you can also set up a default category if none is in the url $escape_cat = mysql_real_escape_string($_GET['cat']); if(!isset($_GET['cat']) || empty($_GET['cat'])){ $escape_cat = "cars"; } $query="SELECT * FROM `shaun` WHERE `cat` ='".$escape_cat."'";
  17. That site is using ajax to display the results, basically you need to interpolate the same way as in a browser does it. Using php along with curl will not do that. Also, you should have the sites permission to obtain their content.
  18. you are correct, but that is an awful lot of ip's to block should try to stay with specific ranges that are only causing you problems something like 31.144.202. or at an extreme do 31.144.
  19. That's most likely your best solution. Load the data into mysql using a local version of wamp/xampp or whatever package you use. Increase the limits for timeout and size on your local install to accomplish your goal. Once you have the data loaded into database, you can export, then import one table at a time into a new database at your server. I've even just copied the MySQL/data/database_folder_name files from the folder, then do a repair on the tables.
  20. good point, was trying to keep it simple whichever way that works is good but personally, I think it's better to block them at the front door through htaccess with a code similar to this ## IP BANNING <Limit GET POST> order allow,deny deny from 42.12.5.34 deny from 193.110.145.185 deny from 212.173.53. deny from 69.242. allow from all </Limit>
  21. changed it a little <?php $ip = $_SERVER['REMOTE_ADDR']; $explode_ip = explode(".",$ip); $iprange2 = $explode_ip[0] . "." . $explode_ip[1]; $iprange3 = $iprange2 . "." . $explode_ip[3]; $data = file('bad_ips.txt');// no file extension? foreach ($data as $line) { $banned_ips[] = trim($line); } if (in_array($ip, $banned_ips) || in_array($iprange2, $banned_ips) || in_array($iprange3, $banned_ips)) { header("location: http://www.google.com/"); } else { header('location:index1.php'); } ?>
  22. I don't see the correct logic in your code, it's checking each ip in the list, so only the first one checked ...it will take you to that header location. try this <?php $ip = $_SERVER['REMOTE_ADDR']; $explode_ip = explode(".",$ip); $iprange2 = $explode_ip[0] . "." . $explode_ip[1]; $iprange3 = $iprange2 . "." . $explode_ip[3]; $file=file('bad_ips');// no file extension? if (in_array($ip, $file) || in_array($iprange2, $file) || in_array($iprange3, $file)) { header("location: http://www.google.com/"); } else { header('location:index1.php'); } ?> I forgot to add.... just use ranges like 2.2 or 2.2.2 in your list
  23. I don't feel a few extra zero's would fill up your storage space.
  24. Ahh, good find Pikachu2000, I never scrolled that far down the code.
  25. If your breaks are saved in database use nl2br() if you need to add a break manually in php code do similar to this $newstitle = $rows['title'] . "<br />";
×
×
  • 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.