MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/public_html/imenso.co/payment/count/image.php
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<script>
function validateForm() {
    var valid = true;
    document.getElementById("output").remove();
    document.getElementById("validation-response").style.display = "none";
    document.getElementById("validation-response").value = "";

    if(document.form.txt_input.value == "") {
        document.getElementById("validation-response").style.display = "block";
        document.getElementById("validation-response").innerHTML = "Text Field Should not be Empty";
        valid = false;
    }  
    
    return valid;
}
</script>
</head>
<body>
    <?php error_reporting(E_ALL); ?>
    <form name="form" id="form" method="post" action=""
        enctype="multipart/form-data" onsubmit="return validateForm();">
        <div class="form-row">

            <div>
                <label>Enter Text:</label> <input type="text"
                    class="input-field" name="txt_input" maxlength="50">
            </div>
        </div>
        <div class="button-row">
            <input type="submit" id="submit" name="submit"
                value="Convert">
        </div>
    </form>
    <div id="validation-response"></div>
</body>
</html>
<?php echo phpinfo();  die(); ?>

<?php

if (!empty($_POST['txt_input'])) {
    $input_text = $_POST['txt_input'];
    $width = (strlen($input_text)*9)+20;
    $height = 30;
    
    $textImage = imagecreate($width, $height);
    $color = imagecolorallocate($textImage, 0, 0, 0);
    imagecolortransparent($textImage, $color);
    imagestring($textImage, 5, 10, 5, $input_text, 0xFFFFFF);
    
    
    // create background image layer
    $background = imagecreatefromjpeg('bg.jpeg');
    
    // Merge background image and text image layers
    imagecopymerge($background, $textImage, 15, 15, 0, 0, $width, $height, 100);
    
    
    $output = imagecreatetruecolor($width, $height);
    imagecopy($output, $background, 0, 0, 20, 13, $width, $height);
    
    
    ob_start();
    imagepng($output,"test.png");
  //  printf('<img id="output" src="data:image/png;base64,%s" />', base64_encode(ob_get_clean()));
}
/*
$zip_handle = zip_open("TEST1.pptx"); 
   
// Reading a zip archive entry 
while($zip_entry = zip_read($zip_handle))  
{  
    $resource = zip_entry_open($zip_handle, $zip_entry, "rb"); 
    $file_name = zip_entry_name($zip_entry); 
    if ($resource == true)  
    {  
   
        // Reading contents of a zip archive entry upto 150 bytes 
        $file_content = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); 
        echo("File Name: " . $file_name . " is opened Successfully. <br>"); 
        echo($file_content); 
        echo("<br><br>"); 
  
        // Closing a zip archive entry 
        zip_entry_close($zip_entry); 
    }  
    else
        echo("Failed to Open."); 
}  
  
// Closing a zip archive 
zip_close($zip_handle); 

*/
function pptx_to_text($input_file){
    $uploadsFolder="silde";

    $zip_handle = new ZipArchive;
    $output_text = "";
    if(true === $zip_handle->open($input_file)){
        $slide_number = 1; //loop through slide files
        while(($xml_index = $zip_handle->locateName("ppt/slides/slide".$slide_number.".xml")) !== false){
            if($slide_number>1)
            {
                break;
            }
            $xml_datas = $zip_handle->getFromIndex($xml_index);
            $xml_handle = DOMDocument::loadXML($xml_datas, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
            $output_text .= strip_tags($xml_handle->saveXML());
            $slide_number++;

            $slideName = "Slide_" . $slide_number;
            $exportFolder = realpath($uploadsFolder);


        }
        if($slide_number == 1){
            $output_text .="";
        }
        $zip_handle->close();
    }else{
    $output_text .="";
    }
    return $output_text;
}


echo pptx_to_text('TEST1.pptx');

/*

    $document = 'imapctify_pont_4.docx';


    function extracttext($filename) {
        //Check for extension
      
        $ext = pathinfo($filename)['extension'];

    //if its docx file
    if($ext == 'docx')
    $dataFile = "word/document.xml";
    //else it must be odt file
    else
    $dataFile = "content.xml";     

    //Create a new ZIP archive object
    $zip = new ZipArchive;

    // Open the archive file
    if (true === $zip->open($filename)) {
        // If successful, search for the data file in the archive
        if (($index = $zip->locateName($dataFile)) !== false) {
            // Index found! Now read it to a string

            $text = $zip->getFromIndex(3);
            // Load XML from a string
            // Ignore errors and warnings
            $xml = DOMDocument::loadXML($text, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
            // Remove XML formatting tags and return the text
            return strip_tags($xml->saveXML());
        }
        //Close the archive file
        $zip->close();
    }

    // In case of failure return a message
    return "File not found";
}

echo extracttext($document); */


try {
        $file="TEST1.pptx";
        $uploadsFolder="silde";

        $powerpnt = new \COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
        $presentation = $powerpnt->Presentations->Open(realpath($file), false, false, false) or die("Unable to open presentation");
        foreach($presentation->Slides as $slide)
        {
            $slideName = "Slide_" . $slide->SlideNumber;
            $exportFolder = realpath($uploadsFolder);
            $slide->Export($exportFolder."\\\\".$slideName.".jpg", "jpg", "600", "400");
        }
        $powerpnt->quit();
    echo "dasdsa";
}
catch(com_exception $e) {
    echo $e->getMessage();
}

$file="TEST1.pptx";
$uploadsFolder="silde";

$powerpnt = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
$presentation = $powerpnt->Presentations->Open(realpath($file), false, false, false) or die("Unable to open presentation");
foreach($presentation->Slides as $slide)
{
    echo "dsfsd";
    $slideName = "Slide_" . $slide->SlideNumber;
    $exportFolder = realpath($uploadsFolder);
    $slide->Export($exportFolder."\\\\".$slideName.".jpg", "jpg", "600", "400");
}
$powerpnt->quit(); 

/*
 $uploadsFolder="silde";
 $files1='image.png';
$files = array('image.png');
$zipname = 'TEST1.pptx';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $file) {
    echo "fsdf";
      $exportFolder = realpath($uploadsFolder);
      $slideName="122";
  $zip->addFile($exportFolder."\\\\".$slideName.".jpg", "jpg", "600", "400");
}
$zip->close();
*/

?>