Lil Josh

A tech blog about web development with PHP, MySQL, jQuery, CSS3 and various other programming languages.

Time to update your WordPress to 4.0!

September 8, 2014

4.0 upgrade Wordpress

Searching entire Dreamweaver site for files by content

I often want to search my entire site for files that contain a specific word, phrase or string. The best way to do this, that I found, was to GET the entire Dreamweaver site to your computer so now you have all the files locally. Then you can use Dreamweaver search (CTRL + F) to search the entire local site for content. Hope this helps and if not here are some additional sources:

http://webdesign.about.com/od/dreamweaverhowtos/ht/dw_find_replace.htm

http://www.wrensoft.com/zoom/support/dreamweaver.html

http://helpx.adobe.com/dreamweaver/using/live-search-mac.html

content dreamweaver entire site search

jQuery JSONP Cross-domain AJAX Callback Function

August 29, 2014

There may be times where you need to make an AJAX call to a resource from another domain, but browsers will not allow a simple AJAX GET. Instead you’ll need to implement a callback function and use JSONP. Here’s an example of the requesting AJAX script:

<script>
var username = 'liljosh';
var url = '//newDomain.com/callbackScript.php?username='+username+'&output=json&callback=?';
        $.getJSON(url, function (data) {
            alert(data);
        });
</script>

and the callbackScript.php could look like this:

<?php
output("Username is $_GET[username]");

// output as JSON
function output($html) {
    if(isset($_GET['callback'])) $html = $_GET['callback'] . '(' . json_encode($html) . ')';
    die($html);
  }
?>
AJAX Callback Function Cross-domain jquery JSONP

Texting with PHP

June 6, 2014

Ever needed to text someone through PHP? It’s very simple! Most cellular providers give an email address with your phone number that can be used to text that number. This is known as “email to SMS gateway”. For example if my number is (555) 555-5555 and I used AT&T then emailing 5555555555@txt.att.net would send a text to my phone. So you can probably guess how the PHP looks, but here’s an example:

<?php
    $from = "Lil Josh <info@liljosh.com>"; // sender
    $subject = "Subject appears in the text message";
    $message = "This is the contents of the text";
    
    // send text message
    mail("5555555555@vtext.com",$subject,$message,"From: $from\n"); // Verizon
    mail("5555555555@txt.att.net",$subject,$message,"From: $from\n"); // AT&T
    mail("5555555555@tmomail.net",$subject,$message,"From: $from\n"); // T-Mobile
    mail("5555555555@vmobl.com",$subject,$message,"From: $from\n"); // Virgin Mobile
    mail("5555555555@messaging.sprintpcs.com",$subject,$message,"From: $from\n"); // Sprint
    mail("5555555555@messaging.nextel.com",$subject,$message,"From: $from\n"); // Nextel
?>

For a more complete list of providers visit http://www.ukrainecalling.com/email-to-text.aspx

AT&T Nextel PHP Sprint T-Mobile texting Verizon Virgin Mobile