sendFile() static public method

Send a file (not a document) to the navigator See Document->send();
static public sendFile ( $file, $filename, $mime = null ) : nothing
$file string: storage filename
$filename string: file title
$mime string: file mime type
return nothing
Ejemplo n.º 1
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkLoginUser();
if (isset($_GET["switchto"])) {
    $_SESSION['glpigraphtype'] = $_GET["switchto"];
    Html::back();
}
if (($uid = Session::getLoginUserID(false)) && isset($_GET["file"])) {
    list($userID, $filename) = explode("_", $_GET["file"]);
    if ($userID == $uid && file_exists(GLPI_GRAPH_DIR . "/" . $_GET["file"])) {
        list($fname, $extension) = explode(".", $filename);
        Toolbox::sendFile(GLPI_GRAPH_DIR . "/" . $_GET["file"], 'glpi.' . $extension);
    } else {
        Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
    }
}
Ejemplo n.º 2
0
  @package   Plugin Monitoring for GLPI
  @author    David Durieux
  @co-author
  @comment
  @copyright Copyright (c) 2011-2014 Plugin Monitoring for GLPI team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2011

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkLoginUser();
$docDir = GLPI_PLUGIN_DOC_DIR . '/monitoring';
if (isset($_GET['file'])) {
    $filename = $_GET['file'];
    $file = $docDir . '/' . $filename;
    if (preg_match("/PluginMonitoringService-([0-9]+)-2h([0-9]+).png/", $filename)) {
        include GLPI_ROOT . "/inc/includes.php";
        $match = array();
        preg_match("/PluginMonitoringService-([0-9]+)-2h([0-9]+).png/", $filename, $match);
        $pmServicegraph = new PluginMonitoringServicegraph();
        $pmService = new PluginMonitoringService();
        $pmComponent = new PluginMonitoringComponent();
        $pmService->getFromDB($match[1]);
        $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']);
        $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $match[1], $match[2], '2h');
    }
    Toolbox::sendFile($file, $filename);
}
Ejemplo n.º 3
0
                // Doc alterated
            } else {
                $doc->send();
            }
        } else {
            Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
            // No right
        }
    }
} else {
    if (isset($_GET["file"])) {
        // for other file
        $splitter = explode("/", $_GET["file"]);
        if (count($splitter) == 2) {
            $send = false;
            if ($splitter[0] == "_dumps" && Session::haveRight("backup", CREATE)) {
                $send = true;
            }
            if ($splitter[0] == "_pictures") {
                $send = true;
            }
            if ($send && file_exists(GLPI_DOC_DIR . "/" . $_GET["file"])) {
                Toolbox::sendFile(GLPI_DOC_DIR . "/" . $_GET["file"], $splitter[1]);
            } else {
                Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
            }
        } else {
            Html::displayErrorAndDie(__('Invalid filename'), true);
        }
    }
}
Ejemplo n.º 4
0
 /**
  * Send a document to navigator
  **/
 function send()
 {
     $file = GLPI_DOC_DIR . "/" . $this->fields['filepath'];
     Toolbox::sendFile($file, $this->fields['filename'], $this->fields['mime']);
 }