about thinkIT


We are a growing web development company from Romania(East Europe) with an experience on the market since 2005, having an expert team and we are handling pretty good PHP, MySql, Symfony, ZF, CodeIgniter, REST, WEB 2.0, HTML 5, Custom Web Development, CSS 3, E-comerce Solutions, CMS, Social Networking, jQuery, automated testing, high traffic web optimizations, outsourcing offering to our customers qualITy, statisfaction and guaranteeing the success of their business

Our company is located in Iasi which is the second most important IT center in the country (mainly due to the local big university center).

We are pretty happy to make our business nearby giant companies like: Ness, Siemens, Embarcadero, Amazon, Endava, Pentalog, Delphi.

Our expert team is working in a relaxed environment, having anything they want in the office: latest generation of working stations / good internet connection / free coffee.

In the past few years we offerred our services for customers/companies from all regions on the Earth
most of them becoming permanent clients and being very happy with our professional work and our prices.

That being said, we are confident that we can have a successful collaboration with you.

ThinkITPro.

what recommends us



experience and professionalism
quality of delivered services
trained web developers (Zend PHP 5 - certified)
our current customers
reasonable cost
real time work tracking
flexible and always thinking forward
business hours 9-19 GMT+2
(overlapping with almost all timezones)

our web development services

Business Requirements Analysis

This is the process where we'll understand your needs for the proposed application and based on our previously experience we can help you to improve it and then to find the best solution to implement it.
Benefits of starting with a requirements analysis:
- excluding the risk of building an application that doesn't actually meet your needs
- creating clear specifications from the beginning
- reduce overall cost
- use properly technologies and infrastructure
- by developing a 'mock-up' of the software (most often just the user interface) before starting full development any issues with the application workflow can be indetified and resolved with minimal costs

Custom Application Development

Custom Application Development service is designed to meet the most complex requirements, software architecture/infrastructure and specifications that are not covered by already existing solutions.

Application Analysis&Optimization

Ensure that your applications are secure and prepare for high traffic with:
- server benchmarking/tunning
- code benchmarking/tuning
- database benchmarking/tuning
- interface load speed benchmarking/tuning
- caching solutions
- analyzing security issues

SEO

SEO will help your website to rank better in search engines for the terms that are important to you, increasing traffic and customers of your business. We can't guarantee about any particular ranking, as ultimately, the exact ranking is out of our control, but we will do our best.

Application Maintenance

Keep your business alive with:
- error tracking and debugging
- version upgrades
- feature improvements
- daily technical troubleshooting
- performance monitoring
- testing
- code review & documentation up to date

Application Redevelopment

Keep your applications up to date with:
- new technologies and platforms
- improved performance and scalability
- code cleanup
- new feature implementation
- data migration

E-Commerce & Open-Source Platforms setup

Although those out of the box solutions are pretty easy to setup by nontechnical people, there are some areas where you may need help:
- layout and coding changes
- deployment & server side configurations
- payment gateways guidance
- products import (from existing documents or databases)
- traffic monitoring and analysis - SEO

Project Management and Collaboration

We offer you access to our online Project Management & Collaboration tool. This way we can keep track of project discussions, files, progress and time tracking from beginning to end-all in one place. We eliminate errors due to miscommunication because this tool keeps everyone on the same page. You'll get a bird's eye view on all of the project parameters.

our tutorials

The Problem:

I started to work with NodeJS few years ago and I didn’t had any issues dealing with it until the application I was working on, considerably grew (tons of obects/json stored in memory) and NodeJS starts crashing regularly.

After some research I realized that the issues were:
- the lack of multi-threading (thus increasing the CPU load)
- and the memory limitation (because NodeJS is a 32bit software)
- and of course my not optimized application :)

So, the issue on my side was that the single thread that NodeJS is using and the RAM limit of 1.76GB, was overloaded by my application that I made and I wasn’t able to keep it stable anymore. And I found some solutions that allows me to use all the threads CPU has and all the RAM server has.

Example:
Your host has 1 CPU QuadCore with 8 Threads and 32GB RAM.
In this example your NodeJS application can use all the 32GB of RAM and can create 1 Main Process and 8 childs for each thread that your CPU has.

The solutions:

Increasing NodeJs Memory
RAM limitation is an impediment for each developer if this is a software limitation, so by default NodeJS limits itself on 1.76GB RAM and for some applications this isn’t enough. At the time I’ve started to work with NodeJS, the developers from Google started to work too on an extension that will allow the JavaScript and NodeJS to use more than 1.76GB. That extension is from Chromium and is called V8.

Note: Node.js v4.0.0 already contains V8 v4.5 and you only need to configure it to use more then 2GB of RAM (which defaults to).

In order to install this extension, compile it and then use the kernel V8 of the JavaScript that you need to use on your NodeJS just follow the next commands after you will download and decompress the SourceCode of NodeJS:


                                                    cd node-v0.6.14/deps/v8
                                                    rm -rf *
                                                    svn export http://v8.googlecode.com/svn/tags/3.10.0.5 .

You can replace the version numbers as appropriate. There may be new versions of either node and/or V8 at the time you are reading this.

Next, you’ll need to add a single line addition to “SConstruct” inside the V8 directory.


                                                'CPPPATH': [src_dir],
                                                'CPPDEFINES': ['V8_MAX_SEMISPACE_SIZE=536870912'],
                                                

The second line above is new. Basically, you just need to set that V8_MAX_SEMISPACE definition. It will otherwise default to a much lower value, causing frequent garbage collection to trigger, depending on the memory characteristics of your server JS.

Next, comment out the call to “CollectAllGarbage” in “V8/heap-inl.h”:


                                                 if (amount_since_last_global_gc > external_allocation_limit_) {
                                                    //CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached");
                                                 }
                                                

This was done “just in case” because it costs me money each time I run a scaling test. I wanted to be damn sure it was not going to trigger the external allocation limit GC!

That’s done and to use this feature that you updated on the NodeJS software you should add those parammeters on the start command line for your script


                                                 node –max-old-space-size=8192 –nouse-idle-notification your_application.js
                                                

“–nouse-idle-notification”

This is a command line parameter you can pass to node. It gets passed along to the V8 engine, and will prevent it from constantly running that garbage collector. IMO, you can’t do a real-time server with constant ~4 second latency hiccups every 30 seconds or so.

You might want to also use the flag “–expose-gc”, which will enable the “gc();” function in your server JavaScript code. You can then tie this to an admin mechanism, so you will retain the power to trigger garbage collection at any time you want, without having to restart the server. For the most part, if you don’t leak Objects all over the place, you won’t really need to do this often, or at all. Still, it’s useful to have the capability.

“–max-old-space-size=8192”

This you can tweak to fit your particular server, but the value is in MB. I chose 8GB because my expectation is that 4GB is going to be plenty, and 8GB was just for good measure. You may also consider using “–max-new-space-size=2048” (measured in KB, as opposed to the other). I don’t believe that one is nearly as critical, though.

Multithreading
This step could be called also “Taking Advantage of Multi-Processor Environments in NodeJS” because it’s implemented with a library that already exists in NodeJS. Actually to take advantage on NodeJS multithreading, you need to create a load-balancer.
Note: I would like you to keep in mind that NodeJS doesn’t know how to share the memory content between the threads. But we’ll cover this too, in this tutorial.
Here is how to do it:


                                                 var cluster = require('cluster');
                                                    var http = require('http');
                                                    var numCPUs = require('os').cpus().length;

                                                    if (cluster.isMaster) {
                                                        // Create the HTTP server on the Master Cluster
                                                        createHttpServer();

                                                        cluster.on('exit', function(worker, code, signal) {
                                                            console.log('worker ' + worker.process.pid + ' died!');
                                                        });
                                                    }

                                                    function createHttpServer()
                                                    {
                                                        http.createServer(function(req, res) {
                                                            res.writeHead(200);
                                                            res.end("hello world\n");
                                                        }).listen(8000);
                                                            
                                                            if (cluster.isMaster) {
                                                                // Fork workers after you started the server to manange something else
                                                                // Like: update some data from cache ( the only way to share the content )
                                                                // , update some data from MySQL,
                                                                // cache them into JSON files / MemCache,
                                                                // (or other cache / sql softwares that you need ) and 
                                                                // then master will read from them and so on...
                                                                for (var i = 0; i < numCPUs; i++) {
                                                                    cluster.fork();
                                                                }
                                                            }
                                                    }

                                                    // Some example for update function
                                                    function updateDataFromCache()
                                                    {
                                                        // In my situation I used the MemCache, MySQL and JSON files
                                                        // to share the data between the workers
                                                        if (!cluster.isMaster) {
                                                            // Code for update your cache ( maybe with a timer )
                                                            // this part of the code will be executed just in the child workers
                                                            // the master worker will keep just the HTTP Server running
                                                        }
                                                    }
                                                

My purpose for this was to create a scheduled HTTP Server with an update function that grabs the data from MySQL and MemCached like this:
- the HTTP server started in MasterCluster and just that it was running there.
- the update function for all data types that I’ve had was running on the rest of the Child Workers, the data was grabbed from MySQL and MemCache and then was stored in some local JSON files.
- the HTTP server has a scheduler that will read those cached JSON files every 30 min.
- the Update function from Child Workers has a scheduler that will pull the data and cache every 10 min.

That’s all about “How to increase the performance of NodeJS to run your scripts”. I hope you enjoyed this tutorial that I’ve made and I hope it helped you.

This solution have advantages and disadvantages and they are as follow:

Advantages

- NodeJS can use all of your CPU threads to balance the overloading from processor and split the work in more processes
- you can use those child workers to make the hard work, like update functions, read from big files, write on big files, execute something that will take long and in this time the Main process will work without any hiccup
- lifting the limitation of RAM will allow you to save more data in NodeJS objects and to keep them in RAM without any overloading, without crashing the NodeJS application and without losing anything

Disadvantages

- the threads can’t share the content from memory, this will force you to use an additional technique that will connect those threads between them and share the data from eachother
- the threads can’t communicate with eachother and they can run the same code if you don’t handle this from your application and this can overwrite the correct data from Child workers.
- if you have an issue on the code for Main Process ( master worker ) then the entire server will crash or will be overloaded, so my suggestion is to use on this master worker, only simple tasks.

Author: Emilian Popa - Senior WebDeveloper @ ThinkITPro

What is Google Cloud SQL?

Google Cloud SQL is a web service that allows you to create, configure, and use relational databases that live in Google's cloud. It is a fully-managed service that maintains, manages, and administers your databases, allowing you to focus on your applications and services.

By offering the capabilities of a familiar MySQL database, the service enables you to easily move your data, applications, and services in and out of the cloud. This enables high data portability and helps you achieve faster time-to-market because you can quickly leverage your existing database.

There is a range of configurations from small instances costing just $0.025 per hour up to high end instances with 16GB of RAM and 100GB of data storage. The per use billing option means you only pay for your instance while it is being accessed. The package option has lower and more predictable costs for instances that are frequently accessed.

CodeIgniter Use Google Cloud SQL

In your CodeIgniter directory, open the file application/config/database.php and edit the $db array which as follow:

<?php
                                                    $db
['default']['hostname'] = ':/cloudsql/YOUR-PROJECT-NAME:YOUR-SQL-INSTANCE-NAME';
                                                    
$db['default']['username'] = 'YOUR-APPLICATION-ACCOUNT-USERNAME';
                                                    
$db['default']['password'] = 'YOUR-APPLICATION-ACCOUNT-PASSWORD';
                                                    
$db['default']['database'] = 'YOUR-DATABASE-FROM-SQL-INSTANCE';
                                                    
$db['default']['dbdriver'] = 'mysql';
                                                    
$db['default']['dbprefix'] = '';
                                                    
$db['default']['pconnect'] = FALSE;
                                                    
$db['default']['db_debug'] = FALSE;
                                                    
$db['default']['cache_on'] = FALSE;
                                                    
$db['default']['cachedir'] = '';
                                                    
$db['default']['char_set'] = 'utf8';
                                                    
$db['default']['dbcollat'] = 'utf8_general_ci';
                                                    
$db['default']['swap_pre'] = '';
                                                    
$db['default']['autoinit'] = TRUE;
                                                    
$db['default']['stricton'] = FALSE;
                                                    
?>

* Don't forget to put the value of 'pconnect' and 'db_debug' to FALSE !

Description

This library gives the php developer much more intuitive access to the facebook api methods and entities. It is well documented and complete.
This library helps you to collect the necessary information from the user connected on your Facebook Application.



How do I use it?

1) Place this code in your CodeIgniter directory application/libraries/fb.php :
* If you want to rename this file you must also rename the class with the same filename without extension php.


                                            <?php
                                            
require(APPPATH.'libraries/facebook/facebook.php');
                                            
/**
                                             * Facebook Library
                                             *
                                             * This library gives the php developer much more intuitive access to
                                             *        the facebook api methods and entities.
                                             *
                                             * @package     fb
                                             * @author      ThinkItPro
                                             * @copyright   Copyright (c) 2013, ThinkItPro, Inc.
                                             * @link        http://thinkitpro.com
                                             * @since       Version 1.0
                                             */
                                            
class fb
                                            
{
                                                private 
$_obj;
                                                private 
$_api_key NULL;
                                                private 
$_secret_key NULL;
                                                
                                                private 
$_login "Login";
                                                private 
$_logout "Logout";
                                                
                                                private 
$_user NULL;
                                                private 
$_user_data NULL;
                                                
                                                private 
$fb_sdk FALSE;
                                                
                                                
/**
                                                 * __contruct() initialize fb class with CodeIgniter instance and read configuration file
                                                 *
                                                 * @access        public
                                                 * @include        application/config/facebook.php
                                                 */
                                                
public function __construct()
                                                {
                                                    
$this->_obj =& get_instance();
                                                    
$this->_obj->load->config('facebook');
                                                    
$this->_obj->load->library('session');
                                                    
$this->_obj->load->helper('cookie');
                                                    
$this->_obj->load->helper('url');
                                                    
$this->_api_key $this->_obj->config->item('facebook_api_key');
                                                    
$this->_secret_key $this->_obj->config->item('facebook_secret_key');
                                                    
                                                    
$this->fb_sdk = new Facebook_SDK(array(
                                                        
'appId' => $this->_api_key,
                                                        
'secret' => $this->_secret_key,
                                                    ));
                                                    
                                                    if(
$this->_obj->input->get('logout')) {
                                                        
$this->_obj->session->sess_destroy();
                                                        
delete_cookie('PHPSESSID');
                                                        echo 
"<script>
                                                            var url = window.location.origin + window.location.pathname;
                                                            window.location = url;
                                                        </script>"
;
                                                        
$this->_user null;
                                                    }
                                                    
                                                    
$this->_user $this->fb_sdk->getUser();
                                                    
$this->initialize();
                                                }
                                                
                                                
/**
                                                 * initialize() initialize Facebook SDK
                                                 *
                                                 * @access        private
                                                 */
                                                
private function initialize()
                                                {
                                                    if(
$this->_user){
                                                        try {
                                                            
$this->_user_data $this->fb_sdk->api('/me');
                                                        } catch (
FacebookApiException $e) {
                                                            
error_log($e);
                                                            
$this->_user null;
                                                        }
                                                    }
                                                }
                                                
                                                
/**
                                                 * set_button_text() set text for login and logout button
                                                 *
                                                 * @access        public
                                                 * @param        string    $login default null
                                                 * @param        string    $logout default null
                                                 */
                                                
public function set_button_text($login=null$logout=null)
                                                {
                                                    
$this->_login $login;
                                                    
$this->_logout $logout;
                                                }
                                                
                                                
/**
                                                 * get_url() get url for login and logout buttons
                                                 *
                                                 * @access        public
                                                 * @param        bool    $array default false if you want to return just the URL,
                                                 *                                 true if you want to return array of URL and text
                                                 * @return        string    if the parameter $array is false
                                                 * @return        array    if the parameter $array is true
                                                 */
                                                
public function get_url($array=false)
                                                {
                                                    if(
$array==true){
                                                        
$ret = array();
                                                        if(
$this->_user){
                                                            
$ret['url'] = $this->fb_sdk->getLogoutUrl();
                                                            
$ret['text'] = $this->_logout;
                                                        } else {
                                                            
$ret['url'] = $this->fb_sdk->getLoginUrl();
                                                            
$ret['text'] = $this->_login;
                                                        }
                                                        return 
$ret;
                                                    } else {
                                                        if(
$this->_user){
                                                            return 
$this->fb_sdk->getLogoutUrl();
                                                        } else {
                                                            return 
$this->fb_sdk->getLoginUrl();
                                                        }
                                                    }
                                                }
                                                
                                                
/**
                                                 * getUserData() get user data
                                                 *
                                                 * @access        public
                                                 * @param        string    $what default null
                                                 * @param        array    $what default null
                                                 * @return        string    when parameter $what is string 
                                                 *                                and equal with which key do you want from user data
                                                 * @return        array    when parameter $what is array
                                                 *                                which contain the keys from user data
                                                 * @return        array    when parameter $what is null ( default ) with all user data
                                                 */
                                                
public function getUserData($what=null)
                                                {
                                                    if(
$what!=null && !is_array($what))
                                                    {
                                                        
$d = array();
                                                        if(
is_array($this->_user_data)){
                                                            foreach (
$this->_user_data as $key => $value) {
                                                                if(
$key == $what){
                                                                    return 
$value;
                                                                }
                                                            }
                                                        } else {
                                                            return 
null;
                                                        }
                                                    } elseif(
$what!=null && is_array($what)) {
                                                        
$data = array();
                                                        foreach(
$what as $val){
                                                            if(
$this->_user_data[$val]){
                                                                if(
$val=="location") {
                                                                    
$data[$val] = $this->_user_data[$val]["name"];
                                                                } else {
                                                                    
$data[$val] = $this->_user_data[$val];
                                                                }
                                                            }
                                                        }
                                                        return 
$data;
                                                    } else {
                                                        return 
$this->_user_data;
                                                    }
                                                }
                                                
                                                
/**
                                                 * LoginStatus() get user AccesToken
                                                 *
                                                 * @access        public
                                                 * @return        string
                                                 */
                                                
public function LoginStatus()
                                                {
                                                    return 
$this->fb_sdk->getAccessToken();
                                                }
                                            }
                                            
?>
2) Upload this code in your CodeIgniter directory application/config/facebook.php :

                                    <?php
                                    
/**
                                     * Facebook Configuration file
                                     *
                                     * Configuration file for Facebook Library
                                     *
                                     * @author      ThinkItPro
                                     * @copyright   Copyright (c) 2013, ThinkItPro, Inc.
                                     * @link        http://thinkitpro.com
                                     * @since       Version 1.0
                                     */
                                    
$config['facebook_api_key'] = 'YOUR_FACEBOOK_API_KEY';
                                    
$config['facebook_secret_key'] = 'YOUR_FACEBBOK_SECRET_KEY';
                                    
                                    
?>

3) Upload in your CodeIgniter directory application/libraries the Facebook PHP SDK and if the folder extracted doesn't have the name facebook, I want you to renamed it in facebook!

4) Make this configuration for your Facebook Application for developing mode:

- Go and "Edit App"
- At "App Domains:" put your localdomain ( default: localhost ) or your host domain
- At "Site URL:" put the url to redirect after login with your application
- If you user your local computer to test this application follow this step: At the left menu go to "Advanced" and at the Security-> "Server IP Whitelist:" put your global IP ( Your global IP is: 23.22.206.103 )



Now what?

Lets re-create the example provided with the sdk to give you a comparison to be able to translate other facebook php-sdk examples to codeigniter friendly semantics.
Now for the CI version

Controller

<?php
                                                
class Example extends CI_Controller {
                                                
                                                    function 
__construct()
                                                    {
                                                        
parent::__construct();
                                                        
$this->load->library("fb");
                                                    }
                                                
                                                    function 
index()
                                                    {
                                                        
$this->fb->set_button_text("LogIn""LogOut");
                                                        
$data['button'] = $this->fb->get_url(true);
                                                        
                                                        
$data['user_data'] = $this->fb->getUserData();
                                                        
                                                        
$this->load->view('view',$data);
                                                    }
                                                }
                                                
?>

View

<html>
                                                <head>
                                                    <title>Facebook API TEST</title>
                                                </head>
                                                <body>
                                                    <h1>Facebook stuff</h1>
                                                
                                                    <?php if (@$user_data): ?>
                                                        <pre>
                                                            <?php echo print_r($user_dataTRUE?>
                                                        </pre>
                                                    <?php else: ?>
                                                        <h2>Welcome to this facebook thing, please login below</h2>
                                                    <?php endif; ?>
                                                    <a href="<?php echo $button['url'?>"><?php echo $button['text'?></a>
                                                
                                                </body>
                                                </html>

* Don't forget to download Facebook PHP SDK and upload it in application/libraries
* If you have issues to implement this library, download the repository file from Facebook Api Integration Repository

Description

PayTpv is a payment gateway service with an impressive number of features:

  • Quick integration into an existing website using generated forms for credit and debit cards
  • Web interface that provides a sales force the option of selling via phone, with finely-grained access for each account
  • Administrative account to review sales, apply chargebacks
  • Easy to use and accurate statistics
  • XML Soap support for handling a large number of concurrent payments
  • Antifraud system to avoid false valid transactions, stolen cards
  • One-click generated buttons for faster shopping
  • Recurrent payments and subscription management

Use Case

For one of our customers we have implemented this payment solution in a way to allow his sales team to create orders and allow the customers to pay while on the field. By implemented both a website and a mobile-optimised wizard we have allowed the team to make sales right after a presentation without needing to carry a laptop with them.

The mobile shopping wizard has been a huge success, getting to be used by regular customers to order needed items while working on the field. This way next-day delivery became easy to do by eliminating almost all late night orders.

Need Help?

If you have questions about payment service in general or about implementing the PayTPV API in your software or web application please contact us.

Description

Garanti Bank is is Turkey's second largest private bank. It provides a web REST-full XML API for merchants that can be used to

  • make payments
  • refund payments
  • query account information
  • starting a recurring payment schedule
  • pausing a recurring payment or modifyng the payment value
  • stopping a recurring payment schedule

It has support for checks and all major credit card companies, including, but not limited to:

  • Visa
  • Master Card
  • American Express

Garanti Bank API allows the use of multiple currencies including:

  • TRL
  • USD
  • EURO
  • GBP
  • JPY

Garanti Bank API supports full secure 3D Secure XML-baset payments, using SSL connections with client authentication, giving merchants a way to reduce uauthorized transaction chargebacks and provides customers with a decreased risk of fraudulent usage of their credit card and personal information.

The XML API provides meaningfull error messages that can be send back to the customer, including non-valid information and not enough funds on the card, helping them to correct any mistyped details. A big advantage of using the API from the server, avoiding redirecting the customers through multiple off-site pages, is a seamless integration with the online shop and provides a better method of tracking the customer's actions.

The provided API provides support for both recurring payments and multiple addresses. Each payment is given an identifier and can be later reviewed if necesarry.

Use Case

We have implemented complete gateway payment solutions that are used by multiple websites, offering the merchants a web-based interface to configure and review their payment processing details, while being PCI-DSS compliant.

Challenges

Our team worked closely with the support staff at Garanti Bank to ensure a fast and secure implementation of the provided api, from the initial documentation until going live and finalising the testing phase with real payments and refunds.

The biggest challenge was using the api - the main documentation being in turkish and the provided english documents were lacking. By talking daily over email and phone with the support staff we've managed to meet the deadline set by our client - with time to spare!.

Need Help?

If you have questions about payment service in general or about implementing the Garanti Payment API in your software or web application please contact us.

Description

As more customers come from search engines, getting them to the right product or product list can sometimes be a challange. With our implementation we show the customers the most probable items that they are interested in based on their searches. The recomended product list ca be edited by the website admin or any employee via a simple web interface.

Use case

The client has a online store with tens of thousands of products. When creating Google Adsense Campaigns for a large number of products he did not want to create a campaign for each product.

We developed a web page page for him to use as the campaign's target. A back-end administrative page was created to allow configuration of products, priority and other per-product settings. When a visitor clics on a Google Adsense Ad it is redirected to the custom page that displays the relevant product, taking into account the search keywords that Adsenses provides.

Need Help?

If you have questions about search engines, landing pages, optimising websites for quick shopping please contact us.

Description

This library gives the php developer much more intuitive access to the twitter api methods and entities. It is well documented and complete.
This library helps you to collect the necessary information from the user connected on your Twitter Application.



How do I use it?

1) Place this code in your CodeIgniter directory application/libraries/twitter_lib.php :
* If you want to rename this file you must also rename the class with the same filename without extension php.


                                            <?php
                                            
require(APPPATH.'libraries/twitter/twitteroauth.php');
                                            
/**
                                             * Twitter Library
                                             *
                                             * This library gives the php developer much more intuitive access to
                                             *        the twitter api methods and entities.
                                             *
                                             * @package     Twitter_lib
                                             * @author      ThinkItPro
                                             * @copyright   Copyright (c) 2013, ThinkItPro, Inc.
                                             * @link        http://thinkitpro.com
                                             * @since       Version 1.0
                                             */
                                            
class twitter_lib
                                            
{
                                                private 
$_obj;
                                                public 
$isLogged false;
                                                
                                                
/**
                                                 * __contruct() initialize twitter_lib class with CodeIgniter instance and read configuration file
                                                 *
                                                 * @access        public
                                                 * @include        application/config/twitter.php
                                                 */
                                                
public function __construct()
                                                {
                                                    
$this->_obj =& get_instance();
                                                    
$this->_obj->load->config('twitter');
                                                    
$this->_obj->load->library('session');
                                                    
$this->_obj->load->helper('cookie');
                                                    
$this->_obj->load->helper('url');
                                                }
                                                
                                                
/**
                                                 * callback() get twitter data after user login
                                                 *
                                                 * @access        public
                                                 */
                                                
function callback(){
                                                    
log_message('debug','TWITTER callback');
                                                    if (   isset(
$_REQUEST['oauth_token']) 
                                                        && 
$this->_obj->session->userdata('oauth_token') !== $_REQUEST['oauth_token']
                                                    ) {
                                                        
log_message('debug','TWITTER clearing old session');
                                                        
$this->_obj->session->set_userdata('oauth_status',false);
                                                        
$this->_obj->session->set_userdata('oauth_token_secret',false);
                                                        
$this->_obj->session->set_userdata('oauth_token',false);
                                                    }
                                                    if(isset(
$_REQUEST['oauth_token']) && $this->_obj->session->userdata('oauth_token')!=false){
                                                        
$connection = new TwitterOAuth(
                                                             
$this->_obj->config->item('consumer_key')
                                                            ,
$this->_obj->config->item('consumer_secret')
                                                            ,
$this->_obj->session->userdata('oauth_token')
                                                            ,
$this->_obj->session->userdata('oauth_token_secret')
                                                            );
                                                         
$access_token $connection->getAccessToken($_REQUEST['oauth_verifier']);
                                                         
log_message('debug','TWITTER oauth_verifier');
                                                         
log_message('debug',$access_token);
                                                         
//$acces_token
                                                         
$this->_obj->session->set_userdata('access_token',$access_token);   
                                                         
$this->_obj->session->set_userdata('oauth_token_secret',false);
                                                         
$this->_obj->session->set_userdata('oauth_token',false);    
                                                        
                                                         
                                                         if (
200 == $connection->http_code) {
                                                            
$this->isLogged true;
                                                            
$this->_obj->session->set_userdata('status','verified');
                                                            
redirect(base_url($this->_obj->config->item('oauth_callback')));
                                                         }else{
                                                             
log_message('debug','TWITTER auth error on '.__FILE_.' '.__LINE__);
                                                             
                                                        }
                                                    }
                                                    
                                                }
                                                
                                                
/**
                                                 * redirect_for_login() redirect to twitter to login and request data for api
                                                 *
                                                 * @access        public
                                                 */
                                                
function redirect_for_login(){
                                                    
log_message('debug','TWITTER redirect_for_login');
                                                    
$connection = new TwitterOAuth
                                                         
$this->_obj->config->item('consumer_key')
                                                        ,
$this->_obj->config->item('consumer_secret')
                                                        );
                                                    
log_message('debug','TWITTER callback url is '.base_url($this->_obj->config->item('twitter_oauth_callback')));
                                                    
$request_token $connection->getRequestToken(
                                                        
base_url($this->_obj->config->item('oauth_callback'))
                                                    );
                                                    
log_message('debug','TWITTER request token');
                                                    
log_message('debug',$request_token);
                                                    
$this->_obj->session->set_userdata('oauth_token',$request_token['oauth_token']);
                                                    
$this->_obj->session->set_userdata('oauth_token_secret',$request_token['oauth_token_secret']);
                                                    switch(
$connection->http_code){
                                                        case 
200:
                                                            
$url $connection->getAuthorizeURL($request_token);
                                                            
log_message('debug','TWITTER authorize URL');
                                                            
log_message('debug',$url);
                                                            
header('Location: ' $url);
                                                            break;
                                                            
                                                        default:
                                                            
log_message('error','TWITTER - could not connect to api '.__FILE__.' '.LINE);
                                                            
// TODO:: change redirect / error code json ?
                                                            
redirect('/twitter');
                                                            break;
                                                    }
                                                }
                                            
                                                
/**
                                                 * logOutUser() remove all api session
                                                 *
                                                 * @access        public
                                                 */
                                                
public function logOutUser(){
                                                    
$this->_obj->session->set_userdata('oauth_status',false);
                                                    
$this->_obj->session->set_userdata('oauth_token_secret',false);
                                                    
$this->_obj->session->set_userdata('oauth_token',false);
                                                    
$this->_obj->session->set_userdata('access_token',false);
                                                }
                                                
                                                
/**
                                                 * getUserId() get twitter user id
                                                 *
                                                 * @access        public
                                                 * @return        string    userId
                                                 * @return        boolean    when user is not logged in
                                                 */
                                                
public function getUserId(){
                                                    
$ac=$this->_obj->session->userdata('access_token');
                                                    if(
is_array($ac) && isset($ac['user_id'])){
                                                        return 
$ac['user_id'];
                                                    }
                                                    return 
false;
                                                }
                                                
                                                
/**
                                                 * getScreenName() get twitter screen name
                                                 *
                                                 * @access        public
                                                 * @return        string    screen name
                                                 * @return        boolean    when user is not logged in
                                                 */
                                                
public function getScreenName(){
                                                    
$ac=$this->_obj->session->userdata('access_token');
                                                    if(
is_array($ac) && isset($ac['screen_name'])){
                                                        return 
$ac['screen_name'];
                                                    }
                                                    return 
false;
                                                }
                                                
                                                
/**
                                                 * isLoggedIn() return true if user is logged in
                                                 *
                                                 * @access        public
                                                 * @return        boolean    return true if user is loggend in otherwise return false
                                                 */
                                                
public function isLoggedIn(){
                                                    if(
false!==$this->_obj->session->userdata('access_token')){
                                                        
$ac=$this->_obj->session->userdata('access_token');
                                                        if(     
is_array($ac
                                                            && isset(
$ac['user_id']) 
                                                            && isset(
$ac['screen_name'])
                                                            && isset(
$ac['oauth_token'])
                                                            && isset(
$ac['oauth_token_secret'])
                                                        ){
                                                            return 
true;
                                                        }
                                                    }
                                                    return 
false;
                                                }
                                            }
                                            
?>

2) Upload this code in your CodeIgniter directory application/config/twitter.php :


                                                            <?php
                                                            
/**
                                                             * Twitter Configuration file
                                                             *
                                                             * Configuration file for Twitter Library
                                                             *
                                                             * @author      ThinkItPro
                                                             * @copyright   Copyright (c) 2013, ThinkItPro, Inc.
                                                             * @link        http://thinkitpro.com
                                                             * @since       Version 1.0
                                                             */
                                                            
$config['consumer_key'] = 'YOUR_TWITTER_CONSUMER_KEY';
                                                            
$config['consumer_secret'] = 'YOUR_TWITTER_CONSUMER_SECRET';
                                                            
$config['oauth_callback'] = 'YOUR_TWITTER_OAUTH_CALLBACK';
                                                            
                                                            
?>

3) Upload in your CodeIgniter directory application/libraries the TwitterOAuth PHP SDK and if the folder extracted doesn't have the name twitter, I want you to renamed it in twitter!



Now what?

Lets re-create the example provided with the sdk to give you a comparison to be able to translate other twitter api examples to codeigniter friendly semantics.
Now for the CI version

Controller

<?php
                                                        
                                                        
class Twitter extends CI_Controller {
                                                            
                                                            public function 
__construct(){
                                                                
parent::__construct();
                                                                
$this->load->library("twitter_lib");
                                                            }
                                                            
                                                            public function 
index(){
                                                                
$this->twitter_lib->callback();
                                                                if(
$this->twitter_lib->isLoggedIn()){
                                                                    echo 
'Button: <a href="'.site_url('/Twitter/logout').'">LogOut</a>'// If you rename the constroller name, edit the site_url path too
                                                                    
echo "<pre>";
                                                                    
var_dump($this->twitter_lib->getUserId());
                                                                    
var_dump($this->twitter_lib->getScreenName());
                                                                    echo 
"</pre>";
                                                                } else {
                                                                    echo 
'Button: <a href="'.site_url('/Twitter/login').'">LogIn With Twitter</a>'// If you rename the constroller name, edit the site_url path too
                                                                
}
                                                            }
                                                            
                                                            public function 
login(){
                                                                
$this->twitter_lib->redirect_for_login();
                                                            }
                                                            
                                                            public function 
logout(){
                                                                
$this->twitter_lib->logOutUser();
                                                                
redirect('Twitter'); // If you rename the constroller name, edit the redirect path too
                                                            
}
                                                            
                                                        }
                                                        
?>

* Don't forget to download TwiterOAuth and upload it in application/libraries
* If you have issues to implement this library, download the repository file from Twitter Api Integration Repository

Description

PCI DSS (Payment Card Industry Data Security Standard) is the industry standard that describes the whay to handle credit card data in a secure manner. It was defined by the Payment Card Industry Security Standards Council which is createad by the major debic, credit, prepaid, e-purse, ATM and POS card companies.

Being PCI-DSS means being subjected to, and passing, yearly audits. Through these audits every step in receving, handling, sending or storing credit cards information is inspected for vulnerabilities.

In the event of a security breah, not being PCI-DSS compliant will mean higher fines and additional penalties compared to PCI-DSS compliant merchants, each credit card information that was stolen of leaked being considered a separate infraction.

Use case

PCI-DSS compliance starts with securing the hardware infrastructure at the physical, network, software and database levels, that is why we start with a good software architecture that supports all the necesary security layers.

Need Help?

If you have questions about handling credit card data or implementing a payment solution for your online store please contact us.

our clients

  • Crawlers
  • Website High Traffic Optimization
  • Aurum24
  • JOL
  • StartupBlink
  • Google Maps Timeline
  • Lawbench
  • Trackitt
  • Neuroncology
  • PIC2012
  • LawStaff
  • Tarrant County College District
  • CPR FAMILY WEBSITES
  • PuzzlesForSale
  • Welist
  • Editors for Students
  • AirlineMeals
  • CharterSchoolCapital
  • BalanceofLove
  • Fusion-India
  • ScriptureLullaby
  • AvasFlowers
  • MagazineDiscountCenter
  • InGaraj
  • Crewlog
  • MagazinulPiticilor
  • BoaTechnology
  • Garanty Payment API
  • PayTPV
  • Google Adsense Redirect
  • PCI-DSS Compliance
This is just a small part of our work in the past few years. Please feel free to browse and request a free quote when you are ready. Thank you!

testimonials

Once again, thank you for all your hard work and brace yourself for some more. Dylan, Red Square

Thank you for your patience and understanding. At the end of the project, I am very satisfied with the work your team performed. Guy Leduc, FunWeb

Excellent team work. George and his team were able to comprehend and digest a very complex existing application in short order prior to enhancing the functionality based on our specifications. They enhanced the functionality, improved security of the system and user friendliness. Successfully maintain website over a period of one year. Plan to hire them again for the next project. Journey of Life

QuickContact


Please feel free to contact us for any further information. You will get the answer/offer in the shorthest time possible!

Your message has been sent. We will contact you as soon as possible.
Thank you


(Allowed files: .pdf .doc .docx .txt. File size: 2MB max)

Company info

Business Hours: 9-19 GMT+2
Local Time: 26-09-2016 04:52:34
18 Stradela Silvestru Iasi, Romania
contact@thinkitpro.com
+40-753-331-098

Connect with us

Last update: 2016