how to check my laravel version

There are two ways available to find the version of the Laravel application. You can either find it by running a command or you can check the Laravel version in files.

Command to find Laravel Version

Open the terminal on your system. Navigate to the webroot directory of the Laravel application. Now execute the following PHP artisan command to check the Laravel version.

$ php artisan --version

Laravel Framework 5.6.39

Check Laravel Version in File

Sometimes you may not have access to the terminal of server-hosted Laravel application. Or you may not much familiar with the command line. In that case, you can simply view the Laravel version in the following file.

First navigation to Laravel webroot directory.

$ vim ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php

upload image ajax

Ajax code for image upload

$(document).ready(function (e) {
    $('#imageUploadForm').on('submit',(function(e) {
        e.preventDefault();
        var formData = new FormData(this);

        $.ajax({
            type:'POST',
            url: $(this).attr('action'),
            data:formData,
            cache:false,
            contentType: false,
            processData: false,
            success:function(data){
                console.log("success");
                console.log(data);
            },
            error: function(data){
                console.log("error");
                console.log(data);
            }
        });
    }));

    $("#ImageBrowse").on("change", function() {
        $("#imageUploadForm").submit();
    });
});

Basic Php Code for File Upload

$filetype = array('jpeg','jpg','png','gif','PNG','JPEG','JPG');
   foreach ($_FILES as $key )
    {

          $name =time().$key['name'];

          $path='local_cdn/'.$name;
          $file_ext =  pathinfo($name, PATHINFO_EXTENSION);
          if(in_array(strtolower($file_ext), $filetype))
          {
            if($key['name']<1000000)
            {

             @move_uploaded_file($key['tmp_name'],$path);
             echo $name;

            }
           else
           {
               echo "FILE_SIZE_ERROR";
           }
        }
        else
        {
            echo "FILE_TYPE_ERROR";
        }

श्र से शब्द

Add title description keyword meta tag without using plugin in wordpress

The search bots will search for necessary information for users based on the meta tags’ and the article’s content. The page or post will rank higher in search result pages if its meta tags contain important keywords. Therefore, it should be concise and contain important keywords. It will be better for SEO if you can put the keyword to the beginner of the description is better.

Description and keyword without plugin
Paste this in theme’s functions.php file.


function add_meta_tags() {
    global $post;
    if ( is_single() ) {
        $meta = strip_tags( $post->post_content );
        $meta = strip_shortcodes( $post->post_content );
        $meta = str_replace( array("\n", "\r", "\t"), ' ', $meta );
        $meta = substr( $meta, 0, 125 );
        $keywords = get_the_category( $post->ID );
        $metakeywords = '';
        foreach ( $keywords as $keyword ) {
            $metakeywords .= $keyword->cat_name . ", ";
        }
        echo '<meta name="description" content="' . $meta . '" />' . "\n";
        echo '<meta name="keywords" content="' . $metakeywords . '" />' . "\n";
    }
}
add_action( 'wp_head', 'add_meta_tags' , 2 );
function gretathemes_meta_description() {
    global $post;
    if ( is_singular() ) {
        $des_post = strip_tags( $post->post_content );
        $des_post = strip_shortcodes( $post->post_content );
        $des_post = str_replace( array("\n", "\r", "\t"), ' ', $des_post );
        $des_post = mb_substr( $des_post, 0, 300, 'utf8' );
        echo '<meta name="description" content="' . $des_post . '" />' . "\n";
    }
    if ( is_home() ) {
        echo '<meta name="description" content="' . get_bloginfo( "description" ) . '" />' . "\n";
    }
    if ( is_category() ) {
        $des_cat = strip_tags(category_description());
        echo '<meta name="description" content="' . $des_cat . '" />' . "\n";
    }
}
add_action( 'wp_head', 'gretathemes_meta_description');

Title tag without plugin

<title><?php wp_title(' | ', 'echo', 'right'); ?><?php bloginfo('name'); ?></title>

Table 1 to 10

12345678910
2468101214161820
36912151821242730
481216202428323640
5101520253035404550
6121824303642485460
7142128354249566370
8162432404856647280
9182736455463728190
102030405060708090100

HTTP to HTTPS and HTTPS to HTTP redirect in php/laravel without htaccess

HTTP to HTTPS


<?php
//echo empty($_SERVER['HTTPS']);
if(empty($_SERVER['HTTPS'])) {
$redirect= "https://www".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//header("location:$redirect"); //php
return redirect()->to($redirect)->send(); //laravel
}
?>

HTTPS to HTTPS


<?php
//echo empty($_SERVER['HTTPS']);
if(!empty($_SERVER['HTTPS'])) {
$redirect= "http://www".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//header("location:$redirect"); //php
return redirect()->to($redirect)->send(); //laravel
}
?>

get key and value from GET in php

For some specific purposes you may want to know the current key of your array without going on a loop. In this case you could do the following:

reset($array);
echo key($array) . ' = ' . current($array);

The following functions are not very well known but can be pretty useful in very specific cases:

key($array);     //Returns current key
reset($array);   //Moves array pointer to first record
current($array); //Returns current value
next($array);    //Moves array pointer to next record and returns its value
prev($array);    //Moves array pointer to previous record and returns its value
end($array);     //Moves array pointer to last record and returns its value

OTHER EXAMPLE :

<?php foreach($array as $text => $url): ?>
    <a href="<?php echo $url; ?>"><?php echo $text; ?></a>
<?php endforeach; ?>


$array = array(
    'SOA' => 'http://soatechnology.net',
    'Delhijurix' => 'http://delhijurix.com'
);

foreach($array as $title => $url){
    echo '<a href="' . $url . '">' . $title . '</a>';
}

How to check my phpmyadmin is secure on ubuntu server?

Useful Tips to Secure PhpMyAdmin Login Interface

  1. Change Default PhpMyAdmin Login URL
/etc/phpmyadmin/apache.conf

------------ On CentOS/RHEL and Fedora ------------ 
# vi /etc/httpd/conf.d/phpMyAdmin.conf

------------ On Debian and Ubuntu ------------ 
# /etc/phpmyadmin/apache.conf

Then add a new one as follows:
# Alias /phpmyadmin /usr/share/phpmyadmin
Alias /my /usr/share/phpmyadmin

------------ On Debian and Ubuntu ------------ 
# echo "Include /etc/phpmyadmin/apache.conf" >> /etc/apache2/apache2.conf
     ------------ On CentOS/RHEL and Fedora ------------ 
# systemctl restart nginx
# systemctl restart php-fpm

------------ On CentOS/RHEL and Fedora ------------ 
# systemctl restart httpd

------------ On Debian and Ubuntu ------------ 
# systemctl restart apache2

------------ On Debian and Ubuntu ------------ 
# systemctl restart nginx
# systemctl restart php5-fpm
  1. Enable HTTPS on PhpMyAdmin

  1. Password Protect on PhpMyAdmin
Add these lines to the Apache configuration file (/etc/apache2/sites-available/000-default.conf or /etc/httpd/conf/httpd.conf):

/etc/apache2/sites-available/000-default.conf – On Ubuntu
<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/apache2/.htpasswd
    Require valid-user
</Directory>
/etc/httpd/conf/httpd.conf – On CentOS
 
<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
</Directory>
Then use htpasswd to generate a password file for an account that will be authorized to access the phpmyadmin login page. We will use /etc/apache2/.htpasswd and tecmint in this case:

---------- On Ubuntu/Debian Systems ---------- 
# htpasswd -c /etc/apache2/.htpasswd tecmint

---------- On CentOS/RHEL Systems ---------- 
# htpasswd -c /etc/httpd/.htpasswd tecmint
Enter password twice and then change the permissions and ownership of the file. This is to prevent anyone not in the www-data or apache group from being able to read .htpasswd:

# chmod 640 /etc/apache2/.htpasswd

---------- On Ubuntu/Debian Systems ---------- 
# chgrp www-data /etc/apache2/.htpasswd 

---------- On CentOS/RHEL Systems ---------- 
# chgrp apache /etc/httpd/.htpasswd 
Open your phpmyadmin url and you’ll see the authentication dialog before accessing the login page.
  1. Disable root Login to PhpMyAdmin
/etc/phpmyadmin/config.inc.php
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowRoot'] = false;

------------- On CentOS/RHEL Systems -------------
# systemctl restart httpd.service

------------- On Debian/Ubuntu Systems -------------
# systemctl restart apache2.service
  1. Prevent remote usage of phpmyadmin

  1. Change password frequently

  1. Check configuration /etc/phpmyadmin

How to disable PHP error logs

By default, PHP errors and warnings generated by your websites are logged in error_log files in the directory where your PHP files are located. The PHP error_log files can grow to a large size.

If you do not need the error_log file you can disable PHP error logging using one of the three ways listed below:

PHP Selector in cPanel — Recommended

  1. Log in to cPanel.
  2. Click Select PHP Version.
  3. Click Switch To PHP Options
  4. Set log_errors to Off
  5. Click Save

.htaccess

  1. Edit .htaccess in your public_html folder
  2. Enter the following code:1php_flag log_errors off
  3. Save the file.

php.ini

  1. Create a new file named php.ini in your public_html folder.
  2. Enter the following code:1log_errors = off
  3. Save the file.

Verify your changes

Create a phpinfo php page to check your settings are active.

Delete existing PHP error_log files

  1. View your webspace using FTP or cPanel File Manager
  2. Select your error_log file
  3. Delete

Problem with phpMyAdmin and PHP 7.2: “Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”

It’s possible that when you installed phpMyAdmin, the version in the repository (phpMyAdmin v4.6.6) was not fully compatible with PHP 7.2. There is a newer version available on the official website (v4.8 as of writing), which fixes these compatibility issues with PHP 7.2.

sql.lib.php

This error is caused by a line of code in /usr/share/phpmyadmin/libraries/sql.lib.php.

If you don’t want to wait for the repositories to update with the latest version, it is strongly recommended that you manually upgrade to the latest version of phpMyAdmin yourself.

Alternatively, you can make a change to sql.lib.php to temporarily fix the error.

Firstly, backup sql.lib.php before editing.

Firstly, backup sql.lib.php before editing.

sudo cp /usr/share/phpmyadmin/libraries/sql.lib.php /usr/share/phpmyadmin/libraries/sql.lib.php.bak

Edit sql.lib.php in nano.

sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php

Press CTRL + W and search for (count($analyzed_sql_results['select_expr'] == 1)

Replace it with ((count($analyzed_sql_results['select_expr']) == 1)

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Import/Export issues

If you are also getting an error Warning in ./libraries/plugin_interface.lib.php#551 under import and export tabs:

Backup plugin_interface.lib.php

sudo cp /usr/share/phpmyadmin/libraries/plugin_interface.lib.php /usr/share/phpmyadmin/libraries/plugin_interface.lib.php.bak

Edit plugin_interface.lib.php

sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

Press CTRL + W and search for if (! is_null($options) && count($options) > 0) {

If not found, try search for if ($options != null && count($options) > 0)

Replace with if (! is_null($options) && count((array)$options) > 0) {

Save file and exit. (Press CTRL + X, press Y and then press ENTER)