net::err_content_decoding_failed 200 in wordpress

It happens when your HTTP request’s headers claim that the content is gzip encoded, but it isn’t. Turn off gzip encoding setting or make sure the content is in fact encoded.

Remove below this, if you used anywhere

<?php   
    ob_start( 'ob_gzhandler' ); 
    echo json_encode($array);
    ob_end_flush();
?>

connection string in laravel for eloquent model

    $data = array();
      $lang = $request->lang;
      $id = $request->id;
      $data['success'] = false;
      $user_id = 0;
      if (Auth::check()) {
      $user = Auth::user();
      $user_id = $user->id;
       }
      //$data['chat_delete'] = DB::connection($lang)->table('astro_chat')->where(['id'=> $id])->delete();
      $astroChatModel  = new AstroChat();
      $astroChatModel->setConnection($lang);
      $astroChat = $astroChatModel->find($id);
      if(  $astroChat && $user_id == $astroChat->user_id ){ $data['success'] = $astroChat->delete();}
      return $this->sendResponse($data, 'Successfully'); 

add soft delete in laravel

In the migration file add:

$table->softDeletes();

In the model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;


class CalNotes extends Model
{
    use HasFactory;
    protected $table = 'cal_notes';
    protected $fillable = ['user_id','title','description','price','ip'];
    protected $primaryKey = 'id';
    use SoftDeletes;

}

In the controller:

 $id = $request->id;
 $calNotesModel  = new CalNotes();
 $calNotes = $calNotesModel->find($id);
 $calNotes->delete();

 if you need to restore the deleted user

$calNotes = CalNotes::withTrashed()->find($id);
        $calNotes->restore();

.htaccess flag list

  • C (chained with next rule)
  • CO=cookie (set specified cookie)
  • E=var:value (set environment variable var to value)
  • F (forbidden – sends a 403 header to the user)
  • G (gone – no longer exists)
  • H=handler (set handler)
  • L (last – stop processing rules)

Last rule: instructs the server to stop rewriting after the preceding directive is processed.

  • N (next – continue processing rules)
  • NC (case insensitive)
  • NE (do not escape special URL characters in output)
  • NS (ignore this rule if the request is a subrequest)
  • P (proxy – i.e., apache should grab the remote content specified in the substitution section and return it)
  • PT (pass through – use when processing URLs with additional handlers, e.g., mod_alias)
  • R (temporary redirect to new URL)
  • R=301 (permanent redirect to new URL)
  • QSA (append query string from request to substituted URL)
  • S=x (skip next x rules)
  • T=mime-type (force specified mime type)

Flags are added to the end of a rewrite rule to tell Apache how to interpret and handle the rule. They can be used to tell apache to treat the rule as case-insensitive, to stop processing rules if the current one matches, or a variety of other options. They are comma-separated, and contained in square brackets.

display error in php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

posted image display in php without save file

<div class="col-12">
<h2>Image Processor</h2>
<form id="image_upload" enctype="multipart/form-data"  method="post" action="image">
<div class="mb-3">
  <label for="formFile" class="form-label">Select Image</label>
  <input type="file" class="form-control" name="image" id="image">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
     <?php if(isset($_FILES)){
echo $_FILES['image']['name'];
echo $_FILES['image']['type'];
echo $_FILES['image']['tmp_name'];
echo $_FILES['image']['error'];
echo $_FILES['image']['size'];
$image = file_get_contents($_FILES["image"]["tmp_name"]);
$enocoded_data = base64_encode($image);
?>
<img src="data:image/jpeg;base64, <?php echo $enocoded_data    ; ?>" />
<img src="data:image/png;base64, <?php echo $enocoded_data    ; ?>" />
<img src="<?php echo $_FILES['image']['name']; ?>">
<?php
 } ?>

How to recursively check file is exist or not in php

How recursively file exist or not in php and change name

		$dirFolder ="../images/".date("Y")."/".date("m")."/"; 
		$file=$_FILES['image']['name'];
		$file_tem_loc=$_FILES['image']['tmp_name'];
	if (!file_exists($dirFolder)) { 
	mkdir($dirFolder, 0777, true); 
	}
	exist:
	if (file_exists($dirFolder.$file)) { 
		$file_name = pathinfo($file);
		$dirName=$file_name['dirname'];
		$fileFullName=$file_name['basename'];
		$fileExtenstion=$file_name['extension'];
		$fileName=$file_name['filename'];
		$tempName=explode('_',$fileName);
		$tempName=end($tempName);
		$file = rtrim($fileName,'_'.$tempName)."_".(++$tempName).".".$fileExtenstion;
		if (file_exists($dirFolder.$file)) { 
			goto exist;
		}
	}
$images=ltrim($dirFolder,'../').$file;
move_uploaded_file($file_tem_loc,($dirFolder.$file));

get filename without extension php

$file_name = pathinfo($file);
		$dirName=$file_name['dirname'];
		$fileFullName=$file_name['basename'];
		$fileExtenstion=$file_name['extension'];
		$fileName=$file_name['filename'];
echo $dirName;
echo $fileFullName;
echo $fileExtension;
echo $fileName;

create class file for connection in php MySQLi with Time zone

<?php
 class Connection
{
	var $link;
public	function Connecton()
{
        date_default_timezone_set('Asia/Kolkata'); 
	                $this->link=mysqli_connect("localhost","root","","mvc");	
return $this->link;

	}
	
	public function Query($cmd)
	{
			$query=mysqli_query($this->link,$cmd);
                       $data = array();
			while ($row = $query->fetch_assoc()) {
					$data[] = $row;
				}
	  			$result = new \stdClass();
				$result->num_rows = $query->num_rows;
				$result->row = isset($data[0]) ? $data[0] : array();
				$result->rows = $data;

				$query->close();

				return $result ;
		
	}
	public function NonQuery($cmd)
	{
			mysqli_query($this->link,$cmd);
			if(mysqli_insert_id($this->link)>0)
			{
				return mysqli_insert_id($this->link);
			}
			else
			{
				return mysqli_affected_rows($this->link);
			}
			
			
		
	}
}

?>

Laravel distinct count group by

    public function showUniqueUsersBhagwatByDate(Request $request)
    {
        \LogActivity::addToLog('admin');
        $data= array();
        $data = DB::table('cal_user_activity')->select(DB::raw('DATE(updated_at) date'),DB::raw('count(DISTINCT  user_id) as page_count'))->where('module','BhagwatAudio')->groupby('date')->get();
        return view('admin/shownewbhagwatgeetalistener',['data'=>$data,'title'=>'Show Uniques Users Listeners','isOthers'=>1]);
    }