%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/devcapijob/public_html/caching-master/
Upload File :
Create Path :
Current File : /home/devcapijob/public_html/caching-master/test.php

<?php
echo phpinfo();exit;
//echo $_SERVER['DOCUMENT_ROOT'];exit;
	$cachefile = $_SERVER['DOCUMENT_ROOT'].'/caching-master/cache/data.html';
	$cachetime = 10;
	
	// Serve from the cache if it is younger than $cachetime
	if (file_exists($cachefile) && filesize($cachefile)>0 && time() - $cachetime < filemtime($cachefile)) {
		////*****************************////
		// Executing From Cache
		////*****************************////
		echo "<h3>Data is from file:</h3><br>";
		include($cachefile);
	}
	else
	{
		////////////content//////////////
		////mysql datbase connection
		$servername = "localhost";
		$username = "capijobnew_site";
		$password = "dXsyJe.7ulam";
		$db = "capijobnew_site2";
		
		// Create connection
		$conn = new mysqli($servername, $username, $password,$db);
		// Check connection
		if ($conn->connect_error) {
			die("Connection failed: " . $conn->connect_error);
		}
		
		$sql = "select DISTINCT a.`id_annonce`, a.`poste`, a.`titre`, a.`h1_page`, a.`alias`, a.`type`, a.`domaine`, a.`region`, a.`depart`,a.`id_pays`, a.`texte`,a.`id_annonceur`, a.`id_candidat`, cap_annonceur.logo , cap_annonceur.raison_social, cap_duree_travail.nom_dure_travail,a.salaire,a.nb_vue,a.date_parution, cap_niveau_etude.nom as niveau_etude,cap_permis.nom_permis,cap_type_poste.type_poste FROM `cap_annonce` AS `a` Inner Join `cap_annonceur` ON `a`.`id_annonceur` = `cap_annonceur`.`id_annonceur` Inner Join `cap_annonce_site` ON `a`.`id_annonce` = `cap_annonce_site`.`id_annonce` Left Join `cap_annonce_departement` ON `a`.`id_annonce` = `cap_annonce_departement`.`id_annonce` Left Join `cap_annonce_domaine` ON `a`.`id_annonce` = `cap_annonce_domaine`.`id_annonce` LEFT JOIN cap_duree_travail ON a.duree_travail = cap_duree_travail.id_dure_travail LEFT JOIN cap_niveau_etude ON a.niveau_etude = cap_niveau_etude.id_niveau LEFT JOIN cap_permis ON a.permis = cap_permis.code_permis LEFT JOIN cap_type_poste ON a.type_contrat = cap_type_poste.id_type_poste where 1=1 and a.etat=1 and a.active=0 AND `cap_annonce_site`.`site_web` = 1 AND a.date_parution <= '2020-02-28' AND a.date_max_parution >= '2020-02-28' AND a.fin_parution >= '2020-02-28' AND (a.parution - a.parution_utilise)>='0' GROUP BY a.id_annonce order by a.flux ASC, a.date_misejour limit 0,10";
		$result = $conn->query($sql);
		
		if ($result->num_rows > 0) {
			// output data of each row
			while($row = $result->fetch_assoc()) {
				$html .= utf8_encode($row["titre"]).'<br/>';
				//$html .= $row["date_parution"].'<br/>';
				//$html .= $row["fin_parution"].'<br/>';
				//$html .= $row["dare_max_parution"];
				$html .='<hr/>';
			}
		} else {
			echo "0 results";
		}
		$conn->close();
		///////////////////////////////
		
		// Cache the contents to a file
		$fp = fopen($cachefile, 'w');
		//https://www.php.net/manual/en/function.flock.php
		if(flock($fp,LOCK_EX))  //LOCK_EX to acquire an exclusive lock (writer)
		 {
			fwrite($fp,$html);
			flock($fp,LOCK_UN);//LOCK_UN to release a lock (shared or exclusive).
            fclose($fp);
		 }
		////*****************************////
		// Executing From Main File DB Connected
		////*****************************////
		echo "<h3>Data is from Mysql:</h3><br>";
		echo $html;
	}
?>

Zerion Mini Shell 1.0