Tag Archives: php

Download Verve Meta Boxes

Verve Meta Boxes used to be available from avenueverve.com at their website – http://www.avenueverve.com/verve-meta-boxes/ The plugin has disappeared from that site as well as from the WordPress plugin repository. The latest version of the plugin, I believe, was Version: 1.2.9 You can download this version from my blog at verve-meta-boxes.zip. Happy WordPressing! Verve Meta Boxes Screenshots

Posted in Tech Tips, Web Development | Tagged , , , | Leave a comment

array_search case insensitive

PHP’s array_search claims that it suppors a case insensitive search, well, sort of, with this message: If needle is a string, the comparison is done in a case-sensitive manner. user says: for case insensitive array_search you could use: function array_search_i($str,$array){ foreach($array as $key => $value) { if(stristr($str,$value)) return $key; } return false; } stefano says: for searching case insensitive better this: array_search(strtolower($element),array_map(‘strtolower’,$array));

Posted in Tech Tips, Web Development | Tagged , , | Leave a comment

strtotime examples

Here are some example strtotime syntaxes for PHP. Leave a comment with an example if you like. strtotime(‘today 14:00’); strtotime(‘tomorrow 14:00’); strtotime(‘tomorrow 2:00pm’); strtotime(‘now +2 hours’); strtotime(‘now +2 minutes’); strtotime(‘now +24 hours’); strtotime(‘now +12 hours’); strtotime(‘today +3 days’); strtotime(‘now +5 days’); A Quick reference of accepted input: Numeric steps (+1, -1 …) Numeric date/time (Y-m-d, H:i:s) Ordinal names / numbers [first – twelfth = 1 – 12] * Special ordinal name / numbers (last = -1, this = 0, next = 1) Special words (tomorrow, yesterday, ago, fortnight, now, today, day, week, month, year, hour, minute, min, second, sec) ** Days / months [sunday – saterday, sun – sat, January – December, Jan – Dec] Timezones (TZ=”…”) * second is reserved for seconds in time notation, therefore is not allowed here ** plurals are also allowed by adding an ‘s’ via php manual

Posted in Tech Tips, Web Development | Tagged , | Leave a comment

List of PHP Frameworks

Here’s a list of recent and popular PHP frameworks as of 2012: Kohana: The Swift PHP Framework Laravel – A Clean & Classy PHP Framework Getting Started with the Fuel PHP Framework | Nettuts+ FUEL — A simple, flexible, community driven PHP5.3 framework. › A simple, flexible, community driven PHP5.3 framework.  Underscore.php

Posted in Linux, Web Development | Tagged , | 1 Comment

iPower: The server encountered an unexpected condition which prevented it from fulfilling the request.

iPower: The server encountered an unexpected condition which prevented it from fulfilling the request. If you’re getting this error on iPower you need to enable CGI / scripts. Sometimes your account will show you that this is enabled, even if it is not. Contact iPower support to get them to resolve it for you. Even if in your control panel homepage CGI / PHP is showing up as active, click on the server configuration tab and you probably will see that CGI is in fact inactive:

Posted in Server Admin, Server Administration, Web Development | Tagged , , , , , , | Leave a comment

Fix “Post Types Order” plugin error with HTTPS

The WordPress Plugin Post Types Order by NSP CODE is helpful in as it allows you to Order Posts and Post Types Objects using a Drag and Drop Sortable javascript capability But unfortunately the plugin does not work with wordpress HTTPS / SSL admin – or at least not without errors: But the good news is that there is an easy fix with changing just a few lines of code: At the top of the post-types-order.php page there are two constant definitions: define(‘CPTPATH’, ABSPATH.’wp-content/plugins/post-types-order’); define(‘CPTURL’, get_option(‘siteurl’).’/wp-content/plugins/post-types-order’); And the second one needs to use the plugins_url() function that WordPress recommends instead: define(‘CPTPATH’, ABSPATH.’wp-content/plugins/post-types-order’); define(‘CPTURL’, plugins_url().’/post-types-order’); After that you should stop receiving the HTTPS error for some insecure content when you are in the WP administration interface.

Posted in Tech Tips, Web Development | Tagged , , , , , | Leave a comment

PHP Auto Generate Status Header: function

PHP Function to Auto Generate Status Header This is from the CodeIgnitor Common Functions Library. It is very useful: // ———————————————————————— /** * Set HTTP Status Header * * @access public * @param int the status code * @param string * @return void */ if ( ! function_exists(‘set_status_header’)) { function set_status_header($code = 200, $text = ”) { $stati = array( 200 => ‘OK’, 201 => ‘Created’, 202 => ‘Accepted’, 203 => ‘Non-Authoritative Information’, 204 => ‘No Content’, 205 => ‘Reset Content’, 206 => ‘Partial Content’, 300 => ‘Multiple Choices’, 301 => ‘Moved Permanently’, 302 => ‘Found’, 304 => ‘Not Modified’, 305 => ‘Use Proxy’, 307 => ‘Temporary Redirect’, 400 => ‘Bad Request’, 401 => ‘Unauthorized’, 403 => ‘Forbidden’, 404 => ‘Not Found’, 405 => ‘Method Not Allowed’, 406 => ‘Not Acceptable’, 407 => ‘Proxy Authentication Required’, 408 => ‘Request Timeout’, 409 => ‘Conflict’, 410 => ‘Gone’, 411 => ‘Length Required’, 412 => ‘Precondition Failed’, 413 => ‘Request Entity Too Large’, 414 => ‘Request-URI Too Long’, 415 => ‘Unsupported Media Type’, 416 => ‘Requested Range Not Satisfiable’, 417 => ‘Expectation Failed’, 500 => ‘Internal Server Error’, 501 => ‘Not Implemented’, 502 => ‘Bad Gateway’, 503 => ‘Service Unavailable’, 504 => ‘Gateway Timeout’, 505 => ‘HTTP Version Not Supported’ ); if ($code == ” OR ! is_numeric($code)) { show_error(‘Status codes must be numeric’, 500); } if (isset($stati[$code]) AND $text == ”) { $text = $stati[$code]; } if ($text == ”) { show_error(‘No status text available. Please check your status code number or … Continue reading

Posted in Web Development | Tagged , , , , | Leave a comment

Fake Sendmail for Mac (linux)

When developing in PHP perhaps you need to set up a sendmail that just outputs things to text. No need to setup delivery via SMTP. Just create an executable ruby script somewhere, for example: /usr/bin/fake-sendmail.sh with following content: $ touch /usr/bin/fake-sendmail.sh # make it executable (will require root priv.) $ chmod +x /usr/bin/fake-sendmail.sh #!/usr/bin/ruby path = “/tmp/fake-mailer” Dir.mkdir(path) if !File.exists?(path) File.open(“#{path}/#{Time.now.to_i}.txt”, “w”) do |f| f.puts ARGV.inspect $stdin.each_line { |line| f.puts line } end Then edit php.ini sendmail_path = /usr/bin/fake-sendmail.sh props to dan for the script Update I changed one line to use a micro-time format because I was having some trouble with a very fast sending script overwriting some of the existing e-mail files. So, here is the new line to insert: File.open(“#{path}/#{(Time.now.to_f.to_s.gsub(“.”,””)+’00000000′)[0..14]}.eml”, “w”) do |f| Do you need fake sendmail for windows? Check out Byron’s fake sendmail for windows.

Posted in Tech Tips, Web Development | Tagged , , , , | 1 Comment

Heredocs and Nowdocs in PHP

A here document (also called a here-document, a heredoc, a here-string or a here-script) is a way of specifying a string literal in command line shells including all the Unix shells (sh, csh, ksh, Bash and zsh) and the Windows PowerShell and in programming or scripting languages such as Perl, PHP, Python and Ruby. It preserves the line breaks and other whitespace (including indentation) in the text. Some languages allow variable substitution and command substitution inside the string. The general syntax is << followed by a delimiting identifier, followed, starting on the next line, by the text to be quoted, and then closed by the same identifier on its own line. Under the Unix shells, here documents are generally used as a way of providing input to commands. from Wikipedia Example Heredoc Syntax <?php $str = <<<EOD Example of string spanning multiple lines using heredoc syntax. EOD; /* More complex example, with variables. */ class foo { var $foo; var $bar; function foo() { $this->foo = ‘Foo’; $this->bar = array(‘Bar1’, ‘Bar2’, ‘Bar3’); } } $foo = new foo(); $name = ‘MyName’; echo <<<EOT My name is “$name”. I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should print a capital ‘A’: \x41 EOT; ?> NowDocs Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. It shares some features in common with the SGML <![CDATA[ ]]> construct, in that it declares a block of text which is not for parsing. A nowdoc is identified with the same <<< seqeuence used for heredocs, but the identifier which follows is enclosed in … Continue reading

Posted in Tech Tips, Web Development | Tagged | Leave a comment

The PHP Object Expands in PHP5

Starting with PHP 5, the object model was rewritten to allow for better performance and more features. This was a major change from PHP 4. PHP 5 has a full object model. Among the features in PHP 5 are the inclusions of visibility, abstract and final classes and methods, additional magic methods, interfaces, cloning and typehinting. PHP treats objects in the same way as references or handles, meaning that each variable contains an object reference rather than a copy of the entire object. See Objects and References from php manual

Posted in Tech Tips, Web Development | Tagged , | Leave a comment