mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
fixes for windows
This commit is contained in:
105
www/admin/adminFeedback.php
Normal file → Executable file
105
www/admin/adminFeedback.php
Normal file → Executable file
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
@@ -24,7 +25,8 @@ $parm = $request->get_parms('action', 'position', 'test', 'renew', 'path', 'test
|
||||
|
||||
$output = '';
|
||||
|
||||
switch ($parm['action']) {
|
||||
switch ($parm['action'])
|
||||
{
|
||||
case 'TREE':
|
||||
$output = module_admin::getTree($parm['position']);
|
||||
break;
|
||||
@@ -40,16 +42,20 @@ switch ($parm['action']) {
|
||||
|
||||
case 'TESTPATH':
|
||||
$tests = true;
|
||||
foreach ($parm['tests'] as $test) {
|
||||
switch ($test) {
|
||||
foreach ($parm['tests'] as $test)
|
||||
{
|
||||
switch ($test)
|
||||
{
|
||||
case 'writeable':
|
||||
if ( ! is_writable($parm['path'])) {
|
||||
if (!is_writable($parm['path']))
|
||||
{
|
||||
$tests = false;
|
||||
}
|
||||
break;
|
||||
case 'readable':
|
||||
default:
|
||||
if ( ! is_readable($parm['path'])) {
|
||||
if (!is_readable($parm['path']))
|
||||
{
|
||||
$tests = true;
|
||||
}
|
||||
break;
|
||||
@@ -61,20 +67,27 @@ switch ($parm['action']) {
|
||||
case 'EMPTYBASE':
|
||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||
$message = _('Base empty successful');
|
||||
try {
|
||||
try
|
||||
{
|
||||
$sbas_id = (int) $parm['sbas_id'];
|
||||
$databox = databox::get_instance($sbas_id);
|
||||
$class_name = 'task_period_emptyColl';
|
||||
foreach ($databox->get_collections() as $collection) {
|
||||
if ($collection->get_record_amount() <= 500) {
|
||||
foreach ($databox->get_collections() as $collection)
|
||||
{
|
||||
if($collection->get_record_amount() <= 500)
|
||||
{
|
||||
$collection->empty_collection(500);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tasksettings><base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
||||
task_abstract::create($appbox, $class_name, $settings);
|
||||
$message = _('A task has been creted, please run it to complete empty collection');
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$message = _('An error occurred');
|
||||
}
|
||||
$output = p4string::jsonencode(array('message'=>$message));
|
||||
@@ -87,20 +100,26 @@ switch ($parm['action']) {
|
||||
, "coll_id" => http_request::SANITIZE_NUMBER_INT
|
||||
)
|
||||
);
|
||||
try {
|
||||
try
|
||||
{
|
||||
$databox = databox::get_instance($parm['sbas_id']);
|
||||
$collection = collection::get_from_coll_id($databox, $parm['coll_id']);
|
||||
|
||||
if ($collection->get_record_amount() <= 500) {
|
||||
if($collection->get_record_amount() <= 500)
|
||||
{
|
||||
$collection->empty_collection(500);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$class_name = 'task_period_emptyColl';
|
||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
||||
|
||||
task_abstract::create($appbox, $class_name, $settings);
|
||||
$message = _('A task has been creted, please run it to complete empty collection');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$message = _('An error occurred');
|
||||
}
|
||||
$output = p4string::jsonencode(array('message'=>$message));
|
||||
@@ -108,7 +127,8 @@ switch ($parm['action']) {
|
||||
|
||||
case 'SETTASKSTATUS':
|
||||
$parm = $request->get_parms('task_id', 'status', 'signal');
|
||||
try {
|
||||
try
|
||||
{
|
||||
$task_manager = new task_manager($appbox);
|
||||
$task = $task_manager->get_task($parm['task_id']);
|
||||
$pid = (int)($task->get_pid());
|
||||
@@ -116,7 +136,9 @@ switch ($parm['action']) {
|
||||
$signal = (int)($parm['signal']);
|
||||
if( $signal > 0 && $pid )
|
||||
posix_kill($pid, $signal);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
$output = json_encode($pid);
|
||||
@@ -124,22 +146,28 @@ switch ($parm['action']) {
|
||||
|
||||
case 'SETSCHEDSTATUS':
|
||||
$parm = $request->get_parms('status', 'signal');
|
||||
try {
|
||||
try
|
||||
{
|
||||
$task_manager = new task_manager($appbox);
|
||||
|
||||
$task_manager->set_sched_status($parm['status']);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'RESETTASKCRASHCOUNTER':
|
||||
$parm = $request->get_parms("task_id");
|
||||
try {
|
||||
try
|
||||
{
|
||||
$task_manager = new task_manager($appbox);
|
||||
$task = $task_manager->get_task($parm['task_id']);
|
||||
$task->reset_crash_counter();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
$ret = new DOMDocument("1.0", "UTF-8");
|
||||
@@ -160,7 +188,8 @@ switch ($parm['action']) {
|
||||
$root->setAttribute("saved", "0");
|
||||
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
$task_manager = new task_manager($appbox);
|
||||
$task = $task_manager->get_task($parm["task_id"]);
|
||||
/**
|
||||
@@ -169,7 +198,9 @@ switch ($parm['action']) {
|
||||
$root->setAttribute("crashed", $task->get_crash_counter());
|
||||
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
||||
$root->setAttribute("saved", "1");
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -183,7 +214,13 @@ switch ($parm['action']) {
|
||||
|
||||
$ret['tasks'] = array();
|
||||
|
||||
foreach ($task_manager->get_tasks(true) as $task) {
|
||||
foreach ($task_manager->get_tasks(true) as $task)
|
||||
{
|
||||
if($task->get_status()==task_abstract::STATUS_TOSTOP && $task->get_pid()===NULL)
|
||||
{
|
||||
// fix
|
||||
$task->set_status(task_abstract::STATUS_STOPPED);
|
||||
}
|
||||
$id = $task->get_task_id();
|
||||
$ret['tasks'][$id] = array(
|
||||
'id'=>$id
|
||||
@@ -194,14 +231,16 @@ switch ($parm['action']) {
|
||||
);
|
||||
}
|
||||
|
||||
if (1) {
|
||||
if(1)
|
||||
{
|
||||
$sql = 'SHOW PROCESSLIST';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchALL(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
$ret['db_processlist'] = array();
|
||||
foreach ($rows as $row) {
|
||||
foreach($rows as $row)
|
||||
{
|
||||
if($row['Info'] != $sql)
|
||||
$ret['db_processlist'][] = $row;
|
||||
}
|
||||
@@ -312,19 +351,25 @@ switch ($parm['action']) {
|
||||
|
||||
$ret = array('sbas_id' => null, 'err' => -1, 'errmsg' => null);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
$sbas_id = (int) $parm['sbas_id'];
|
||||
$databox = databox::get_instance($sbas_id);
|
||||
if ($databox->get_record_amount() == 0) {
|
||||
if ($databox->get_record_amount() == 0)
|
||||
{
|
||||
$databox->unmount_databox($appbox);
|
||||
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
||||
$databox->delete();
|
||||
$ret['sbas_id'] = $parm['sbas_id'];
|
||||
$ret['err'] = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret['errmsg'] = _('admin::base: vider la base avant de la supprimer');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$ret['errmsg'] = $e->getMessage();
|
||||
}
|
||||
$output = p4string::jsonencode($ret);
|
||||
|
Reference in New Issue
Block a user