• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » OpenStack Swift & HPCloud CDN PHP Bindings : Basics

By Abhishek Ghosh February 19, 2015 7:40 am Updated on February 19, 2015

OpenStack Swift & HPCloud CDN PHP Bindings : Basics

Advertisement

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.

Advertisement

---

 

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

 

OpenStack Swift & HPCloud CDN PHP Bindings : Basics

 

You will get the Tagged source code from here :

Vim
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:

Vim
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 :

Vim
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 :

Vim
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) :

Vim
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 :

Vim
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 :

Vim
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.

Tagged With limelight cdn openstack swift , openstack cdn url , openstack swift cdn , paperuri:(c0b6511e6d354d1238cab7ee4f046b3f)

This Article Has Been Shared 143 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to OpenStack Swift & HPCloud CDN PHP Bindings : Basics

  • Cloud and SaaS : Is Cloud Based SaaS Becoming the Mainstream ?

    Cloud Computing is becoming the dominant global trend not only in enterprise IT but also in Private Small Sectors. Better,faster,cheaper is pushing Cloud ahead.

  • Juju on Rackspace Cloud Server : Test Drive with Ubuntu 12.04

    Juju on Rackspace Cloud Server is a test drive in real time. It is some what like driving a F1 car on a busy avenue for the first time in life. Start the Cloud. And the ride is too without wearing helmet – on an Operating System without any smartness – Windows 7 with PuTTY. […]

  • SaaS : Everything You Wanted To Know

    SaaS or Software as a Service is designed by the architecture to be used by the consumer. SaaS is the model oCloud which the general users mostly know to exist.

  • Rackspace Deployment Services Early Access Video Guide

    Rackspace Deployment Services Early Access Video Guide Shows How to Setup Rackspace Cloud Server, Load Balancers, Cloud Database in easy clicks from GUI.

  • Points to Check Before Switching to Cloud Computing

    If you work as a IT service provider you need either to explain the benefits of cloud computing or decide to switch own business, some points to check before switching to Cloud.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (22.1K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • How Artificial Intelligence (AI) Is Changing The Way We Play Bingo May 16, 2022
  • Why You Need A Big Data Consultant May 15, 2022
  • The Connection Between AI And Online Slots May 13, 2022
  • How To Choose Your Niche As An Instagram Influencer May 12, 2022
  • How to Choose a Powerful Domain Name for Your New Venture May 12, 2022

About This Article

Cite this article as: Abhishek Ghosh, "OpenStack Swift & HPCloud CDN PHP Bindings : Basics," in The Customize Windows, February 19, 2015, May 16, 2022, https://thecustomizewindows.com/2015/02/openstack-swift-hpcloud-cdn-php-bindings-basics/.

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2022 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy