Jump to content

[SOLVED] Saving my file instead of executing script


blackcell

Recommended Posts

I have been working on a file management application and apparently somewhere within the past week a feature stopped working and nobody noticed. 

 

I have been backing it up daily but can't tell where the change occurred that is causing the problem.

 

I have a page that will display every file within a folder.  With each file is a href that will link to itself passing my variable "usermode".  If this href is clicked it will pass usermode=delete&file=$file. 

 

It worked fine until I checked it today and now it wants to save my index.php "the page I am on" to my desktop with pure html and none of my php in it. It should do nothing but unlink($_REQUEST['file'] and print the listed items in the directory again.

 

Any ideas?  I am lost on any and have to present this tomorrow.

 

I started using session_start() to have variables on a require("header.php") that is included on all of the pages.  I don't know if that affects anything because this is my first time using session vars.

 

Also, when the file was clicked it would display the file in a right frame wheras the listing of files were in left frame.

 

<?php
//This is my header file included in everything
<?
//******************************************************************************
//******************************Header Data*************************************
//******************************************************************************
$phpSelf = $_SERVER['PHP_SELF'];
//echo $phpSelf;
$jamRoot = $_SERVER["DOCUMENT_ROOT"] . "/jam";
$persInfo_ID = $_REQUEST['id'];
$_JAMSYS['version'] = "1.21";
session_start();

$bannerHead = "<img src='images/banner_main.png' width='351' height='38' alt='' />";
//echo "<center>JamRoot = $jamRoot</center><br>";


//SYSTEM MESSAGES***************************************************************
//These messages are excluded from the scan manager windows.
if(!($phpSelf == "/jam/index.php" || $phpSelf == "/jam/form.php" || $phpSelf == "/jam/attachment.php" || $phpSelf == "/jam/iforms.php")){
    //echo "<center><b>JAM Message:</b> JAM is undergoing maintenance. Although JAM may appear to be functional, changes should wait until this message is gone.</center><br>";
    //echo "<center><b>JAM Message:</b> JAM is undergoing maintenance but should be working normally.</center><br>";
    //die("<center><big>JAM Message:</big><br> A serious problem with JAM was found. Try again later.</center><br>");
    //echo("<center><big>JAM Message:</big><br> A serious problem with JAM was found. Try again later.</center><br>");
    //echo "<center>Please help us improve JAM. Report any errors, needed corrections, or suggestions to the IT Department.</center><br>";
    //echo "<center><big><b>JAM R&D</b></big><br>JAM Development Team is working within JAM and you may have odd encounters.  Ignore any messages you see at the top, they are used for development and troubleshooting.<br><br>";
}
//******************************************************************************

//ENGINE CHECK******************************************************************
//Turn on to check each module that loads with each page.
$checkEngineModules = 0;


if($checkEngineModules)echo"<left><big><b>Checking JAM Engine Modules...</b></big></left><br>";
     if($checkEngineModules)echo"<left><b>JAMINC.ENG.PHP</b> Successfully Loaded!</left><br>";

//******************************************************************************


//functions,handleINI,sqlUserPass,sqlConnect,SAB,mailto,trashMan,jcpLinker,jamJar,selectOptions
require("other/engineconfigs.eng.php");
if(substr($JAMINC,10,1))require("$jamRoot/engine/other/defineUsers.eng.php");   //10
if(substr($JAMINC,0,1))require("$jamRoot/engine/function/functions.eng.php");   //1
if(substr($JAMINC,1,1))require("$jamRoot/engine/function/handleINI.eng.php");   //2
if(substr($JAMINC,2,1))require("$jamRoot/engine/sql/sqlUserPass.cfg");          //2
if(substr($JAMINC,3,1))require("$jamRoot/engine/sql/sqlConnect.cfg");           //2
if(substr($JAMINC,4,1))require("$jamRoot/engine/other/SAB.eng.php");
if(substr($JAMINC,5,1))require("$jamRoot/engine/other/mailto.maildata.php");
if(substr($JAMINC,6,1))require("$jamRoot/engine/other/trashMan.eng.php");
if(substr($JAMINC,7,1))require("$jamRoot/engine/other/jcpLinker.eng.php");
if(substr($JAMINC,8,1))require("$jamRoot/engine/other/jamJar.eng.php");
if(substr($JAMINC,9,1))require("$jamRoot/engine/other/selectOptions.eng.php");
if(substr($JAMINC,11,1))require("$jamRoot/engine/function/viewQuery.eng.php");

?>

************************************************************

<?php
//Here is my delete button routine

$jamRoot = $_SERVER["DOCUMENT_ROOT"] . "/jam";
    //Delete Button
    if($userMode == "delete"){
        $file = $_REQUEST['file'];
        $binName = date("Y-n-d H_i_s-") . rand(0,999) . ".pdf";
        if(copy("$jamRoot/incoming/$file","$jamRoot/jcp/backup/trash_bin/$binName")){
            unlink("incoming/$file");
            $onLoad = "onLoad='top.open(\"index.php\",\"_self\")'";
        }else{
            JamErrorLog("JAM","Application Delete","JAM failed to move file from incoming/$file to ../jcp/backup/trash_bin/$binName.");
        }
    }

// Stopped self management whenever control panel featured a self-restore button.
    //Trash Bin Management
    if(!$userMode == "delete"){
        //Monthly Dumping of trash_bin
        $handle = opendir("file_repos/trash_bin");
        while(false !== ($file = readdir($handle))){
            if($file == ".")continue;
            if($file == "..")continue;
            if($file == "...")continue;
            $binM = substr($file,5,1);
            if($binM < date("n") ){
                unlink("file_repos/trash_bin/$file");
            }
            //To take care of files in december.
            if($binM == "1"){
                if($binM > date("n") ){
                    unlink("file_repos/trash_bin/$file");
                }
            }
        }
        closedir($handle);
    }
*/

     if($checkEngineModules)echo"<left>trashMan.eng.php Successfully Loaded!</left><br>";

?>

************************************************************

<?php
//Here is my index.php where the display happens
    $JAMINC = 1111100001;
    $JAMINC  = 1; //functions
    $JAMINC .= 1; //handleINI
    $JAMINC .= 1; //sqlUserPass
    $JAMINC .= 1; //sqlConnect
    $JAMINC .= 1; //SAB
    $JAMINC .= 0; //mailto data
    $JAMINC .= 1; //trashMan
    $JAMINC .= 0; //jcpLinker
    $JAMINC .= 0; //jamJar
    $JAMINC .= 1; //selectOptions
    $JAMINC .= 1; //defineUsers REQUIRED
    require("engine/JAMINC.ENG.PHP");

    $userMode = $_REQUEST['usermode'];
    $userIP = $_SERVER['REMOTE_ADDR'];
    $phpSelf = $_SERVER['PHP_SELF'];
    $onLoad = "";


    $tasks =
    "
    <table align='center' width='100%' border='0'>
        <tr>
            <td width='100%' align='center'></td>
        </tr>
    ";

    //Finding Files in INCOMING directory
    $handle = opendir("incoming/");
    $sideBar =
    "
    <table align='left' width='100%' border='0'>
        <tr>
            <td width='100%' align='left'><font size='4'><u>Scans</u></font></td>
        </tr>
    ";
    $x = 1;
    while (false !== ($file = readdir($handle))){
        if($file == ".")continue;
        if($file == "..")continue;
        if($file == "...")continue;
        if(substr($file,-22,22) == "jam.attachment.request")continue;

        $fileView = str_ireplace("im4510_","",$file);

        //Determines if the file viewing is for attachment or application submitting
        $jamJAR = "incoming/" . str_ireplace(".","_",$userIP) . ".jam.attachment.request";
        //echo"[$jamJAR]<br>";
        if(file_exists($jamJAR)){
            $onLoad = "onLoad='top.open(\"attachment.php\",\"_self\")'";
        }else{
            //echo"[JAM JAR File Does Not Exist]<br>";
            $sideTarget = "form.php?file=$file";
        }

        $sideBar .=
        "
            <tr>
                <td><a href='index.php?usermode=delete&file=$file' target='_self'><img src='images/delete_button.gif' border='0' width='16' height='16' alt='' /></a><a href='$sideTarget' target='_self'><b> $x. </b>$fileView</a>
                </td>
            </tr>
        ";

        $x++;
    }

    closedir($handle);

    if($x <= 1){
        $sideBar .=
        "
            <tr>
                <td>Directory is Empty</a>
                </td>
            </tr>
        </table>
        ";
    }else{
        $sideBar .=
        "
        </table>
        ";
    }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>JAM Scan Manager</title>
    <style type="text/css">
        a { text-decoration : none;
            color : #000000;
        }
        a:visited { text-decoration : none;
            color : #000000;
        }
        a:hover {
            color : #F5AE25;
            background : ;
        }
        .hdr { text-decoration : none;
            color : #ff0000;
        }
        .hdr:visited { text-decoration : none;
            color : #ff0000;
        }
        .hdr:hover {
            color : #F5AE25;
            background : #bb0000;
        }
        .hihiterow:hover {
            color : #F5AE25;
            background : #ffffff;
        }
    </style>

</head>
<body bgcolor="#FFFFFF" style="font-family: arial; font-size: 14px;" <? echo $onLoad ?>>

<table align="center" width="100%" border="0">
  <tr>
    <td align='center'><b><big>JAM Scan Manager</big></b></td>
  </tr>
  <tr>
    <td align='center'><a href="view.php" title="Viewer"><b><font color="#000080">Go to Viewer</font></b></a></td>
  </tr>
  <tr>
    <td align='center'><? echo $tasks ?></td>
  </tr>
</table>
<table align="left" width="75%" border="0">
  <tr>
    <td valign='top' width='50%'><? echo $sideBar ?></td>
  </tr>
</table>

</body>
</html>

I know it is sloppy and probably not the preferred method of doing things but I am learning.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.