working on it ...

Filters

Explore Public Snippets

Sort by

Found 60k snippets

    public by azazqadir modified Thursday at 10:25:40 AM  63  0  3  0

    Adding Captcha in CodeIgniter

    Source: https://www.cloudways.com/blog/captcha-in-codeigniter/
    <?php
    
    defined('BASEPATH') OR exit('your exit message');
    
    class Captcha extends CI_Controller
    
    {
    
       function __construct()
    
       {
    
           parent::__construct();
    
           $this->load->helper('captcha');
    
       }
    
       public function index()
    
       {
    
           if ($this->input->post('submit')) {
    
               $captcha_insert = $this->input->post('captcha');
    
               $contain_sess_captcha = $this->session->userdata('valuecaptchaCode');
    
               if ($captcha_insert === $contain_sess_captcha) {
    
                   echo 'Success';
    
               } else {
    
                   echo 'Failure';
    
               }
    
           }
    
           $config = array(
    
               'img_url' => base_url() . 'image_for_captcha/',
    
               'img_path' => 'image_for_captcha/',
    
               'img_height' => 45,
    
               'word_length' => 5,
    
               'img_width' => '45',
    
               'font_size' => 10
    
           );
    
           $captcha = create_captcha($config);
    
           $this->session->unset_userdata('valuecaptchaCode');
    
           $this->session->set_userdata('valuecaptchaCode', $captcha['word']);
    
           $data['captchaImg'] = $captcha['image'];
    
           $this->load->view('captcha/index', $data);
    
       }
    
       public function refresh()
    
       {
    
           $config = array(
    
               'img_url' => base_url() . 'image_for_captcha/',
    
               'img_path' => 'image_for_captcha/',
    
               'img_height' => 45,
    
               'word_length' => 5,
    
               'img_width' => '45',
    
               'font_size' => 10
    
           );
    
           $captcha = create_captcha($config);
    
           $this->session->unset_userdata('valuecaptchaCode');
    
           $this->session->set_userdata('valuecaptchaCode', $captcha['word']);
    
           echo $captcha['image'];
    
       }
    
    }

    public by azazqadir modified Dec 15, 2017  168  1  4  0

    Installing PHP Website on Linode Server

    Here is how you can easily host a PHP based website easily and quickly on Linode using Cloudways PaaS: https://www.cloudways.com/blog/host-php-on-linode/
    <?php
    echo rand() . "\n";
    echo rand() . "\n";
    
    echo rand(5, 15);
    ?>

    public by azazqadir modified Nov 21, 2017  216  0  5  1

    CDN integration in Yii2 App

    How to integrate CloudwaysCDN with Yii2 applications: https://www.cloudways.com/blog/cdn-in-yii2/
    // ...
    
    'components' => [
    
       // ...
    
    'cdn' => [
                'class' => '\yii2cdn\Cdn',
                'baseUrl' => defined ('YII2CDN_OFFLINE')
                    ? 'http://localhost/yii2/cdn'
                    : '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn',
                'basePath' => dirname(__DIR__, 2) . '/cdn',
                'components' => [
                    'font-awesome' => [
                        'css' => [
                            [
                                // local version
                                'font-awesome.min.css',
                                // cdn version
                                '@cdn' => '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn/font-awesome/css/font-awesome.min.css',
                            ]
                        ]
                    ]
                ],
            ],
     // ...
    
    ],
    
    // ...

    public by azazqadir modified Nov 15, 2017  59  0  1  0

    Using Eloquent Outside of Laravel for Other PHP Apps. Source: https://www.cloudways.com/blog/eloquent-illuminate-in-php-without-laravel/

    Using Eloquent Outside of Laravel for Other PHP Apps. Source: https://www.cloudways.com/blog/eloquent-illuminate-in-php-without-laravel/: bootstrap.php
    <?php
    
    
    
    require "vendor/autoload.php";
    
    use Illuminate\Database\Capsule\Manager as Capsule;
    
    
    
    $capsule = new Capsule;
    
    
    
    $capsule->addConnection([
    
       "driver" => "mysql",
    
       "host" =>"127.0.0.1",
    
       "database" => "acl",
    
       "username" => "root",
    
       "password" => ""
    
    ]);
    
    $capsule->setAsGlobal();
    
    $capsule->bootEloquent();
    
    

    public by AbhishekGhosh modified Oct 11, 2017  117  1  2  0

    ob flush example

    ob flush example: ob_flush.php
    <?php
    
    /*
    	== ob_end_flush() ==
    	Flush (send) the output buffer and turn off output buffering
    
    	== ob_end_clean() ==
    	Clean (erase) the output buffer and turn off output buffering
    
    	== ob_get_contents() ==
    	Return the contents of the output buffer
    */
    
    
    # The following two functions result in the same output.
    
    function output_some_html_with_var() {
    	ob_start();
    	?>
    	<p>This is a paragraph echoed from a variable.</p>
    	<?php
    	$para = ob_get_contents();
    	ob_end_clean();
    	echo $para;
    }
    
    function output_some_html_with_end_flush() {
    	ob_start();
    	?>
    	<p>This is a paragraph sent with ob_end_flush.</p>
    	<?php
    	ob_end_flush();
    }
    
    output_some_html_with_var();
    
    output_some_html_with_end_flush();
    
    /*
    	If you want to return the contents of ob_start()
    	you should store ob_get_contents() into a variable,
    	then call ob_end_clean(), and then return the variable.
    */
    
    function return_some_html_with_var() {
    	ob_start();
    	?>
    	<p>This is a paragraph being stored into a variable and returned.</p>
    	<?php
    	$para = ob_get_contents();
    	ob_end_clean();
    	return $para;
    }
    
    echo return_some_html_with_var();
    
    echo '<a style="text-decoration:none;" href="http://php.net/manual/en/function.ob-start.php">See the ob_start documentiation for more info</a>';
    
    

    public by azazqadir modified Oct 9, 2017  46  0  1  0

    Laravel REST API Authentication with Passport: https://www.cloudways.com/blog/rest-api-laravel-passport-authentication/

    Laravel REST API Authentication with Passport: https://www.cloudways.com/blog/rest-api-laravel-passport-authentication/: auth.php
    'guards' => [
    
       'web' => [
    
           'driver' => 'session',
    
           'provider' => 'users',
    
       ],
    
    
    
       'api' => [
    
           'driver' => 'passport',
    
           'provider' => 'users',
    
       ],
    
    ],
    
    

    public by azazqadir modified Sep 27, 2017  44  0  1  0

    Laravel Browser Testing: https://www.cloudways.com/blog/laravel-dusk-testing-todo-app/

    Laravel Browser Testing: https://www.cloudways.com/blog/laravel-dusk-testing-todo-app/: AppServiceProvider.php
    use Laravel\Dusk\DuskServiceProvider;
    
    public function register()
    {
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
        }
    }
    
    

    public by azazqadir modified Aug 18, 2017  41  1  1  0

    Controller for File Upload in CodeIgniter. Full tutorial here: https://www.cloudways.com/blog/codeigniter-upload-file-image/

    Controller for File Upload in CodeIgniter. Full tutorial here: https://www.cloudways.com/blog/codeigniter-upload-file-image/: upload_controller.php
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Upload_Controller extends CI_Controller {
    public function __construct() {
    parent::__construct();
    }
    public function custom_view(){
    $this->load->view('custom_view', array('error' => ' ' ));
    }
    public function do_upload(){
    $config = array(
    'upload_path' => "./uploads/",
    'allowed_types' => "gif|jpg|png|jpeg|pdf",
    'overwrite' => TRUE,
    'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
    'max_height' => "768",
    'max_width' => "1024"
    );
    $this->load->library('upload', $config);
    if($this->upload->do_upload())
    {
    $data = array('upload_data' => $this->upload->data());
    $this->load->view('upload_success',$data);
    }
    else
    {
    $error = array('error' => $this->upload->display_errors());
    $this->load->view('custom_view', $error);
    }
    }
    }
    ?>
    
    

    public by AbhishekGhosh modified Jun 8, 2017  95  0  1  0

    GEO IP TEST PHP Script

    GEO IP TEST PHP Script: geoip.php
    <html>
    <body>
    <?php
    
    $geoip_country_code = getenv(GEOIP_COUNTRY_CODE);
    $geoip_country_name = getenv(GEOIP_COUNTRY_NAME);
    $geoip_region = getenv(GEOIP_REGION);
    $geoip_city = getenv(GEOIP_CITY);
    $geoip_postal_code = getenv(GEOIP_POSTAL_CODE);
    $geoip_latitude = getenv(GEOIP_LATITUDE);
    $geoip_longitude = getenv(GEOIP_LONGITUDE);
    
    
    echo 'Country code: '.$geoip_country_code.'<br>';
    echo 'Country name: '.$geoip_country_name.'<br>';
    echo 'Region: '.$geoip_region.'<br>';
    echo 'City: '.$geoip_city.'<br>';
    echo 'Postal code: '.$geoip_postal_code.'<br>';
    echo 'Latitude: '.$geoip_latitude.'<br>';
    echo 'Longitude: '.$geoip_longitude.'<br>';
    
    ?>
    </body>
    </html>
    
    

    public by vnhgroup4m modified May 22, 2017  303  0  4  0

    update wp

    update wp
    php
    $wpdb->update('usertb', array('xu'=>$xuThang,'RemainMoney'=>$tienThang ,'RemainTime'=>$newTime) ,array('FirstName'=>$username)); // cộng tiền gỡ 
    
    • Public Snippets
    • Channels Snippets