Jump to content

digibucc

Members
  • Posts

    142
  • Joined

  • Last visited

Everything posted by digibucc

  1. i'm not exactly sure what this line is meant to be: $url = ($_SERVER['REMOTE_ADDR'] != "127.0.0.1") ? ; it looks like an attempted ternary operator, but it is incomplete and makes no sense in the way $url is used below. i changed it to this: $url = $_SERVER['REMOTE_ADDR']; also, did you listen to gristoi and change http_post_vars to _post? $origem = $_POST["origem"]; $nome = $_POST["nome"]; $telefone = $_POST["telefone"]; $email = $_POST["e_mail"]; $informacao = $_POST["informacao"];
  2. your order is wrong, the to email comes first. <?php mail($email, $subject, $fname);
  3. i haven't figured it out yet, but since you declared $images anyway, use it on this line instead of $_FILES: any difference? if everything else works and all you need is the uploaded filename, why not use <? $_POST['image_field_name_from_form'];
  4. how automatic? if you want it immediately after entering it into the box, it will require javascript and be much more complicated. if you want it after the submit button, then it just needs php and you can use php's curl function to accomplish what you want. the piece of code you show needs the info already, where is the address entered by a user, and where is the code that that form uses for an action?
  5. ok? do you have any code to be modified? everything you are talking about can be done, but personally i'm not going to type it out from scratch.
  6. The best way would be to use google's own api made for this: https://developers.google.com/custom-search/json-api/v1/overview the free edition will contain ads. another alternative: http://stackoverflow.com/questions/9392818/i-want-to-curl-google-search-result-in-php
  7. php curl here's a little function i wrote for simple queries, adapted for you: // Functions function docurl($data, $posturl) { $ch = curl_init($posturl); curl_setopt_array($ch, array(CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $data, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1,)); $Rec_Data = curl_exec($ch); return $Rec_Data; } $result = docurl('?field1=a&field2=b', 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8'); with this, you will get the html of the resulting page into the $result variable. you can echo/print/dump that to just print the page, or you can parse the data for the specific info you want. good luck.
  8. i am not seeing a problem with your expected outcome. i'd do it a little different but that's normal, long story short i copy/pasted/uploaded and added my ip to bannedips.txt, it it prints: sooo... yeah.
  9. I don't know that table structure just looks messy to me, however my mysql skills are not top notch
  10. with the current structure and what you need to do, it's a pita, you actually have to compare 3 columns right now, name ,entry & results. I would change the db/table structure, make it: NAME | ENTRIES | RESULT | ID and have ID be an auto-incrementing primary key. then in the results field, you want to put "serialized array" with each result. then when a user enters a value it would unserialize that array, add the value to it, and then serialize and insert the whole thing. that way your data is ready to use, you just pull the row and it will have a name & entry, run an if on each entry and then unserialize it's results field and you can use count() on the resulting array. that makes the code simpler and it's more efficient, no need to check the name on every entry if they are all tied to the name specifically.
  11. Ok, I can throw actual code here but it's all rather long, so i am going to give an example: <?php $max = 10; // max runs per exec $arr = array_fill(0, 50, 0); $last = file_get_contents('last.txt'); $n = 0; echo 'left off on '. $last; while ($n < $max) { foreach ($arr as $k => $v) { if ($k > $last) { // do something with the value ($v) $n ++; } } } file_put_contents(last.txt, $k)); ?> <meta http-equiv="refresh" content="3"> this isn't anything i use, but i do something similar when i want to save where i left off in a program to come back to later. that way if the program crashes or i have to close it, i haven't lost my place. this is normally when working with database records. it makes it run incrementally and as i said save it's place to return to. it just feels wrong though, and i'm sure it is. especially the refresh. what is the best way to do this? I would use array_slice instead of if ($k > $last), but that is normally comparing row values from a db, so i can't just arbitrarily slice that.
  12. thank you neil, i did not know that.
  13. the issue i foresee is that question marks are used in code as well, namely addresses but they could appear elsewhere. you want to change the visible question marks but not any that are strictly code...
  14. google hosts libraries for common tools, here is jquery: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> it also has the old library that this calls for, but i would use the newer one if possible, don't mix versions with ui. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> and here is jquery ui: <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> but I actually don't know what jquery.easing or jquery.core are. or ui.core for that matter. I've only seen the regular and min varieties of each, no "core" in the title, and easing idk. sorry.
  15. the thing is the code is going to be custom to your situation, you're not asking someone to just show you working code, you are asking someone to code it for you. someone will, i just unfortunately don't have the time atm. good luck.
  16. unfortunately those are outdated libraries. you can look for the old ones, or try the new ones. what you would do either way is put all the required .js files into a folder "includes" that is right alongside the index.html, styles.css, etc files. and then put something like this: <head> <script src="includes/jquery.core.js"></script> <script src="includes/jquery.ui.core.js"></script> <script src="includes/jquery.easing.js"></script> <script src="includes/jquery.min.js"></script> </head> in between the <html><body> tags at the very beginning of index.html. I say"something like". the only thing that would change would be the names of the files themselves.
  17. You are asking for someone to walk you through something that is very well documented. I'll give you some pointers but you're going to have to read up on your own. when you say php form what do you mean? is it actually html in a .php file or are you just calling it a php form? the form is on the user(client/browser) end. php runs on the server's end. two different things. you have no action in <form id="form1" name="form1" method="post" action=""> , that is what will tell your form to use php for processing. change that to <form id="form1" name="form1" method="post" action="process.php"> and then create a file called "process.php". in there put: <?php $post = $_POST; foreach ($post as $key=>$value){ echo $key. ' = '. $value. '<br />'; that will give you a simple script that accepts your form data and then prints out the results. that's the first step. make sure the submitted results come through properly. then you'll want to compare them. to do this you need to GET the existing password from the database you'll also want to encrypt the password but that is ANOTHER script unless you are adding them manually. check this out for the answer to both then use PDO, with prepared statements, and you do not have to worry about injection attacks. an example of that: $db = new PDO('mysql:host=localhost;dbname=DBNAME;charset=utf8_general_ci', 'USER', 'PASS'); $sql = 'UPDATE DBNAME SET ipaddress=? WHERE email=?'; $sth = $db->prepare($sql); $sth->execute(array($_SERVER['REMOTE_ADDR'], $post['email'])); ?> note you'll need to create the database, table, and structure (email, pass, ipaddress) so read. good luck.
  18. As said, no. to the second question, it's easily done however, think hard about how you want the site to come across. any popup whether immediate or delayed is spammy, and delaying it only creates confusion ("what did i do to cause that?..."). If you still decide you want to do it just throw the delayed code at the end of the script and put sleep() before it.
  19. oh absolutely, that's what i was looking for i am aware of the dangers and so was looking for the most efficient option. i am using the wordpress api, which allows me to load the information(url) which is in a database, however through their functions only which do not allow specifying an image to exist. I could call the database directly but i would like not to do that. i have updated the code. right now, the code: it's not in a loop, but an if statement gets all categories (Except excluded) picks 2 posts from each category checks to make sure each post has an image if 1 or none, remove the category trim categories to final desired number use images <?php $ci = 8; // Companies Included, integer that is divisible by 2 $to = 48; // timeout in hours if ( false === ( $scroller = get_transient( $stransient ) ) ) { if (!is_array($scroller) || count($scroller)==0) { $args = array( 'type' => 'post', 'parent' => 18, 'exclude' => 63, 149, 278, 62 ); $companies = get_categories( $args ); shuffle($companies);$truckco= array(); $x=3; foreach ($companies as $company){ $count=0; $argus = array('numberposts' => 2, 'orderby' => 'rand', 'post_type' => 'post', 'category' => $company->cat_ID ); $listings = get_posts($argus); foreach($listings as $tn=>$post) { $truckco[$company->slug]['truck_'. $tn]['image'] = get_the_image( array( 'image_scan' => true, 'format' => 'array', 'width' => '172', 'height' => '129' ) ); $truckco[$company->slug]['truck_'. $tn]['pid'] = $post->ID; $file_loc = str_replace('http://www', '', $truckco[$company->slug]['truck_'. $tn]['image'][src]); //echo $file_loc. '<br>'; if (file_exists($file_loc)) { //echo 'image found! <br>'; } else { //echo 'image not found <br>'; unset($truckco[$company->slug]['truck_'. $tn]); } } } //var_dump($truckco); //echo count($truckco). '<br>'; foreach ($truckco as $co=>$trks){ if (count($trks) < 2) { unset($truckco[$co]); } } //var_dump($truckco); //echo 'count here ='. count($truckco); while (count($trucko) > $ci){unset($trucko[array_rand($trucko)]);} ?> instead of just removing the category, i would like to try again $x number of times. the only thing i can think of is creating a function and calling it in a while statement in that event, but i figured there would be a better way.
  20. i had not. that should fit in very nicely i think i was going to use goto but for some reason i really don't want to, this way i don't have to. thanks
  21. I don't even really know how to title it. I have this piece of code, i wrote. it works with wordpress api but honestly i don't think that matters much. what it does, is pick $ci number of categories, and then picks 2 posts from each category. it then assigns the image in/attached to that post to an array, to be used later. this all works fine, the problem is when it picks a post that doesn't have an image. right now, it can't tell that. writing in a bit to be able to tell whether there is an image or not should be easy. i'm thinking it can be as basic as file_exists or as complicated as parsing the post. the part i have the problem with - is how do i make it go back and pick another post/category when it comes up short? more than once? i want it to keep going back until it comes up with an image. i'd rather not expand the search any farther than necessary <?php if ( false === ( $scroller = get_transient( $stransient ) ) ) { if (!is_array($scroller) || count($scroller)==0) { $args = array( 'type' => 'post', 'parent' => 18, 'exclude' => 63, 149, 278, 62 ); $companies = get_categories( $args ); while (count($companies) > $ci){unset($companies[array_rand($companies)]);} shuffle($companies);$truckco= array(); foreach ($companies as $company){ $argus = array('numberposts' => 2, 'orderby' => 'rand', 'post_type' => 'post', 'category' => $company->cat_ID ); $listings = get_posts($argus); foreach($listings as $tn=>$post) { $truckco[$company->slug]['truck_'. $tn]['image'] = get_the_image( array( 'image_scan' => true, 'format' => 'array', 'width' => '172', 'height' => '129' ) ); $truckco[$company->slug]['truck_'. $tn]['pid'] = $post->ID; } } ?> thank you
  22. wrap the whole update part in a while statement that runs as long as they have points
  23. create a form that manipulates the database. it's pretty basic. as for the code - it finds the lowest time and compares every other time to that. if that's not what you want, just replace $min with whatever value you want to compare against each time is compared against min, not as you seem to think, 6->5, 5->4, etc.
  24. i would store the times in a db, though here i have just supplied an array. <?php $times = array ( 16789, 14000, 15258, 13249, 12054, 19985 ); $min = min($times); function format_time($t1, $t2) // t = miliseconds { $t = $t1 - $t2; $minutes = floor($t / 60000); $seconds = sprintf('%02d',floor(($t / 1000) % 60)); $ms = sprintf('%03d', $t % 1000); return $minutes . ":" . $seconds . "." . $ms; } foreach ($times as $time){ echo '+ '. format_time($time, $min). '<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.