Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 03/21/2018 in all areas

  1. 2 points
    Commencing with test_config.txt as # interface eth0 subnet 10.0.10.0 netmask 255.255.255.0 { } host cm-test1 { hardware ethernet 78:8d:f7:2b:bc:79; fixed-address 172.17.12.80; filename "srv-050.cfg"; } host cm-test2 { hardware ethernet 5c:35:3b:4d:73:4b; fixed-address 172.17.13.119; filename "srv-042.cfg"; } host cm-instrumenti { hardware ethernet 78:8d:f7:2b:bc:79; fixed-address 172.17.12.80; filename "srv-050.cfg"; } host cm-nimonmehmetaj { hardware ethernet 5c:35:3b:4d:73:4b; fixed-address 172.17.13.119; filename "srv-042.cfg"; } This is one way $unwanted = [ 'cm-instrumenti', 'cm-nimonmehmetaj' ]; // unwantedt host names $text = file_get_contents('test_config.txt'); $config = array_map('trim',explode('}', $text)); $new_config = array_filter($config, function ($v) use($unwanted) { foreach ($unwanted as $name) { if (strpos($v, $name)!==false) return false; // remove unwanted elements } return $v!=''; // remove blank entries }); file_put_contents('new_config.txt', join("\n}\n", $new_config) . "\n}\n"); giving new_config.txt as # interface eth0 subnet 10.0.10.0 netmask 255.255.255.0 { } host cm-test1 { hardware ethernet 78:8d:f7:2b:bc:79; fixed-address 172.17.12.80; filename "srv-050.cfg"; } host cm-test2 { hardware ethernet 5c:35:3b:4d:73:4b; fixed-address 172.17.13.119; filename "srv-042.cfg"; }
  2. 1 point
    Your <option> tags should ech have a correponding </option> closing tag. Your name="MM_Balance should have closing quote. No need to do the months manually: <?php function monthOptions($current) { $opts = ''; $dt1 = new DateTime('2018-01-01'); $dp = new DatePeriod($dt1, new DateInterval('P1M'), 11); foreach ($dp as $d) { $sel = $d->format('m')==$current ? 'selected' : ''; $opts .= sprintf("<option value='%d' $sel>%s</option>\n", $d->format('m'), $d->format('M') ); } return $opts; } ?> <select name="MM_Balance" style="width:60px"> <?=monthOptions(12)?> </select>
  3. 1 point
    I would kick off an AJAX request on page load to call the curl request then return the results Example <?php /** * IF AJAX CALL, PROCESS */ if (isset($_GET['ajax'])) { $data = get_data('http://www.geoplugin.net/json.gp?ip=19.117.63.253'); exit($data); } /** * curl call * * @param string $path cUrl url */ function get_data($path){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$path); curl_setopt($ch, CURLOPT_FAILONERROR,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $retValue = curl_exec($ch); curl_close($ch); return $retValue; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="generator" content="PhpED 18.0 (Build 18044, 64bit)"> <title>Example ajax/curl</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type='text/javascript'> $().ready( function() { $.get( "", {"ajax" : 1 }, function(resp) { var txt = "Country " + resp["geoplugin_countryName"] + "<br>Latitude " + resp["geoplugin_latitude"] + "<br>Longitude " + resp["geoplugin_longitude"] $("#curloutput").html(txt) }, 'JSON' ) }) </script> </head> <body> <h1>Sample page</h1> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem. </p> <p>In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy. Fusce aliquet pede non pede. Suspendisse dapibus lorem pellentesque magna. Integer nulla. Donec blandit feugiat ligula. Donec hendrerit, felis et imperdiet euismod, purus ipsum pretium metus, in lacinia nulla nisl eget sapien. </p> <p>Donec ut est in lectus consequat consequat. Etiam eget dui. Aliquam erat volutpat. Sed at lorem in nunc porta tristique. Proin nec augue. Quisque aliquam tempor magna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc ac magna. Maecenas odio dolor, vulputate vel, auctor ac, accumsan id, felis. Pellentesque cursus sagittis felis. </p> <p>Pellentesque porttitor, velit lacinia egestas auctor, diam eros tempus arcu, nec vulputate augue magna vel risus. Cras non magna vel ante adipiscing rhoncus. Vivamus a mi. Morbi neque. Aliquam erat volutpat. Integer ultrices lobortis eros. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin semper, ante vitae sollicitudin posuere, metus quam iaculis nibh, vitae scelerisque nunc massa eget pede. Sed velit urna, interdum vel, ultricies vel, faucibus at, quam. Donec elit est, consectetuer eget, consequat quis, tempus quis, wisi. </p> <p>In qui nunc. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Donec ullamcorper fringilla eros. Fusce in sapien eu purus dapibus commodo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras faucibus condimentum odio. Sed ac ligula. Aliquam at eros. Etiam at ligula et tellus ullamcorper ultrices. In fermentum, lorem non cursus porttitor, diam urna accumsan lacus, sed interdum wisi nibh nec nisl. </p> <div id='curloutput'> </div> </body> </html>
  4. 1 point
    @gizmola, You seem to be a drill-sergeant an loving father all in one?! I am very interested in learning how to do all of that, but I also stick to what I said (or implied) above... That being, I have a very large code-base I as working on a couple of years ago for a couple more years, and when I was 95% done, life happened and my work got tabled. My goal is to "finish what I started" and get my existing environment, tools, approach and code-base into prod so I can get my website up and try to make some $$$ while I regroup. (Starting to re-organize a Terabyte of crap on my old Macbook and laying it down in a way that I can actually find things on my new MacBook made total sense. But getting fancy with anything else is likely an unnecessary distraction...) And I am interested, but it was quicker to change a few lines of code in my httpd.conf file then do what you suggested. (For v2.0, I will check that and your other advice out.) There is nothing more than I want moving forward to learn how to code like a modern professional, and start being EFFICIENT, because that is what sunk me the first go around. (I have solid code that works, but it takes me 10 times longer to do and maintain things than it should for me to be successful. And, NO, that has nothing to do with tools, but has a s***load to do with architecture and coding styles!)) MAMP des what I need it to do for now. Took me an evening to research, and a few minutes to type the code to make it adapt to my new filing system. Now on trying to find all of my old code and notes and get my website working in my new dev environment on my new macBook. Thanks for the thoughts!
  5. 1 point
    Besides switching to PDO simply because it is easy and better, why not examine why you have this 'query' function. Functions are great for tasks that may be repetitive or complex and you will benefit by writing a block of code that does the work for you and can be relied on at multiple times. In your case you have a function that executes ONE LINE OF CODE! What is the point of that? How do the 6 lines of code in your function (including the call line itself) help you when you could have simply written that query call line in place of it all? If your function actually accomplished some real work it would be great. You could have validated that the query call actually runs or that it actually ran before blindly returning, but you don't. So why the extra overhead here?
  6. 1 point
    Perhaps, in your php, you could put those two values into hidden fields. Then, in your javascript, pick up the values from there. var myVal1 = $("#myvar1").val()
  7. 1 point
    In fact, the cause is exactly the same reason that it was in your post on July 5th The idea here is for you to read the replies.
  8. 1 point
    Most things in a simplexml array are a simplexml objects. It is often necessary to cast elements as string types EG $title = (string)$row->title;
  9. 1 point
    Most of the time WordPress needs to show a label it does so through translations. "Personal Info" works as both the identifier for a particular translatable phrase as well as the default if there is no translation for it. Changing the code to say "Contact Info" changes the default, which you do want, but it also changes the identifier, which you don't want because then translations won't work for it. Instead of changing the code, I suggest setting up a "translation" that turns the phrase "Personal Info" into "Contact Info". And what did you want to do about fonts? For the caching problem, either your browser is caching the page (try using privacy/incognito mode, a different browser, or even another device) or WordPress is caching it. Check if you have any plugins installed which might be doing that. Also check that you're editing the right files in the right places, and obviously that you're uploading the changed versions properly.
  10. 0 points
    I hope you two will be very happy together 😀
This leaderboard is set to New York/GMT-04:00
  • Newsletter

    Want to keep up to date with all our latest news and information?

    Sign Up
×

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.