Jump to content

maxxd

Gurus
  • Content Count

    922
  • Joined

  • Last visited

  • Days Won

    24

Everything posted by maxxd

  1. Hey, 'all. I think I'm just tired because I can't see the issue here, but I'm trying to run a SOAP 1.2 call to a legit endpoint using a legit function call and getting nothing but a 'Could not connect to host' message with a fault code of 'HTTP'. Here's some code: class Testing{ private $_user = "username"; private $_pass = "password"; private $_system = 1; private $_uri = "http://legit.com/endpoint/"; private $_location = "givenlocation.asmx"; private $_soapClient; public function __construct(){ $this->_soapClient = new SoapClient(null, [ 'location' => "{$this->_uri}{$this->_location}", 'uri' => $this->_uri, 'soap_version' => SOAP_1_2, 'exceptions' => true, 'trace' => true, ]); } public function makeCall(){ try{ $data = $this->_soapClient->__soapCall('functionCall', [ 'username' => $this->_user, 'password' => $this->_pass, ]); }catch(SoapFault $e){ die("<pre>".var_export($e, true)."</pre>"); } } } $testSoap = new Testing(); $testSoap->makeCall(); I'll happily take a "Let me Google that for you" result link if it's that simple, but I'm just not seeing the problem. Anybody? As always, help is greatly appreciated. Forgot to mention - I don't get an error on instantiation of the SoapClient() object, just the __soapCall() call.
  2. From the office system it works fine when the username/password is appended to the URL. I'm wondering if there was a snafu in the IP whitelist where our office was whitelisted correctly but the development system wasn't. I've got an email in with the provider to find out, just wanted to post here in case there was something glaringly obvious that I just yawned over...
  3. maxxd

    Issue with PHP

    All WordPress AJAX requests are routed through admin_ajax.php. You need to supply an 'action' index in your passed array, then use the 'wp_ajax_{your-action}' and 'wp_ajax_nopriv_{your-action}' hooks. See here for further information.
  4. So, clearly you're working with WordPress for this project. WordPress has enough issues and pain points by and of itself - why are you making it harder on yourself? If you're actually (as it seems) working within the WP infrastructure, why not just use the WordPress database object? The connection to the database is already made, you can use it like an ORM (kinda), and depending on how you use it, it kinda sorta sanitizes database interactions by default. The reason you'll see a check in most WP theme and/or plugin files for the ABSPATH constant is to make sure the WordPress core has been loaded. If you're trying to do something within WordPress before the core is loaded, I'd recommend looking at why you're trying to do it and why it needs to be done exactly then. I hope that makes sense, and sorry if I'm missing the point of what you're actually trying to do, but it really seems like you're making things much more difficult than they need to or should be.
  5. maxxd

    Insert into database at all at once

    Also, part of the joy of prepared statements is that you only need to prepare them once. Do the PDO::prepare() outside the loop, then bind the variables and run the query in the loop. Which, again, we can't see.
  6. maxxd

    Insert into database at all at once

    Nothing in your code shows a loop. If there's a loop inserting data but the only data being inserted via that loop is the last row of data, then there's probably a problem with the loop; which we haven't seen.
  7. Create a variable called "$currentSalesRep". At the start of your while loop, grab the current record's name field and compare the value to $currentSalesRep. If the values are different, create a new worksheet then store the current record's name value in $currentSalesRep.
  8. maxxd

    Generating voice into wave form using php

    PHP is a server-side language. You're going to want JavaScript so as to handle things on the client side. Check out https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API
  9. Check this list out. I think it's probably not exhaustive, but it should be big enough to get you started.
  10. maxxd

    Newbie Question!

    Put the code from the example in your child theme's functions.php file. I assume you're using a child theme - if not, create one and then do it. You don't want to modify any plugin or pre-built theme files directly as those changes will be overwritten every time the plugin or theme updates. Now, that having been said, you can't just copy and paste the example code - you'll have to modify it to fit your purposes. For instance, the example code checks for any fields with an ID of 100, 101, or 102 before running the rest of the logic. The likelihood that the fields you're looking to compare against are ID 100, 101, or 102 is slim...
  11. maxxd

    Text Area Entry

    Explode the string on newline and you'll have an array of emails which you can loop through to insert. You may want to run additional checks for commas and/or whitespace just in case your users don't read the instructions.
  12. maxxd

    Read EXIF Orientation & Rotate Image

    This seems like a good place to start.
  13. Is there a reason you're not using the WordPress database class?
  14. maxxd

    Output wp shortcode in php page

    I may not be understanding your question, but do_shortcode() is not a PHP function, it's a WordPress function. If you're trying to call it from a script that isn't run through WordPress (if it's an external script [I think is what you're describing]), it's not going to work.
  15. maxxd

    PHP Templating

    Couldn't even begin to say why, but I always forget about __DIR__. It's weird, honestly.
  16. maxxd

    PHP Templating

    I've typically used something along the lines of this: require_once(dirname(__FILE__).'/style/navbar.php'); I don't know if it's better or not, but it does make me feel like I've got more control over the file structure and as though there's less of a chance of somehow injecting "../../{whatever nefarious thing}" into $_SERVER['DOCUMENT_ROOT']. Also, (really no point in lying here) I don't even know if it's possible to inject into$_SERVER['DOCUMENT_ROOT'], but I know that $_SERVER['PHP_SELF'] can be spoofed, so I think it may just be possible. Maybe I'm just being paranoid.
  17. maxxd

    Poll Folders for new File

    It's a kludge, but you could always keep a list of files in a database or flatfile and schedule a CRON to run a script that scans the directory for file names, then compare that to the saved list. You'd know if something had been added or removed, though it wouldn't be instant.
  18. maxxd

    Plugin Template PHP

    Just don't forget that you'll have to make those changes to the plugin file every time you update your plugin.
  19. maxxd

    Check if User and Email already exists

    Not as it is now - if you want to tell the user which is taken you'll have to update the query. Right now it just returns a count of records that match either the username or the email. You'll have to actually select both and then check in PHP which one matches, or rewrite the query to return the offending column. However, I'd recommend just letting people know that one of the two has been taken. That way you're not confirming to an outside party which of the two actually exists in the database - a hacker that knows for a fact a username exists has less work to do and can focus only on figuring out a correct password.
  20. maxxd

    Create form send to database

    Don't do that. Try PHP The Right Way or codecademy - there are a lot of tutorials and lessons out there. If you don't know whether or not they're any good, ask here first. Someone can tell you. w3shools.com is a great place to look up what exactly you need to Google in order to figure out how something works, but it's not a great place to actually learn how something works.
  21. maxxd

    Check if User and Email already exists

    SELECT COUNT(*) AS recs FROM users WHERE username = :username OR email = :email You're overwriting your query and only checking for the email match - try the above as the only value of $sql. Also (and I could be wrong so hopefully someone will correct me if I am) I seem to remember having run into to troubles using 'email' as a column name in MySql - I tend to use something like "email_address" (or "eAddy" if I'm tired of typing). As to the unique index point that mac_gyver raised, if those columns are already set to 'UNIQUE', just insert the data. If there's a duplicate in either column, the insert will throw an error - check that and let the user know what's up. No data will actually be inserted because the attempt violates the unique constraints so no harm done.
  22. I don't program Python, but I have to say that VSCode is quickly becoming my favorite IDE. It's fast, has a huge amount of plugins, and seems light and nimble on my Mac desktop, Windows 10 desktop, and my Surface. The biggest issue I have with it as of right now is that some of the Windows version keyboard shortcuts are different from the Mac version shortcuts.
  23. maxxd

    Update to database

    The biggest thing about WordPress and AJAX is that WP routes all AJAX calls through the admin_ajax file, and what exactly it does at that point is dependent on the `action` parameter of the passed data - at that point it uses it's internal routing and the 'action' parameter to figure out what file and function/method to call via the add_action() call - however, it doesn't actually pass any parameters to the called function. So you need to pass all the data in the AJAX request but don't expect any of it to actually hit the handling function that you've written - you're still going to have to go to the $_POST or $_GET superglobals for that. Sure, you could use the $_REQUEST superglobal, but WP has enough security concerns without adding more so skip $_REQUEST entirely please. Sorry, none of that is entirely unusual but IMO if you're going to force everything to go through a centralized location you should at least consolidate and pass data to the called target. It's just courtesy for making me jump through the extra hoop. Anyway (long and random "it's my second glass of wine" rant aside), the important part is that you technically can - like any other application - send your AJAX request to any receptive PHP file you want. The problem is that if you don't use the admin_ajax link, the WordPress core won't be loaded. So any and all of the functions, objects, or hooks you want or need to use won't exist at the time of the AJAX call.
  24. maxxd

    Update to database

    First, if you're going to be handling form processing via AJAX you don't need an action attribute on the form. Your JavaScript preventDefault() on the submit event stops the form from submitting to the action target anyway. Your AJAX handling functions are doing a few redundant things. For instance, the acikudos_ajax_handler() function is invoking the global $wpdb in order to ignore it completely before sending the program to acikudos_process_request(), where the global $wpdb is invoked again. Then acikudos_process_request() echos the JSON encoded data before returning the array data to acikudos_ajax_handler(), which prints the JSON encoded array. Again. Beyond that, WordPress runs all AJAX calls through the wp_ajax_{action}() and wp_ajax_nopriv_{action}() hooks, so I'm a bit confused as to how the acikudos-update.php file is even getting called at this point if the hooks for those actions are actually in that file. It's pretty normal to put all the action and filter hooks into the plugin main (or 'functions') file (I assume at this point that is acikudos-plugin.php). You can always call to external classes from the functions file by using an array as the second parameter in the add_action() or add_filter() calls - for instance: add_action('wp_ajax_acikudos', [myObject, 'acikudos_ajax_handler'], 0, 1); It's late so I hope I'm not missing something you've described in your code, but I would recommend doing some more searching into how WordPress handles AJAX in general - it can be a bit confusing at first. Beyond that, you've got a random quotation mark in the acikudos-edit.php file that should be easy to see in any decent IDE or even here in your post. I'm assuming it's an issue in the copy/paste as the file wouldn't work at all if that were the verbatim code in development and testing.
  25. maxxd

    Physical Width (Inches) Of The Screen

    requinix is right - don't worry about the physical size of the screen. As monitors are packing more pixels in per inch it doesn't matter at all. I personally use pixel-based breakpoints for my media queries with rem or percentages for element sizing and placement. It's an approach some people disagree with - I've talked to developers that think using rem or em is the only way to go, I've just not really been able to wrap my head around applying rem or em units to a Photoshop file, and I guarantee the designers here won't do it either.
×

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.