How to redirect from http to https using web-hooks in codeigniter

By // No comments:

 



If you have a website with HTTP and have an AutoSSL or purchased the SSL for your site, it’s hard to manage redirection because every request to your site has HTTP before any request.

For Codigniter 3

You can redirect your every request from HTTP to HTTPS in Codeigniter 3 using hook  Only 3 steps are given below:

1. Enable hook from config.php file 

          File Path:  PROJECT_DIRETORY/application/config/config.php

          
$config['enable_hooks'] = TRUE;

    Note:  Set $config['index_page']  to blank string else it will redirect to yourdomain/index.php

            
$config['index_page'] = 'index.php';  ==>    $config['index_page'] = '';

2. Create a new file named hooks.php in config Folder

             File Path:  PROJECT_DIRETORY/application/config/hooks.php

        and add below code in hooks.php
   
$hook['post_controller_constructor'][] = array( 'function' => 'redirect_ssl', 'filename' => 'ssl.php', 'filepath' => 'hooks' );
3. Then create a new directory with named “hooks” under application directory and then create new file named “ssl.php” in “application/hooks/ssl.php” and add below code to "ssl.php"

             Directory Path: PROJECT_DIRETORY/application/hooks

            File Path: PROJECT_DIRETORY/application/hooks/ssl.php

and add below code in ssl.php
function redirect_ssl() {
    $CI =& get_instance();
    $class = $CI->router->fetch_class();
    $CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
    if ($_SERVER['SERVER_PORT'] != 443){
        redirect($CI->uri->uri_string());
    }
}

if you want to exclude some controllers from HTTPS redirection then use below code function
function redirect_ssl() {
    $CI =& get_instance();
    $class = $CI->router->fetch_class();
    $exclude = array('Home'); 
    if(!in_array($class,$exclude)) {
        // redirecting to SSL.
        $CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
        if ($_SERVER['SERVER_PORT'] != 443) {
            redirect($CI->uri->uri_string());
        }
    }
    else {
        // redirecting with no SSL.
        $CI->config->config['base_url'] = str_replace('https://', 'http://', $CI->config->config['base_url']);
        if ($_SERVER['SERVER_PORT'] == 443) {
            redirect($CI->uri->uri_string());
        }   
    }
}




For Codigniter 4

You can redirect your every request from HTTP to HTTPS in Codeigniter 4  Only one change in App.php in directory config:

    
    /*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| If true, this will force every request made to this application to be
| made via a secure connection (HTTPS). If the incoming request is not
| secure, the user will be redirected to a secure version of the page
| and the HTTP Strict Transport Security header will be set.
*/
public $forceGlobalSecureRequests = false;
           
  change false into true

    
    public $forceGlobalSecureRequests = true;

How to destroy an activity in other activity in Android?

By // No comments:
Create a static Activity object which activity finish on other activity and assign activity in this i.e you can can add more activities
public class demoActivity extends AppCompatActivity {
    public static Activity self_intent;
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.demo_activity);
            selfintent=this;
    } 

   //Other functions--------------
} 
do same for other activities on other
public class finishingActivity extends AppCompatActivity {
        public Button activityCloseBtn;
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.finishing_activity);

            activityCloseBtn= (Button) view.findViewById(R.id.activity_close_btn);
            activityCloseBtn.setOnClickListener(new View.OnClickListener() {      
            @Override
            public void onClick(View v) {
               demoActivity.selfintent.finish(); //for finish demoActivityactivity

              //for other activities Activity.selfintent.finish();
               finish();  //for finish current activity
          }
    });

Uploade WordPress Site From Local Server to Live Site

By // No comments:
Develop a WordPress site  on Localhost . It  can help speed up the development process.After you have finished the WordPress site development on localhost, the next step is to move the site to live Server.

Some Pre-Steps
                First You Need a live web server to upload site who support WordPress & a Domain name .
                You  need to have C panel details of server or a FTP program , so you can upload your content to the live Server.

Step 1: Export  WordPress Database Backup  from Localhost
First  you need to backup  your local WordPress database.In WAMP  We will be using phpMyAdmin to do that. Simply go to http://localhost/phpmyadmin/ and click on your WordPress database. Then click on the Export button from the top menu bar.








Step 2: Uploading All WordPress Files to Live Site Server

Open CPanel of your server  using URL https://www.yourdomain.com/cpanel and login .
 In cPanel dashboard  click on the File Manager icon which can be found in the Files section.




Step 3: Creating MySQL Database on Live Site Server

 In cPanel dashboard  click on the MySQL databases icon which can be found in the databases section.

Create New Database 



Step 4: Importing WordPress Database on Live Site

 In cPanel dashboard  click on the phpMyAdmin icon which can be found in the databases section.
phpMyAdmin will show your new database with no tables. Click on theImport tab in the top menu. On the import page, click on choose file button and then select the database file you saved in step 1. and  import your WordPress database.

Step 5: Now Change the Site URL

Now you need to change the site URL, so you can setup your live WordPress site. In your phpMyAdmin, look for the wp_options table in your database. and Click on the wp_options link that you see in the sidebar to open the page with a list of fields within the wp_options table.
Under the field options_name, you need to look for siteurl. Click on the Edit and change option_value to your live site URL

And also in  options_name, you need to look for home. Click on the Edit and change option_value to your live site URL

Step 6: Setting Up your Live Site
Now that we have imported the database, and all your site content should be uploaded, Now you configure WordPress. At this time, your site should be showing an Error Establishing Database Connection error. To fix this error  edit wp-config.php file. Provide the database name, user and password you created earlier in Step 3. Save the wp-config.php file to your server. 
Now Login to your WordPress admin panel, and go to Settings » General. Click save Options. This will ensure that the site url is corrected anywhere else that needs to be.
Then go to Settings » Permalink and click Save to ensure that all post links are working fine.

Step 7: Fixing Images and Broken Links by updating Paths

Whenever you are moving a WordPress site from local server to a live server site, you would face broken links and missing images issue. You can use the SQL query 
UPDATE wp_posts SET post_content = REPLACE(post_content,'localhost/myproject/''www.yourlivesite.com/');

Run All Thease Query

UPDATE wp_commentmeta SET meta_value = REPLACE(meta_value,'localhost/myproject/', 'www.yourlivesite.com/');


UPDATE wp_comments SET comment_content = REPLACE(comment_content,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_links SET link_description = REPLACE(link_description,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_options SET option_value = REPLACE(option_value,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_postmeta SET meta_value = REPLACE(meta_value,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_posts SET post_content = REPLACE(post_content,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_posts SET post_title = REPLACE(post_title,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_term_taxonomy SET description = REPLACE(description,'localhost/myproject/', 'www.yourlivesite.com/');

UPDATE wp_usermeta SET meta_value = REPLACE(meta_value,'localhost/myproject/', 'www.yourlivesite.com/');


PHP 5.6.2 and 5.4.34 Update for Critical Security Flaws

By // No comments:

While much of the security world is consumed with the latest branded vulnerability (last week it was POODLE), the open-source PHP programming language fixed some very serious bugs.
PHP is widely deployed across the Internet and is the language used to power much of the world's leading Content Management Systems (CMS) and blogs (including this one).


  • In the PHP 5.6.2 update, four security vulnerabilities are being fixed including: CVE-2014-3668, CVE-2014-3669 and CVE-2014-3670. Bug #68089 does not yet have a CVE number but it's a non-trivial Null byte injection flaw.
  • PHP 5.4.34 is being patched for six vulnerabilities including CVE-2014-3668, CVE-2014-3669 and CVE-2014-3670. The non-CVE number issues include bug #66242, 67985, 68089 and 41631.
  • Across both PHP 5.4.x and PHP 5.6 updates, the CVE-2014-3669 is one of the most serious.
  • "An integer overflow flaw in PHP's unserialize() function was reported, a Red Hat security advisory warns. "If unserialize() were used on untrusted data, this issue could lead to a crash or potentially information disclosure."

International PHP Conference Spring 2015 in Burlin at June 7th - 10th, 2015

By // No comments:

The International PHP Conference is a globally recognized event for PHP developers, webworkers, IT managers and everyone interested in web technology.

Once again, the conference will explore key topics and core technologies for developers and decision makers. We will show you how to scale your applications, explain the details of Continuous Integration or evaluate different approaches to NoSQL. Attendees will have the opportunity to meet with speakers, core developers and consultants, and there are often opportunities to evaluate your code. Community and enterprise projects profit from our international reputation and impulses given from the developer community.

Below is the information for our Call for Papers, the deadline is November 24th, 2014:

We are already planning for the IPC Spring 2015 which will take place in Berlin again. We hope that next week's conference will give you some inspiration for new talks for the next conference.

We are very much looking forward to your submissions for workshops, sessions & keynotes, which can be either in English or in German. Our goal is to provide at least 60% of the whole program of the integrated conference in English, so that our international friends have plenty of sessions to choose from. Please see below our list of topics which we would like to have covered, but please feel free to add additional topics, if you believe they fit into the scope of the conference. We are looking forward to your exciting submissions and wish you all the best!

Basic facts:
Date: June 7th - 10th, 2015
Location: Berlin
Deadline for Submissions: November 24th, 2014
URL for Submissions: conftool.sandsmedia.com


Topics:
Core PHP /PHPNG
PHP Frameworks
PHP Scaling & Performance
PHP Security
PHP Testing & Quality
HHVM & Hack
Architecture
JavaScript / ECMAScript 6
JavaScript Frameworks
JavaScript Performance & Security
Web APIs & Services
Agile
Continuous Delivery
DevOps
Cloud
Data Stores

Create Three Flying Jet Planes making tricolor flag of India on your website

By // 3 comments:

Create Three Flying Planes making tricolor flag of India on your website 

For this function Google provide  a javascript file 
  1. Go to your website page where you want to display these flying planes.
  2. Add below script before </body> tag on your web page 

<script type="text/javascript" src="https://demo.zafinfosoft.com/jet/jet-planes.js"></script>



You can also change the plan's picture to your own picture.
 Just change link  doodle.init("jet.png");


You can also download this file from this link click here  to download the javascript file.



Add Flying Twitter Bird to your Website/Blog

By // No comments:



  • Open Your Webpage in any Editor 
  • Copy the following code and paste this code above </body> tag in your Web page.
<script type="text/javascript" src="twitterflyingbrd.js"></script>
<script type="text/javascript">
     var twitterAccount="jafar5029";
     var tweetThisText="Web/Mobile App Development Services, https://www.zafinfosoft.com";
     tripleflapInit();
 </script>
  • Replace "jafar5029" with your twitter username in abow coding.
  • then Save Your Web Page.
Powered by Blogger.

Blog Archive