Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Wednesday, February 8, 2023

move files from one folder to another by php code if you have no access to cpanel

 Hello.

TOday I will explain how to move files one folder to another folder in server with php code. Recently I face problem to move files from my computer to server. SO i make zip file ad upload it to server and i unzip it. But it creates a folder and put all files into that folder. My cpanel has not enough rights to move all files. IT has right only for one by one file move. It is very tedious job. SO I make this php code for move files.


<?php

//File Manager - Home Folder: dede.cptost-h.net/public_html/wp-includes/files_zip_0/

//File Manager - Home Folder: dede.cptost.h.net/public_html/wp-admin/wpadmin_zip_0/

$dir = "wp-admin/wpadmin_zip_0";

$new_location = "wp-admin/";

$i = 1;

if ($handle = opendir($dir)) {

    while (false !== ($entry = readdir($handle))) {


        if ($entry != "." && $entry != "..") {

            $file = $dir . "/" . $entry;

            $new_file = $new_location . $entry;


            if (!rename($file, $new_file)) {

                echo "<br>$i Error: Unable to move the file: $entry.";

            } else {

                echo "<br>$i File $entry moved successfully.";

            }

        }

        $i++;

    }


    closedir($handle);

} else {

    echo "Error: Unable to open the directory. <br>";

}


?>

Thursday, June 13, 2019

make magento faster

Hello

Use these settings to make magento more faster.

1. Disable Signed content (Don't need for developer mode)

insert into core_config_data (scope, scope_id, path, value) values ('default',0, 'dev/static/sign', 0);


2. Make sure you have used SSD for store Magento 2 Source Code.

3. Make sure you have used the latest MySQL version.

4. You are developing, please enable developer mode and doing step 1.

5. If your site got too many products, please run php bin/magento catalog:image:resize

6. The suggestion is Use Redis cache and saves the session to DB or Redis

These will help you to make fast magento website. 


Friday, February 3, 2017

Server side email validation in php with filter_var

Validating email address on server side is more secure way to prevent from span entry, Some people disabled javascript on their browser and enter wrong or garbage username/email address, So validating email on server side is good approach.

You can use the filter_var() function, which gives you a lot of handy validation and more options.
Note: PHP 5.2.0 or higher is required for the filter_var function. Here is the quick function in php to validate email address in single line.
function checkValidEmail($email){ 
    return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}
 
Above function will validate email like “chirag@gmail” as a valid email, In Standard HTML5 email validation also pass this string too as a valid email, You need to add some extra security in your function to validate TLS so that you can get more filtered email data.
Email with TLS validation.

function checkValidEmail($email){ 
   return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email);
}
 

Example:

echo checkValidEmail('chirag@gmail'); // false
echo checkValidEmail('chirag@gmail.'); // false  
echo checkValidEmail('chirag@gmail.com'); // true  
echo checkValidEmail('chirag@gmail.com.'); // false