<?php

// Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';

    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];

        $pdo = new PDO($dsn, $user, $pass, $options);

        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }


$columnExists = false;
$query = $pdo->query("SHOW COLUMNS FROM `common` LIKE 'css'");
if ($query->rowCount() > 0) {
    $columnExists = true;
}

$sql = "SELECT * FROM common";

    $stmt = $pdo->prepare($sql);

    $stmt->execute();

    foreach ($stmt as $row) {


        $city = $row['city_name'];

        $url = $row['url'];

        $title = $row['title'];

        $burl = $row['burl'];

        $footerhead = $row['footer_head'];

        $footer= $row['footer_text'];

        $bgcolor = $row['head_footer_bg_color'];
        
        $map = $row['map_url'];
        
        $short=$row['short'];
        
        $css=NULL;
        
        if ($columnExists) {
            $css=$row['css'];
            
        }


}

function destination() {
    
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM destination";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        
        $data['title'] = $row['title'];
    
        $data['heading'] = $row['heading'];
        
        $data['headingsecond'] = $row['headingsecond'];
        
        $data['headingtitle'] = $row['headingtitle'];
        
    }
    
    
    $sql = "SELECT * FROM top";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    foreach ($stmt as $row) {
        $data['top'][$jk]['img'] =  $row['img'];
    
        $data['top'][$jk]['alt'] = $row['alt'];
        
        $data['top'][$jk]['content'] =  $row['content'];
        
        $jk++;
        
    }
    
    
    
    
    
    
    
    
    return($data);
}

function gallery() {
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM gallery";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        $data['title'] = $row['title'];
    
        $data['pageheading'] =  $row['pageheading'];
        
        $data['pageinfo']   =   $row['pageinfo'];
    }
    
    
    $sql = "SELECT * FROM gallery_photo
    WHERE `type`='Gallery'
    LIMIT 100";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    $gallery='';
    foreach ($stmt as $row) {
        
        
        $img = $row['img'];

$img1 = str_replace("-og",'-770x516',$img);

$img2 = str_replace("-og",'-300x201',$img);

$img3 = str_replace("-og",'-768x514',$img);
        
        
        $ngallery = '<figure class="gallery-item">
			<div class="gallery-icon landscape">
				<a data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="89b325d" data-elementor-lightbox-title="'. $row['heading'] . '" href="'. $row['img'] . '">
				
				<img loading="lazy" decoding="async" width="770" height="515" src="'. $row['img'] . '" class="attachment-full size-full" alt="'. $row['heading'] . '" aria-describedby="gallery-1-1049" srcset="' .  $img1 . ' 770w, ' . $img2 . ' 300w, ' .  $img3	. ' 768w" sizes="(max-width: 770px) 100vw, 770px">
				
				</a>
			</div>
				<figcaption class="wp-caption-text gallery-caption" id="gallery-1-1049">
				'. $row['heading'] . '
				</figcaption></figure>';
        
        
        
        $gallery=$gallery . '' . $ngallery;
    }
    
    $data['gallery'] = $gallery;
    
    
    
    
    
    
    
    return($data);
    
}




function festivals() {
    
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM festival_page";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        
        $data['page_heading'] = $row['page_heading'];
    
        $data['page_info'] = $row['page_info'];
        
        
        
    }
    
    
    $sql = "SELECT * FROM festival_info";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    foreach ($stmt as $row) {
        $data['top'][$jk]['img'] =  $row['img'];
    
        $data['top'][$jk]['alt'] = $row['alt'];
        
        $data['top'][$jk]['content'] =  $row['content'];
        
        $jk++;
        
    }
    
    
    
    
    
    
    
    
    return($data);
}

/*
function festivals() {
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'portal_ta';
    $user = 'portal_ta';
    $pass = 'L1spjB+DUF*I';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM festival_page";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        
    
        $data['pageheading'] =  $row['page_heading'];
        
        $data['pageinfo']   =   $row['page_info'];
    }
    
    
    $sql = "SELECT * FROM gallery_photo
    WHERE `type`='festivals'
    LIMIT 100";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    $gallery='';
    foreach ($stmt as $row) {
        
        
        $ngallery = '<figure class="gallery-item">
			<div class="gallery-icon landscape">
				<a data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="89b325d" data-elementor-lightbox-title="'. $row['heading'] . '" href="'. $row['img'] . '">
				<img loading="lazy" decoding="async" width="770" height="515" src="'. $row['img'] . '" class="attachment-full size-full" alt="'. $row['heading'] . '" aria-describedby="gallery-1-1049" sizes="(max-width: 770px) 100vw, 770px">
				</a>
			</div>
				<figcaption class="wp-caption-text gallery-caption" id="gallery-1-1049">
				'. $row['heading'] . '
				</figcaption></figure>';
        
        
        
        $gallery=$gallery . '' . $ngallery;
    }
    
    $data['gallery'] = $gallery;
    
    
    
    
    
    
    
    return($data);
    
}
*/

function foods() {
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM food_page";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        
    
        $data['pageheading'] =  $row['page_heading'];
        
        $data['pageinfo']   =   $row['page_info'];
    }
    
    
    $sql = "SELECT * FROM gallery_photo
    WHERE `type`='Food Page'
    LIMIT 100";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    $gallery='';
    foreach ($stmt as $row) {
        
        
        $img = $row['img'];
        
        

$img1 = str_replace("-og",'-770x516',$img);

$img2 = str_replace("-og",'-300x201',$img);

$img3 = str_replace("-og",'-768x514',$img);
        
        $ngallery = '<figure class="gallery-item">
			<div class="gallery-icon landscape">
				<a data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="89b325d" data-elementor-lightbox-title="'. $row['heading'] . '" href="'. $row['img'] . '">
				
				<img loading="lazy" decoding="async" width="770" height="515" src="'. $row['img'] . '" class="attachment-full size-full" alt="'. $row['heading'] . '" aria-describedby="gallery-1-1049" srcset="' .  $img1 . ' 770w, ' . $img2 . ' 300w, ' .  $img3	. ' 768w" sizes="(max-width: 770px) 100vw, 770px">
				
				</a>
			</div>
				<figcaption class="wp-caption-text gallery-caption" id="gallery-1-1049">
				'. $row['heading'] . '
				</figcaption></figure>';
        
        
        
        $gallery=$gallery . '' . $ngallery;
    }
    
    $data['gallery'] = $gallery;
    
    
    
    
    
    
    
    return($data);
    
}

function about() {
    
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM about";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        
        $data['title'] = $row['title'];
    
        $data['pageheading'] = $row['pageheading'];
        
        $data['heading'] = $row['heading'];
        
        $data['headingimg'] = $row['headingimg'];
        
        
        
        $data['b1head'] = $row['b1head'];
        
        $data['b1text'] = $row['b1text'];
        
        $data['b2head'] = $row['b2head'];
        
        $data['b2text'] = $row['b2text'];
        
        $data['b3head'] = $row['b3head'];
        
        $data['b3text'] = $row['b3text'];
        
        $data['b4head'] = $row['b4head'];
        
        $data['b4text'] = $row['b4text'];
        
        
    }
    
    
    return($data);
}

function home() {
    
    
    // Database credentials
    $host = 'localhost';  // Change to your database host if not localhost
    $db = 'reliableenterpri_pune';
    $user = 'reliableenterpri_pk';
    $pass = 'gq;u[e]W=OR-';
    
    try {
        // Create a new PDO instance
        $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; // DSN for MySQL with UTF-8 character set
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Default fetch mode
            PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepared statements
        ];
    
        $pdo = new PDO($dsn, $user, $pass, $options);
        
        //echo "Connected successfully!";
    } catch (PDOException $e) {
        // Handle connection errors
        die();
    }
    
    
    $sql = "SELECT * FROM home";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    foreach ($stmt as $row) {
        
        $data['title'] = $row['title'];
    
        $data['heading'] = $row['heading'];
        
        $data['headinginfo'] = $row['headinginfo'];
        
        $data['headingimg'] = $row['headingimg'];
        
    }
    
    
    
    
    $sql = "SELECT * FROM top
    LIMIT 3";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    foreach ($stmt as $row) {
        
        $data['top'][$jk]['img'] =  $row['img'];
    
        $data['top'][$jk]['alt'] = $row['alt'];
        
        $content = $row['content'];
        
        $words = explode(" ", $content);

        // Get the first 7 words
        $firstSevenWords = array_slice($words, 0, 7);
        
        // Join the first 7 words back into a string
        $content = implode(" ", $firstSevenWords);
        
        $content = $content . ' ...';
        
        $data['top'][$jk]['content']=$content;
        
        
        
        $jk++;
        
    }
    
     // festivalenable = 1 enabled = 0 disabled 
    
    $data['festivalenable'] = '1';
    
    
    $sql = "SELECT * FROM festival_info
    LIMIT 3";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    foreach ($stmt as $row) {
        $data['festival'][$jk]['img'] =  $row['img'];
    
        $data['festival'][$jk]['alt'] = $row['alt'];
        
        $content = $row['content'];
        
        $words = explode(" ", $content);

        // Get the first 7 words
        $firstSevenWords = array_slice($words, 0, 7);
        
        // Join the first 7 words back into a string
        $content = implode(" ", $firstSevenWords);
        
        $content = $content . ' ...';
        
        $data['festival'][$jk]['content'] =  $content;
        
        $jk++;
        
    }
    
    
    
    $sql = "SELECT * FROM faq
    LIMIT 5";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    foreach ($stmt as $row) {
        
        $data['faq'][$jk]['questions'] =  $row['questions'];
    
        $data['faq'][$jk]['answers'] = $row['answers'];
        
        $jk++;
        
    }
    
    
    
    
    $sql = "SELECT * FROM gallery_photo
    WHERE `type`='Gallery'
    LIMIT 4";
    
    $stmt = $pdo->prepare($sql);
    
    $stmt->execute();
    
    $jk='0';
    
    $gallery= '';
    
    foreach ($stmt as $row) {
        
        if($jk=='2') {
            $ngallery = '<figure class="gallery-item">
    			<div class="gallery-icon landscape">
    				<a data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="89b325d" data-elementor-lightbox-title="'. $row['heading'] . '" href="'. $row['img'] . '">
    				<img loading="lazy" decoding="async" width="770" height="515" src="https://www.shutterstock.com/shutterstock/photos/2359270881/display_1500/stock-vector-space-available-for-advertising-empty-slot-banner-sign-outboard-billboard-ads-2359270881.jpg" class="attachment-full size-full" alt="Space for Ads" aria-describedby="gallery-1-1049" sizes="(max-width: 770px) 100vw, 770px">
    				</a>
    			</div>
    				<figcaption class="wp-caption-text gallery-caption" id="gallery-1-1049">
    				Space For Ads
    				</figcaption></figure>';
            
        }
        else {
            
            
            
            
            $img = $row['img'];

$img1 = $img;

$img0 = str_replace("-og",'-770x516',$img);

$img2 = str_replace("-og",'-300x201',$img);

$img3 = str_replace("-og",'-768x514',$img);


        
            $ngallery = '<figure class="gallery-item">
    			<div class="gallery-icon landscape">
    				<a data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="89b325d" data-elementor-lightbox-title="'. $row['heading'] . '" href="'. $row['img'] . '">
    				
    				<img loading="lazy" decoding="async" width="770" height="515" src="'. $row['img'] . '" class="attachment-full size-full" alt="'. $row['heading'] . '" aria-describedby="gallery-1-1049" srcset="' .  $img0 . ' 770w, ' . $img2 . ' 300w, ' .  $img3	. ' 768w" sizes="(max-width: 770px) 100vw, 770px">
    				
    				</a>
    			</div>
    				<figcaption class="wp-caption-text gallery-caption" id="gallery-1-1049">
    				'. $row['heading'] . '
    				</figcaption></figure>';
        }
        
        $gallery=$gallery . $ngallery;
        
        // $jk++;
        
    }
    
    

				
				
				
				$data['gallery'] = $gallery;
    
    return($data);
    
}

?>
