示例#1
0
文件: xml.php 项目: joksnet/php-old
/**
 * Convierte el contenido del archivo a un array
 *
 * @param string $fileName
 * @return array
 */
function xml2array($fileName)
{
    $xml = fileGetContents($fileName);
    $xmlParser = new xmlParser();
    $xmlParser->parse($xml);
    return $xmlParser->data;
}
示例#2
0
/**
 * Devuelve el contenido del archivo JavaScript y si no se
 * le pasa un nombre de archivo, devuelve los archivos basicos.
 *
 * @param string $fileName
 * @return string
 */
function importJS($fileName = null)
{
    if (is_null($fileName)) {
        $basicFiles = array('jquery.js');
        $js = '';
        foreach ($basicFiles as $fileName) {
            $js .= importJS($fileName);
        }
        return $js;
    }
    $fileTpl = pathTpl($fileName);
    $filePub = 'pub/js/' . $fileName;
    if (@file_exists($fileTpl)) {
        return fileGetContents($fileTpl);
    } elseif (@file_exists($filePub)) {
        return fileGetContents($filePub);
    } else {
        return '';
    }
}
require_once "../classes/BiblioField.php";
require_once "../classes/BiblioQuery.php";
require_once "../functions/fileIOFuncs.php";
require_once "../shared/logincheck.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
if (count($_FILES) == 0) {
    header("Location: upload_usmarc_form.php");
    exit;
}
include "../shared/header.php";
require_once "import_usmarc_excludes.php";
$recordterminator = "";
$fieldterminator = "";
$delimiter = "";
$usmarc_str = fileGetContents($_FILES["usmarc_data"]["tmp_name"]);
$records = explode($recordterminator, $usmarc_str);
// We separated with a terminator, so the last element will always be empty.
array_pop($records);
$biblios = array();
foreach ($records as $record) {
    $biblio = new Biblio();
    $biblio->setLastChangeUserid($_POST["userid"]);
    $biblio->setMaterialCd($_POST["materialCd"]);
    $biblio->setCollectionCd($_POST["collectionCd"]);
    $biblio->setOpacFlg($_POST["opac"] == 'Y');
    $start = substr($record, 12, 5);
    $header = substr($record, 24, $start - 25);
    $codes = array();
    for ($l = 0; $l < strlen($header); $l += 12) {
        $code = substr($header, $l, 12);
    //echo $isbn_Pic . "</br>";
    //echo $file_Size;
    ?>
   <tr>
           <td rowspan="18" nowrap="true" class="primary" valign="top" > 
           <img src="<?php 
    echo $isbn_Pic;
    ?>
 " style= "margin-left:10px;padding:3px;border:solid 1px #000;border-radius:5px;" alt="<?php 
    echo $isbn_Pic;
    ?>
" />
          </td>
          <td rowspan="18" nowrap="true" class="primary" valign="top" >
		          <?php 
    echo $isbn_Pic . "</br>" . substr(fileGetContents($isbn_Pic), 0, 6);
    ?>
          </td>
   </tr>
 </table>
</br>
<?php 
    echo $loc->getText("biblioViewNoAddInfoIsbn");
}
?>
 </br>

<?php 
#****************************************************************************
#*  muestra ruta del archivo digital si esta definido
#* Agregado por jalg para capacidad de archivos digitales joanlaga@hotmail.com
示例#5
0
 * It will setup a base Sympal project for you to start working with.
 *
 */
function fileGetContents($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
$classes = array('sfSympalServerCheck', 'sfSympalServerCheckRenderer', 'sfSympalServerCheckCliRenderer', 'sfSympalServerCheckUnit');
foreach ($classes as $file) {
    $code = fileGetContents('http://svn.symfony-project.org/plugins/sfSympalPlugin/trunk/lib/check/' . $file . '.class.php');
    file_put_contents(sys_get_temp_dir() . '/' . $file . '.class.php', $code);
    require sys_get_temp_dir() . '/' . $file . '.class.php';
}
class sfSympalServerCheckInstallRenderer extends sfSympalServerCheckCliRenderer
{
    public function hasErrors()
    {
        return !empty($this->_errors) ? true : false;
    }
    public function hasWarnings()
    {
        return !empty($this->_warnings) ? true : false;
    }
}
$error = false;
require_once "../classes/BiblioCopy.php";
require_once "../classes/DmQuery.php";
$loc = new Localize(OBIB_LOCALE, $tab);
if (count($_FILES) == 0) {
    header("Location: upload_csv_form.php");
    exit;
}
include "../shared/header.php";
$recordterminator = "\n";
$fieldterminator = "\t";
/* 1. read the header lines.
 *    Check if the neccessary fields are listed and
 *    if all others are known.
 * 2. Read the biblio entries by line and show / import the data.
 */
$records = explode($recordterminator, fileGetContents($_FILES["csv_data"]["tmp_name"]));
//check the last record if there is content after the delimiter
$record = array_pop($records);
if (trim($record) != "") {
    array_push($records, $record);
}
// get the targets as encoded in the header
$record = array_shift($records);
$targets = explode($fieldterminator, $record);
?>

<form name="Display" action="">
<p>
  <input type="text" size="6" name="Records" value="0" readonly>
  <?php 
echo $loc->getText("CSVRecordsRead", array('total' => count($records)));
    echo "This script cannot be run outside of generating a new project. See http://sympalphp.org \n";
    die;
}
function fileGetContents($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
$classes = array('sfSympalServerCheck', 'sfSympalServerCheckRenderer', 'sfSympalServerCheckCliRenderer', 'sfSympalServerCheckUnit');
foreach ($classes as $file) {
    $code = fileGetContents('http://github.com/sympal/sympal/raw/master/lib/check/' . $file . '.class.php');
    file_put_contents(sys_get_temp_dir() . '/' . $file . '.class.php', $code);
    require sys_get_temp_dir() . '/' . $file . '.class.php';
}
class sfSympalServerCheckInstallRenderer extends sfSympalServerCheckCliRenderer
{
    public function hasErrors()
    {
        return !empty($this->_errors) ? true : false;
    }
    public function hasWarnings()
    {
        return !empty($this->_warnings) ? true : false;
    }
}
$error = false;