403Webshell
Server IP : 172.64.80.1  /  Your IP : 172.70.50.62
Web Server : Apache
System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64
User : federalpolyede.edu.ng_idh35skikv ( 10000)
PHP Version : 7.4.33
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/vhosts/federalpolyede.edu.ng/httpdocs/externalCall/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/federalpolyede.edu.ng/httpdocs/externalCall/SpreadsheetAPI_pdo.php
<?php
	// Functions for export to csv.
	function setExcelContentType() {
		if(headers_sent())
			return false;
		//
		header('Content-type: application/vnd.ms-excel');
		return true;
	}

	function setDownloadAsHeader($filename) {
		if(headers_sent())
			return false;
		//
		header('Content-disposition: attachment; filename=' . $filename);
		header('Pragma: no-cache');    
		header('Expires: 0');
		return true;
	}

	function csvFromResult($stream, $result, $showColumnHeaders = true) {
		if($showColumnHeaders) {
			$columnHeaders = array();
			$nfields = mysql_num_fields($result);
			for($i = 0; $i < $nfields; $i++) {
				$field = mysql_fetch_field($result, $i);
				$columnHeaders[] = $field->name;
			}
			fputcsv($stream, $columnHeaders);
		}
		//
		$nrows = 0;
		while($row = mysql_fetch_row($result)) {
			fputcsv($stream, $row);
			$nrows++;
		}
		//
		return $nrows;
	}

	function csvFileFromResult($filename, $result, $showColumnHeaders = true) {
		$fp = fopen($filename, 'w');
		$rc = csvFromResult($fp, $result, $showColumnHeaders);
		fclose($fp);
		return $rc;
	}

	function csvToExcelDownloadFromResult($result,$asFilename = 'data.csv',$showColumnHeaders = true) {
		setExcelContentType();
		setDownloadAsHeader($asFilename);
		return csvFileFromResult('php://output', $result, $showColumnHeaders);
	}


	// Functions for export to excel.
	function xlsBOF() {
		echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
		return; 
	} 
	function xlsEOF() { 
		echo pack("ss", 0x0A, 0x00); 
		return; 
	} 
	function xlsWriteNumber($Row, $Col, $Value) { 
		echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); 
		echo pack("d", $Value); 
		return; 
	} 
	function xlsWriteLabel($Row, $Col, $Value ) { 
		$L = strlen($Value); 
		echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); 
		echo $Value; 
		return; 
	} 

	function xlsProcess($filename){
		//
		header("Content-Type: application/force-download");
		header("Content-Type: application/octet-stream");
		header("Content-Disposition: attachment;filename=".$filename); 
		header("Content-Transfer-Encoding: binary");
		//
		xlsBOF();

		// make column headers from selected fields
		// Make a top line on your excel sheet at line 1 (starting at 0)
		// The first number is the row number and the second number is the column, both are start at '0'
        require_once('../connect.php');
        $db=db_connect();
		//$fields = $queryHandle->columnCount();
        $result = $db->query("Describe export2016_17");
       $colums=$result->fetchAll(PDO::FETCH_COLUMN);

        $i = 0;
         foreach($colums as $col){

            xlsWriteLabel(0,$i, $col);
            $i++;
      }

		$xlsRow = 1;
		// Put data records from mysql by while loop.
        $result = $db->query("select * from export2016_17");
		while($row=$result->fetch(PDO::FETCH_ASSOC)){
			$xlsCol = 0;
			foreach($row as $value) {   
				xlsWriteLabel($xlsRow,$xlsCol,$value);
				$xlsCol++;
			} 
			$xlsRow++;
		}

		xlsEOF();

	}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit