function main() { global $rootDir; # Very primitive check if path tries to go above DOCUMENT_ROOT or is absolute if (strpos($_GET['src'], "..") !== False || substr($_GET['src'], 0, 1) == DIRECTORY_SEPARATOR) { return; } # If we don't want realpath to append any prefixes we need to pass it an absolute path $src = realpath(getAbsolutePath($_GET['src'])); echo "<html><body>"; # TODO: Add link following and syntax highlighting for html and js. highlight_string(file_get_contents($src)); echo "</body></html>"; }
//== Plugin pour GLPI - Dévelloppeur: Viduc (Fleury Tristan) - ©2013 ==// //== http://viduc.sugarbox.fr - viduc@sugarbox.fr ==// //============================================================================// // récupération des chemins absolus $cheminSmarty = getAbsolutePath() . "Smarty"; // définition de l'emplacement de la bibliothèque define('SMARTY_DIR', $cheminSmarty . "/libs/"); // instanciation de la class Smarty require_once SMARTY_DIR . 'Smarty.class.php'; $smarty = new Smarty(); // définition des dossiers Smarty $smarty->template_dir = $cheminSmarty . "/templates/"; $smarty->compile_dir = $cheminSmarty . "/templates_c/"; $smarty->config_dir = $cheminSmarty . "/configs/"; $smarty->cache_dir = $cheminSmarty . "/cache/"; define('GLPI_ROOT', str_replace("/plugins/twins/", "", getAbsolutePath())); include GLPI_ROOT . "/inc/includes.php"; $id = $_GET['id']; $twins = new PluginTwinsTwins(); $smarty->assign('historique', $twins->getHistorique($id)); $smarty->assign('httpPath', getHttpPath()); $smarty->display('historique.tpl'); /** * Récupère le chemin absolue de l'instance glpi * @return String : le chemin absolue (racine principale) */ function getAbsolutePath() { return str_replace("popup/twins.popup.php", "", $_SERVER['SCRIPT_FILENAME']); } /**
function deleteAttachment($isduplicate = "false") { if ($this->ACLAccess('edit')) { if ($isduplicate == "true") { return true; } $removeFile = clean_path(getAbsolutePath("{$GLOBALS['sugar_config']['upload_dir']}{$this->id}")); } if (file_exists($removeFile)) { if (!unlink($removeFile)) { $GLOBALS['log']->error("*** Could not unlink() file: [ {$removeFile} ]"); } else { $this->filename = ''; $this->file_mime_type = ''; $this->file = ''; $this->save(); return true; } } return false; }
} # Do not translate this string, the collection name is translated when displayed! $collection_add = create_collection($userref, $collectionname); } if ($collection_add != "") { # Switch to the selected collection (existing or newly created) and refresh the frame. set_user_collection($userref, $collection_add); refresh_collection_frame($collection_add); } if ($use_local) { # File list from local upload directory. # Define the titles: $titleh1 = $lang["addresourcebatchlocalfolder"]; $titleh2 = str_replace(array("%number", "%subtitle"), array("2", $lang["upload_file"]), $lang["header-upload-subtitle"]); # We compute the folder name from the upload folder option. $folder = getAbsolutePath($local_ftp_upload_folder, true); if ($groupuploadfolders) { $folder .= DIRECTORY_SEPARATOR . $usergroup; } if ($useruploadfolders) { $udata = get_user($userref); $folderadd = htmlspecialchars($udata["username"]); $folder .= DIRECTORY_SEPARATOR . $folderadd; } if (!file_exists($folder)) { mkdir($folder, 0777); } // We list folder contents $files = getFolderContents($folder); } else { # Connect to FTP server for file listing
<?php //============================================================================// //== Plugin pour GLPI - Dévelloppeur: fleuryt (Fleury Tristan) - ©2014 ==// //== http://viduc.sugarbox.fr - viduc@sugarbox.fr ==// //============================================================================// /** * Description de plugin.form * * */ // récupération des chemins absolus define('GLPI_ROOT', getAbsolutePath("reforme")); include GLPI_ROOT . "inc/includes.php"; $cheminSmarty = getAbsolutePath("reforme") . "plugins/reforme/Smarty"; // définition de l'emplacement de la bibliothèque define('SMARTY_DIR', $cheminSmarty . "/libs/"); // instanciation de la class Smarty require_once SMARTY_DIR . 'Smarty.class.php'; $smarty = new Smarty(); // définition des dossiers Smarty $smarty->template_dir = $cheminSmarty . "/templates/"; $smarty->compile_dir = $cheminSmarty . "/templates_c/"; $smarty->config_dir = $cheminSmarty . "/configs/"; $smarty->cache_dir = $cheminSmarty . "/cache/"; $profile = new PluginReformeProfile(); if ($profile->estAutorise()) { $trie = "date"; $ascdesc = "ASC"; //Vérification de l'appel (via le bouton glpi plugin ou via le trie et autre requête du form if (isset($_GET["trie"])) {
<?php //============================================================================// //== Plugin pour GLPI - Dévelloppeur: Viduc (Fleury Tristan) - ©2013 ==// //== http://viduc.sugarbox.fr - viduc@sugarbox.fr ==// //============================================================================// /** * Gestion des droits du plugin groupeAD * Reçoit les informations depuis un formulaire de configuration des droits (profile) * Renvoi sur la page de l'item traité */ // récupération des chemins absolus define('GLPI_ROOT', getAbsolutePath()); include GLPI_ROOT . "inc/includes.php"; include "../inc/profileold.class.php"; if (isset($_POST["Modifier"])) { $arrayItem[0] = $_POST["id"]; if ($_POST["droit"] == "Lecture") { $arrayItem[1] = "r"; } elseif ($_POST["droit"] == "Modification") { $arrayItem[1] = "w"; } else { $arrayItem[1] = "0"; } // Modification des droits dans la base $profile = new PluginGroupeadProfileold(); $profile->majDroit($arrayItem); // Retour à la page d'appel Html::back(); } //========================================================================//
function unlinkTempFiles() { global $sugar_config; @unlink($_FILES['upgrade_zip']['tmp_name']); @unlink(getAbsolutePath($sugar_config['upload_dir'] . $_FILES['upgrade_zip']['name'], true)); }
function deleteAttachment($isduplicate = "false") { if ($this->ACLAccess('edit')) { if ($isduplicate == "true") { return true; } $removeFile = clean_path(getAbsolutePath("{$GLOBALS['sugar_config']['upload_dir']}{$this->id}")); } if (!empty($this->doc_type) && !empty($this->doc_id)) { $document = ExternalAPIFactory::loadAPI($this->doc_type); $response = $document->deleteDoc($this); $this->doc_type = ''; $this->doc_id = ''; $this->doc_url = ''; $this->filename = ''; $this->file_mime_type = ''; } if (file_exists($removeFile)) { if (!unlink($removeFile)) { $GLOBALS['log']->error("*** Could not unlink() file: [ {$removeFile} ]"); } else { $this->filename = ''; $this->file_mime_type = ''; $this->file = ''; $this->save(); return true; } } else { $this->filename = ''; $this->file_mime_type = ''; $this->file = ''; $this->doc_id = ''; $this->save(); return true; } return false; }
/* Copyright (c) 2012 kayson (kaysond) & Noah Manneschmidt (psoplayer) * https://github.com/noahm/MobileTribunal * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ require_once 'support/config.php'; require_once 'support/partials.php'; if (FORCE_SSL && !usingSSL()) { header('Location: ' . getAbsolutePath() . '?secure'); die; } startSession(); // only use this on the endpoint pages (index.php and ajax.php) include 'assets/layouts/mobiletrib.html';
function main() { global $rootDir; if (!isset($_GET['separator'])) { $separator = "\n"; } else { $separator = $_GET['separator']; } $recurse = strtolower($_GET['recurse']) != 'false'; if (strtolower($_GET['mode']) == 'folders') { $mode = 'folders'; } else { $mode = 'files'; } # Very primitive check if path tries to go above DOCUMENT_ROOT or is absolute $path = $_GET['path']; if (strpos($path, "..") !== False || substr($path, 0, 1) == DIRECTORY_SEPARATOR) { return; } # If we don't want realpath to append any prefixes we need to pass it an absolute path $relPath = substr(realpath(getAbsolutePath($path)), strlen($rootDir) + 1); # If the path is not found, return nothing. if ($path !== "" && $relPath == "") { return; } # If there is an error of some sort it will be output as a part of the answer! foreach (getAllFilesUnderAsArray($relPath, $recurse, $mode) as $i => $value) { echo "{$value}{$separator}"; } }
/** * Check if default file content exists - to update .bash_profile * Connot update hosts due to permissions - don't have an easy solution yet * * @param String $path File to check content of * @param String $default Default content file */ function checkFileContent($file, $default) { output("\nUpdating " . basename($file)); // $file = preg_replace("/\~/", $_SERVER['HOME'], $file); // $default = preg_replace("/\~/", $_SERVER['HOME'], $default); $file = getAbsolutePath($file); $default = getAbsolutePath($default); $source_lines = file($file); $default_lines = file($default); $updated_lines = array(); foreach ($default_lines as $d_line) { $d_line = trim($d_line); if ($d_line && !preg_match("/^\\#/", $d_line)) { preg_match("/^\"([^\"]+)\" ([^\$]+)/", $d_line, $d_parts); if (count($d_parts) == 3) { $d_line_match = $d_parts[1]; $d_line_value = $d_parts[2]; foreach ($source_lines as $line_no => $s_line) { // REMOVE AUTO APPENDING LINE if (preg_match("/ADDED BY parentNode DEV TOOL/", $s_line)) { $source_lines[$line_no] = ""; } // remove existing line if match exists if (preg_match("/" . $d_line_match . "/", $s_line)) { $source_lines[$line_no] = ""; } } // add correct line to line updates $updated_lines[] = preg_replace("/\\#TOOLPATH\\#/", getAbsolutePath(dirname(__FILE__)), $d_line_value) . "\n"; } } } $fp = fopen($file, "w+"); foreach ($source_lines as $line) { fwrite($fp, $line); } fwrite($fp, "\n# ADDED BY parentNode DEV TOOL\n"); foreach ($updated_lines as $line) { fwrite($fp, $line); } fclose($fp); }
$backup_path = getAbsolutePath("~/Dropbox/backup/") . $backup_time; } else { if (file_exists(getAbsolutePath("~/Google\\ Drive/backup"))) { $backup_path = getAbsolutePath("~/Google\\ Drive/backup/") . $backup_time; } else { goodbye("Could not find Dropbox or Google Drive for backup. You should create a folder named 'backup' to enable backup."); } } if (!file_exists($backup_path)) { mkdir($backup_path); } output("Backup location:" . $backup_path . "\n"); // Applications list $root_applications = scandir("/Applications"); array_unshift($root_applications, "Root apps:"); $home_applications = scandir(getAbsolutePath("~/Applications")); array_unshift($home_applications, "Home apps:"); file_put_contents($backup_path . "/Applications.txt", implode("\n", array_merge($root_applications, $home_applications))); output("Created applications list\n"); // Macports list $port_output = shell_exec("sudo port installed requested" . " 2>&1"); file_put_contents($backup_path . "/Macports.txt", $port_output); output("Created Macports list\n"); // MySQL command("php " . $_SERVER["HOME"] . "/" . dirname($_SERVER["PHP_SELF"]) . "/mysql_dump_all.php mysqldump", true, false); moveFile("~/mysqldump.sql", $backup_path . "/mysqldump.sql"); // config files copyFile("~/.bash_profile", $backup_path . "/bash_profile"); copyFile("~/.gitconfig", $backup_path . "/gitconfig"); copyFile("~/.gitignore_global", $backup_path . "/gitignore_global"); copyFile("~/.tm_properties", $backup_path . "/tm_properties");
$smarty = new Smarty(); // définition des dossiers Smarty $smarty->template_dir = $cheminSmarty . "/templates/"; $smarty->compile_dir = $cheminSmarty . "/templates_c/"; $smarty->config_dir = $cheminSmarty . "/configs/"; $smarty->cache_dir = $cheminSmarty . "/cache/"; /** * Si un fihcier image (logo) est envoyé par le template, on l'enregistre */ if (isset($_FILES['logo'])) { if (!empty($_FILES['logo']['tmp_name']) && is_uploaded_file($_FILES['logo']['tmp_name'])) { // Le fichier a bien été téléchargé if (exif_imagetype($_FILES['logo']['tmp_name']) == IMAGETYPE_PNG) { $size = getimagesize($_FILES['logo']['tmp_name']); if ($size[0] <= 165 && $size[1] <= 180) { move_uploaded_file($_FILES['logo']['tmp_name'], getAbsolutePath() . "plugins/reforme/images/logo.png"); } } } } //Instanciation de la class config $config = new PluginReformeConfig(); //Gestion des images $logoOption['title'] = 'Logo'; $logoOption['alt'] = "Relancer le formulaire de configuration pour recharger l'image, puis faites F5"; $testOption['title'] = 'Tester'; $testOption['alt'] = "Tester"; $actualiserOption['title'] = "Modifier"; $actualiserOption['alt'] = "Modifier"; $menuaddOption['title'] = "Ajouter AD"; $menuaddOption['alt'] = "Ajouter AD";