Here is the basics of OpenStack Swift & HPCloud CDN PHP Bindings for the WordPress Plugin developers and those who works with PHP based CMS. PHP, honestly is a bad programming language. Why bad, it is quite difficult to explain. But, Perl was intended to work instead of PHP.
We first described the method to use OpenStack Swift (HP Cloud CDN) with WordPress W3TC. If you use that method, you must pay us a fee. Else, we will file criminal case against you. Because that is a concept not software. There is no question of Freedom here, because might earn money from your Plugin sucking us. This is to stop the exploit what ~60% WordPress developers including W3TC do. OpenStack and HP need not to pay, You must read all the lines here. We might charge a ransom for an existing plugin’s extension or can charge a minimum for a new plugin. If you do not want to pay, then work from original official resource.
You will require PHP 5.3.x or greater. We suggest to test on Apache2-PHP setup, that is a typical LAMP.
---
OpenStack Swift & HPCloud CDN PHP Bindings : Important
We do not like PHP, but frankly we need to use because the community development is more around PHP. It never means that PHP will never die();
. Now, there are PHP Experts
, then WordPress Experts
, even WordPress Frontend Experts
. The Public directory of a server is NOT exactly out of the server. Running those scripts to hack, practically nicely works at /root
with 100% sudo privilege. We use GNU/Linux, not UNIX. There is no UNIX Wheel Group in Linux. Kindly do not echo the path on your WordPress plugin’s output on frontend like :
include_once('/usr/share/nginx/html/wp-content/plugins/this_plugin/that_thing.php'
Such HTML comment can fully blow a full OpenStack installation, forget about the only server where the website is running. It is fully telling the hidden fact – WordPress is installed at /usr/share/nginx/html/
and one owner is www-data
. Only a form is what is needed if the user uses W3TC or any Cache Plugin to run SQL injection.
There is absolutely no shortcut to just modify any existing plugin intended for Rackspace Cloud Files as they use API based authentication for the tenant (read USERS OF Rackspace Cloud Files). Your Plugin FOR OpenStack Swift WILL WORK WITH HPCloud CDN – the official code contribution is by HP.
Other ways are described by us – that includes using the Python Script. You are bound to give us clear credit (not money) if you use any of our method is being used. You need not to give us credit if you use any of the method which is described by OpenStack. You are bound to give HP the credit if any of their method is being used. You must not delete the commented out Licensing Parts of codes.
HP uses GNU GPL compatible license, that is very old method which were used in 1960 for software development. There was no Microsoft like companies, there were no concept of closed sourced software. If you are NOT their partner, you must follow their rules.
We might be able to use the things related to HP, but you must check their rules.
Working with these demands account information for your HPCloud account or OpenStack account. We are taking it granted that you know them.
Methods are described for using the Plugin for Shared Hosting too. Namespaces are separated with double-colon (::) not backslash (\) as backslash have special meaning to Doxygen. HP uses @retval
instead of @return
.
These were for PHP compatibility. These method avoids using Composer. Doxygen is the standard tool for creating documentation from C++. If you are PHP Expert (pun intended), you’ll not know.
OpenStack Swift & HPCloud CDN PHP Bindings : Basics
You will get the Tagged source code from here :
1 | https://github.com/hpcloud/HPCloud–PHP/releases |
You need to use stream wrapper support, so that you can transparently read and write files to the HPCloud Object Storage and CDN service without using any API at all. You can use the methods like this:
1 2 3 4 5 6 | fopen()/fclose() fread()/fwrite() file_get_contents() stream_get_contents() stat()/fstat() is_readable()/is_writable() |
These are more related to PHP than WordPress :
1 | http://us3.php.net/manual/en/ref.filesystem.php |
This is how you can call the Bootstrap file, PSR-0 autoloader will not be needed :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?php // call the file, add . according to the relative position require ‘HPCloud/Bootstrap.php’; // fail safe \HPCloud\Bootstrap::useAutoloader(); // stream wrappers ON \HPCloud\Bootstrap::useStreamWrappers(); // provide info $cxt = stream_context_create(array( ‘username’ => ‘johndoe’, // use lowercase ‘password’ => ‘secret’, // that is used for dashboard ‘tenantid’ => ‘123456’, // you’ll get in the OpenStack RC file ‘endpoint’ => ‘https://region-a.geo-1.objects.hpcloudsvc.com/v1/xxxxxxxxxxx/example-container’, // double check )); // Get an object // right into $myObject. $myObject = file_get_contents(‘swift://region-a.geo-1.objects.hpcloudsvc.com/v1/xxxxxxxxxxx/example-container/foo.txt’, FALSE, $cxt); // double check // PHP closure might not be needed // ?> |
xxxxxxxxxxx is a unique identity number. You should ask it and GET via PHP-HTML form via WordPress Setting page of the Plugin. We can authenticate by calling the Python Bash Script. That can be used as alternate failsafe method or for pushing in advanced mode.
We can create the main file (in WordPress Plugin) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | <?php /* Plugin Name: HP Cloud OpenStack CDN Plugin URI: https://thecustomizewindows.com/ Description: This plugin stores WordPress media files on, and delivers them from, the HP Cloud CDN or OpenStack Swift. Version: Pre-Alpha Contributors: Dr. Abbhishek Ghosh, Abhishek_Ghosh Author URI: https://thecustomizewindows.com/ License: Not Released */ // Admin restriction defined(‘WP_PLUGIN_URL’) or die(‘Restricted access’); //Require scripts and libraries require_once(“lib/functions.php”); // assumed require_once(“admin/functions.php”); require_once(“lib/class.hp_cdn.php”); // assumed if( !class_exists(“OpenStack”) ) { require_once(“lib/HP Cloud PHP Binding goes here”); } // constants define(‘HP_CDN_PATH’, ABSPATH.PLUGINDIR.‘/hp-cloud-files-cdn/’); define(‘HP_CDN_URL’, WP_PLUGIN_URL.‘/hp-cloud-files-cdn/’); define(‘HP_CDN_OPTIONS’, “wp_hp_cdn_settings” ); // you know why global $wpdb; // plugin install check function rscdn_install() { require_once( ABSPATH . ‘wp-admin/includes/upgrade.php’ ); global $wpdb; // example default CDN settings $cdn_settings = new stdClass(); $cdn_settings->username = ‘Username’; // add more here add_option( HP_CDN_OPTIONS, $cdn_settings, ”, ‘yes’ ); unset($_SESSION[‘cdn’]); } register_activation_hook( __FILE__, ‘hpcdn_install’ ); function hpcdn_uninstall() { global $wpdb; @delete_option( HP_CDN_OPTIONS ); @delete_site_option( HP_CDN_OPTIONS ); unset($_SESSION[‘cdn’]); } register_uninstall_hook( __FILE__, ‘hpcdn_uninstall’ ); // examples function hp_cdn_admin_js() { wp_enqueue_script(‘media-upload’); wp_enqueue_script(‘admin-js’, HP_CDN_URL.‘assets/js/admin.js’); } add_action(‘admin_enqueue_scripts’, ‘hp_cdn_admin_js’); ?> |
Yeah, that :
1 2 3 4 | require_once(“lib/class.hp_cdn.php”); // assumed if( !class_exists(“OpenStack”) ) { require_once(“lib/HP Cloud PHP Binding goes here”); } |
will call the stuffs. You can add the credentials here :
1 2 3 4 5 6 | // example default CDN settings $cdn_settings = new stdClass(); $cdn_settings->username = ‘Username’; // add more here add_option( HP_CDN_OPTIONS, $cdn_settings, ”, ‘yes’ ); unset($_SESSION[‘cdn’]); |
$cdn_settings->username = 'this value';
, $cdn_settings->endpoint = 'this value';
practically ends the game. Thats why we added We might charge a ransom for an existing plugin's extension
, else people can publish it as a paid plugin on those WordPress Jungle marketplace with $160 value.