/** * recursively create a long directory path */ function createPath($path) { if (is_dir($path)) { return true; } $prev_path = substr($path, 0, strrpos($path, '/', -2) + 1); $return = createPath($prev_path); return $return && is_writable($prev_path) ? mkdir($path) : false; }
function createPath($iden, $db) { $s = "SELECT * FROM agrupaciones WHERE id='" . $iden . "' and visible=1"; $row = $db->GetRow($s); if ($row['padre'] == 0) { return '<a href="navegacion.php">Inicio</a> / <a href="navegacion.php?c=' . $iden . '">' . $row['etiqueta_corta'] . '</a> '; } else { return createPath($row['padre'], $db) . ' / <a href="navegacion.php?c=' . $iden . '">' . $row['etiqueta_corta'] . '</a>'; } }
function startSession($time = 3600, $ses = TITLE) { session_set_cookie_params($time); session_name($ses); session_save_path(createPath(ROOT . '/tmp/session')); session_start(); // Reset the expiration time upon page load if (isset($_COOKIE[$ses])) { setcookie(session_name(), session_id(), time() + $time, "/"); } }
/** * Sube un archivo a la carpeta uploads * @param unknown_type $arr_file_desc * @param unknown_type $destino * @param unknown_type $name */ function subirArchivo($arr_file_desc, $destino = null, $name = null) { $arr_file = array(); $file_extension = file_extension($arr_file_desc['name']); if ($destino == null) { $dia = date("j"); $mes = date("n"); $anyo = date("Y"); $new_relative_path = $anyo . BARRA_SERVIDOR . $mes . BARRA_SERVIDOR . $dia; } else { $new_relative_path = $destino; } if ($name != null) { $new_file_name = $name; } else { $new_file_name = str_replace("." . $file_extension, "", $arr_file_desc['name']); } // Creamos la ruta de carpetas createPath($new_relative_path); // Si existe el archivo, con un contador cambio el nombre hasta que deje de existir $cont = 0; while (file_exists(UPLOAD_DIR . BARRA_SERVIDOR . $new_relative_path . BARRA_SERVIDOR . $new_file_name . "." . $file_extension)) { $cont++; $new_file_name .= $cont; } if (file_exists($arr_file_desc['tmp_name'])) { if (!copy($arr_file_desc['tmp_name'], UPLOAD_DIR . BARRA_SERVIDOR . $new_relative_path . BARRA_SERVIDOR . $new_file_name . "." . $file_extension)) { print "Error, no ha sido posible la copia del archivo"; } else { //borro el archivo temporal unlink($arr_file_desc['tmp_name']); } } else { header('Content-type: application/json'); //objeto json que devolverá la respuesta $jsondata = array(); $jsondata['error'] = true; $jsondata['msg'] = "No se ha podido subir el archivo, intentelo de nuevo o contacte con su administrador."; echo json_encode($jsondata); exit; } $new_file_path = $new_relative_path . BARRA_SERVIDOR . $new_file_name . "." . $file_extension; $origen_dir = UPLOAD_DIR . BARRA_SERVIDOR . substr($new_file_path, 0, strrpos($new_file_path, BARRA_SERVIDOR)) . BARRA_SERVIDOR; $nombre_archivo = substr($new_file_path, strrpos($new_file_path, BARRA_SERVIDOR) + 1); $nombre_sin_extension = substr($nombre_archivo, 0, strrpos($nombre_archivo, ".")); $extension = substr($new_file_path, strrpos($new_file_path, ".") + 1); //si es una imagen, creo una más pequeña para agilizar la carga con thumbnails if ($extension == "jpg" || $extension == "gif" || $extension == "png") { //$info = getimagesize ($new_file_path); img_resize($origen_dir . $nombre_archivo, THUMBNAIL_WIDTH, $origen_dir, $nombre_sin_extension . "." . $extension, THUMBNAIL_HEIGHT); } // Devuelvo la ruta sin la carpeta padre por si se cambia en la configuracion return $new_file_path; }
public function savePortrait() { createPath(UPLOAD_DIR); if (isset($_FILES['fileToUpload']['tmp_name'])) { $uploadTmp = $_FILES['fileToUpload']['tmp_name']; $imginfo_array = getimagesize($uploadTmp); if ($imginfo_array == false) { // this is not a valid image file } else { $uploadName = $_FILES['fileToUpload']['name']; $uploadType = $_FILES['fileToUpload']['type']; $destination = md5_file($uploadTmp) . '.' . explode('/', $uploadType)[1]; $absolute_path = UPLOAD_DIR . $destination; if (!file_exists($absolute_path)) { move_uploaded_file($uploadTmp, $absolute_path); } $this->m_userProf->savePtrt(UPLOAD_URL_DIR . $destination); } } $this->m_contentView = "setting.php"; $this->showProfile(); $this->m_variables[self::TAB] = self::TAB_PORTRAIT; }
$totalPages = $pages->TotalPages; $lastPageFileName = "{$federationPath}/lastpage"; $startPage = readStartPage($lastPageFileName); // iterate pages for ($pageNum = $startPage; $pageNum <= $totalPages; $pageNum++) { // create page dir $pagePath = "{$federationPath}/p{$pageNum}"; createPath($pagePath); // iterate over documents of a federation echo "iterating page {$pageNum}\n"; // get & save page $page = getSentDocuments($federationId, $accountId, $pageNum); file_put_contents("{$federationPath}/federation_p{$pageNum}_{$federationId}.json", json_encode($page)); foreach ($page->Items as $item) { $documentId = $item->DocumentId; echo " > {$documentId} \n"; $documentPath = "{$pagePath}/{$documentId}"; createPath($documentPath); // iterate over details of a document $detail = getDocumentDetails($documentId); file_put_contents("{$documentPath}/documentDetail_{$documentId}.json", json_encode($detail)); // copy detail XML $detailXML = getDetailXML($documentId); $detailXML = base64_decode($detailXML); file_put_contents("{$documentPath}/xml_{$documentId}.xml", $detailXML); } writeStartPage($lastPageFileName, $pageNum); } } //print_r($federations); //print($file);
</div> <?php } ?> </div> <?php } ?> <ul class="nav nav-tabs" id="listContentTab"> <li class="active"><a href="#currentContentTab"><i class="icon icon-color icon-book-empty"></i> Current Content</a></li> <li><a href="#newContentTab"><i class="icon icon-color icon-plus"></i> Add New Content</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="currentContentTab"> <h4>Content >> <a href="index.php?action=listContent">Top</a> <?php echo (isset($_GET['categoryId']) ? ' > ' : '') . createPath($_GET['categoryId']); ?> </h4><br /> <table class="table table-striped table-bordered bootstrap-datatable datatable dataTable"> <thead> <tr> <td class="hide-below-480 table-id-head" style="width:2.5%;">ID</td> <td class="hide-below-480 table-id-head" style="width:2.5%;">Sort</td> <td class="table-title-head">Title</td> <td class="hide-below-480 table-title-head" style="width:10%;">Index <i class="icon-info-sign" data-rel="popover" data-content="And here's some amazing content. It's very engaging. right?" title="A Title"></td> <td class="hide-below-480 table-title-head" style="width:10%;">Status <i class="icon-info-sign" data-rel="popover" data-content="And here's some amazing content. It's very engaging. right?" title="A Title"></td> <td class="table-title-head" style="text-align:right;" style="width:20%;">Actions <i class="icon-info-sign" data-rel="popover" data-placement="left" data-content="And here's some amazing content. It's very engaging. right?" title="A Title"></td> </tr> </thead> <tbody id="content-list"> <?php
function generateFnImageAnnotationXmlV03() { // make sure <entry>...<entry> is clearly generated global $FN_FEED_PATH, $FN_FEED_STYLESHEET_PATH, $FN_FOTONOTES_DATA_PATH_PREFIX, $FILETYPES; global $ANNOTATIONS_ORIGINALS_FOLDER, $ANNOTATIONS_THUMBNAILS_FOLDER; $xml = null; // get unique uuid for feed $feed_uuid = getNewUUID(); $this->param["feed_uuid"] = $feed_uuid; // get feed file destination based on today's date $createdtime = time(); $year = gmdate("Y", $createdtime); $month = gmdate("m", $createdtime); $day = gmdate("d", $createdtime); $created = gmdate("Y-m-d\\TH:i:s\\Z", $createdtime); $storagepath = $FN_FEED_PATH . $year . "/" . $month . "/" . $day; $feed_file_path = $storagepath . "/" . $feed_uuid . ".xml"; $this->param["feed_file_path"] = $feed_file_path; displayDebug("feed_file_path: {$feed_file_path}", 3); displayDebug("param[feed_file_path]: " . $this->param["feed_file_path"], 3); //make sure path exists createPath($storagepath); // parse incoming xml displayDebug("this->param[src_xml]", 2); displayDebugParam($this->param["src_xml"], 2); $entry_array = $this->parseEntryXML($this->param["src_xml"]); // ASSIGN *entry_array* values to *annotations* params foreach ($entry_array as $key => $value) { $this->setFnImageAnnotationParam($key, $value); } // fix uuid // first transform existing <id> in xml to <fn:id> //$xml = preg_replace("#<id>(.*)</id>#","<fn2:id>$1</fn2:id>",$xml); $this->param["src_xml"] = preg_replace("#<id>(.*)</id>#", "<fn:id>\$1</fn:id>", $this->param["src_xml"]); $entry_uuid = "<id>{$entry_array['id']}</id>\n"; $parent_entry_id = $entry_array['parent_id']; $parent_entry_uuid = "<parent_uuid>" . $entry_array['parent_id'] . "</parent_uuid>"; $parent_entry_array = null; //getEntriesXML2Array($parent_entry_id); //echo "\ngeom: ".$parent_entry_array['geometry']. "\n"; $entry_geometry = "<geometry>" . $parent_entry_array['geometry'] . "</geometry>"; // SET parent_image_link in fn_anntoation $this->param["parent_link_jpg"] = $parent_entry_array["link_jpg"]; // PREPARE *make image* parameters displayDebug("<p>parent_entry_array: {$parent_entry_array}", 2); displayDebugParam($parent_entry_array, 2); $annotation_storagepath = $ANNOTATIONS_ORIGINALS_FOLDER . "/" . $year . "/" . $month . "/" . $day; displayDebug("annotation_storagepath: {$annotation_storagepath}", 1); // CHECK AND CREATE *file path* createPath($annotation_storagepath); // PREPARE xml links for section of photo $entry_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes.php#", "", $_SERVER['REQUEST_URI']) . $annotation_storagepath . '/' . $entry_array[id] . '.jpg'; $entry_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes2.php#", "", $_SERVER['REQUEST_URI']) . $annotation_storagepath . '/' . $entry_array[id] . '.jpg'; displayDebug("\$entry_link_jpg: {$entry_link_jpg}", 3); // this won't always be jpg $entry_mimetype = "image/jpg"; $entry_annotation_link = "<link href=\"{$entry_link_jpg}\" rel=\"annotated_region\" type=\"{$entry_mimetype}\" />"; $entry_jpg_link = "<link href=\"{$entry_link_jpg}\" rel=\"jpg\" type=\"{$entry_mimetype}\" />"; // WRITE annotated section of photo to file system displayDebug("\n fn_makeImage ({$parent_entry_array['link_jpg']}, " . str_replace(",", " ", $entry_array[boundingbox]) . ", 1,\n\t\t\tnull, null, {$annotation_storagepath}.'/'.{$entry_array['id']}.'.jpg')"); fn_makeImage($parent_entry_array['link_jpg'], str_replace(",", " ", $entry_array[boundingbox]), 1, null, null, $annotation_storagepath . '/' . $entry_array[id] . '.jpg', 1); // PREPARE *make image* parameters for *thumbnail* of annotated region $annotation_thumbnail_storagepath = $ANNOTATIONS_THUMBNAILS_FOLDER . "/" . $year . "/" . $month . "/" . $day; displayDebug("annotation_storagepath: {$annotation_thumbnail_storagepath}", 3); // calculate thumbscale factor - This needs to be better, to actually calculate scale! $thumbscale = 1; // CHECK AND CREATE *file path* for *thumbnail* of annotated region createPath($annotation_thumbnail_storagepath); // PREPARE xml links for *thumbnail* of annotated region $entry_thumbnail_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes.php#", "", $_SERVER['REQUEST_URI']) . $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg'; $entry_thumbnail_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes2.php#", "", $_SERVER['REQUEST_URI']) . $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg'; // this won't always be jpg $entry_mimetype = "image/jpg"; $entry_mimetype_thn = "image/thn-jpg"; $entry_thumbnail_link = "<link href=\"{$entry_link_jpg}\" rel=\"annotated region image\" type=\"{$entry_mimetype}\" />"; $entry_annotation_thumbnail_link = "<link href=\"{$entry_thumbnail_link_jpg}\" rel=\"thn\" type=\"{$entry_mimetype_thn}\" />"; // this won't always be jpg $parent_entry_mimetype = "image/jpg"; $parent_entry_url = ""; $parent_entry_link = "<link href=\"\" rel=\"annotated image\" type=\"{$parent_entry_mimetype}\" />"; // WRITE *thumbnail of annotated section of photo to file system fn_makeImage($parent_entry_array['link_jpg'], str_replace(",", " ", $entry_array[boundingbox]), $thumbscale, null, null, $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg'); // Almost done - just need to create annotation entry xml, store it properly, and put feed on file system. // BUILD *annotation entry xml* // this needs fixing - what should $xml be that is getting replaced? $xml_entryinfo = preg_replace("#<entry>#", "<entry title=\"FotoNotes Annotation\" type=\"fn\" " . " xmlns:fn=\"http://fotonotes.net/protocol/fotonotes_0.2\">" . $entry_uuid . $entry_geometry . $entry_jpg_link . $entry_annotation_link . $entry_annotation_thumbnail_link . $parent_entry_uuid, $this->param["src_xml"]); $xml_entryinfo = preg_replace("#<([a-zA-Z])#", "\n<\$1", $xml_entryinfo); $xml_entryinfo = preg_replace("#</fn:selection>#", "\n</fn:selection>", $xml_entryinfo); $xml_entryinfo = preg_replace("#</author>#", "\n</author>", $xml_entryinfo); $xml_entryinfo = preg_replace("#</entry>#", "\n</entry>", $xml_entryinfo); displayDebug("xml_entryinfo: ", 2); displayDebugParam($xml_entryinfo, 2); $this->param["xml_entryinfo"] = $xml_entryinfo; displayDebug("generateFnImageAnnotationXml xml_entryinfo:", 2); displayDebugParam($this->param["xml_entryinfo"]); return $this->param["xml_entryinfo"]; }
function createPath($path) { if (!trim($path)) { return false; } $dir_ext = substr($path, 0, strrpos($path, '/')); if (!is_dir($dir_ext)) { //echo "<BR/>dir_ext:".$dir_ext; createPath($dir_ext); //call itself means recursive loop if (!is_dir($path)) { mkdir($path); chmod($path, 0777); } return true; } else { clearstatcache(); if (!is_dir($path)) { mkdir($path); chmod($path, 0777); } return true; } }
// set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://cruzroja.vivocomtech.net/Destacados.xml"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser $out = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $xmlDestino = $_SESSION['workfolder_webdir'] . "Destacados.xml"; //krumo(mb_detect_encoding($out)); $fp = fopen($xmlDestino, 'w'); fwrite($fp, $out); fclose($fp); //krumo(dirname($_SESSION['workfolder_webdir'])); $safeFolder = dirname($_SESSION['workfolder_webdir']) . "/_safe/"; if (!createPath($safeFolder)) { $message .= "No se puede crear _safe folder"; } //.strftime("%d%B%y")." $xmlDestinoSAFE = $safeFolder . "Destacados.xml"; $fp = fopen($xmlDestinoSAFE, 'w'); fwrite($fp, $out); fclose($fp); $message .= "<h2>Archivo <a href='{$xmlDestino}' target='_blank'>{$xmlDestino}</a> creado</h2>"; $message .= "<a href='{$nextPaso}'>Próximo paso</a>"; // $message.=krumo(file_get_contents($xmlDestino)); } // http://cruzroja.vivocomtech.net/Destacados.xml ?> <!doctype html> <html>
/** * @brief Executes a build managing its status and output information. * * @param build Build to perform. */ function runBuild($build) { // TODO: measure and record execution time of the build // TODO: record time and date of the build $build->setStatus('running'); $rawOutput = ''; $buildPath = BUILDS_PATH . "/{$build->buildername}"; createPath($buildPath); $handle = popen("cd {$buildPath} && " . BUILDERS_PATH . '/' . $build->buildername . ' 2>&1', 'r'); while (!feof($handle)) { $rawOutput .= fgets($handle); // TODO: append output to database record every N lines (e.g. 100) } $exitcode = pclose($handle); $output = makeReport($rawOutput); $build->setResult($exitcode == 0 ? 'OK' : 'FAIL', $output, $exitcode); }
$row = $db->GetRow($s); return '<div style="font-size:18px; float:left; color:white;"><a href="navegacion.php">Inicio</a> / <a href="navegacion_institucion.php">Instituciones</a> / ' . $row['nombre'] . '</div><br><br>'; } function padreName($iden, $db) { $s = "SELECT * FROM instituciones WHERE id='" . $iden . "' "; $row = $db->GetRow($s); $nombre = $row['nombre']; /*$s ="SELECT * FROM agrupaciones WHERE id='".$row['padre']."'"; $r = mysql_query($s); $row = mysql_fetch_array($r);*/ return $nombre; } if ($c > 0) { $primer_padre_ident = $c; echo createPath($primer_padre_ident, $db); $pathbread = padreName($primer_padre_ident, $db); } else { echo "<h3>Instituciones que entregan trámites aquí:</h3>"; $pathbread = "Listado instituciones"; } ?> </div> <script> document.title = "<?php echo $pathbread; ?> "; </script>
{ global $TargetFolder; $path = preg_replace('/[^\\/]+$/i', '', $outFile); if (strlen($path) > 0) { $path = $TargetFolder . "/" . $path; if (!file_exists($path)) { mkdir($path); } } } foreach ($sections as $sect) { $file = $sect->getAttribute("file"); $outFile = preg_replace('/xml$/i', "html", $file); $html = xml2html($Settings["ContentFolder"] . "/pages/" . $file, $Settings["XsltFolder"] . "/article.xslt", $xsltSettings); $html = setDocType($html); createPath($outFile); file_put_contents($TargetFolder . "/{$outFile}", $html); } buildMenu(); function buildMenu() { global $Settings; global $xsltSettings; $menu = xml2html($Settings["ContentFolder"] . "/toc.xml", $Settings["XsltFolder"] . "/menu.xslt", $xsltSettings); file_put_contents($Settings["CacheFolder"] . "/menu.xml", $menu); } function xml2html($xmlcontent, $xsl, $settings) { global $debugMode; global $Settings; $xmlDoc = new DOMDocument();
include_once $root_path . 'lib/Images.php'; include_once $root_path . '../libs/krumo/class.krumo.php'; $paso1 = "CR_form1.php"; setlocale(LC_ALL, 'es_ES'); $todayFolder = $_SESSION['workfolder'] ? $_SESSION['workfolder'] : strftime("%d%B%y"); if (!isset($_SESSION['workfolder_webdir'])) { $message = "Necesitas crear carpeta para xml e imágenes <a href='{$paso1}'>Paso 1</a>"; } else { //$xmlDestino=$_SESSION['workfolder_webdir']."Destacados.xml"; $folder = $_SESSION['workfolder_webdir']; } $destacados_img_folder = $_SESSION['workfolder_webdir'] . "img/destacados/" . $todayFolder . "/"; if (!is_dir($destacados_img_folder)) { $message = "Creando carpeta<br>"; //krumo($folder); if (!createPath($destacados_img_folder)) { $message = "Error making folder"; } $message .= "Carpeta {$destacados_img_folder} creada"; $message .= "<br> {$destacados_img_folder} es la carpeta activa"; } $_SESSION['destacados_img_folder'] = $destacados_img_folder; if (isset($_GET['delete'])) { //unset($_SESSION); unlink($_GET['delete']); header("Location:" . $_SERVER['PHP_SELF']); } if ($_SERVER['REQUEST_METHOD'] == "POST") { $image = new Images(); //$folder="archivo/".$_POST['folder']."/web/img/destacados/prepor_"; $folder = $_SESSION['destacados_img_folder'];
function createPath($id) { try { $pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $st = $pdo->prepare("SELECT id, title, categoryId FROM " . DB_PREFIX . "content WHERE id = :id"); $st->bindValue(":id", $id, PDO::PARAM_INT); $st->execute(); $result = $st->fetch(); $pdo = null; } catch (PDOException $e) { echo "ERROR: " . $e->getMessage(); } if ($result['categoryId'] == 0) { $name = '<a href="index.php?action=listContent&categoryId=' . $result['id'] . '">' . $result['title'] . '</a>'; return $name; } else { $name = ' > <a href="index.php?action=listContent&categoryId=' . $result['id'] . '">' . $result['title'] . '</a>'; return createPath($result['categoryId']) . " " . $name; } }
include_once $root_path . 'lib/Images.php'; include_once $root_path . '../libs/krumo/class.krumo.php'; $paso1 = "CR_form1.php"; setlocale(LC_ALL, 'es_ES'); $todayFolder = $_SESSION['workfolder'] ? $_SESSION['workfolder'] : strftime("%d%B%y"); if (!isset($_SESSION['workfolder_webdir'])) { $message = "Necesitas crear carpeta para xml e imágenes <a href='{$paso1}'>Paso 1</a>"; } else { //$xmlDestino=$_SESSION['workfolder_webdir']."Destacados.xml"; $folder = $_SESSION['workfolder_webdir']; } $cruzrojatv_img_folder = $_SESSION['workfolder_webdir'] . "img/cruzrojatv/" . $todayFolder . "/"; if (!is_dir($cruzrojatv_img_folder)) { $message = "Creando carpeta<br>"; //krumo($folder); if (!createPath($cruzrojatv_img_folder)) { $message = "Error making folder"; } $message .= "Carpeta {$cruzrojatv_img_folder} creada"; $message .= "<br> {$cruzrojatv_img_folder} es la carpeta activa"; } $_SESSION['cruzrojatv_img_folder'] = $cruzrojatv_img_folder; if ($_SERVER['REQUEST_METHOD'] == "POST") { $folder = $_SESSION['cruzrojatv_img_folder']; //Upload limit size in megabytes $upload_size_limit = 10; //this is the image destination path $path = $folder; //temp image storage directory $temp_path = "temp/"; //list all accepted image formats here (extensions)