This commit is contained in:
Romain Neutron
2012-02-21 16:53:28 +01:00
parent 5e8f21b65b
commit a84954cf78
12 changed files with 0 additions and 876 deletions

View File

@@ -1,58 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$registry = $appbox->get_registry();
?>
<html lang="<?php echo $session->get_I18n(); ?>">
<head>
</head>
<body>
<form>
<div>
ajouter une preset de publication automatique :
<select>
<?php
if (($dir = opendir($registry->get('GV_RootPath') . '/lib/classes/publi/')) !== false)
{
while (($file = readdir($dir)) !== false)
{
$substr = substr($file, -10);
if (is_file($file) && trim($substr) !== false)
{
?><option value="<?php echo $substr; ?>"><?php echo $substr; ?></option><?php
}
}
}
?>
</select>
<input type="text" value=""/>
</div>
</form>
</body>
</html>

View File

@@ -1,71 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
$request = http_request::getInstance();
$parm = $request->get_parms('p', 'ses_id', 'usr_id', 'debug');
if (!$parm['debug'])
{
phrasea::headers(200, true, 'text/xml', 'UTF-8', false);
}
$sxParms = simplexml_load_string($parm['p']);
$action = (string) $sxParms['action'];
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$result = $dom->appendChild($dom->createElement('result'));
$result->setAttribute('action', $action);
$status = 'OK';
$f = '_' . mb_strtolower($action) . '.php';
if (file_exists($f))
{
include($f);
}
else
{
err('bad action');
}
$result->appendChild($dom->createElement('status'))->appendChild($dom->createTextNode($status));
if ($parm['debug'])
echo('<pre>' . htmlentities($dom->saveXML()) . '</pre>');
else
echo $dom->saveXML();
function err($msg)
{
global $dom, $result, $status;
$result->appendChild($dom->createElement('err_msg'))->appendChild($dom->createTextNode($msg));
$status = 'ERR';
}

View File

@@ -1,67 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
$appbox = appbox::get_instance();
$login = (string) ($sxParms->login);
$pwd = (string) ($sxParms->pwd);
try
{
$auth = new Session_Authentication_Native($appbox, $login, $pwd);
$lm = $appbox->get_session()->signOn($auth);
}
catch (Exception $e)
{
err($lm['error']);
}
$sessid = $appbox->get_session()->get_ses_id();
$usrid = $appbox->get_session()->get_usr_id();
$result->appendChild($dom->createElement('ses_id'))->appendChild($dom->createTextNode((string) $sessid));
$result->appendChild($dom->createElement('usr_id'))->appendChild($dom->createTextNode((string) $usrid));
$xbases = $result->appendChild($dom->createElement('bases'));
foreach ($appbox->get_databoxes() as $databox)
{
$xbase = $xbases->appendChild($dom->createElement('base'));
$xbase->appendChild($dom->createElement('name'))->appendChild($dom->createTextNode($databox->get_viewname()));
$xcolls = $xbase->appendChild($dom->createElement('collections'));
foreach ($databox->get_collections() as $collection)
{
$xcoll = $xcolls->appendChild($dom->createElement('collection'));
$xcoll->setAttribute('id', (string) $collection->get_base_id());
$xcoll->appendChild($dom->createElement('name'))->appendChild($dom->createTextNode($collection->get_name()));
}
$xstats = $xbase->appendChild($dom->createElement('statusbits'));
$status = $databox->get_statusbits();
foreach ($status as $bit => $datas)
{
$xstat = $xstats->appendChild($dom->createElement('statusbit'));
$xstat->setAttribute('name', $datas['name']);
$xstat->setAttribute('index', $bit);
$xstat0 = $xstat->appendChild($dom->createElement('label_0'))->appendChild($dom->createTextNode($datas['labeloff']));
$xstat1 = $xstat->appendChild($dom->createElement('label_1'))->appendChild($dom->createTextNode($datas['labelon']));
}
}

View File

@@ -1,35 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../../lib/bootstrap.php";
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
// -------------- api_utils will set vars :
//$request = http_request::getInstance();
//$parm = $request->get_parms('p', 'ses_id', 'usr_id', 'debug');
// $sxParms = simplexml_load_string($parm['p']);
// $dom : domdocument for result
// $result : documentElement for result
$registry = registry::get_instance();
require($registry->get('GV_RootPath') . 'www/api/api_utils.php');
?>

View File

@@ -1,181 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance();
$session = $appbox->get_session();
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
?>
<html lang="<?php echo $session->get_I18n(); ?>">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<style>
* {
font-family:courier;
font-size:14px;
}
H1 {
font-size:20px;
background-color:#e0e0e0;
margin-top:20px;
}
</style>
</head>
<body>
<h1/>identification</h1>
<form action="./login/login.php" target="RESULT">
./login/login.php
<input type="checkbox" name="debug" />debug
<br/>
<textarea name="p" cols="80" rows="6">
<?php
echo htmlentities(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parms action="OPEN_SESSION">
<login>api</login>
<pwd>api</pwd>
</parms>');
?>
</textarea>
<input type="submit" />
</form>
<h1/>preparer un batch</h1>
<form action="./upload/upload.php" target="RESULT_UPL">
./upload/upload.php
&nbsp;&nbsp;
ses_id : <input type="text" value="<?php echo $session->get_ses_id() ?>" name="ses_id" />
&nbsp;&nbsp;
usr_id : <input type="text" value="<?php echo $session->get_usr_id() ?>" name="usr_id" />
&nbsp;&nbsp;
<input type="checkbox" name="debug" />debug<br/>
<textarea name="p" cols="80" rows="6">
<?php
echo htmlentities(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parms action="PREPARE_UPLOAD">
<base_id>2</base_id>
<nfiles>2</nfiles>
</parms>');
?>
</textarea>
<input type="submit" />
</form>
<h1/>envoi par form</h1>
<form enctype="multipart/form-data" action="./upload/upload.php" target="RESULT_UPL" method="POST">
./upload/upload.php
&nbsp;&nbsp;
ses_id : <input type="text" value="<?php echo $session->get_ses_id() ?>" name="ses_id" />
&nbsp;&nbsp;
usr_id : <input type="text" value="<?php echo $session->get_usr_id() ?>" name="usr_id" />
&nbsp;&nbsp;
<input type="checkbox" name="debug" />debug<br/>
file : <input type="file" name="file" /><br/>
<textarea name="p" cols="80" rows="10">
<?php
echo htmlentities(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parms action="UPLOAD">
<upload_batch_id>???</upload_batch_id>
<index>1</index>
<filename></filename>
<filesize></filesize>
<md5></md5>
</parms>');
?>
</textarea>
<input type="submit" />
</form>
<h1/>envoi simul&eacute; par curl (size, md5,... calcul&eacute;s)</h1>
<form action="./test_upl.php" target="RESULT_UPL" method="POST">
./test_upl.php
&nbsp;&nbsp;
ses_id : <input type="text" value="<?php echo $session->get_ses_id() ?>" name="ses_id" />
&nbsp;&nbsp;
usr_id : <input type="text" value="<?php echo $session->get_usr_id() ?>" name="usr_id" />
<br/>
upload_batch_id : <input type="text" value="" name="upload_batch_id" />
&nbsp;&nbsp;
index : <input type="text" value="1" name="index" />
&nbsp;&nbsp;
<input type="checkbox" name="debug" />debug<br/>
<?php
if (($o = opendir('./testfiles')))
{
$nf = 0;
while (($f = readdir($o)))
{
if (substr($f, -4) != '.jpg')
continue;
echo('<input type="radio" ' . ($nf == 0 ? 'checked' : '') . ' name="file" value="./testfiles/' . $f . '"/>testfiles/' . $f . '<br/>');
$nf++;
}
closedir($o);
}
?>
<input type="submit" />
</form>
<h1/>finir un batch</h1>
<form action="./upload/upload.php" target="RESULT_UPL">
./upload/upload.php
&nbsp;&nbsp;
ses_id : <input type="text" value="<?php echo $session->get_ses_id() ?>" name="ses_id" />
&nbsp;&nbsp;
usr_id : <input type="text" value="<?php echo $session->get_usr_id() ?>" name="usr_id" />
&nbsp;&nbsp;
<input type="checkbox" name="debug" />debug<br/>
<textarea name="p" cols="80" rows="6">
<?php
echo htmlentities(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parms action="END_UPLOAD">
<upload_batch_id></upload_batch_id>
</parms>');
?>
</textarea>
<input type="submit" />
</form>
</body>
</html>

View File

@@ -1,85 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
$appbox = appbox::get_instance();
$session = $appbox->get_session();
?>
<html lang="<?php echo $session->get_I18n(); ?>">
<body>
<div style='background-color:#e0e0e0'>
<?php
require_once __DIR__ . "/../../lib/bootstrap.php";
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
$request = http_request::getInstance();
$parm = $request->get_parms('ses_id', 'usr_id', 'upload_batch_id', 'index', 'file', 'debug');
$fil = $parm['file'];
$filesize = filesize($fil);
$filename = basename($fil);
$k = file_get_contents($fil);
$md5 = md5($k, false);
// $crc32 = crc32($k);
$url = dirname($_SERVER["HTTP_REFERER"]) . '/upload/upload.php';
$post = array(
'debug' => $parm['debug'],
'file' => '@' . realpath($fil),
'ses_id' => $parm['ses_id'],
'usr_id' => $parm['usr_id'],
'p' => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parms action="UPLOAD">
<upload_batch_id>' . htmlentities($parm['upload_batch_id']) . '</upload_batch_id>
<index>' . htmlentities($parm['index']) . '</index>
<filename>' . htmlentities($filename) . '</filename>
<filesize>' . htmlentities($filesize) . '</filesize>
<md5>' . htmlentities($md5) . '</md5>
</parms>'
);
?>
<b>post to :</b><?php echo htmlentities($url) ?> <br/>
<pre>
<?php
echo htmlentities(var_export($post, true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true); // same as <input type="file" name="file">
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
?>
</pre>
</div>
<b>reponse : </b><br/>
<?php echo $response ?>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

View File

@@ -1,100 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
$upload_batch_id = (string) ($sxParms->upload_batch_id);
// -------------------------------------------------------------------
// check cnx & session
// -------------------------------------------------------------------
try
{
$conn = connection::getPDOConnection();
}
catch (Exception $e)
{
err('bad conn');
return;
}
if (!$ses_id || !$usr_id || !$upload_batch_id)
{
err('missing ses_id, usr_id or upload_batch_id');
return;
}
// -------------------------------------------------------------------
// check batch
// -------------------------------------------------------------------
$sql = 'SELECT * FROM uplbatch WHERE uplbatch_id = :upload_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array('upload_id' => $upload_batch_id));
$nr = $stmt->rowCount();
$stmt->closeCursor();
if ($nr == 0)
{
err('bad upload_batch_id');
return;
}
try
{
$sql = 'UPDATE uplbatch SET complete="1" WHERE uplbatch_id = :upload_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array('upload_id' => $upload_batch_id));
$stmt->closeCursor();
}
catch (Exception $e)
{
err('could not finish uplbatch');
return;
}
// -------------------------------------------------------------------
// do the job
// -------------------------------------------------------------------
$result->appendChild($dom->createElement('upload_batch'))->setAttribute('id', $upload_batch_id);
$xfiles = $result->appendChild($dom->createElement('files'));
$sql = 'SELECT * FROM uplfile WHERE uplbatch_id = :upload_id ORDER BY idx ASC';
$stmt = $conn->prepare($sql);
$stmt->execute(array('upload_id' => $upload_batch_id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$nr = $stmt->rowCount();
$result->appendChild($dom->createElement('n_ok'))->appendChild($dom->createTextNode($nr));
foreach ($rs as $row)
{
$xfile = $xfiles->appendChild($dom->createElement('file'));
$xfile->setAttribute('index', $row['idx']);
$xfile->appendChild($dom->createElement('filename'))->appendChild($dom->createTextNode($row['filename']));
}

View File

@@ -1,66 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
$base_id = (string) ($sxParms->base_id);
$nfiles = (int) ($sxParms->nfiles);
try
{
$conn = connection::getPDOConnection();
}
catch (Exception $e)
{
err('bad conn');
return;
}
if (!$ses_id || !$usr_id)
{
err('!ses_id || !usr_id');
return;
}
try
{
$sql = 'INSERT INTO uplbatch (base_id, nfiles, usr_id)
VALUES (:base_id, :nfiles, :usr_id);';
$params = array(
':base_id' => $base_id
, ':nfiles' => $nfiles
, ':usr_id' => $usr_id
);
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$uplbatch_id = $conn->lastInsertId();
$result->appendChild($dom->createElement('upload_batch_id'))->appendChild($dom->createTextNode((string) $uplbatch_id));
}
catch (Exception $e)
{
}

View File

@@ -1,179 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
$upload_batch_id = (string) ($sxParms->upload_batch_id);
$index = (int) ($sxParms->index);
$filename = (string) ($sxParms->filename);
$filesize = (int) ($sxParms->filesize);
$md5 = (string) ($sxParms->md5);
//$crc32 = (int)($sxParms->crc32);
// -------------------------------------------------------------------
// check parms, size, name, md5 etc...
// between post and _FILE
// -------------------------------------------------------------------
if (count($_FILES) != 1 || !array_key_exists('file', $_FILES))
{
err('$_FILES[\'file\'] unknown');
return;
}
$fil = $_FILES['file']['tmp_name'];
$tmp_filesize = filesize($fil);
$tmp_filename = $_FILES['file']['name'];
$tmp_k = file_get_contents($fil);
$tmp_md5 = md5($tmp_k, false);
//$tmp_crc32 = crc32($tmp_k);
if ($tmp_filename != $filename)
{
err('filename : \'' . $tmp_filename . '\' != \'' . $filename . '\'');
return;
}
if ($tmp_md5 != $md5)
{
err('md5 : \'' . $tmp_md5 . '\' != \'' . $md5 . '\'');
return;
}
// -------------------------------------------------------------------
// check cnx & session
// -------------------------------------------------------------------
try
{
$conn = connection::getPDOConnection();
}
catch (Exception $e)
{
err('bad conn');
return;
}
if (!$ses_id || !$usr_id || !$upload_batch_id)
{
err('missing ses_id, usr_id or upload_batch_id');
return;
}
// -------------------------------------------------------------------
// check batch
// -------------------------------------------------------------------
$batchok = false;
$batch_nfiles = false;
$sql = 'SELECT * FROM uplbatch WHERE uplbatch_id = :upload_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array('upload_id' => $upload_batch_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
{
$batch_nfiles = $row['nfiles'];
$batchok = true;
}
if (!$batchok)
{
err('bad upload_batch_id');
return;
}
if ($index > $batch_nfiles)
{
err('index : ' . $index . ' > ' . $batch_nfiles);
return;
}
$registry = registry::get_instance();
$dir = $registry->get('GV_RootPath') . 'tmp/batches/' . $upload_batch_id . '/';
if (!is_dir($dir))
{
@mkdir($dir, 0777, true);
}
//$tmp_k = file_get_contents($fil);
if (is_dir($dir))
{
if (!@move_uploaded_file($fil, $dir . $index))
{
err('error moving file \'' . $fil . '\' to \'' . $dir . $index . '\'');
return;
}
}
else
{
err('error creating tmp folder \'' . $dir . '\'');
return;
}
// -------------------------------------------------------------------
// ok, add (or replace) the file to the batch
// -------------------------------------------------------------------
$sql = 'REPLACE INTO uplfile (uplbatch_id, idx, filename)
VALUES (:upload_id, :idx, :filename) ';
$params = array(
':upload_id' => $upload_batch_id
, ':idx' => $index
, ':filename' => $filename
);
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$affected = $stmt->rowCount();
$stmt->closeCursor();
$xupload_batch = $result->appendChild($dom->createElement('upload_batch'));
$xupload_batch->setAttribute('id', $upload_batch_id);
$xupload_batch->appendChild($dom->createElement('nfiles'))->appendChild($dom->createTextNode($batch_nfiles));
$xindex = $result->appendChild($dom->createElement('index'));
$xindex->appendChild($dom->createTextNode((string) $index));
if ($affected == 1)
{
// inserted
$xindex->setAttribute('action', 'INSERTED');
}
elseif ($affected == 2)
{
// inserted
$xindex->setAttribute('action', 'REPLACED');
}
?>

View File

@@ -1,34 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../../lib/bootstrap.php";
//SPECIAL ZINO
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
ini_set('log_errors', 'off');
//SPECIAL ZINO
// -------------- api_utils will set vars :
//$request = http_request::getInstance();
//$parm = $request->get_parms('p', 'ses_id', 'usr_id', 'debug');
// $sxParms = simplexml_load_string($parm['p']);
// $dom : domdocument for result
// $result : documentElement for result
$registry = registry::get_instance();
require($registry->get('GV_RootPath') . 'www/api/api_utils.php');
?>