mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 02:54:26 +00:00
Add curly braces
This commit is contained in:
@@ -36,12 +36,13 @@ return call_user_func(function() {
|
|||||||
|
|
||||||
$app->get('/', function() use ($app) {
|
$app->get('/', function() use ($app) {
|
||||||
$browser = \Browser::getInstance();
|
$browser = \Browser::getInstance();
|
||||||
if ($browser->isMobile())
|
if ($browser->isMobile()) {
|
||||||
return $app->redirect("/login/?redirect=/lightbox");
|
return $app->redirect("/login/?redirect=/lightbox");
|
||||||
elseif ($browser->isNewGeneration())
|
} elseif ($browser->isNewGeneration()) {
|
||||||
return $app->redirect("/login/?redirect=/prod");
|
return $app->redirect("/login/?redirect=/prod");
|
||||||
else
|
} else {
|
||||||
return $app->redirect("/login/?redirect=/client");
|
return $app->redirect("/login/?redirect=/client");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/robots.txt', function() use ($app) {
|
$app->get('/robots.txt', function() use ($app) {
|
||||||
|
@@ -56,10 +56,11 @@ return call_user_func(function() {
|
|||||||
|
|
||||||
|
|
||||||
$app->get('/', function() use ($app) {
|
$app->get('/', function() use ($app) {
|
||||||
if ($app['install'] === true)
|
if ($app['install'] === true) {
|
||||||
return $app->redirect('/setup/installer/');
|
return $app->redirect('/setup/installer/');
|
||||||
if ($app['upgrade'] === true)
|
}if ($app['upgrade'] === true) {
|
||||||
return $app->redirect('/setup/upgrader/');
|
return $app->redirect('/setup/upgrader/');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@@ -83,8 +83,9 @@ class Publications implements ControllerProviderInterface
|
|||||||
$feed = new \Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if ( ! $feed->is_owner($user))
|
if ( ! $feed->is_owner($user)) {
|
||||||
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
||||||
|
}
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
@@ -107,29 +108,35 @@ class Publications implements ControllerProviderInterface
|
|||||||
$feed = new \Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if ( ! $feed->is_owner($user))
|
if ( ! $feed->is_owner($user)) {
|
||||||
return new Response('ERROR:you are not allowed');
|
return new Response('ERROR:you are not allowed');
|
||||||
|
}
|
||||||
|
|
||||||
$request = $app["request"];
|
$request = $app["request"];
|
||||||
|
|
||||||
$fileData = $request->files->get("Filedata");
|
$fileData = $request->files->get("Filedata");
|
||||||
|
|
||||||
if ($fileData['error'] !== 0)
|
if ($fileData['error'] !== 0) {
|
||||||
return new Response('ERROR:error while upload');
|
return new Response('ERROR:error while upload');
|
||||||
|
}
|
||||||
|
|
||||||
$file = new \system_file($fileData['tmp_name']);
|
$file = new \system_file($fileData['tmp_name']);
|
||||||
if ( ! in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
|
if ( ! in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif'))) {
|
||||||
return new Response('ERROR:bad filetype');
|
return new Response('ERROR:bad filetype');
|
||||||
|
}
|
||||||
|
|
||||||
if ($file->getSize() > 200000)
|
if ($file->getSize() > 200000) {
|
||||||
return new Response('ERROR:file too large');
|
return new Response('ERROR:file too large');
|
||||||
|
}
|
||||||
|
|
||||||
$datas = $file->get_technical_datas();
|
$datas = $file->get_technical_datas();
|
||||||
if ( ! isset($datas[\system_file::TC_DATAS_WIDTH]) || ! isset($datas[\system_file::TC_DATAS_HEIGHT]))
|
if ( ! isset($datas[\system_file::TC_DATAS_WIDTH]) || ! isset($datas[\system_file::TC_DATAS_HEIGHT])) {
|
||||||
return new Response('ERROR:file is not square');
|
return new Response('ERROR:file is not square');
|
||||||
|
}
|
||||||
|
|
||||||
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT])
|
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT]) {
|
||||||
return new Response('ERROR:file is not square');
|
return new Response('ERROR:file is not square');
|
||||||
|
}
|
||||||
|
|
||||||
$feed->set_icon($file);
|
$feed->set_icon($file);
|
||||||
unlink($file->getPathname());
|
unlink($file->getPathname());
|
||||||
|
@@ -62,8 +62,9 @@ class MoveCollection extends RecordHelper
|
|||||||
{
|
{
|
||||||
$this->available_destinations = array();
|
$this->available_destinations = array();
|
||||||
|
|
||||||
if ( ! $this->is_possible)
|
if ( ! $this->is_possible) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->available_destinations = array_keys(
|
$this->available_destinations = array_keys(
|
||||||
$this->getCore()->getAuthenticatedUser()->ACL()->get_granted_base(
|
$this->getCore()->getAuthenticatedUser()->ACL()->get_granted_base(
|
||||||
|
@@ -291,8 +291,9 @@ class Basket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($total_el1 === $total_el2)
|
if ($total_el1 === $total_el2) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $total_el1 < $total_el2 ? 1 : -1;
|
return $total_el1 < $total_el2 ? 1 : -1;
|
||||||
}
|
}
|
||||||
@@ -313,8 +314,9 @@ class Basket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($total_el1 === $total_el2)
|
if ($total_el1 === $total_el2) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $total_el1 < $total_el2 ? 1 : -1;
|
return $total_el1 < $total_el2 ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
@@ -121,8 +121,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
|
|
||||||
$key = $record->get_serialize_key();
|
$key = $record->get_serialize_key();
|
||||||
|
|
||||||
if (array_key_exists($key, $this->_rights_records_document))
|
if (array_key_exists($key, $this->_rights_records_document)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -229,8 +230,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function apply_model(User_Interface $template_user, Array $base_ids)
|
public function apply_model(User_Interface $template_user, Array $base_ids)
|
||||||
{
|
{
|
||||||
if (count($base_ids) == 0)
|
if (count($base_ids) == 0) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$sbas_ids = array();
|
$sbas_ids = array();
|
||||||
|
|
||||||
@@ -378,8 +380,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
|
|
||||||
if ( ! $this->has_access_to_base($base_id))
|
if ( ! $this->has_access_to_base($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->is_limited($base_id)) {
|
if ($this->is_limited($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -463,8 +466,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
|
|
||||||
if ( ! $this->has_access_to_base($base_id))
|
if ( ! $this->has_access_to_base($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_rights_bas[$base_id]['restrict_dwnld'];
|
return $this->_rights_bas[$base_id]['restrict_dwnld'];
|
||||||
}
|
}
|
||||||
@@ -479,8 +483,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
|
|
||||||
if ( ! $this->has_access_to_base($base_id))
|
if ( ! $this->has_access_to_base($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (int) $this->_rights_bas[$base_id]['remain_dwnld'];
|
return (int) $this->_rights_bas[$base_id]['remain_dwnld'];
|
||||||
}
|
}
|
||||||
@@ -496,8 +501,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
|
|
||||||
if ( ! $this->has_access_to_base($base_id))
|
if ( ! $this->has_access_to_base($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_rights_bas[$base_id]['remain_dwnld'] =
|
$this->_rights_bas[$base_id]['remain_dwnld'] =
|
||||||
$this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n;
|
$this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n;
|
||||||
@@ -535,14 +541,16 @@ class ACL implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->load_rights_sbas();
|
$this->load_rights_sbas();
|
||||||
|
|
||||||
if ( ! isset($this->_rights_sbas[$sbas_id]))
|
if ( ! isset($this->_rights_sbas[$sbas_id])) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset($this->_rights_sbas[$sbas_id][$right]))
|
if ( ! isset($this->_rights_sbas[$sbas_id][$right]))
|
||||||
throw new Exception('This right does not exists');
|
throw new Exception('This right does not exists');
|
||||||
|
|
||||||
if ($this->_rights_sbas[$sbas_id][$right] === true)
|
if ($this->_rights_sbas[$sbas_id][$right] === true) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -556,8 +564,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
public function get_mask_and($base_id)
|
public function get_mask_and($base_id)
|
||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
if ( ! $this->has_access_to_base($base_id))
|
if ( ! $this->has_access_to_base($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_rights_bas[$base_id]['mask_and'];
|
return $this->_rights_bas[$base_id]['mask_and'];
|
||||||
}
|
}
|
||||||
@@ -571,8 +580,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
public function get_mask_xor($base_id)
|
public function get_mask_xor($base_id)
|
||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
if ( ! $this->has_access_to_base($base_id))
|
if ( ! $this->has_access_to_base($base_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_rights_bas[$base_id]['mask_xor'];
|
return $this->_rights_bas[$base_id]['mask_xor'];
|
||||||
}
|
}
|
||||||
@@ -698,8 +708,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
protected function load_hd_grant()
|
protected function load_hd_grant()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->_rights_records_preview)
|
if ($this->_rights_records_preview) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$tmp_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_RECORDS);
|
$tmp_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_RECORDS);
|
||||||
@@ -747,8 +758,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
protected function load_rights_sbas()
|
protected function load_rights_sbas()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->_rights_sbas && $this->_global_rights)
|
if ($this->_rights_sbas && $this->_global_rights) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->_rights_sbas = $this->get_data_from_cache(self::CACHE_RIGHTS_SBAS);
|
$this->_rights_sbas = $this->get_data_from_cache(self::CACHE_RIGHTS_SBAS);
|
||||||
@@ -804,8 +816,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected function load_rights_bas()
|
protected function load_rights_bas()
|
||||||
{
|
{
|
||||||
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited))
|
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->_rights_bas = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS);
|
$this->_rights_bas = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS);
|
||||||
@@ -1286,8 +1299,9 @@ class ACL implements cache_cacheableInterface
|
|||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ( ! $row)
|
if ( ! $row) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->give_access_to_base(array($base_id_dest));
|
$this->give_access_to_base(array($base_id_dest));
|
||||||
|
|
||||||
@@ -1445,8 +1459,10 @@ class ACL implements cache_cacheableInterface
|
|||||||
public function get_limits($base_id)
|
public function get_limits($base_id)
|
||||||
{
|
{
|
||||||
$this->load_rights_bas();
|
$this->load_rights_bas();
|
||||||
if ( ! isset($this->_limited[$base_id]))
|
if ( ! isset($this->_limited[$base_id])) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return ($this->_limited[$base_id]);
|
return ($this->_limited[$base_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -194,8 +194,9 @@ class API_OAuth2_Adapter extends OAuth2
|
|||||||
try {
|
try {
|
||||||
$application = API_OAuth2_Application::load_from_client_id($this->appbox, $client_id);
|
$application = API_OAuth2_Application::load_from_client_id($this->appbox, $client_id);
|
||||||
|
|
||||||
if ($client_secret === NULL)
|
if ($client_secret === NULL) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$crypted = $this->crypt_secret($client_secret, $application->get_nonce());
|
$crypted = $this->crypt_secret($client_secret, $application->get_nonce());
|
||||||
|
|
||||||
@@ -610,13 +611,16 @@ class API_OAuth2_Adapter extends OAuth2
|
|||||||
$token_param = $this->getAccessTokenParams();
|
$token_param = $this->getAccessTokenParams();
|
||||||
|
|
||||||
|
|
||||||
if ($token_param === FALSE) // Access token was not provided
|
if ($token_param === FALSE) { // Access token was not provided
|
||||||
return $exit_not_present ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_BAD_REQUEST, $realm, OAUTH2_ERROR_INVALID_REQUEST, 'The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.', NULL, $scope) : FALSE;
|
return $exit_not_present ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_BAD_REQUEST, $realm, OAUTH2_ERROR_INVALID_REQUEST, 'The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.', NULL, $scope) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the stored token data (from the implementing subclass)
|
// Get the stored token data (from the implementing subclass)
|
||||||
$token = $this->getAccessToken($token_param);
|
$token = $this->getAccessToken($token_param);
|
||||||
|
|
||||||
if ($token === NULL)
|
if ($token === NULL) {
|
||||||
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'The access token provided is invalid.', NULL, $scope) : FALSE;
|
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'The access token provided is invalid.', NULL, $scope) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($token['revoked']) && $token['revoked']) {
|
if (isset($token['revoked']) && $token['revoked']) {
|
||||||
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'End user has revoked access to his personal datas for your application.', NULL, $scope) : FALSE;
|
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'End user has revoked access to his personal datas for your application.', NULL, $scope) : FALSE;
|
||||||
@@ -624,14 +628,15 @@ class API_OAuth2_Adapter extends OAuth2
|
|||||||
|
|
||||||
if ($this->enable_expire) {
|
if ($this->enable_expire) {
|
||||||
// Check token expiration (I'm leaving this check separated, later we'll fill in better error messages)
|
// Check token expiration (I'm leaving this check separated, later we'll fill in better error messages)
|
||||||
if (isset($token["expires"]) && time() > $token["expires"])
|
if (isset($token["expires"]) && time() > $token["expires"]) {
|
||||||
return $exit_expired ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_EXPIRED_TOKEN, 'The access token provided has expired.', NULL, $scope) : FALSE;
|
return $exit_expired ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_EXPIRED_TOKEN, 'The access token provided has expired.', NULL, $scope) : FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Check scope, if provided
|
// Check scope, if provided
|
||||||
// If token doesn't have a scope, it's NULL/empty, or it's insufficient, then throw an error
|
// If token doesn't have a scope, it's NULL/empty, or it's insufficient, then throw an error
|
||||||
if ($scope && ( ! isset($token["scope"]) || ! $token["scope"] || ! $this->checkScope($scope, $token["scope"])))
|
if ($scope && ( ! isset($token["scope"]) || ! $token["scope"] || ! $this->checkScope($scope, $token["scope"]))) {
|
||||||
return $exit_scope ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_FORBIDDEN, $realm, OAUTH2_ERROR_INSUFFICIENT_SCOPE, 'The request requires higher privileges than provided by the access token.', NULL, $scope) : FALSE;
|
return $exit_scope ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_FORBIDDEN, $realm, OAUTH2_ERROR_INSUFFICIENT_SCOPE, 'The request requires higher privileges than provided by the access token.', NULL, $scope) : FALSE;
|
||||||
|
}
|
||||||
//save token's linked ses_id
|
//save token's linked ses_id
|
||||||
$this->session_id = $token['session_id'];
|
$this->session_id = $token['session_id'];
|
||||||
$this->usr_id = $token['usr_id'];
|
$this->usr_id = $token['usr_id'];
|
||||||
|
@@ -1116,6 +1116,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
* @todo ajouter une option pour avoir les values serialisées
|
* @todo ajouter une option pour avoir les values serialisées
|
||||||
* dans un cas multi
|
* dans un cas multi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'meta_id' => $value->getId()
|
'meta_id' => $value->getId()
|
||||||
, 'meta_structure_id' => $field->get_meta_struct_id()
|
, 'meta_structure_id' => $field->get_meta_struct_id()
|
||||||
|
@@ -112,8 +112,9 @@ class API_V1_result
|
|||||||
|
|
||||||
protected function parse_response_type()
|
protected function parse_response_type()
|
||||||
{
|
{
|
||||||
if (trim($this->request->get('callback')) !== '')
|
if (trim($this->request->get('callback')) !== '') {
|
||||||
return $this->response_type = self::FORMAT_JSONP;
|
return $this->response_type = self::FORMAT_JSONP;
|
||||||
|
}
|
||||||
|
|
||||||
$accept = $this->request->getAcceptableContentTypes();
|
$accept = $this->request->getAcceptableContentTypes();
|
||||||
$response_types = array();
|
$response_types = array();
|
||||||
|
@@ -108,8 +108,10 @@ class Bridge_Api
|
|||||||
*/
|
*/
|
||||||
public function is_disabled()
|
public function is_disabled()
|
||||||
{
|
{
|
||||||
if ($this->disable_time === null)
|
if ($this->disable_time === null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$date_obj = new DateTime();
|
$date_obj = new DateTime();
|
||||||
if ($date_obj > $this->disable_time) {
|
if ($date_obj > $this->disable_time) {
|
||||||
$this->enable();
|
$this->enable();
|
||||||
|
@@ -647,14 +647,17 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
|
|||||||
|
|
||||||
public function is_configured()
|
public function is_configured()
|
||||||
{
|
{
|
||||||
if ( ! $this->registry->get('GV_dailymotion_api'))
|
if ( ! $this->registry->get('GV_dailymotion_api')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_dailymotion_client_id')) === '')
|
if (trim($this->registry->get('GV_dailymotion_client_id')) === '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_dailymotion_client_secret')) === '')
|
if (trim($this->registry->get('GV_dailymotion_client_secret')) === '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -353,8 +353,10 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
|
|||||||
$response = $this->_api->executeMethod('flickr.photosets.addPhoto', $params);
|
$response = $this->_api->executeMethod('flickr.photosets.addPhoto', $params);
|
||||||
|
|
||||||
if ( ! $response->isOk()) {
|
if ( ! $response->isOk()) {
|
||||||
if ($response->err_code === 3) //Already exists in photoset
|
if ($response->err_code === 3) { //Already exists in photoset
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
throw new Bridge_Exception_ApiConnectorRequestFailed();
|
throw new Bridge_Exception_ApiConnectorRequestFailed();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -626,14 +628,17 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
|
|||||||
public function is_configured()
|
public function is_configured()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( ! $this->registry->get('GV_flickr_api'))
|
if ( ! $this->registry->get('GV_flickr_api')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_flickr_client_id')) === '')
|
if (trim($this->registry->get('GV_flickr_client_id')) === '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_flickr_client_secret')) === '')
|
if (trim($this->registry->get('GV_flickr_client_secret')) === '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -98,8 +98,10 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
|
|
||||||
private function generate_page_url($entry)
|
private function generate_page_url($entry)
|
||||||
{
|
{
|
||||||
if (isset($entry["owner"]) && isset($entry["id"]))
|
if (isset($entry["owner"]) && isset($entry["id"])) {
|
||||||
return sprintf("http://www.flickr.com/%ss/%s/%s/", $this->type, (string) $entry["owner"], (string) $entry["id"]);
|
return sprintf("http://www.flickr.com/%ss/%s/%s/", $this->type, (string) $entry["owner"], (string) $entry["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,27 +114,30 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
*/
|
*/
|
||||||
private function generate_thumb_url($entry, $size = '', $extension = '')
|
private function generate_thumb_url($entry, $size = '', $extension = '')
|
||||||
{
|
{
|
||||||
if (isset($entry["url_t"]))
|
if (isset($entry["url_t"])) {
|
||||||
return (string) $entry["url_t"];
|
return (string) $entry["url_t"];
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]))
|
if ( ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"])) {
|
||||||
return '';
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$farm = (string) $entry["farm"];
|
$farm = (string) $entry["farm"];
|
||||||
$server_id = (string) $entry["server"];
|
$server_id = (string) $entry["server"];
|
||||||
$id_photo = (string) $entry["id"];
|
$id_photo = (string) $entry["id"];
|
||||||
$secret = (string) $entry["secret"];
|
$secret = (string) $entry["secret"];
|
||||||
|
|
||||||
if (empty($size) && empty($extension))
|
if (empty($size) && empty($extension)) {
|
||||||
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s.jpg', $farm, $server_id, $id_photo, $secret);
|
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s.jpg', $farm, $server_id, $id_photo, $secret);
|
||||||
elseif ( ! empty($size) && ! empty($extension))
|
} elseif ( ! empty($size) && ! empty($extension)) {
|
||||||
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size);
|
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size);
|
||||||
elseif ( ! empty($size))
|
} elseif ( ! empty($size)) {
|
||||||
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size, '.jpg');
|
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size, '.jpg');
|
||||||
elseif ( ! empty($extension))
|
} elseif ( ! empty($extension)) {
|
||||||
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_o.%s', $farm, $server_id, $id_photo, $secret, $extension);
|
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_o.%s', $farm, $server_id, $id_photo, $secret, $extension);
|
||||||
else
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -632,8 +632,9 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter
|
|||||||
$xml = simplexml_load_string($string);
|
$xml = simplexml_load_string($string);
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
|
|
||||||
if ( ! $xml)
|
if ( ! $xml) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($xml->HEAD) || isset($xml->head)) {
|
if (isset($xml->HEAD) || isset($xml->head)) {
|
||||||
return array();
|
return array();
|
||||||
@@ -793,14 +794,17 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter
|
|||||||
|
|
||||||
public function is_configured()
|
public function is_configured()
|
||||||
{
|
{
|
||||||
if ( ! $this->registry->get('GV_youtube_api'))
|
if ( ! $this->registry->get('GV_youtube_api')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_youtube_client_id')) === '')
|
if (trim($this->registry->get('GV_youtube_client_id')) === '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_youtube_dev_key')) === '')
|
if (trim($this->registry->get('GV_youtube_dev_key')) === '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -63,8 +63,9 @@ class Bridge_Api_Youtube_Element implements Bridge_Api_ElementInterface
|
|||||||
$video_thumbnails = $this->entry->getVideoThumbnails();
|
$video_thumbnails = $this->entry->getVideoThumbnails();
|
||||||
|
|
||||||
foreach ($video_thumbnails as $thumb) {
|
foreach ($video_thumbnails as $thumb) {
|
||||||
if (120 == $thumb['width'] && 90 == $thumb['height'])
|
if (120 == $thumb['width'] && 90 == $thumb['height']) {
|
||||||
return $thumb['url'];
|
return $thumb['url'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -130,8 +130,9 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
|
|||||||
*/
|
*/
|
||||||
public function get_icon_url()
|
public function get_icon_url()
|
||||||
{
|
{
|
||||||
if ($this->icon_url)
|
if ($this->icon_url) {
|
||||||
return $this->icon_url;
|
return $this->icon_url;
|
||||||
|
}
|
||||||
|
|
||||||
$url = '/skins/icons/rss32.gif';
|
$url = '/skins/icons/rss32.gif';
|
||||||
|
|
||||||
|
@@ -83,8 +83,9 @@ class Feed_Aggregate extends Feed_Abstract implements Feed_Interface
|
|||||||
{
|
{
|
||||||
$result = new Feed_Entry_Collection();
|
$result = new Feed_Entry_Collection();
|
||||||
|
|
||||||
if (count($this->feeds) === 0)
|
if (count($this->feeds) === 0) {
|
||||||
return $result;
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
$offset_start = (int) $offset_start;
|
$offset_start = (int) $offset_start;
|
||||||
$how_many = $how_many > 20 ? 20 : (int) $how_many;
|
$how_many = $how_many > 20 ? 20 : (int) $how_many;
|
||||||
@@ -117,8 +118,10 @@ class Feed_Aggregate extends Feed_Abstract implements Feed_Interface
|
|||||||
*/
|
*/
|
||||||
public function get_count_total_entries()
|
public function get_count_total_entries()
|
||||||
{
|
{
|
||||||
if (count($this->feeds) === 0)
|
if (count($this->feeds) === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT count(id) as number
|
$sql = 'SELECT count(id) as number
|
||||||
FROM feed_entries
|
FROM feed_entries
|
||||||
WHERE feed_id
|
WHERE feed_id
|
||||||
|
@@ -406,8 +406,9 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
|
|||||||
*/
|
*/
|
||||||
public function get_content()
|
public function get_content()
|
||||||
{
|
{
|
||||||
if ($this->items)
|
if ($this->items) {
|
||||||
return $this->items;
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
$rs = $this->retrieve_elements();
|
$rs = $this->retrieve_elements();
|
||||||
$items = array();
|
$items = array();
|
||||||
|
@@ -210,7 +210,9 @@ class Feed_Publisher_Adapter implements Feed_Publisher_Interface, cache_cacheabl
|
|||||||
{
|
{
|
||||||
foreach ($feed->get_publishers() as $publisher) {
|
foreach ($feed->get_publishers() as $publisher) {
|
||||||
if ($publisher->get_user()->get_id() === $user->get_id())
|
if ($publisher->get_user()->get_id() === $user->get_id())
|
||||||
|
{
|
||||||
return $publisher;
|
return $publisher;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw new Exception_Feed_PublisherNotFound('Publisher not found');
|
throw new Exception_Feed_PublisherNotFound('Publisher not found');
|
||||||
}
|
}
|
||||||
|
@@ -227,11 +227,13 @@ abstract class Feed_XML_Abstract
|
|||||||
|
|
||||||
$medium = strtolower($content->get_record()->get_type());
|
$medium = strtolower($content->get_record()->get_type());
|
||||||
|
|
||||||
if ( ! in_array($medium, array('image', 'audio', 'video')))
|
if ( ! in_array($medium, array('image', 'audio', 'video'))) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $preview_permalink || ! $thumbnail_permalink)
|
if ( ! $preview_permalink || ! $thumbnail_permalink) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$group = $this->addTag($document, $item, 'media:group');
|
$group = $this->addTag($document, $item, 'media:group');
|
||||||
|
|
||||||
|
@@ -357,11 +357,13 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
|||||||
|
|
||||||
$medium = strtolower($content->get_record()->get_type());
|
$medium = strtolower($content->get_record()->get_type());
|
||||||
|
|
||||||
if ( ! in_array($medium, array('image', 'audio', 'video')))
|
if ( ! in_array($medium, array('image', 'audio', 'video'))) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $preview_permalink || ! $thumbnail_permalink)
|
if ( ! $preview_permalink || ! $thumbnail_permalink) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
//add item node to channel node
|
//add item node to channel node
|
||||||
$item = $this->addTag($document, $node, 'item');
|
$item = $this->addTag($document, $node, 'item');
|
||||||
|
@@ -260,8 +260,9 @@ class Session_Authentication_Native implements Session_Authentication_Interface
|
|||||||
$row_count = $stmt->rowCount();
|
$row_count = $stmt->rowCount();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($row_count == 0)
|
if ($row_count == 0) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->captcha_challenge_result === true) {
|
if ($this->captcha_challenge_result === true) {
|
||||||
$sql = 'UPDATE badlog SET locked="0" WHERE (login=:login OR ip=:ip)';
|
$sql = 'UPDATE badlog SET locked="0" WHERE (login=:login OR ip=:ip)';
|
||||||
|
@@ -79,8 +79,9 @@ class Session_Handler
|
|||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
// $this->remove_cookies();
|
// $this->remove_cookies();
|
||||||
if ( ! $this->is_authenticated())
|
if ( ! $this->is_authenticated()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->storage()->reset();
|
$this->storage()->reset();
|
||||||
$this->close_phrasea_session();
|
$this->close_phrasea_session();
|
||||||
@@ -240,12 +241,13 @@ class Session_Handler
|
|||||||
*/
|
*/
|
||||||
public static function get_cookie($name, $default_value = null)
|
public static function get_cookie($name, $default_value = null)
|
||||||
{
|
{
|
||||||
if (http_request::is_command_line() && isset(self::$_cookie[$name]))
|
if (http_request::is_command_line() && isset(self::$_cookie[$name])) {
|
||||||
return self::$_cookie[$name];
|
return self::$_cookie[$name];
|
||||||
elseif ( ! http_request::is_command_line() && isset($_COOKIE[$name]))
|
} elseif ( ! http_request::is_command_line() && isset($_COOKIE[$name])) {
|
||||||
return $_COOKIE[$name];
|
return $_COOKIE[$name];
|
||||||
elseif ($default_value !== null)
|
} elseif ($default_value !== null) {
|
||||||
return $default_value;
|
return $default_value;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,10 +281,11 @@ class Session_Handler
|
|||||||
else
|
else
|
||||||
unset($_COOKIE[$name]);
|
unset($_COOKIE[$name]);
|
||||||
}
|
}
|
||||||
if ( ! http_request::is_command_line())
|
if ( ! http_request::is_command_line()) {
|
||||||
return setcookie($name, $value, $expire, '/', '', $https, $http_only);
|
return setcookie($name, $value, $expire, '/', '', $https, $http_only);
|
||||||
else
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -292,10 +295,11 @@ class Session_Handler
|
|||||||
*/
|
*/
|
||||||
public static function isset_cookie($name)
|
public static function isset_cookie($name)
|
||||||
{
|
{
|
||||||
if (http_request::is_command_line())
|
if (http_request::is_command_line()) {
|
||||||
return isset(self::$_cookie[$name]);
|
return isset(self::$_cookie[$name]);
|
||||||
else
|
}
|
||||||
return isset($_COOKIE[$name]);
|
|
||||||
|
return isset($_COOKIE[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renew_phrasea_session()
|
public function renew_phrasea_session()
|
||||||
@@ -417,8 +421,9 @@ class Session_Handler
|
|||||||
$basks = array();
|
$basks = array();
|
||||||
$oldusr = self::get_cookie('invite-usr_id');
|
$oldusr = self::get_cookie('invite-usr_id');
|
||||||
|
|
||||||
if ($oldusr == $this->get_usr_id())
|
if ($oldusr == $this->get_usr_id()) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT sselcont_id, s.ssel_id
|
$sql = 'SELECT sselcont_id, s.ssel_id
|
||||||
FROM sselcont c, ssel s
|
FROM sselcont c, ssel s
|
||||||
|
@@ -125,8 +125,10 @@ class Setup_Upgrade
|
|||||||
*/
|
*/
|
||||||
protected function get_percentage()
|
protected function get_percentage()
|
||||||
{
|
{
|
||||||
if ($this->total_steps === 0)
|
if ($this->total_steps === 0) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return round(max(min(($this->completed_steps / $this->total_steps), 1), 0), 2);
|
return round(max(min(($this->completed_steps / $this->total_steps), 1), 0), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -891,8 +891,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
public static function get_usr_id_from_email($email)
|
public static function get_usr_id_from_email($email)
|
||||||
{
|
{
|
||||||
if (is_null($email))
|
if (is_null($email)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$sql = 'SELECT usr_id FROM usr
|
$sql = 'SELECT usr_id FROM usr
|
||||||
@@ -1260,8 +1261,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
protected function load_preferences()
|
protected function load_preferences()
|
||||||
{
|
{
|
||||||
if ($this->_prefs)
|
if ($this->_prefs) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$registry = \registry::get_instance();
|
$registry = \registry::get_instance();
|
||||||
|
|
||||||
@@ -1484,8 +1486,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
if ( ! $session->is_authenticated())
|
if ( ! $session->is_authenticated()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$ses_id = $session->get_ses_id();
|
$ses_id = $session->get_ses_id();
|
||||||
$usr_id = $session->get_usr_id();
|
$usr_id = $session->get_usr_id();
|
||||||
@@ -1733,8 +1736,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
public function get_nonce()
|
public function get_nonce()
|
||||||
{
|
{
|
||||||
if ($this->nonce)
|
if ($this->nonce) {
|
||||||
return $this->nonce;
|
return $this->nonce;
|
||||||
|
}
|
||||||
|
|
||||||
$nonce = false;
|
$nonce = false;
|
||||||
|
|
||||||
$sql = 'SELECT nonce FROM usr WHERE usr_id = :usr_id ';
|
$sql = 'SELECT nonce FROM usr WHERE usr_id = :usr_id ';
|
||||||
|
@@ -540,8 +540,9 @@ class User_Query implements User_QueryInterface
|
|||||||
*/
|
*/
|
||||||
public function get_total()
|
public function get_total()
|
||||||
{
|
{
|
||||||
if ($this->total)
|
if ($this->total) {
|
||||||
return $this->total;
|
return $this->total;
|
||||||
|
}
|
||||||
|
|
||||||
$conn = $this->appbox->get_connection();
|
$conn = $this->appbox->get_connection();
|
||||||
|
|
||||||
@@ -698,8 +699,9 @@ class User_Query implements User_QueryInterface
|
|||||||
*/
|
*/
|
||||||
public function on_base_ids(Array $base_ids = null)
|
public function on_base_ids(Array $base_ids = null)
|
||||||
{
|
{
|
||||||
if ( ! $base_ids)
|
if ( ! $base_ids) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->bases_restrictions = true;
|
$this->bases_restrictions = true;
|
||||||
|
|
||||||
@@ -722,8 +724,9 @@ class User_Query implements User_QueryInterface
|
|||||||
*/
|
*/
|
||||||
public function on_sbas_ids(Array $sbas_ids = null)
|
public function on_sbas_ids(Array $sbas_ids = null)
|
||||||
{
|
{
|
||||||
if ( ! $sbas_ids)
|
if ( ! $sbas_ids) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->sbas_restrictions = true;
|
$this->sbas_restrictions = true;
|
||||||
|
|
||||||
|
@@ -140,12 +140,14 @@ class appbox extends base
|
|||||||
}
|
}
|
||||||
$custom_path.= $collection->get_base_id();
|
$custom_path.= $collection->get_base_id();
|
||||||
|
|
||||||
if (is_null($pathfile))
|
if (is_null($pathfile)) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$datas = file_get_contents($pathfile->getPathname());
|
$datas = file_get_contents($pathfile->getPathname());
|
||||||
if (is_null($datas))
|
if (is_null($datas)) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents($file, $datas);
|
file_put_contents($file, $datas);
|
||||||
file_put_contents($custom_path, $datas);
|
file_put_contents($custom_path, $datas);
|
||||||
@@ -190,12 +192,14 @@ class appbox extends base
|
|||||||
}
|
}
|
||||||
$custom_path.= $pic_type . '_' . $databox->get_sbas_id();
|
$custom_path.= $pic_type . '_' . $databox->get_sbas_id();
|
||||||
|
|
||||||
if (is_null($pathfile))
|
if (is_null($pathfile)) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$datas = file_get_contents($pathfile->getPathname());
|
$datas = file_get_contents($pathfile->getPathname());
|
||||||
if (is_null($datas))
|
if (is_null($datas)) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents($file, $datas);
|
file_put_contents($file, $datas);
|
||||||
file_put_contents($custom_path, $datas);
|
file_put_contents($custom_path, $datas);
|
||||||
@@ -515,8 +519,9 @@ class appbox extends base
|
|||||||
*/
|
*/
|
||||||
public function get_databoxes()
|
public function get_databoxes()
|
||||||
{
|
{
|
||||||
if ($this->databoxes)
|
if ($this->databoxes) {
|
||||||
return $this->databoxes;
|
return $this->databoxes;
|
||||||
|
}
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($this->retrieve_sbas_ids() as $sbas_id) {
|
foreach ($this->retrieve_sbas_ids() as $sbas_id) {
|
||||||
|
@@ -76,8 +76,9 @@ abstract class base implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function get_schema()
|
public function get_schema()
|
||||||
{
|
{
|
||||||
if ($this->schema)
|
if ($this->schema) {
|
||||||
return $this->schema;
|
return $this->schema;
|
||||||
|
}
|
||||||
|
|
||||||
$this->load_schema();
|
$this->load_schema();
|
||||||
|
|
||||||
@@ -223,9 +224,9 @@ abstract class base implements cache_cacheableInterface
|
|||||||
|
|
||||||
public function get_version()
|
public function get_version()
|
||||||
{
|
{
|
||||||
|
if ($this->version) {
|
||||||
if ($this->version)
|
|
||||||
return $this->version;
|
return $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
$version = '0.0.0';
|
$version = '0.0.0';
|
||||||
|
|
||||||
@@ -251,10 +252,11 @@ abstract class base implements cache_cacheableInterface
|
|||||||
|
|
||||||
public function upgradeavailable()
|
public function upgradeavailable()
|
||||||
{
|
{
|
||||||
if ($this->get_version())
|
if ($this->get_version()) {
|
||||||
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
|
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
|
||||||
else
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function upgradeDb($apply_patches, Setup_Upgrade &$upgrader)
|
protected function upgradeDb($apply_patches, Setup_Upgrade &$upgrader)
|
||||||
@@ -375,8 +377,9 @@ abstract class base implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected function load_schema()
|
protected function load_schema()
|
||||||
{
|
{
|
||||||
if ($this->schema)
|
if ($this->schema) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
|
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
|
||||||
|
|
||||||
|
@@ -203,8 +203,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
|
|||||||
public function get_field($fieldname)
|
public function get_field($fieldname)
|
||||||
{
|
{
|
||||||
foreach ($this->get_fields() as $meta_struct_id => $field) {
|
foreach ($this->get_fields() as $meta_struct_id => $field) {
|
||||||
if ($field->get_name() == $fieldname)
|
if ($field->get_name() == $fieldname) {
|
||||||
return $field;
|
return $field;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception('Field not found');
|
throw new \Exception('Field not found');
|
||||||
|
@@ -52,8 +52,10 @@ class connection
|
|||||||
public static function printLog()
|
public static function printLog()
|
||||||
{
|
{
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
if ( ! $registry->get('GV_debug'))
|
if ( ! $registry->get('GV_debug')) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$totalTime = 0;
|
$totalTime = 0;
|
||||||
|
|
||||||
foreach (self::$log as $entry) {
|
foreach (self::$log as $entry) {
|
||||||
@@ -109,9 +111,9 @@ class connection
|
|||||||
$name = 'appbox';
|
$name = 'appbox';
|
||||||
} elseif (is_int((int) $name)) {
|
} elseif (is_int((int) $name)) {
|
||||||
$name = (int) $name;
|
$name = (int) $name;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset(self::$_PDO_instance[$name])) {
|
if ( ! isset(self::$_PDO_instance[$name])) {
|
||||||
$hostname = $port = $user = $password = $dbname = false;
|
$hostname = $port = $user = $password = $dbname = false;
|
||||||
@@ -149,8 +151,10 @@ class connection
|
|||||||
throw new Exception('Connection not available');
|
throw new Exception('Connection not available');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (array_key_exists($name, self::$_PDO_instance))
|
if (array_key_exists($name, self::$_PDO_instance)) {
|
||||||
return self::$_PDO_instance[$name];
|
return self::$_PDO_instance[$name];
|
||||||
|
}
|
||||||
|
|
||||||
throw new Exception('Connection not available');
|
throw new Exception('Connection not available');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,10 +65,11 @@ class connection_pdo extends connection_abstract implements connection_interface
|
|||||||
*/
|
*/
|
||||||
public function prepare($statement, $driver_options = array())
|
public function prepare($statement, $driver_options = array())
|
||||||
{
|
{
|
||||||
if ($this->registry->get('GV_debug'))
|
if ($this->registry->get('GV_debug')) {
|
||||||
return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options));
|
return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options));
|
||||||
else
|
} else {
|
||||||
return parent::prepare($statement, $driver_options);
|
return parent::prepare($statement, $driver_options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -429,8 +429,9 @@ class databox extends base
|
|||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($row)
|
if ($row) {
|
||||||
return self::get_instance((int) $row['sbas_id']);
|
return self::get_instance((int) $row['sbas_id']);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sql = 'CREATE DATABASE `' . $dbname . '`
|
$sql = 'CREATE DATABASE `' . $dbname . '`
|
||||||
@@ -664,8 +665,9 @@ class databox extends base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($n > $limit)
|
if ($n > $limit) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1151,8 +1153,10 @@ class databox extends base
|
|||||||
*/
|
*/
|
||||||
public function get_structure()
|
public function get_structure()
|
||||||
{
|
{
|
||||||
if ($this->structure)
|
if ($this->structure) {
|
||||||
return $this->structure;
|
return $this->structure;
|
||||||
|
}
|
||||||
|
|
||||||
$this->structure = $this->retrieve_structure();
|
$this->structure = $this->retrieve_structure();
|
||||||
|
|
||||||
return $this->structure;
|
return $this->structure;
|
||||||
@@ -1187,8 +1191,9 @@ class databox extends base
|
|||||||
*/
|
*/
|
||||||
public function get_cterms()
|
public function get_cterms()
|
||||||
{
|
{
|
||||||
if ($this->cterms)
|
if ($this->cterms) {
|
||||||
return $this->cterms;
|
return $this->cterms;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT value FROM pref WHERE prop='cterms'";
|
$sql = "SELECT value FROM pref WHERE prop='cterms'";
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
@@ -1343,8 +1348,9 @@ class databox extends base
|
|||||||
|
|
||||||
public function get_cgus()
|
public function get_cgus()
|
||||||
{
|
{
|
||||||
if ($this->cgus)
|
if ($this->cgus) {
|
||||||
return $this->cgus;
|
return $this->cgus;
|
||||||
|
}
|
||||||
|
|
||||||
$this->load_cgus();
|
$this->load_cgus();
|
||||||
|
|
||||||
|
@@ -95,8 +95,9 @@ class databox_descriptionStructure implements IteratorAggregate
|
|||||||
{
|
{
|
||||||
$name = databox_field::generateName($name);
|
$name = databox_field::generateName($name);
|
||||||
|
|
||||||
if (isset($this->cache_name_id[$name]))
|
if (isset($this->cache_name_id[$name])) {
|
||||||
return $this->elements[$this->cache_name_id[$name]];
|
return $this->elements[$this->cache_name_id[$name]];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->elements as $id => $meta) {
|
foreach ($this->elements as $id => $meta) {
|
||||||
if ($meta->get_name() === $name) {
|
if ($meta->get_name() === $name) {
|
||||||
|
@@ -62,8 +62,9 @@ class databox_status
|
|||||||
$sbas_params = phrasea::sbas_params();
|
$sbas_params = phrasea::sbas_params();
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
if ( ! isset($sbas_params[$sbas_id]))
|
if ( ! isset($sbas_params[$sbas_id])) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$path = $this->path = $registry->get('GV_RootPath') . "config/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
$path = $this->path = $registry->get('GV_RootPath') . "config/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
||||||
$url = $this->url = "/custom/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
$url = $this->url = "/custom/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
||||||
@@ -115,8 +116,9 @@ class databox_status
|
|||||||
|
|
||||||
public static function getDisplayStatus()
|
public static function getDisplayStatus()
|
||||||
{
|
{
|
||||||
if (self::$_statuses)
|
if (self::$_statuses) {
|
||||||
return self::$_statuses;
|
return self::$_statuses;
|
||||||
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
@@ -243,8 +245,9 @@ class databox_status
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
|
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$status = self::getStatus($sbas_id);
|
$status = self::getStatus($sbas_id);
|
||||||
|
|
||||||
@@ -295,8 +298,9 @@ class databox_status
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
|
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$status = self::getStatus($sbas_id);
|
$status = self::getStatus($sbas_id);
|
||||||
|
|
||||||
@@ -372,15 +376,17 @@ class databox_status
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
|
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$status = self::getStatus($sbas_id);
|
$status = self::getStatus($sbas_id);
|
||||||
|
|
||||||
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
|
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
|
||||||
|
|
||||||
if ( ! $switch)
|
if ( ! $switch) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($status[$bit]['img_' . $switch]) {
|
if ($status[$bit]['img_' . $switch]) {
|
||||||
if (isset($status[$bit]['path_' . $switch]))
|
if (isset($status[$bit]['path_' . $switch]))
|
||||||
|
@@ -44,8 +44,9 @@ function giveMeBases($usr = null)
|
|||||||
$rsU = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rsU = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if (count($rsU) == 0)
|
if (count($rsU) == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rsU as $rowU) {
|
foreach ($rsU as $rowU) {
|
||||||
if ( ! isset($usrerRegis[$rowU['dbname']]))
|
if ( ! isset($usrerRegis[$rowU['dbname']]))
|
||||||
|
@@ -316,8 +316,9 @@ class eventsmanager_broker
|
|||||||
|
|
||||||
function read(Array $notifications, $usr_id)
|
function read(Array $notifications, $usr_id)
|
||||||
{
|
{
|
||||||
if (count($notifications) == 0)
|
if (count($notifications) == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE notifications SET unread="0"
|
$sql = 'UPDATE notifications SET unread="0"
|
||||||
WHERE usr_id = :usr_id
|
WHERE usr_id = :usr_id
|
||||||
|
@@ -49,8 +49,9 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
|
|||||||
$params = array_merge($default, $params);
|
$params = array_merge($default, $params);
|
||||||
$base_ids = array_keys($params['autoregister']);
|
$base_ids = array_keys($params['autoregister']);
|
||||||
|
|
||||||
if (count($base_ids) == 0)
|
if (count($base_ids) == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$mailColl = array();
|
$mailColl = array();
|
||||||
|
|
||||||
@@ -261,8 +262,9 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
|
|||||||
{
|
{
|
||||||
$bool = false;
|
$bool = false;
|
||||||
$session = $this->appbox->get_session();
|
$session = $this->appbox->get_session();
|
||||||
if ( ! $session->is_authenticated() || ! login::register_enabled())
|
if ( ! $session->is_authenticated() || ! login::register_enabled()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
||||||
|
@@ -73,9 +73,9 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($users) == 0)
|
if (count($users) == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
@@ -239,8 +239,9 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
|
|||||||
{
|
{
|
||||||
$bool = false;
|
$bool = false;
|
||||||
$session = $this->appbox->get_session();
|
$session = $this->appbox->get_session();
|
||||||
if ( ! $session->is_authenticated())
|
if ( ! $session->is_authenticated()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
||||||
|
@@ -49,8 +49,9 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
|
|||||||
$params = array_merge($default, $params);
|
$params = array_merge($default, $params);
|
||||||
$base_ids = $params['demand'];
|
$base_ids = $params['demand'];
|
||||||
|
|
||||||
if (count($base_ids) == 0)
|
if (count($base_ids) == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$mailColl = array();
|
$mailColl = array();
|
||||||
|
|
||||||
@@ -267,8 +268,9 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
|
|||||||
$bool = false;
|
$bool = false;
|
||||||
|
|
||||||
$session = $this->appbox->get_session();
|
$session = $this->appbox->get_session();
|
||||||
if ( ! $session->is_authenticated() || ! login::register_enabled())
|
if ( ! $session->is_authenticated() || ! login::register_enabled()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
||||||
|
@@ -212,8 +212,9 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
|
|||||||
$bool = false;
|
$bool = false;
|
||||||
|
|
||||||
$session = $this->appbox->get_session();
|
$session = $this->appbox->get_session();
|
||||||
if ( ! $session->is_authenticated())
|
if ( ! $session->is_authenticated()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);
|
||||||
|
@@ -169,8 +169,9 @@ class ftpclient
|
|||||||
public function mkdir($remote_directory)
|
public function mkdir($remote_directory)
|
||||||
{
|
{
|
||||||
$remote_directory = $this->get_absolute_path($remote_directory);
|
$remote_directory = $this->get_absolute_path($remote_directory);
|
||||||
if (isset($this->cached_dirs[$remote_directory]))
|
if (isset($this->cached_dirs[$remote_directory])) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "Creation du dossier $remote_directory\n<br>";
|
echo "Creation du dossier $remote_directory\n<br>";
|
||||||
@@ -311,8 +312,10 @@ class ftpclient
|
|||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "Fermeture de la connexion\n<br>";
|
echo "Fermeture de la connexion\n<br>";
|
||||||
if ( ! $this->connexion)
|
if ( ! $this->connexion) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ftp_close($this->connexion)) === false) {
|
if ((ftp_close($this->connexion)) === false) {
|
||||||
throw new Exception('Impossible de fermer la connexion');
|
throw new Exception('Impossible de fermer la connexion');
|
||||||
}
|
}
|
||||||
@@ -334,8 +337,9 @@ class ftpclient
|
|||||||
protected function get_absolute_path($file)
|
protected function get_absolute_path($file)
|
||||||
{
|
{
|
||||||
$file = str_replace('//', '/', $file);
|
$file = str_replace('//', '/', $file);
|
||||||
if ($this->is_absolute_path($file))
|
if ($this->is_absolute_path($file)) {
|
||||||
return $file;
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
$pwd = $this->add_end_slash($this->pwd());
|
$pwd = $this->add_end_slash($this->pwd());
|
||||||
|
|
||||||
@@ -346,8 +350,9 @@ class ftpclient
|
|||||||
{
|
{
|
||||||
$path = trim($path);
|
$path = trim($path);
|
||||||
|
|
||||||
if ($path == "" || $path == '/' || $path == '//')
|
if ($path == "" || $path == '/' || $path == '//') {
|
||||||
return("/");
|
return("/");
|
||||||
|
}
|
||||||
|
|
||||||
if (substr($path, -1, 1) != "/")
|
if (substr($path, -1, 1) != "/")
|
||||||
$path .= "/";
|
$path .= "/";
|
||||||
|
@@ -77,8 +77,9 @@ class gatekeeper
|
|||||||
$appbox = appbox::get_instance($this->Core);
|
$appbox = appbox::get_instance($this->Core);
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
if (http_request::is_command_line())
|
if (http_request::is_command_line()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) {
|
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) {
|
||||||
$this->_PHP_SELF = $_SERVER['PHP_SELF'];
|
$this->_PHP_SELF = $_SERVER['PHP_SELF'];
|
||||||
@@ -119,16 +120,18 @@ class gatekeeper
|
|||||||
case 'thesaurus2':
|
case 'thesaurus2':
|
||||||
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|
||||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|
||||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
phrasea::redirect('/login/?redirect=/thesaurus2');
|
phrasea::redirect('/login/?redirect=/thesaurus2');
|
||||||
break;
|
break;
|
||||||
case 'report':
|
case 'report':
|
||||||
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
|
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
|
||||||
break;
|
break;
|
||||||
case 'admin':
|
case 'admin':
|
||||||
if ($this->_script_name === 'runscheduler.php')
|
if ($this->_script_name === 'runscheduler.php') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
|
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
|
||||||
break;
|
break;
|
||||||
case 'login':
|
case 'login':
|
||||||
@@ -145,10 +148,11 @@ class gatekeeper
|
|||||||
case '':
|
case '':
|
||||||
return;
|
return;
|
||||||
case 'setup':
|
case 'setup':
|
||||||
if ($appbox->upgradeavailable())
|
if ($appbox->upgradeavailable()) {
|
||||||
return;
|
return;
|
||||||
else
|
} else {
|
||||||
phrasea::redirect('/login/');
|
phrasea::redirect('/login/');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
phrasea::redirect('/login/');
|
phrasea::redirect('/login/');
|
||||||
@@ -246,8 +250,9 @@ class gatekeeper
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$parm = $request->get_parms('LOG');
|
$parm = $request->get_parms('LOG');
|
||||||
|
|
||||||
if (is_null($parm["LOG"]))
|
if (is_null($parm["LOG"])) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($session->is_authenticated())
|
if ($session->is_authenticated())
|
||||||
|
@@ -91,8 +91,9 @@ class geonames
|
|||||||
$output = array();
|
$output = array();
|
||||||
$cityName = self::clean_input($cityName);
|
$cityName = self::clean_input($cityName);
|
||||||
|
|
||||||
if (strlen($cityName) === 0)
|
if (strlen($cityName) === 0) {
|
||||||
return $output;
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
|
$url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
|
||||||
@@ -128,8 +129,9 @@ class geonames
|
|||||||
|
|
||||||
public function find_geoname_from_ip($ip)
|
public function find_geoname_from_ip($ip)
|
||||||
{
|
{
|
||||||
if (array_key_exists($ip, $this->cache_ips))
|
if (array_key_exists($ip, $this->cache_ips)) {
|
||||||
return $this->cache_ips[$ip];
|
return $this->cache_ips[$ip];
|
||||||
|
}
|
||||||
|
|
||||||
$output = array(
|
$output = array(
|
||||||
'city' => '',
|
'city' => '',
|
||||||
|
@@ -25,11 +25,13 @@ class http_query
|
|||||||
*/
|
*/
|
||||||
public static function getHttpCodeFromUrl($url)
|
public static function getHttpCodeFromUrl($url)
|
||||||
{
|
{
|
||||||
if ( ! is_scalar($url))
|
if ( ! is_scalar($url)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($url) === '')
|
if (trim($url) === '') {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@@ -51,11 +53,14 @@ class http_query
|
|||||||
|
|
||||||
public static function getHttpHeaders($url)
|
public static function getHttpHeaders($url)
|
||||||
{
|
{
|
||||||
if ( ! is_scalar($url))
|
if ( ! is_scalar($url)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($url) === '')
|
if (trim($url) === '') {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@@ -82,11 +87,13 @@ class http_query
|
|||||||
*/
|
*/
|
||||||
public static function getUrl($url, $post_data = false)
|
public static function getUrl($url, $post_data = false)
|
||||||
{
|
{
|
||||||
if ( ! is_scalar($url))
|
if ( ! is_scalar($url)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($url) === '')
|
if (trim($url) === '') {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
@@ -87,8 +87,10 @@ class http_request
|
|||||||
public function is_ajax()
|
public function is_ajax()
|
||||||
{
|
{
|
||||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
|
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
|
||||||
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
|
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,8 +33,9 @@ class lazaret extends set_abstract
|
|||||||
|
|
||||||
$base_ids = array_keys($user->ACL()->get_granted_base(array('canaddrecord')));
|
$base_ids = array_keys($user->ACL()->get_granted_base(array('canaddrecord')));
|
||||||
|
|
||||||
if (count($base_ids) == 0)
|
if (count($base_ids) == 0) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT id, filepath, filename, base_id,
|
$sql = "SELECT id, filepath, filename, base_id,
|
||||||
uuid, errors, created_on, usr_id
|
uuid, errors, created_on, usr_id
|
||||||
|
@@ -190,8 +190,9 @@ class mail
|
|||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email']))
|
if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email'])) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$mail = new PHPMailer();
|
$mail = new PHPMailer();
|
||||||
|
|
||||||
|
@@ -105,10 +105,11 @@ abstract class media_abstract
|
|||||||
*/
|
*/
|
||||||
public function get_orientation()
|
public function get_orientation()
|
||||||
{
|
{
|
||||||
if ($this->width > $this->height)
|
if ($this->width > $this->height) {
|
||||||
return self::PAYSAGE;
|
return self::PAYSAGE;
|
||||||
else
|
} else {
|
||||||
return self::PORTRAIT;
|
return self::PORTRAIT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -152,10 +152,11 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
|
|||||||
*/
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
if (isset($this->dashboard) && sizeof($this->dashboard) > 0)
|
if (isset($this->dashboard) && sizeof($this->dashboard) > 0) {
|
||||||
return true;
|
return true;
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -228,10 +228,11 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
|
|||||||
*/
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
if (isset($this->report) && sizeof($this->report) > 0)
|
if (isset($this->report) && sizeof($this->report) > 0) {
|
||||||
return true;
|
return true;
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,10 +69,11 @@ class module_report_dashboard_group implements module_report_dashboard_component
|
|||||||
*/
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
if (isset($this->group_dash) && sizeof($this->group_dash) > 0)
|
if (isset($this->group_dash) && sizeof($this->group_dash) > 0) {
|
||||||
return true;
|
return true;
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -121,10 +121,11 @@ class module_report_dashboard_merge implements module_report_dashboard_component
|
|||||||
*/
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
if (isset($this->sorted) && sizeof($this->sorted) > 0)
|
if (isset($this->sorted) && sizeof($this->sorted) > 0) {
|
||||||
return true;
|
return true;
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -122,10 +122,11 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
|
|||||||
|
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0)
|
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0) {
|
||||||
return true;
|
return true;
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDash()
|
public function getDash()
|
||||||
@@ -135,8 +136,9 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
|
|||||||
|
|
||||||
public function getTop($nbtop)
|
public function getTop($nbtop)
|
||||||
{
|
{
|
||||||
if ( ! is_int($nbtop))
|
if ( ! is_int($nbtop)) {
|
||||||
return array();
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
|
|
||||||
|
@@ -113,10 +113,11 @@ class module_report_sql
|
|||||||
public function getTransQuery($champ)
|
public function getTransQuery($champ)
|
||||||
{
|
{
|
||||||
$tanslation = $this->filter->getCorFilter();
|
$tanslation = $this->filter->getCorFilter();
|
||||||
if (array_key_exists($champ, $tanslation))
|
if (array_key_exists($champ, $tanslation)) {
|
||||||
return $tanslation[$champ];
|
return $tanslation[$champ];
|
||||||
else
|
} else {
|
||||||
return $champ;
|
return $champ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -184,8 +184,9 @@ class module_report_sqlfilter
|
|||||||
$this->filter['collection'] = false;
|
$this->filter['collection'] = false;
|
||||||
$coll_filter = array();
|
$coll_filter = array();
|
||||||
|
|
||||||
if ($report->getUserId() == '')
|
if ($report->getUserId() == '') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$tab = explode(",", $report->getListCollId());
|
$tab = explode(",", $report->getListCollId());
|
||||||
if (count($tab) > 0) {
|
if (count($tab) > 0) {
|
||||||
|
@@ -59,8 +59,9 @@ class patch_310 implements patchInterface
|
|||||||
|
|
||||||
$subdefgroups = $sx_structure->xpath('//subdefgroup');
|
$subdefgroups = $sx_structure->xpath('//subdefgroup');
|
||||||
|
|
||||||
if (count($subdefgroups) > 0)
|
if (count($subdefgroups) > 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$subdefs = $sx_structure->xpath('/record/subdefs');
|
$subdefs = $sx_structure->xpath('/record/subdefs');
|
||||||
|
|
||||||
|
@@ -215,8 +215,9 @@ class phrasea
|
|||||||
|
|
||||||
public static function sbas_params()
|
public static function sbas_params()
|
||||||
{
|
{
|
||||||
if (self::$_sbas_params)
|
if (self::$_sbas_params) {
|
||||||
return self::$_sbas_params;
|
return self::$_sbas_params;
|
||||||
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
try {
|
try {
|
||||||
@@ -247,8 +248,9 @@ class phrasea
|
|||||||
public static function guest_allowed()
|
public static function guest_allowed()
|
||||||
{
|
{
|
||||||
$usr_id = User_Adapter::get_usr_id_from_login('invite');
|
$usr_id = User_Adapter::get_usr_id_from_login('invite');
|
||||||
if ( ! $usr_id)
|
if ( ! $usr_id) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = User_Adapter::getInstance($usr_id, $appbox);
|
||||||
|
|
||||||
|
@@ -68,8 +68,9 @@ class phraseadate
|
|||||||
*/
|
*/
|
||||||
public static function getPrettyString(DateTime $date = null)
|
public static function getPrettyString(DateTime $date = null)
|
||||||
{
|
{
|
||||||
if (is_null($date))
|
if (is_null($date)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$compareTo = new DateTime('now');
|
$compareTo = new DateTime('now');
|
||||||
$diff = $compareTo->format('U') - $date->format('U');
|
$diff = $compareTo->format('U') - $date->format('U');
|
||||||
|
@@ -71,11 +71,13 @@ class queries
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$registry = $appbox->get_registry();
|
$registry = $appbox->get_registry();
|
||||||
|
|
||||||
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics_' . $session->get_I18n() . '.xml'))
|
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics_' . $session->get_I18n() . '.xml')) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics.xml'))
|
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics.xml')) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -239,8 +241,10 @@ class queries
|
|||||||
|
|
||||||
private static function hastopics(&$topics)
|
private static function hastopics(&$topics)
|
||||||
{
|
{
|
||||||
foreach ($topics->topics as $subtopic)
|
foreach ($topics->topics as $subtopic) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -255,10 +255,11 @@ class record_exportElement extends record_adapter
|
|||||||
*/
|
*/
|
||||||
public function get_size($name = false)
|
public function get_size($name = false)
|
||||||
{
|
{
|
||||||
if ($name)
|
if ($name) {
|
||||||
return $this->size[$name];
|
return $this->size[$name];
|
||||||
else
|
} else {
|
||||||
return $this->size;
|
return $this->size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -196,8 +196,9 @@ class record_preview extends record_adapter
|
|||||||
|
|
||||||
public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null)
|
public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null)
|
||||||
{
|
{
|
||||||
if ($this->train)
|
if ($this->train) {
|
||||||
return $this->train;
|
return $this->train;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->env) {
|
switch ($this->env) {
|
||||||
case 'RESULT':
|
case 'RESULT':
|
||||||
@@ -257,8 +258,9 @@ class record_preview extends record_adapter
|
|||||||
*/
|
*/
|
||||||
public function get_title($highlight = '', searchEngine_adapter $search_engine = null)
|
public function get_title($highlight = '', searchEngine_adapter $search_engine = null)
|
||||||
{
|
{
|
||||||
if ($this->title)
|
if ($this->title) {
|
||||||
return $this->title;
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
$this->title = collection::getLogo($this->get_base_id()) . ' ';
|
$this->title = collection::getLogo($this->get_base_id()) . ' ';
|
||||||
|
|
||||||
|
@@ -74,13 +74,15 @@ class recordutils_image extends recordutils
|
|||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$debug = false;
|
$debug = false;
|
||||||
|
|
||||||
if ( ! $registry->get('GV_imagick'))
|
if ( ! $registry->get('GV_imagick')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sbas_id = phrasea::sbasFromBas($bas);
|
$sbas_id = phrasea::sbasFromBas($bas);
|
||||||
|
|
||||||
if ( ! isset($sbas_id))
|
if ( ! isset($sbas_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$connSbas = connection::getPDOConnection($sbas_id);
|
$connSbas = connection::getPDOConnection($sbas_id);
|
||||||
|
|
||||||
@@ -114,8 +116,9 @@ class recordutils_image extends recordutils
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($domprefs === FALSE || $sxxml === FALSE)
|
if ($domprefs === FALSE || $sxxml === FALSE) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$xpprefs = new DOMXPath($domprefs);
|
$xpprefs = new DOMXPath($domprefs);
|
||||||
|
|
||||||
@@ -124,8 +127,9 @@ class recordutils_image extends recordutils
|
|||||||
$pathTmpStamp = $registry->get('GV_RootPath') . 'tmp/'
|
$pathTmpStamp = $registry->get('GV_RootPath') . 'tmp/'
|
||||||
. time() . '-stamptmp_' . $file['file'];
|
. time() . '-stamptmp_' . $file['file'];
|
||||||
|
|
||||||
if ( ! is_file($pathIn))
|
if ( ! is_file($pathIn)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($file['type'] != 'image' ||
|
if ($file['type'] != 'image' ||
|
||||||
$xpprefs->query('/baseprefs/stamp')->length == 0) {
|
$xpprefs->query('/baseprefs/stamp')->length == 0) {
|
||||||
@@ -151,8 +155,9 @@ class recordutils_image extends recordutils
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------- CACHING !
|
// ------------- CACHING !
|
||||||
if (is_file($pathOut))
|
if (is_file($pathOut)) {
|
||||||
return $pathOut;
|
return $pathOut;
|
||||||
|
}
|
||||||
|
|
||||||
$fields = $xpprefs->query('/baseprefs/stamp/*/field');
|
$fields = $xpprefs->query('/baseprefs/stamp/*/field');
|
||||||
for ($i = 0; $i < $fields->length; $i ++ ) {
|
for ($i = 0; $i < $fields->length; $i ++ ) {
|
||||||
@@ -174,9 +179,9 @@ class recordutils_image extends recordutils
|
|||||||
|
|
||||||
$collname = phrasea::bas_names($bas);
|
$collname = phrasea::bas_names($bas);
|
||||||
|
|
||||||
if ( ! ($tailleimg = @getimagesize($pathIn)))
|
if ( ! ($tailleimg = @getimagesize($pathIn))) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$image_width = $tailleimg[0];
|
$image_width = $tailleimg[0];
|
||||||
$image_height = $tailleimg[1];
|
$image_height = $tailleimg[1];
|
||||||
@@ -326,8 +331,9 @@ class recordutils_image extends recordutils
|
|||||||
|
|
||||||
unlink($pathTmpStamp);
|
unlink($pathTmpStamp);
|
||||||
|
|
||||||
if (is_file($pathOut))
|
if (is_file($pathOut)) {
|
||||||
return $pathOut;
|
return $pathOut;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -346,8 +352,9 @@ class recordutils_image extends recordutils
|
|||||||
|
|
||||||
$sbas_id = phrasea::sbasFromBas($bas);
|
$sbas_id = phrasea::sbasFromBas($bas);
|
||||||
|
|
||||||
if ( ! isset($sbas_id))
|
if ( ! isset($sbas_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$connSbas = connection::getPDOConnection($sbas_id);
|
$connSbas = connection::getPDOConnection($sbas_id);
|
||||||
|
|
||||||
@@ -360,8 +367,9 @@ class recordutils_image extends recordutils
|
|||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ( ! $row)
|
if ( ! $row) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$file = array(
|
$file = array(
|
||||||
'type' => $row['type']
|
'type' => $row['type']
|
||||||
@@ -374,12 +382,13 @@ class recordutils_image extends recordutils
|
|||||||
|
|
||||||
$pathOut = $file['path'] . 'watermark_' . $file['file'];
|
$pathOut = $file['path'] . 'watermark_' . $file['file'];
|
||||||
|
|
||||||
if ( ! is_file($pathIn))
|
if ( ! is_file($pathIn)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_file($pathOut))
|
if (is_file($pathOut)) {
|
||||||
return $pathOut;
|
return $pathOut;
|
||||||
|
}
|
||||||
|
|
||||||
if ($registry->get('GV_pathcomposite') &&
|
if ($registry->get('GV_pathcomposite') &&
|
||||||
file_exists($registry->get('GV_RootPath') . 'config/wm/' . $bas)) { // si il y a un WM
|
file_exists($registry->get('GV_RootPath') . 'config/wm/' . $bas)) { // si il y a un WM
|
||||||
@@ -469,8 +478,9 @@ class recordutils_image extends recordutils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_file($pathOut))
|
if (is_file($pathOut)) {
|
||||||
return $pathOut;
|
return $pathOut;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -131,10 +131,11 @@ class registry implements registryInterface
|
|||||||
if ( ! $this->cache->contains($key))
|
if ( ! $this->cache->contains($key))
|
||||||
$this->load();
|
$this->load();
|
||||||
|
|
||||||
if ( ! $this->cache->contains($key) && ! is_null($defaultvalue))
|
if ( ! $this->cache->contains($key) && ! is_null($defaultvalue)) {
|
||||||
return $defaultvalue;
|
return $defaultvalue;
|
||||||
else
|
}
|
||||||
return $this->cache->fetch($key);
|
|
||||||
|
return $this->cache->fetch($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -607,7 +607,10 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ( ! isset($res['results']) || ! is_array($res['results']))
|
if ( ! isset($res['results']) || ! is_array($res['results']))
|
||||||
|
{
|
||||||
return array();
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$rs = $res['results'];
|
$rs = $res['results'];
|
||||||
$res = array_shift($rs);
|
$res = array_shift($rs);
|
||||||
if ( ! isset($res['xml'])) {
|
if ( ! isset($res['xml'])) {
|
||||||
|
@@ -118,11 +118,14 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
|
|
||||||
$this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
|
$this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
|
||||||
$this->phq = $this->mb_trim($phq, 'UTF-8');
|
$this->phq = $this->mb_trim($phq, 'UTF-8');
|
||||||
if ($this->phq != "")
|
if ($this->phq != "") {
|
||||||
return($this->maketree(0));
|
return($this->maketree(0));
|
||||||
else {
|
} else {
|
||||||
if ($this->errmsg != "")
|
|
||||||
|
if ($this->errmsg != "") {
|
||||||
$this->errmsg .= sprintf("\\n");
|
$this->errmsg .= sprintf("\\n");
|
||||||
|
}
|
||||||
|
|
||||||
$this->errmsg .= _('qparser::la question est vide');
|
$this->errmsg .= _('qparser::la question est vide');
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
@@ -133,32 +136,37 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
{
|
{
|
||||||
switch ($tree["CLASS"]) {
|
switch ($tree["CLASS"]) {
|
||||||
case "SIMPLE":
|
case "SIMPLE":
|
||||||
if (is_array($tree["VALUE"]))
|
if (is_array($tree["VALUE"])) {
|
||||||
return(implode(" ", $tree["VALUE"]));
|
return(implode(" ", $tree["VALUE"]));
|
||||||
else
|
} else {
|
||||||
|
|
||||||
return($tree["VALUE"]);
|
return($tree["VALUE"]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "QSIMPLE":
|
case "QSIMPLE":
|
||||||
if (is_array($tree["VALUE"]))
|
if (is_array($tree["VALUE"])) {
|
||||||
return("\"" . implode(" ", $tree["VALUE"]) . "\"");
|
return("\"" . implode(" ", $tree["VALUE"]) . "\"");
|
||||||
else
|
} else {
|
||||||
return("\"" . $tree["VALUE"] . "\"");
|
return("\"" . $tree["VALUE"] . "\"");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_ALL":
|
case "PHRASEA_KW_ALL":
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_LAST":
|
case "PHRASEA_KW_LAST":
|
||||||
if ($tree["PNUM"] !== null)
|
if ($tree["PNUM"] !== null) {
|
||||||
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
||||||
else
|
} else {
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "OPS":
|
case "OPS":
|
||||||
case "OPK":
|
case "OPK":
|
||||||
if (isset($tree["PNUM"]))
|
if (isset($tree["PNUM"])) {
|
||||||
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext($tree["RB"]) . ")");
|
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext($tree["RB"]) . ")");
|
||||||
else
|
} else {
|
||||||
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . " " . $this->astext($tree["RB"]) . ")");
|
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . " " . $this->astext($tree["RB"]) . ")");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,10 +184,11 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
function calc_complexity(&$tree)
|
function calc_complexity(&$tree)
|
||||||
{
|
{
|
||||||
if ($tree) {
|
if ($tree) {
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
||||||
return($tree["COMPLEXITY"] = $this->calc_complexity($tree["LB"]) + $this->calc_complexity($tree["RB"]));
|
return($tree["COMPLEXITY"] = $this->calc_complexity($tree["LB"]) + $this->calc_complexity($tree["RB"]));
|
||||||
else
|
} else {
|
||||||
return($tree["COMPLEXITY"] = 1);
|
return($tree["COMPLEXITY"] = 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,8 +347,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
|
|
||||||
function priority_opk(&$tree, $depth = 0)
|
function priority_opk(&$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK")) {
|
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK")) {
|
||||||
// on a un truc du genre ((a ou b) < 5), on le transforme en (a ou (b < 5))
|
// on a un truc du genre ((a ou b) < 5), on le transforme en (a ou (b < 5))
|
||||||
$t = $tree["LB"];
|
$t = $tree["LB"];
|
||||||
@@ -347,16 +358,19 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$t["RB"] = $tree;
|
$t["RB"] = $tree;
|
||||||
$tree = $t;
|
$tree = $t;
|
||||||
}
|
}
|
||||||
if (isset($tree["LB"]))
|
if (isset($tree["LB"])) {
|
||||||
$this->priority_opk($tree["LB"], $depth + 1);
|
$this->priority_opk($tree["LB"], $depth + 1);
|
||||||
if (isset($tree["RB"]))
|
}if (isset($tree["RB"])) {
|
||||||
$this->priority_opk($tree["RB"], $depth + 1);
|
$this->priority_opk($tree["RB"], $depth + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function distrib_opk(&$tree, $depth = 0)
|
function distrib_opk(&$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS")) {
|
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS")) {
|
||||||
// on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6))
|
// on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6))
|
||||||
$tmp = array("CLASS" => $tree["CLASS"],
|
$tmp = array("CLASS" => $tree["CLASS"],
|
||||||
@@ -380,8 +394,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
|
|
||||||
function thesaurus2_apply(&$tree, $bid)
|
function thesaurus2_apply(&$tree, $bid)
|
||||||
{
|
{
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"])) {
|
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"])) {
|
||||||
$tids = array();
|
$tids = array();
|
||||||
foreach ($tree["SREF"]["TIDS"] as $tid) {
|
foreach ($tree["SREF"]["TIDS"] as $tid) {
|
||||||
@@ -440,8 +456,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
{
|
{
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
$ret = $tree;
|
$ret = $tree;
|
||||||
if ( ! $useThesaurus)
|
if ( ! $useThesaurus) {
|
||||||
return; // full-text only : inchangé
|
return; // full-text only : inchangé
|
||||||
|
}
|
||||||
|
|
||||||
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE")) {
|
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE")) {
|
||||||
if (isset($tree["CONTEXT"]))
|
if (isset($tree["CONTEXT"]))
|
||||||
$copy = $this->_extendToThesaurus_Simple($tree, false, $keepfuzzy, $path);
|
$copy = $this->_extendToThesaurus_Simple($tree, false, $keepfuzzy, $path);
|
||||||
@@ -565,8 +583,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
$this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
|
$this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
|
||||||
|
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(0);
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
$ambigus = 0;
|
$ambigus = 0;
|
||||||
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON) {
|
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON) {
|
||||||
@@ -686,17 +705,19 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_LAST":
|
case "PHRASEA_KW_LAST":
|
||||||
if ($tree["PNUM"] !== null)
|
if ($tree["PNUM"] !== null) {
|
||||||
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
||||||
else
|
} else {
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "OPS":
|
case "OPS":
|
||||||
case "OPK":
|
case "OPK":
|
||||||
if (isset($tree["PNUM"]))
|
if (isset($tree["PNUM"])) {
|
||||||
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . '[' . $tree["PNUM"] . '] ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . '[' . $tree["PNUM"] . '] ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
||||||
else
|
} else {
|
||||||
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . ' ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . ' ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -841,10 +862,12 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
|
|
||||||
function containsColonOperator(&$tree)
|
function containsColonOperator(&$tree)
|
||||||
{
|
{
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(false);
|
return(false);
|
||||||
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE"))
|
}
|
||||||
|
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE")) {
|
||||||
return(true);
|
return(true);
|
||||||
|
}
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
||||||
$ret |= $this->containsColonOperator($tree["LB"]);
|
$ret |= $this->containsColonOperator($tree["LB"]);
|
||||||
@@ -950,25 +973,29 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_LAST":
|
case "PHRASEA_KW_LAST":
|
||||||
if ($tree["PNUM"] !== null)
|
if ($tree["PNUM"] !== null) {
|
||||||
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
||||||
else
|
} else {
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "OPS":
|
case "OPS":
|
||||||
case "OPK":
|
case "OPK":
|
||||||
if (isset($tree["PNUM"]))
|
if (isset($tree["PNUM"])) {
|
||||||
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
||||||
else
|
} else {
|
||||||
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . " " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . " " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_ambigu(&$tree, $mouseCallback = "void", $depth = 0)
|
function get_ambigu(&$tree, $mouseCallback = "void", $depth = 0)
|
||||||
{
|
{
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return("");
|
return("");
|
||||||
|
}
|
||||||
|
|
||||||
unset($tree["DEPTH"]);
|
unset($tree["DEPTH"]);
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
||||||
$this->get_ambigu($tree["LB"], $mouseCallback, $depth + 1);
|
$this->get_ambigu($tree["LB"], $mouseCallback, $depth + 1);
|
||||||
@@ -987,16 +1014,19 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
|
|
||||||
function set_default(&$tree, &$emptyw, $depth = 0)
|
function set_default(&$tree, &$emptyw, $depth = 0)
|
||||||
{
|
{
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(true);
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
|
||||||
if ($tree["CLASS"] == "OPS") {
|
if ($tree["CLASS"] == "OPS") {
|
||||||
if ( ! $this->set_default($tree["LB"], $emptyw, $depth + 1))
|
if ( ! $this->set_default($tree["LB"], $emptyw, $depth + 1)) {
|
||||||
return(false);
|
return(false);
|
||||||
if ( ! $this->set_default($tree["RB"], $emptyw, $depth + 1))
|
}
|
||||||
|
if ( ! $this->set_default($tree["RB"], $emptyw, $depth + 1)) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
else { // OPK !
|
} else { // OPK !
|
||||||
// jy 20041223 : ne pas appliquer d'op. par def. derriere un op arith.
|
// jy 20041223 : ne pas appliquer d'op. par def. derriere un op arith.
|
||||||
// ex : "d < 1/2/2003" : grouper la liste "1","2","2004" en "mot" unique
|
// ex : "d < 1/2/2003" : grouper la liste "1","2","2004" en "mot" unique
|
||||||
if ( ! $tree["LB"] || ($tree["LB"]["CLASS"] != "SIMPLE" && $tree["LB"]["CLASS"] != "QSIMPLE") || (is_array($tree["LB"]["VALUE"]) && count($tree["LB"]["VALUE"]) != 1)) {
|
if ( ! $tree["LB"] || ($tree["LB"]["CLASS"] != "SIMPLE" && $tree["LB"]["CLASS"] != "QSIMPLE") || (is_array($tree["LB"]["VALUE"]) && count($tree["LB"]["VALUE"]) != 1)) {
|
||||||
@@ -1473,10 +1503,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
if ($inquote) {
|
if ($inquote) {
|
||||||
// quand on est entre guillements les tokens perdent leur signification
|
// quand on est entre guillements les tokens perdent leur signification
|
||||||
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
if ($depth <= 0) { // ')' : retour de récursivité
|
if ($depth <= 0) { // ')' : retour de récursivité
|
||||||
if ($this->errmsg != "")
|
if ($this->errmsg != "")
|
||||||
$this->errmsg .= sprintf("\\n");
|
$this->errmsg .= sprintf("\\n");
|
||||||
@@ -1492,10 +1522,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
if ($inquote) {
|
if ($inquote) {
|
||||||
// quand on est entre guillements les tokens perdent leur signification
|
// quand on est entre guillements les tokens perdent leur signification
|
||||||
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
else { // '(' : appel récursif
|
} else { // '(' : appel récursif
|
||||||
if ( ! $tree)
|
if ( ! $tree)
|
||||||
$tree = $this->maketree($depth + 1);
|
$tree = $this->maketree($depth + 1);
|
||||||
else {
|
else {
|
||||||
@@ -1515,8 +1545,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
"RB" => $this->maketree($depth + 1));
|
"RB" => $this->maketree($depth + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(null);
|
return(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "TOK_VOID":
|
case "TOK_VOID":
|
||||||
@@ -1562,8 +1593,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
"RB" => $this->maketree($depth + 1, true));
|
"RB" => $this->maketree($depth + 1, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(null);
|
return(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1573,8 +1605,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
var_dump($tree);
|
var_dump($tree);
|
||||||
print("-------------------------\n");
|
print("-------------------------\n");
|
||||||
}
|
}
|
||||||
if ( ! $tree)
|
if ( ! $tree) {
|
||||||
return(null);
|
return(null);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1597,8 +1630,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
print("-------------------------\n");
|
print("-------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $t)
|
if ( ! $t) {
|
||||||
return($tree);
|
return($tree);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($t["CLASS"]) {
|
switch ($t["CLASS"]) {
|
||||||
case "TOK_CONTEXT":
|
case "TOK_CONTEXT":
|
||||||
// if($this->debug)
|
// if($this->debug)
|
||||||
@@ -1823,8 +1858,10 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
|
|
||||||
function nexttoken($inquote = false)
|
function nexttoken($inquote = false)
|
||||||
{
|
{
|
||||||
if ($this->phq == "")
|
if ($this->phq == "") {
|
||||||
return(null);
|
return(null);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($c = substr($this->phq, 0, 1)) {
|
switch ($c = substr($this->phq, 0, 1)) {
|
||||||
case "<":
|
case "<":
|
||||||
case ">":
|
case ">":
|
||||||
@@ -1940,10 +1977,11 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
// le délimiteur était une simple ponctuation, on le saute
|
// le délimiteur était une simple ponctuation, on le saute
|
||||||
$this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8');
|
$this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8');
|
||||||
}
|
}
|
||||||
if ($t != "")
|
if ($t != "") {
|
||||||
return(array("CLASS" => "TOK_WORD", "VALUE" => $t));
|
return(array("CLASS" => "TOK_WORD", "VALUE" => $t));
|
||||||
else
|
} else {
|
||||||
return(array("CLASS" => "TOK_VOID", "VALUE" => $t));
|
return(array("CLASS" => "TOK_VOID", "VALUE" => $t));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -100,8 +100,10 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
public function __isset($key)
|
public function __isset($key)
|
||||||
{
|
{
|
||||||
trigger_error("Unable to use magic method get for key $key");
|
trigger_error("Unable to use magic method get for key $key");
|
||||||
if (isset($this->$key))
|
if (isset($this->$key)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -136,8 +136,9 @@ class set_ordermanager extends set_abstract
|
|||||||
{
|
{
|
||||||
$comp = strcasecmp($a['usage'], $b['usage']);
|
$comp = strcasecmp($a['usage'], $b['usage']);
|
||||||
|
|
||||||
if ($comp == 0)
|
if ($comp == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $comp < 0 ? -1 : 1;
|
return $comp < 0 ? -1 : 1;
|
||||||
}
|
}
|
||||||
@@ -152,8 +153,9 @@ class set_ordermanager extends set_abstract
|
|||||||
{
|
{
|
||||||
$comp = strcasecmp($a['usr_display'], $b['usr_display']);
|
$comp = strcasecmp($a['usr_display'], $b['usr_display']);
|
||||||
|
|
||||||
if ($comp == 0)
|
if ($comp == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $comp < 0 ? -1 : 1;
|
return $comp < 0 ? -1 : 1;
|
||||||
}
|
}
|
||||||
@@ -168,8 +170,9 @@ class set_ordermanager extends set_abstract
|
|||||||
{
|
{
|
||||||
$comp = $b->format('U') - $a->format('U');
|
$comp = $b->format('U') - $a->format('U');
|
||||||
|
|
||||||
if ($comp == 0)
|
if ($comp == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $comp < 0 ? -1 : 1;
|
return $comp < 0 ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
@@ -268,12 +268,14 @@ class setup
|
|||||||
|
|
||||||
protected static function discover_binary($binary, array $look_here = array())
|
protected static function discover_binary($binary, array $look_here = array())
|
||||||
{
|
{
|
||||||
if (system_server::get_platform() == 'WINDOWS')
|
if (system_server::get_platform() == 'WINDOWS') {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($look_here as $place) {
|
foreach ($look_here as $place) {
|
||||||
if (is_executable($place))
|
if (is_executable($place)) {
|
||||||
return $place;
|
return $place;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return exec(sprintf('which %s', $binary));
|
return exec(sprintf('which %s', $binary));
|
||||||
@@ -283,23 +285,24 @@ class setup
|
|||||||
{
|
{
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
if ($registry->get('GV_h264_streaming') !== true)
|
if ($registry->get('GV_h264_streaming') !== true) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<h1>mod_auth_token configuration </h1>
|
<h1>mod_auth_token configuration </h1>
|
||||||
<ul class="setup">
|
<ul class="setup">
|
||||||
<?php
|
<?php
|
||||||
$fileName = $registry->get('GV_mod_auth_token_directory_path') . '/test_mod_auth_token.txt'; // The file to access
|
$fileName = $registry->get('GV_mod_auth_token_directory_path') . '/test_mod_auth_token.txt'; // The file to access
|
||||||
|
|
||||||
touch($fileName);
|
touch($fileName);
|
||||||
|
|
||||||
$url = $registry->get('GV_ServerName') . p4file::apache_tokenize($fileName);
|
$url = $registry->get('GV_ServerName') . p4file::apache_tokenize($fileName);
|
||||||
|
|
||||||
if (http_query::getHttpCodeFromUrl($url) == 200)
|
if (http_query::getHttpCodeFromUrl($url) == 200)
|
||||||
echo '<li>' . _('mod_auth_token correctement configure') . '</li>';
|
echo '<li>' . _('mod_auth_token correctement configure') . '</li>';
|
||||||
else
|
else
|
||||||
echo '<li class="blocker">' . _('mod_auth_token mal configure') . '</li>';
|
echo '<li class="blocker">' . _('mod_auth_token mal configure') . '</li>';
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -310,9 +313,9 @@ class setup
|
|||||||
?>
|
?>
|
||||||
<h1>Apache Server mods avalaibility</h1>
|
<h1>Apache Server mods avalaibility</h1>
|
||||||
<div style="position:relative;float:left;">
|
<div style="position:relative;float:left;">
|
||||||
<?php
|
<?php
|
||||||
echo _('Attention, seul le test de l\'activation des mods est effectue, leur bon fonctionnement ne l\'est pas ')
|
echo _('Attention, seul le test de l\'activation des mods est effectue, leur bon fonctionnement ne l\'est pas ')
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul id="apache_mods_checker" class="setup">
|
<ul id="apache_mods_checker" class="setup">
|
||||||
@@ -322,27 +325,27 @@ class setup
|
|||||||
</li>
|
</li>
|
||||||
<li class="blocker">
|
<li class="blocker">
|
||||||
<a href="#" onclick="check_apache_mod(this,'xsendfile');return false;">mod_xsendfile (optionnal)</a>
|
<a href="#" onclick="check_apache_mod(this,'xsendfile');return false;">mod_xsendfile (optionnal)</a>
|
||||||
<?php
|
<?php
|
||||||
if ($registry->get('GV_modxsendfile')) {
|
if ($registry->get('GV_modxsendfile')) {
|
||||||
?>
|
?>
|
||||||
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration xsendfile, actuellement activee dans le setup'); ?></div>
|
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration xsendfile, actuellement activee dans le setup'); ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</li>
|
</li>
|
||||||
<li class="blocker">
|
<li class="blocker">
|
||||||
<a href="#" onclick="check_apache_mod(this,'authtoken');return false;">mod_auth_token (optionnal)</a>
|
<a href="#" onclick="check_apache_mod(this,'authtoken');return false;">mod_auth_token (optionnal)</a>
|
||||||
<?php
|
<?php
|
||||||
if ($registry->get('GV_h264_streaming')) {
|
if ($registry->get('GV_h264_streaming')) {
|
||||||
?>
|
?>
|
||||||
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration h264_streaming, actuellement activee dans le setup'); ?></div>
|
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration h264_streaming, actuellement activee dans le setup'); ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</li>
|
</li>
|
||||||
<li class="blocker">
|
<li class="blocker">
|
||||||
<a href="#" onclick="check_apache_mod(this,'h264');return false;">mod_h264_streaming (optionnal)</a>
|
<a href="#" onclick="check_apache_mod(this,'h264');return false;">mod_h264_streaming (optionnal)</a>
|
||||||
<?php
|
<?php
|
||||||
if ($registry->get('GV_h264_streaming')) {
|
if ($registry->get('GV_h264_streaming')) {
|
||||||
?>
|
?>
|
||||||
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration h264_streaming, actuellement activee dans le setup'); ?></div>
|
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration h264_streaming, actuellement activee dans le setup'); ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</li>
|
</li>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#apache_mods_checker div.infos{
|
#apache_mods_checker div.infos{
|
||||||
@@ -387,96 +390,96 @@ class setup
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function check_phrasea()
|
public static function check_phrasea()
|
||||||
{
|
{
|
||||||
$constraints = array();
|
$constraints = array();
|
||||||
if (function_exists('phrasea_info')) {
|
if (function_exists('phrasea_info')) {
|
||||||
foreach (phrasea_info() as $name => $value) {
|
foreach (phrasea_info() as $name => $value) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
default:
|
default:
|
||||||
$result = true;
|
$result = true;
|
||||||
$message = $name . ' = ' . $value;
|
$message = $name . ' = ' . $value;
|
||||||
break;
|
break;
|
||||||
case 'temp_writable':
|
case 'temp_writable':
|
||||||
$result = $value == '1';
|
$result = $value == '1';
|
||||||
if ($result)
|
if ($result)
|
||||||
$message = 'Directory is writeable';
|
$message = 'Directory is writeable';
|
||||||
else
|
else
|
||||||
$message = 'Directory MUST be writable';
|
$message = 'Directory MUST be writable';
|
||||||
break;
|
break;
|
||||||
case 'version':
|
case 'version':
|
||||||
$result = version_compare($value, '1.18.0.3', '>=');
|
$result = version_compare($value, '1.18.0.3', '>=');
|
||||||
if ($result)
|
if ($result)
|
||||||
$message = sprintf('Phrasea version %s is ok', $value);
|
$message = sprintf('Phrasea version %s is ok', $value);
|
||||||
else
|
else
|
||||||
$message = sprintf('Phrasea version %s is NOT ok', $value);
|
$message = sprintf('Phrasea version %s is NOT ok', $value);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
$blocker = $name == 'temp_writable' ? ($value ? '' : 'blocker') : '';
|
||||||
|
$constraints[] = new Setup_Constraint($name, $result, $message, true);
|
||||||
}
|
}
|
||||||
$blocker = $name == 'temp_writable' ? ($value ? '' : 'blocker') : '';
|
|
||||||
$constraints[] = new Setup_Constraint($name, $result, $message, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Setup_ConstraintsIterator($constraints);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function check_writability(registryInterface $registry)
|
|
||||||
{
|
|
||||||
$root = p4string::addEndSlash(realpath(__DIR__ . '/../../'));
|
|
||||||
|
|
||||||
$pathes = array(
|
|
||||||
$root . 'config',
|
|
||||||
$root . 'config/stamp',
|
|
||||||
$root . 'config/status',
|
|
||||||
$root . 'config/minilogos',
|
|
||||||
$root . 'config/templates',
|
|
||||||
$root . 'config/topics',
|
|
||||||
$root . 'config/wm',
|
|
||||||
$root . 'logs',
|
|
||||||
$root . 'tmp',
|
|
||||||
$root . 'www/custom',
|
|
||||||
$root . 'tmp/locks',
|
|
||||||
$root . 'tmp/cache_twig',
|
|
||||||
$root . 'tmp/cache_minify',
|
|
||||||
$root . 'tmp/lazaret',
|
|
||||||
$root . 'tmp/desc_tmp',
|
|
||||||
$root . 'tmp/download',
|
|
||||||
$root . 'tmp/batches');
|
|
||||||
|
|
||||||
if ($registry->is_set('GV_base_datapath_web')) {
|
|
||||||
$pathes[] = $registry->get('GV_base_datapath_web');
|
|
||||||
}
|
|
||||||
if ($registry->is_set('GV_base_datapath_noweb')) {
|
|
||||||
$pathes[] = $registry->get('GV_base_datapath_noweb');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$constraints = array();
|
|
||||||
|
|
||||||
foreach ($pathes as $p) {
|
|
||||||
if ( ! is_writable($p)) {
|
|
||||||
$message = sprintf('%s not writeable', $p);
|
|
||||||
} else {
|
|
||||||
$message = sprintf('%s OK', $p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$constraints[] = new Setup_Constraint(
|
return new Setup_ConstraintsIterator($constraints);
|
||||||
'Writeability test', is_writable($p), $message, true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$php_constraints = new Setup_ConstraintsIterator($constraints);
|
|
||||||
|
|
||||||
return $php_constraints;
|
public static function check_writability(registryInterface $registry)
|
||||||
}
|
{
|
||||||
|
$root = p4string::addEndSlash(realpath(__DIR__ . '/../../'));
|
||||||
|
|
||||||
function check_mail_form()
|
$pathes = array(
|
||||||
{
|
$root . 'config',
|
||||||
echo '<h1>' . _('setup::Tests d\'envois d\'emails') . '</h1>';
|
$root . 'config/stamp',
|
||||||
?>
|
$root . 'config/status',
|
||||||
|
$root . 'config/minilogos',
|
||||||
|
$root . 'config/templates',
|
||||||
|
$root . 'config/topics',
|
||||||
|
$root . 'config/wm',
|
||||||
|
$root . 'logs',
|
||||||
|
$root . 'tmp',
|
||||||
|
$root . 'www/custom',
|
||||||
|
$root . 'tmp/locks',
|
||||||
|
$root . 'tmp/cache_twig',
|
||||||
|
$root . 'tmp/cache_minify',
|
||||||
|
$root . 'tmp/lazaret',
|
||||||
|
$root . 'tmp/desc_tmp',
|
||||||
|
$root . 'tmp/download',
|
||||||
|
$root . 'tmp/batches');
|
||||||
|
|
||||||
|
if ($registry->is_set('GV_base_datapath_web')) {
|
||||||
|
$pathes[] = $registry->get('GV_base_datapath_web');
|
||||||
|
}
|
||||||
|
if ($registry->is_set('GV_base_datapath_noweb')) {
|
||||||
|
$pathes[] = $registry->get('GV_base_datapath_noweb');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$constraints = array();
|
||||||
|
|
||||||
|
foreach ($pathes as $p) {
|
||||||
|
if ( ! is_writable($p)) {
|
||||||
|
$message = sprintf('%s not writeable', $p);
|
||||||
|
} else {
|
||||||
|
$message = sprintf('%s OK', $p);
|
||||||
|
}
|
||||||
|
|
||||||
|
$constraints[] = new Setup_Constraint(
|
||||||
|
'Writeability test', is_writable($p), $message, true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$php_constraints = new Setup_ConstraintsIterator($constraints);
|
||||||
|
|
||||||
|
return $php_constraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_mail_form()
|
||||||
|
{
|
||||||
|
echo '<h1>' . _('setup::Tests d\'envois d\'emails') . '</h1>';
|
||||||
|
?>
|
||||||
<form method="post" action="/admin/sitestruct.php" target="_self">
|
<form method="post" action="/admin/sitestruct.php" target="_self">
|
||||||
<label>Email : </label><input name="email" type="text" />
|
<label>Email : </label><input name="email" type="text" />
|
||||||
<input type="submit" value="<?php echo _('boutton::valider'); ?>"/>
|
<input type="submit" value="<?php echo _('boutton::valider'); ?>"/>
|
||||||
@@ -643,8 +646,9 @@ class setup
|
|||||||
{
|
{
|
||||||
$constraints = array();
|
$constraints = array();
|
||||||
|
|
||||||
if ( ! extension_loaded('gettext'))
|
if ( ! extension_loaded('gettext')) {
|
||||||
return new Setup_ConstraintsIterator($constraints);
|
return new Setup_ConstraintsIterator($constraints);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (User_Adapter::$locales as $code => $language_name) {
|
foreach (User_Adapter::$locales as $code => $language_name) {
|
||||||
phrasea::use_i18n($code, 'test');
|
phrasea::use_i18n($code, 'test');
|
||||||
@@ -670,14 +674,19 @@ class setup
|
|||||||
if ($is_flag)
|
if ($is_flag)
|
||||||
$current = strtolower($current);
|
$current = strtolower($current);
|
||||||
|
|
||||||
if (($current === '' || $current === 'off' || $current === '0') && $is_flag)
|
if (($current === '' || $current === 'off' || $current === '0') && $is_flag) {
|
||||||
if ($value === 'off' || $value === '0' || $value === '')
|
if ($value === 'off' || $value === '0' || $value === '') {
|
||||||
return $current;
|
return $current;
|
||||||
if (($current === '1' || $current === 'on') && $is_flag)
|
}
|
||||||
if ($value === 'on' || $value === '1')
|
}
|
||||||
|
if (($current === '1' || $current === 'on') && $is_flag) {
|
||||||
|
if ($value === 'on' || $value === '1') {
|
||||||
return $current;
|
return $current;
|
||||||
if ($current === $value)
|
}
|
||||||
|
}
|
||||||
|
if ($current === $value) {
|
||||||
return $current;
|
return $current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function rollback(connection_pdo $conn, connection_pdo $connbas = null)
|
public static function rollback(connection_pdo $conn, connection_pdo $connbas = null)
|
||||||
|
@@ -250,8 +250,10 @@ class system_file extends SplFileObject
|
|||||||
, 'x3f' => 'image/x-tika-sigma');
|
, 'x3f' => 'image/x-tika-sigma');
|
||||||
|
|
||||||
|
|
||||||
if (in_array($this->get_mime(), $raws))
|
if (in_array($this->get_mime(), $raws)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,10 +277,11 @@ class system_file extends SplFileObject
|
|||||||
$extension = isset($pi['extension']) ? $pi['extension'] : '';
|
$extension = isset($pi['extension']) ? $pi['extension'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lowercase)
|
if ($lowercase) {
|
||||||
return mb_strtolower($extension);
|
return mb_strtolower($extension);
|
||||||
else
|
}
|
||||||
return $extension;
|
|
||||||
|
return $extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_sha256()
|
public function get_sha256()
|
||||||
@@ -452,8 +455,9 @@ class system_file extends SplFileObject
|
|||||||
|
|
||||||
$this->technical_datas = array();
|
$this->technical_datas = array();
|
||||||
|
|
||||||
if ( ! is_executable($registry->get('GV_mplayer')))
|
if ( ! is_executable($registry->get('GV_mplayer'))) {
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$cmd = $registry->get('GV_mplayer')
|
$cmd = $registry->get('GV_mplayer')
|
||||||
. ' -identify '
|
. ' -identify '
|
||||||
@@ -669,8 +673,9 @@ class system_file extends SplFileObject
|
|||||||
|
|
||||||
public function read_uuid()
|
public function read_uuid()
|
||||||
{
|
{
|
||||||
if ($this->uuid)
|
if ($this->uuid) {
|
||||||
return $this->uuid;
|
return $this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);
|
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);
|
||||||
$domrdf = new DOMDocument();
|
$domrdf = new DOMDocument();
|
||||||
@@ -701,8 +706,9 @@ class system_file extends SplFileObject
|
|||||||
|
|
||||||
public function is_new_in_base($sbas_id)
|
public function is_new_in_base($sbas_id)
|
||||||
{
|
{
|
||||||
if ( ! $this->uuid)
|
if ( ! $this->uuid) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$connbas = connection::getPDOConnection($sbas_id);
|
$connbas = connection::getPDOConnection($sbas_id);
|
||||||
|
|
||||||
@@ -764,8 +770,9 @@ class system_file extends SplFileObject
|
|||||||
|
|
||||||
if (($v = $x->firstChild) && $v->nodeType == XML_TEXT_NODE) {
|
if (($v = $x->firstChild) && $v->nodeType == XML_TEXT_NODE) {
|
||||||
$value = $base64_encoded ? base64_decode($v->nodeValue) : $v->nodeValue;
|
$value = $base64_encoded ? base64_decode($v->nodeValue) : $v->nodeValue;
|
||||||
if (uuid::is_valid($value))
|
if (uuid::is_valid($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -859,8 +866,10 @@ class system_file extends SplFileObject
|
|||||||
|
|
||||||
public function get_phrasea_tech_field($field)
|
public function get_phrasea_tech_field($field)
|
||||||
{
|
{
|
||||||
if (isset($this->phrasea_tech_field[$field]))
|
if (isset($this->phrasea_tech_field[$field])) {
|
||||||
return $this->phrasea_tech_field[$field];
|
return $this->phrasea_tech_field[$field];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1151,16 +1160,17 @@ class system_file extends SplFileObject
|
|||||||
if (mb_convert_encoding(mb_convert_encoding($s, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') == $s) {
|
if (mb_convert_encoding(mb_convert_encoding($s, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') == $s) {
|
||||||
$mac = mb_convert_encoding($s, 'windows-1252', 'UTF-8');
|
$mac = mb_convert_encoding($s, 'windows-1252', 'UTF-8');
|
||||||
for ($i = strlen($mac); $i;) {
|
for ($i = strlen($mac); $i;) {
|
||||||
if (strpos($macchars, $mac[ -- $i]) !== false)
|
if (strpos($macchars, $mac[ -- $i]) !== false) {
|
||||||
return(iconv('MACINTOSH', 'UTF-8', $mac));
|
return(iconv('MACINTOSH', 'UTF-8', $mac));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return($s);
|
return($s);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for ($i = strlen($s); $i;) {
|
for ($i = strlen($s); $i;) {
|
||||||
if (strpos($macchars, $s[ -- $i]) !== false)
|
if (strpos($macchars, $s[ -- $i]) !== false) {
|
||||||
return(iconv('MACINTOSH', 'UTF-8', $s));
|
return(iconv('MACINTOSH', 'UTF-8', $s));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(iconv('windows-1252', 'UTF-8', $s));
|
return(iconv('windows-1252', 'UTF-8', $s));
|
||||||
|
@@ -42,8 +42,10 @@ class system_server
|
|||||||
*/
|
*/
|
||||||
public function is_nginx()
|
public function is_nginx()
|
||||||
{
|
{
|
||||||
if (strpos($this->_server_software, 'nginx') !== false)
|
if (strpos($this->_server_software, 'nginx') !== false) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,8 +56,10 @@ class system_server
|
|||||||
*/
|
*/
|
||||||
public function is_lighttpd()
|
public function is_lighttpd()
|
||||||
{
|
{
|
||||||
if (strpos($this->_server_software, 'lighttpd') !== false)
|
if (strpos($this->_server_software, 'lighttpd') !== false) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +70,10 @@ class system_server
|
|||||||
*/
|
*/
|
||||||
public function is_apache()
|
public function is_apache()
|
||||||
{
|
{
|
||||||
if (strpos($this->_server_software, 'apache') !== false)
|
if (strpos($this->_server_software, 'apache') !== false) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +88,10 @@ class system_server
|
|||||||
static $_system = NULL;
|
static $_system = NULL;
|
||||||
if ($_system === NULL) {
|
if ($_system === NULL) {
|
||||||
$_system = strtoupper(php_uname('s'));
|
$_system = strtoupper(php_uname('s'));
|
||||||
if ($_system == 'WINDOWS NT')
|
|
||||||
|
if ($_system == 'WINDOWS NT') {
|
||||||
$_system = 'WINDOWS';
|
$_system = 'WINDOWS';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return($_system);
|
return($_system);
|
||||||
|
@@ -34,8 +34,10 @@ class task_manager
|
|||||||
|
|
||||||
public function old_get_tasks($refresh = false)
|
public function old_get_tasks($refresh = false)
|
||||||
{
|
{
|
||||||
if ($this->tasks && ! $refresh)
|
if ($this->tasks && ! $refresh) {
|
||||||
return $this->tasks;
|
return $this->tasks;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
||||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -62,8 +64,9 @@ class task_manager
|
|||||||
|
|
||||||
public function get_tasks($refresh = false)
|
public function get_tasks($refresh = false)
|
||||||
{
|
{
|
||||||
if ($this->tasks && ! $refresh)
|
if ($this->tasks && ! $refresh) {
|
||||||
return $this->tasks;
|
return $this->tasks;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
||||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||||
|
@@ -153,9 +153,9 @@ class task_period_apibridge extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
$element->set_connector_status($connector_status);
|
$element->set_connector_status($connector_status);
|
||||||
|
|
||||||
if ($status === $previous_status)
|
if ($status === $previous_status) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case Bridge_Element::STATUS_ERROR:
|
case Bridge_Element::STATUS_ERROR:
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -273,17 +273,17 @@ class task_period_cindexer extends task_abstract
|
|||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:host') ?> : <input type="text" name="host" style="width:100px;" onchange="chgxmltxt(this, 'host');" value="">
|
<?php echo _('task::cindexer:host') ?> : <input type="text" name="host" style="width:100px;" onchange="chgxmltxt(this, 'host');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:port') ?> : <input type="text" name="port" style="width:100px;" onchange="chgxmltxt(this, 'port');" value="">
|
<?php echo _('task::cindexer:port') ?> : <input type="text" name="port" style="width:100px;" onchange="chgxmltxt(this, 'port');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:base') ?> : <input type="text" name="base" style="width:200px;" onchange="chgxmltxt(this, 'base');" value="">
|
<?php echo _('task::cindexer:base') ?> : <input type="text" name="base" style="width:200px;" onchange="chgxmltxt(this, 'base');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:user') ?> : <input type="text" name="user" style="width:200px;" onchange="chgxmltxt(this, 'user');" value="">
|
<?php echo _('task::cindexer:user') ?> : <input type="text" name="user" style="width:200px;" onchange="chgxmltxt(this, 'user');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:password') ?> : <input type="text" name="password" style="width:200px;" onchange="chgxmltxt(this, 'password');" value="">
|
<?php echo _('task::cindexer:password') ?> : <input type="text" name="password" style="width:200px;" onchange="chgxmltxt(this, 'password');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo _('task::cindexer:control socket') ?> : <input type="text" name="socket" style="width:200px;" onchange="chgxmltxt(this, 'socket');" value="">
|
<?php echo _('task::cindexer:control socket') ?> : <input type="text" name="socket" style="width:200px;" onchange="chgxmltxt(this, 'socket');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
<br/>
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php echo _('task::cindexer:MySQL charset') ?> : <input type="text" name="charset" style="width:200px;" onchange="chgxmltxt(this, 'charset');" value="">
|
<?php echo _('task::cindexer:MySQL charset') ?> : <input type="text" name="charset" style="width:200px;" onchange="chgxmltxt(this, 'charset');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@@ -315,60 +315,60 @@ class task_period_cindexer extends task_abstract
|
|||||||
<center>
|
<center>
|
||||||
<div style="margin:10px; padding:5px; border:1px #000000 solid; font-family:monospace; font-size:16px; text-align:left; color:#00e000; background-color:#404040" id="cmd">cmd</div>
|
<div style="margin:10px; padding:5px; border:1px #000000 solid; font-family:monospace; font-size:16px; text-align:left; color:#00e000; background-color:#404040" id="cmd">cmd</div>
|
||||||
</center>
|
</center>
|
||||||
<?php
|
<?php
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $sx_task_settings
|
||||||
|
* @return task_cindexer
|
||||||
|
*/
|
||||||
|
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
||||||
|
{
|
||||||
|
$this->host = trim($sx_task_settings->host);
|
||||||
|
$this->port = trim($sx_task_settings->port);
|
||||||
|
$this->base = trim($sx_task_settings->base);
|
||||||
|
$this->user = trim($sx_task_settings->user);
|
||||||
|
$this->password = trim($sx_task_settings->password);
|
||||||
|
$this->socket = trim($sx_task_settings->socket);
|
||||||
|
$this->use_sbas = p4field::isyes(trim($sx_task_settings->use_sbas));
|
||||||
|
$this->charset = trim($sx_task_settings->charset);
|
||||||
|
$this->nolog = p4field::isyes(trim($sx_task_settings->nolog));
|
||||||
|
$this->winsvc_run = p4field::isyes(trim($sx_task_settings->winsvc_run));
|
||||||
|
$this->binpath = p4string::addEndSlash(trim($sx_task_settings->binpath));
|
||||||
|
|
||||||
|
parent::load_settings($sx_task_settings);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function run2()
|
||||||
|
{
|
||||||
|
$this->method = self::METHOD_PROC_OPEN;
|
||||||
|
$this->method = self::METHOD_FORK;
|
||||||
|
$this->method = self::METHOD_EXEC;
|
||||||
|
|
||||||
|
$cmd = $this->binpath . 'phraseanet_indexer';
|
||||||
|
$nullfile = '/dev/null';
|
||||||
|
|
||||||
|
if ($this->system == 'WINDOWS') {
|
||||||
|
$cmd .= '.exe';
|
||||||
|
$nullfile = 'NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
||||||
*
|
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
||||||
* @param SimpleXMLElement $sx_task_settings
|
|
||||||
* @return task_cindexer
|
|
||||||
*/
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
|
||||||
{
|
|
||||||
$this->host = trim($sx_task_settings->host);
|
|
||||||
$this->port = trim($sx_task_settings->port);
|
|
||||||
$this->base = trim($sx_task_settings->base);
|
|
||||||
$this->user = trim($sx_task_settings->user);
|
|
||||||
$this->password = trim($sx_task_settings->password);
|
|
||||||
$this->socket = trim($sx_task_settings->socket);
|
|
||||||
$this->use_sbas = p4field::isyes(trim($sx_task_settings->use_sbas));
|
|
||||||
$this->charset = trim($sx_task_settings->charset);
|
|
||||||
$this->nolog = p4field::isyes(trim($sx_task_settings->nolog));
|
|
||||||
$this->winsvc_run = p4field::isyes(trim($sx_task_settings->winsvc_run));
|
|
||||||
$this->binpath = p4string::addEndSlash(trim($sx_task_settings->binpath));
|
|
||||||
|
|
||||||
parent::load_settings($sx_task_settings);
|
return;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function run2()
|
|
||||||
{
|
|
||||||
$this->method = self::METHOD_PROC_OPEN;
|
|
||||||
$this->method = self::METHOD_FORK;
|
|
||||||
$this->method = self::METHOD_EXEC;
|
|
||||||
|
|
||||||
$cmd = $this->binpath . 'phraseanet_indexer';
|
|
||||||
$nullfile = '/dev/null';
|
|
||||||
|
|
||||||
if ($this->system == 'WINDOWS') {
|
|
||||||
$cmd .= '.exe';
|
|
||||||
$nullfile = 'NULL';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
|
||||||
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $cmd .= $this->host ? " -h=" . $this->host : '';
|
// $cmd .= $this->host ? " -h=" . $this->host : '';
|
||||||
// $cmd .= $this->port ? " -P=" . $this->port : '';
|
// $cmd .= $this->port ? " -P=" . $this->port : '';
|
||||||
// $cmd .= $this->base ? " -b=" . $this->base : '';
|
// $cmd .= $this->base ? " -b=" . $this->base : '';
|
||||||
@@ -380,196 +380,135 @@ class task_period_cindexer extends task_abstract
|
|||||||
// $cmd .= $this->nolog ? " -n" : '';
|
// $cmd .= $this->nolog ? " -n" : '';
|
||||||
// $cmd .= $this->winsvc_run ? " --run" : '';
|
// $cmd .= $this->winsvc_run ? " --run" : '';
|
||||||
|
|
||||||
$args = array();
|
$args = array();
|
||||||
if ($this->host)
|
if ($this->host)
|
||||||
$args[] = '-h=' . $this->host;
|
$args[] = '-h=' . $this->host;
|
||||||
if ($this->port)
|
if ($this->port)
|
||||||
;
|
;
|
||||||
$args[] = '-P=' . $this->port;
|
$args[] = '-P=' . $this->port;
|
||||||
if ($this->base)
|
if ($this->base)
|
||||||
$args[] = '-b=' . $this->base;
|
$args[] = '-b=' . $this->base;
|
||||||
if ($this->user)
|
if ($this->user)
|
||||||
$args[] = '-u=' . $this->user;
|
$args[] = '-u=' . $this->user;
|
||||||
if ($this->password)
|
if ($this->password)
|
||||||
$args[] = '-p=' . $this->password;
|
$args[] = '-p=' . $this->password;
|
||||||
if ($this->socket)
|
if ($this->socket)
|
||||||
$args[] = '--socket=' . $this->socket;
|
$args[] = '--socket=' . $this->socket;
|
||||||
if ($this->use_sbas)
|
if ($this->use_sbas)
|
||||||
$args[] = '-o';
|
$args[] = '-o';
|
||||||
if ($this->charset)
|
if ($this->charset)
|
||||||
$args[] = '--default-character-set=' . $this->charset;
|
$args[] = '--default-character-set=' . $this->charset;
|
||||||
if ($this->nolog)
|
if ($this->nolog)
|
||||||
$args[] = '-n';
|
$args[] = '-n';
|
||||||
if ($this->winsvc_run)
|
if ($this->winsvc_run)
|
||||||
$args[] = '--run';
|
$args[] = '--run';
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
|
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
|
||||||
|
|
||||||
$this->return_value = self::RETURNSTATUS_STOPPED; // will be normal ending
|
$this->return_value = self::RETURNSTATUS_STOPPED; // will be normal ending
|
||||||
|
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
$descriptors = array();
|
$descriptors = array();
|
||||||
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".log", "a+");
|
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".log", "a+");
|
||||||
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".error.log", "a+");
|
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".error.log", "a+");
|
||||||
$descriptors[1] = array("file", $nullfile, "a+");
|
$descriptors[1] = array("file", $nullfile, "a+");
|
||||||
$descriptors[2] = array("file", $nullfile, "a+");
|
$descriptors[2] = array("file", $nullfile, "a+");
|
||||||
|
|
||||||
$pipes = array();
|
$pipes = array();
|
||||||
|
|
||||||
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args)));
|
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args)));
|
||||||
$process = proc_open($cmd . ' ' . implode(' ', $args), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
|
$process = proc_open($cmd . ' ' . implode(' ', $args), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
|
||||||
|
|
||||||
$pid = NULL;
|
$pid = NULL;
|
||||||
if (is_resource($process)) {
|
if (is_resource($process)) {
|
||||||
$proc_status = proc_get_status($process);
|
$proc_status = proc_get_status($process);
|
||||||
if ($proc_status['running'])
|
if ($proc_status['running'])
|
||||||
$pid = $proc_status['pid'];
|
$pid = $proc_status['pid'];
|
||||||
}
|
|
||||||
|
|
||||||
$qsent = '';
|
|
||||||
$timetokill = NULL;
|
|
||||||
$sock = NULL;
|
|
||||||
|
|
||||||
$this->running = true;
|
|
||||||
|
|
||||||
while ($this->running) {
|
|
||||||
$this->check_task_status();
|
|
||||||
|
|
||||||
if ($this->task_status == self::STATUS_TOSTOP && $this->socket > 0) {
|
|
||||||
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
|
||||||
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
|
||||||
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
|
||||||
socket_write($sock, 'Q', 1);
|
|
||||||
socket_write($sock, "\r\n", strlen("\r\n"));
|
|
||||||
for ($i = 0; $this->running && $i < 5; $i ++ )
|
|
||||||
sleep(1);
|
|
||||||
$qsent = 'Q';
|
|
||||||
$timetokill = time() + 10;
|
|
||||||
} else {
|
|
||||||
socket_close($sock);
|
|
||||||
$sock = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$proc_status = proc_get_status($process);
|
|
||||||
if ( ! $proc_status['running']) {
|
|
||||||
// the cindexer died
|
|
||||||
if ($qsent == 'Q') {
|
|
||||||
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
|
||||||
} elseif ($qsent == 'K') {
|
|
||||||
$this->log(_('task::cindexer:the cindexer has been killed'));
|
|
||||||
} else {
|
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
|
||||||
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
|
|
||||||
}
|
|
||||||
$this->running = false;
|
|
||||||
} else {
|
|
||||||
if ($qsent == 'Q') {
|
|
||||||
if (time() > $timetokill) {
|
|
||||||
// must kill cindexer
|
|
||||||
$this->log(_('task::cindexer:killing the cindexer'));
|
|
||||||
$qsent = 'K';
|
|
||||||
proc_terminate($process); // sigint
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ($i = 0; $this->running && $i < 5; $i ++ )
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($sock) {
|
|
||||||
socket_close($sock);
|
|
||||||
$sock = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (array_keys($pipes) as $offset) {
|
|
||||||
if (is_resource($pipes[$offset]))
|
|
||||||
fclose($pipes[$offset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
proc_terminate($process); // sigint
|
|
||||||
proc_close($process);
|
|
||||||
}
|
}
|
||||||
elseif ($this->method == self::METHOD_FORK) {
|
|
||||||
$pid = pcntl_fork();
|
|
||||||
if ($pid == -1) {
|
|
||||||
die("failed to fork");
|
|
||||||
} elseif ($pid == 0) {
|
|
||||||
// child
|
|
||||||
umask(0);
|
|
||||||
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
|
||||||
if (posix_setsid() < 0)
|
|
||||||
die("Forked process could not detach from terminal\n");
|
|
||||||
//chdir(dirname(__FILE__));
|
|
||||||
fclose(STDIN);
|
|
||||||
fclose(STDOUT);
|
|
||||||
fclose(STDERR);
|
|
||||||
$fdIN = fopen($nullfile, 'r');
|
|
||||||
// $fdOUT = fopen($nullfile, 'a+');
|
|
||||||
// $fdERR = fopen($nullfile, 'a+');
|
|
||||||
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
|
|
||||||
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
|
|
||||||
|
|
||||||
pcntl_exec($cmd, $args);
|
$qsent = '';
|
||||||
|
$timetokill = NULL;
|
||||||
|
$sock = NULL;
|
||||||
|
|
||||||
sleep(2);
|
$this->running = true;
|
||||||
}
|
|
||||||
else {
|
|
||||||
// parent
|
|
||||||
$this->running = true;
|
|
||||||
|
|
||||||
$sigsent = NULL;
|
while ($this->running) {
|
||||||
while ($this->running) {
|
$this->check_task_status();
|
||||||
// is the cindexer alive ?
|
|
||||||
if ( ! posix_kill($pid, 0)) {
|
|
||||||
// dead...
|
|
||||||
if ($sigsent === NULL) {
|
|
||||||
// but it's not my fault
|
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
|
||||||
$this->running = false;
|
|
||||||
// return self::RETURNSTATUS_STOPPED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->check_task_status();
|
if ($this->task_status == self::STATUS_TOSTOP && $this->socket > 0) {
|
||||||
|
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
||||||
if ($this->task_status == self::STATUS_TOSTOP) {
|
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
||||||
posix_kill($pid, ($sigsent = SIGINT));
|
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
||||||
sleep(2);
|
socket_write($sock, 'Q', 1);
|
||||||
}
|
socket_write($sock, "\r\n", strlen("\r\n"));
|
||||||
|
for ($i = 0; $this->running && $i < 5; $i ++ )
|
||||||
$status = NULL;
|
sleep(1);
|
||||||
if (pcntl_wait($status, WNOHANG) == $pid) {
|
$qsent = 'Q';
|
||||||
// child (indexer) has exited
|
$timetokill = time() + 10;
|
||||||
if ($sigsent == SIGINT) {
|
|
||||||
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
|
||||||
} elseif ($sigsent == SIGKILL) {
|
|
||||||
$this->log(_('task::cindexer:the cindexer has been killed'));
|
|
||||||
} else {
|
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
|
||||||
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
|
|
||||||
}
|
|
||||||
$this->running = false;
|
|
||||||
} else {
|
} else {
|
||||||
if ($sigsent == SIGINT && time() > $timetokill) {
|
socket_close($sock);
|
||||||
// must kill cindexer
|
$sock = NULL;
|
||||||
$this->log(_('task::cindexer:killing the cindexer'));
|
|
||||||
$qsent = 'K';
|
|
||||||
posix_kill($pid, ($sigsent = SIGKILL));
|
|
||||||
}
|
|
||||||
sleep(2);
|
|
||||||
}
|
}
|
||||||
} // while running (method fork)
|
}
|
||||||
}
|
}
|
||||||
} elseif ($this->method == self::METHOD_EXEC) {
|
|
||||||
|
$proc_status = proc_get_status($process);
|
||||||
|
if ( ! $proc_status['running']) {
|
||||||
|
// the cindexer died
|
||||||
|
if ($qsent == 'Q') {
|
||||||
|
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
||||||
|
} elseif ($qsent == 'K') {
|
||||||
|
$this->log(_('task::cindexer:the cindexer has been killed'));
|
||||||
|
} else {
|
||||||
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
|
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
|
||||||
|
}
|
||||||
|
$this->running = false;
|
||||||
|
} else {
|
||||||
|
if ($qsent == 'Q') {
|
||||||
|
if (time() > $timetokill) {
|
||||||
|
// must kill cindexer
|
||||||
|
$this->log(_('task::cindexer:killing the cindexer'));
|
||||||
|
$qsent = 'K';
|
||||||
|
proc_terminate($process); // sigint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ($i = 0; $this->running && $i < 5; $i ++ )
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sock) {
|
||||||
|
socket_close($sock);
|
||||||
|
$sock = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array_keys($pipes) as $offset) {
|
||||||
|
if (is_resource($pipes[$offset]))
|
||||||
|
fclose($pipes[$offset]);
|
||||||
|
}
|
||||||
|
|
||||||
|
proc_terminate($process); // sigint
|
||||||
|
proc_close($process);
|
||||||
|
}
|
||||||
|
elseif ($this->method == self::METHOD_FORK) {
|
||||||
|
$pid = pcntl_fork();
|
||||||
|
if ($pid == -1) {
|
||||||
|
die("failed to fork");
|
||||||
|
} elseif ($pid == 0) {
|
||||||
|
// child
|
||||||
umask(0);
|
umask(0);
|
||||||
|
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
||||||
|
if (posix_setsid() < 0)
|
||||||
|
die("Forked process could not detach from terminal\n");
|
||||||
|
//chdir(dirname(__FILE__));
|
||||||
fclose(STDIN);
|
fclose(STDIN);
|
||||||
fclose(STDOUT);
|
fclose(STDOUT);
|
||||||
fclose(STDERR);
|
fclose(STDERR);
|
||||||
$fdIN = fopen($nullfile, 'r');
|
$fdIN = fopen($nullfile, 'r');
|
||||||
|
// $fdOUT = fopen($nullfile, 'a+');
|
||||||
|
// $fdERR = fopen($nullfile, 'a+');
|
||||||
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
|
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
|
||||||
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
|
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
|
||||||
|
|
||||||
@@ -577,8 +516,69 @@ class task_period_cindexer extends task_abstract
|
|||||||
|
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// parent
|
||||||
|
$this->running = true;
|
||||||
|
|
||||||
return($this->return_value);
|
$sigsent = NULL;
|
||||||
|
while ($this->running) {
|
||||||
|
// is the cindexer alive ?
|
||||||
|
if ( ! posix_kill($pid, 0)) {
|
||||||
|
// dead...
|
||||||
|
if ($sigsent === NULL) {
|
||||||
|
// but it's not my fault
|
||||||
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
|
$this->running = false;
|
||||||
|
// return self::RETURNSTATUS_STOPPED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->check_task_status();
|
||||||
|
|
||||||
|
if ($this->task_status == self::STATUS_TOSTOP) {
|
||||||
|
posix_kill($pid, ($sigsent = SIGINT));
|
||||||
|
sleep(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = NULL;
|
||||||
|
if (pcntl_wait($status, WNOHANG) == $pid) {
|
||||||
|
// child (indexer) has exited
|
||||||
|
if ($sigsent == SIGINT) {
|
||||||
|
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
||||||
|
} elseif ($sigsent == SIGKILL) {
|
||||||
|
$this->log(_('task::cindexer:the cindexer has been killed'));
|
||||||
|
} else {
|
||||||
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
|
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
|
||||||
|
}
|
||||||
|
$this->running = false;
|
||||||
|
} else {
|
||||||
|
if ($sigsent == SIGINT && time() > $timetokill) {
|
||||||
|
// must kill cindexer
|
||||||
|
$this->log(_('task::cindexer:killing the cindexer'));
|
||||||
|
$qsent = 'K';
|
||||||
|
posix_kill($pid, ($sigsent = SIGKILL));
|
||||||
|
}
|
||||||
|
sleep(2);
|
||||||
|
}
|
||||||
|
} // while running (method fork)
|
||||||
|
}
|
||||||
|
} elseif ($this->method == self::METHOD_EXEC) {
|
||||||
|
umask(0);
|
||||||
|
fclose(STDIN);
|
||||||
|
fclose(STDOUT);
|
||||||
|
fclose(STDERR);
|
||||||
|
$fdIN = fopen($nullfile, 'r');
|
||||||
|
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
|
||||||
|
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
|
||||||
|
|
||||||
|
pcntl_exec($cmd, $args);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return($this->return_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -160,542 +160,543 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');">
|
||||||
<?php echo('task::_common_:secondes (unite temporelle)') ?><br/>
|
<?php echo('task::_common_:secondes (unite temporelle)') ?><br/>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveChanges(connection_pdo $conn, $taskid, &$taskrow)
|
public function saveChanges(connection_pdo $conn, $taskid, &$taskrow)
|
||||||
{
|
{
|
||||||
$request = http_request::getInstance();
|
$request = http_request::getInstance();
|
||||||
|
|
||||||
$parm = $request->get_parms("xml", "name", "active", "proxy", "proxyport", "period", "debug");
|
$parm = $request->get_parms("xml", "name", "active", "proxy", "proxyport", "period", "debug");
|
||||||
|
|
||||||
if ($parm["xml"] === null) {
|
if ($parm["xml"] === null) {
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if ($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"])) {
|
if ($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"])) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period") as $f) {
|
foreach (array("proxy", "proxyport", "period") as $f) {
|
||||||
if ($parm[$f] !== NULL) {
|
if ($parm[$f] !== NULL) {
|
||||||
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
|
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
|
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
|
||||||
$ns = $domTaskSettings->documentElement->appendChild($domTaskSettings->createElement($f));
|
$ns = $domTaskSettings->documentElement->appendChild($domTaskSettings->createElement($f));
|
||||||
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\n"));
|
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\n"));
|
||||||
}
|
|
||||||
// on fixe sa valeur
|
|
||||||
$ns->appendChild($domTaskSettings->createTextNode($parm[$f]));
|
|
||||||
$xmlchanged = true;
|
|
||||||
}
|
}
|
||||||
|
// on fixe sa valeur
|
||||||
|
$ns->appendChild($domTaskSettings->createTextNode($parm[$f]));
|
||||||
|
$xmlchanged = true;
|
||||||
}
|
}
|
||||||
if ($xmlchanged)
|
|
||||||
$parm["xml"] = $domTaskSettings->saveXML();
|
|
||||||
}
|
}
|
||||||
|
if ($xmlchanged)
|
||||||
|
$parm["xml"] = $domTaskSettings->saveXML();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// si on doit changer le xml, on verifie qu'il est valide
|
// si on doit changer le xml, on verifie qu'il est valide
|
||||||
if ($parm["xml"] && ! @DOMDocument::loadXML($parm["xml"]))
|
if ($parm["xml"] && ! @DOMDocument::loadXML($parm["xml"])) {
|
||||||
return(false);
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "";
|
$sql = "";
|
||||||
$params = array(':task_id' => $taskid);
|
$params = array(':task_id' => $taskid);
|
||||||
if ($parm["xml"] !== NULL) {
|
if ($parm["xml"] !== NULL) {
|
||||||
$sql .= ( $sql ? " ," : "") . "settings = :settings";
|
$sql .= ( $sql ? " ," : "") . "settings = :settings";
|
||||||
$params[':settings'] = $parm['xml'];
|
$params[':settings'] = $parm['xml'];
|
||||||
}
|
}
|
||||||
if ($parm["name"] !== NULL) {
|
if ($parm["name"] !== NULL) {
|
||||||
$sql .= ( $sql ? " ," : "") . "name = :name";
|
$sql .= ( $sql ? " ," : "") . "name = :name";
|
||||||
$params[':name'] = $parm['name'];
|
$params[':name'] = $parm['name'];
|
||||||
}
|
}
|
||||||
if ($parm["active"] !== NULL) {
|
if ($parm["active"] !== NULL) {
|
||||||
$sql .= ( $sql ? " ," : "") . "active = :active";
|
$sql .= ( $sql ? " ," : "") . "active = :active";
|
||||||
$params[':active'] = $parm['active'];
|
$params[':active'] = $parm['active'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sql) {
|
if ($sql) {
|
||||||
try {
|
try {
|
||||||
$sql = "UPDATE task2 SET $sql WHERE task_id = :task_id";
|
$sql = "UPDATE task2 SET $sql WHERE task_id = :task_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
protected $proxy;
|
}
|
||||||
protected $proxyport;
|
protected $proxy;
|
||||||
protected $debug;
|
protected $proxyport;
|
||||||
|
protected $debug;
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->proxy = (string) $sx_task_settings->proxy;
|
$this->proxy = (string) $sx_task_settings->proxy;
|
||||||
$this->proxyport = (string) $sx_task_settings->proxyport;
|
$this->proxyport = (string) $sx_task_settings->proxyport;
|
||||||
|
|
||||||
parent::load_settings($sx_task_settings);
|
parent::load_settings($sx_task_settings);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieve_content(appbox $appbox)
|
protected function retrieve_content(appbox $appbox)
|
||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
$time2sleep = null;
|
$time2sleep = null;
|
||||||
$ftp_exports = array();
|
$ftp_exports = array();
|
||||||
|
|
||||||
$period = $this->period;
|
$period = $this->period;
|
||||||
$time2sleep = (int) ($period);
|
$time2sleep = (int) ($period);
|
||||||
|
|
||||||
$sql = "SELECT id FROM ftp_export WHERE crash>=nbretry
|
$sql = "SELECT id FROM ftp_export WHERE crash>=nbretry
|
||||||
AND date < :date";
|
AND date < :date";
|
||||||
|
|
||||||
$params = array(':date' => phraseadate::format_mysql(new DateTime('-30 days')));
|
$params = array(':date' => phraseadate::format_mysql(new DateTime('-30 days')));
|
||||||
|
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($rs as $rowtask) {
|
||||||
|
$sql = "DELETE FROM ftp_export WHERE id = :export_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute(array(':export_id' => $rowtask['id']));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs as $rowtask) {
|
$sql = "DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id";
|
||||||
$sql = "DELETE FROM ftp_export WHERE id = :export_id";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':export_id' => $rowtask['id']));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':export_id' => $rowtask['id']));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM ftp_export WHERE crash<nbretry ORDER BY id";
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute(array(':export_id' => $rowtask['id']));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
$sql = "SELECT * FROM ftp_export WHERE crash<nbretry ORDER BY id";
|
||||||
$ftp_exports[$row["id"]] = array_merge(array('files' => array()), $row);
|
$stmt = $conn->prepare($sql);
|
||||||
}
|
$stmt->execute();
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "SELECT e.* from ftp_export f
|
foreach ($rs as $row) {
|
||||||
|
$ftp_exports[$row["id"]] = array_merge(array('files' => array()), $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT e.* from ftp_export f
|
||||||
INNER JOIN ftp_export_elements e
|
INNER JOIN ftp_export_elements e
|
||||||
ON (f.id=e.ftp_export_id AND f.crash<f.nbretry
|
ON (f.id=e.ftp_export_id AND f.crash<f.nbretry
|
||||||
AND (e.done = 0 or error=1))
|
AND (e.done = 0 or error=1))
|
||||||
ORDER BY f.id";
|
ORDER BY f.id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs as $rowtask) {
|
foreach ($rs as $rowtask) {
|
||||||
if (isset($ftp_exports[$rowtask["ftp_export_id"]]))
|
if (isset($ftp_exports[$rowtask["ftp_export_id"]]))
|
||||||
$ftp_exports[$rowtask["ftp_export_id"]]["files"][] = $rowtask;
|
$ftp_exports[$rowtask["ftp_export_id"]]["files"][] = $rowtask;
|
||||||
}
|
|
||||||
|
|
||||||
return $ftp_exports;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(appbox $appbox, Array $ftp_export)
|
return $ftp_exports;
|
||||||
{
|
}
|
||||||
$conn = $appbox->get_connection();
|
|
||||||
$registry = $appbox->get_registry();
|
|
||||||
|
|
||||||
$id = $ftp_export['id'];
|
protected function process_one_content(appbox $appbox, Array $ftp_export)
|
||||||
$ftp_export[$id]["crash"] = $ftp_export["crash"];
|
{
|
||||||
$ftp_export[$id]["nbretry"] = $ftp_export["nbretry"] < 1 ? 3 : (int) $ftp_export["nbretry"];
|
$conn = $appbox->get_connection();
|
||||||
|
$registry = $appbox->get_registry();
|
||||||
|
|
||||||
$state = "";
|
$id = $ftp_export['id'];
|
||||||
$ftp_server = $ftp_export["addr"];
|
$ftp_export[$id]["crash"] = $ftp_export["crash"];
|
||||||
$ftp_user_name = $ftp_export["login"];
|
$ftp_export[$id]["nbretry"] = $ftp_export["nbretry"] < 1 ? 3 : (int) $ftp_export["nbretry"];
|
||||||
$ftp_user_pass = $ftp_export["pwd"];
|
|
||||||
$usr_id = (int) $ftp_export["usr_id"];
|
|
||||||
|
|
||||||
$ftpLog = $ftp_user_name . "@" . p4string::addEndSlash($ftp_server) . $ftp_export["destfolder"];
|
$state = "";
|
||||||
|
$ftp_server = $ftp_export["addr"];
|
||||||
|
$ftp_user_name = $ftp_export["login"];
|
||||||
|
$ftp_user_pass = $ftp_export["pwd"];
|
||||||
|
$usr_id = (int) $ftp_export["usr_id"];
|
||||||
|
|
||||||
if ($ftp_export["crash"] == 0) {
|
$ftpLog = $ftp_user_name . "@" . p4string::addEndSlash($ftp_server) . $ftp_export["destfolder"];
|
||||||
$state .= $line = sprintf(
|
|
||||||
_('task::ftp:Etat d\'envoi FTP vers le serveur' .
|
|
||||||
' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL
|
|
||||||
, $ftp_server
|
|
||||||
, $ftp_user_name
|
|
||||||
, $ftp_export["destfolder"]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($this->debug)
|
|
||||||
echo $line;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($ftp_export["crash"] == 0) {
|
||||||
$state .= $line = sprintf(
|
$state .= $line = sprintf(
|
||||||
_("task::ftp:TENTATIVE no %s, %s")
|
_('task::ftp:Etat d\'envoi FTP vers le serveur' .
|
||||||
, $ftp_export["crash"] + 1
|
' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL
|
||||||
, " (" . date('r') . ")"
|
, $ftp_server
|
||||||
) . PHP_EOL;
|
, $ftp_user_name
|
||||||
|
, $ftp_export["destfolder"]
|
||||||
|
);
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo $line;
|
echo $line;
|
||||||
|
}
|
||||||
|
|
||||||
if (($ses_id = phrasea_create_session($usr_id)) == null) {
|
$state .= $line = sprintf(
|
||||||
echo "Unable to create session\n";
|
_("task::ftp:TENTATIVE no %s, %s")
|
||||||
continue;
|
, $ftp_export["crash"] + 1
|
||||||
|
, " (" . date('r') . ")"
|
||||||
|
) . PHP_EOL;
|
||||||
|
|
||||||
|
if ($this->debug)
|
||||||
|
echo $line;
|
||||||
|
|
||||||
|
if (($ses_id = phrasea_create_session($usr_id)) == null) {
|
||||||
|
echo "Unable to create session\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! ($ph_session = phrasea_open_session($ses_id, $usr_id))) {
|
||||||
|
echo "Unable to open session\n";
|
||||||
|
phrasea_close_session($ses_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$ssl = ($ftp_export['ssl'] == '1');
|
||||||
|
$ftp_client = new ftpclient($ftp_server, 21, 300, $ssl, $this->proxy, $this->proxyport);
|
||||||
|
$ftp_client->login($ftp_user_name, $ftp_user_pass);
|
||||||
|
|
||||||
|
if ($ftp_export["passif"] == "1") {
|
||||||
|
try {
|
||||||
|
$ftp_client->passive(true);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! ($ph_session = phrasea_open_session($ses_id, $usr_id))) {
|
if (trim($ftp_export["destfolder"]) != '') {
|
||||||
echo "Unable to open session\n";
|
try {
|
||||||
phrasea_close_session($ses_id);
|
$ftp_client->chdir($ftp_export["destfolder"]);
|
||||||
continue;
|
$ftp_export["destfolder"] = '/' . $ftp_export["destfolder"];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$ftp_export["destfolder"] = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (trim($ftp_export["foldertocreate"]) != '') {
|
||||||
$ssl = ($ftp_export['ssl'] == '1');
|
try {
|
||||||
$ftp_client = new ftpclient($ftp_server, 21, 300, $ssl, $this->proxy, $this->proxyport);
|
$ftp_client->mkdir($ftp_export["foldertocreate"]);
|
||||||
$ftp_client->login($ftp_user_name, $ftp_user_pass);
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
if ($ftp_export["passif"] == "1") {
|
|
||||||
try {
|
|
||||||
$ftp_client->passive(true);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if (trim($ftp_export["destfolder"]) != '') {
|
$new_dir = $ftp_client->add_end_slash($ftp_export["destfolder"])
|
||||||
try {
|
. $ftp_export["foldertocreate"];
|
||||||
$ftp_client->chdir($ftp_export["destfolder"]);
|
$ftp_client->chdir($new_dir);
|
||||||
$ftp_export["destfolder"] = '/' . $ftp_export["destfolder"];
|
} catch (Exception $e) {
|
||||||
} catch (Exception $e) {
|
echo $e->getMessage();
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$ftp_export["destfolder"] = '/';
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($ftp_export["foldertocreate"]) != '') {
|
$obj = array();
|
||||||
try {
|
|
||||||
$ftp_client->mkdir($ftp_export["foldertocreate"]);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$new_dir = $ftp_client->add_end_slash($ftp_export["destfolder"])
|
|
||||||
. $ftp_export["foldertocreate"];
|
|
||||||
$ftp_client->chdir($new_dir);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj = array();
|
$basefolder = '';
|
||||||
|
if ( ! in_array(trim($ftp_export["destfolder"]), array('.', './', '')))
|
||||||
|
$basefolder = p4string::addEndSlash($ftp_export["destfolder"]);
|
||||||
|
|
||||||
$basefolder = '';
|
$basefolder .= $ftp_export["foldertocreate"];
|
||||||
if ( ! in_array(trim($ftp_export["destfolder"]), array('.', './', '')))
|
|
||||||
$basefolder = p4string::addEndSlash($ftp_export["destfolder"]);
|
|
||||||
|
|
||||||
$basefolder .= $ftp_export["foldertocreate"];
|
if (in_array(trim($basefolder), array('.', './', '')))
|
||||||
|
$basefolder = '/';
|
||||||
|
|
||||||
if (in_array(trim($basefolder), array('.', './', '')))
|
foreach ($ftp_export['files'] as $fileid => $file) {
|
||||||
$basefolder = '/';
|
$base_id = $file["base_id"];
|
||||||
|
$record_id = $file["record_id"];
|
||||||
|
$subdef = $file['subdef'];
|
||||||
|
|
||||||
foreach ($ftp_export['files'] as $fileid => $file) {
|
try {
|
||||||
$base_id = $file["base_id"];
|
$sbas_id = phrasea::sbasFromBas($base_id);
|
||||||
$record_id = $file["record_id"];
|
$record = new record_adapter($sbas_id, $record_id);
|
||||||
$subdef = $file['subdef'];
|
|
||||||
|
|
||||||
try {
|
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
|
||||||
$sbas_id = phrasea::sbasFromBas($base_id);
|
|
||||||
$record = new record_adapter($sbas_id, $record_id);
|
|
||||||
|
|
||||||
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
|
$remotefile = $file["filename"];
|
||||||
|
|
||||||
$remotefile = $file["filename"];
|
if ($subdef == 'caption') {
|
||||||
|
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
|
||||||
|
|
||||||
if ($subdef == 'caption') {
|
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
|
||||||
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
|
if (file_put_contents($localfile, $desc) === false) {
|
||||||
|
throw new Exception('Impossible de creer un fichier temporaire');
|
||||||
|
}
|
||||||
|
} elseif ($subdef == 'caption-yaml') {
|
||||||
|
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $ftp_export["businessfields"]);
|
||||||
|
|
||||||
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
|
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
|
||||||
if (file_put_contents($localfile, $desc) === false) {
|
if (file_put_contents($localfile, $desc) === false) {
|
||||||
throw new Exception('Impossible de creer un fichier temporaire');
|
throw new Exception('Impossible de creer un fichier temporaire');
|
||||||
}
|
}
|
||||||
} elseif ($subdef == 'caption-yaml') {
|
} else {
|
||||||
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $ftp_export["businessfields"]);
|
$sd = $record->get_subdefs();
|
||||||
|
|
||||||
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
|
if ( ! $sd || ! isset($sd[$subdef])) {
|
||||||
if (file_put_contents($localfile, $desc) === false) {
|
continue;
|
||||||
throw new Exception('Impossible de creer un fichier temporaire');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$sd = $record->get_subdefs();
|
|
||||||
|
|
||||||
if ( ! $sd || ! isset($sd[$subdef])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$localfile = $sd[$subdef]->get_pathfile();
|
|
||||||
if ( ! file_exists($localfile)) {
|
|
||||||
throw new Exception('Le fichier local n\'existe pas');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_folder = p4string::delEndSlash(str_replace('//', '/', $basefolder . $file['folder']));
|
$localfile = $sd[$subdef]->get_pathfile();
|
||||||
|
if ( ! file_exists($localfile)) {
|
||||||
if ($ftp_client->pwd() != $current_folder) {
|
throw new Exception('Le fichier local n\'existe pas');
|
||||||
try {
|
|
||||||
$ftp_client->chdir($current_folder);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ftp_client->put($remotefile, $localfile);
|
$current_folder = p4string::delEndSlash(str_replace('//', '/', $basefolder . $file['folder']));
|
||||||
|
|
||||||
|
if ($ftp_client->pwd() != $current_folder) {
|
||||||
$obj[] = array(
|
try {
|
||||||
"name" => $subdef, "size" => filesize($localfile),
|
$ftp_client->chdir($current_folder);
|
||||||
"shortXml" => ($sdcaption ? $sdcaption : '')
|
} catch (Exception $e) {
|
||||||
);
|
echo $e->getMessage();
|
||||||
|
|
||||||
if ($subdef == 'caption') {
|
|
||||||
unlink($localfile);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export_elements
|
$ftp_client->put($remotefile, $localfile);
|
||||||
|
|
||||||
|
|
||||||
|
$obj[] = array(
|
||||||
|
"name" => $subdef, "size" => filesize($localfile),
|
||||||
|
"shortXml" => ($sdcaption ? $sdcaption : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($subdef == 'caption') {
|
||||||
|
unlink($localfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE ftp_export_elements
|
||||||
SET done='1', error='0' WHERE id = :file_id";
|
SET done='1', error='0' WHERE id = :file_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':file_id' => $file['id']));
|
$stmt->execute(array(':file_id' => $file['id']));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$this->logexport($appbox->get_session(), $record, $obj, $ftpLog);
|
$this->logexport($appbox->get_session(), $record, $obj, $ftpLog);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' .
|
$state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' .
|
||||||
' (Export du Document) : Transfert cancelled (le document n\'existe plus)')
|
' (Export du Document) : Transfert cancelled (le document n\'existe plus)')
|
||||||
, basename($localfile), $record_id
|
, basename($localfile), $record_id
|
||||||
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>";
|
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>";
|
||||||
|
|
||||||
if ($this->debug)
|
|
||||||
echo $line;
|
|
||||||
|
|
||||||
$done = $file['error'];
|
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export_elements
|
|
||||||
SET done = :done, error='1' WHERE id = :file_id";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':done' => $done, ':file_id' => $file['id']));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ftp_export['logfile']) {
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "\nlogfile \n";
|
echo $line;
|
||||||
|
|
||||||
$date = new DateTime();
|
$done = $file['error'];
|
||||||
$remote_file = $date->format('U');
|
|
||||||
|
|
||||||
$sql = 'SELECT filename, folder
|
$sql = "UPDATE ftp_export_elements
|
||||||
|
SET done = :done, error='1' WHERE id = :file_id";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute(array(':done' => $done, ':file_id' => $file['id']));
|
||||||
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ftp_export['logfile']) {
|
||||||
|
if ($this->debug)
|
||||||
|
echo "\nlogfile \n";
|
||||||
|
|
||||||
|
$date = new DateTime();
|
||||||
|
$remote_file = $date->format('U');
|
||||||
|
|
||||||
|
$sql = 'SELECT filename, folder
|
||||||
FROM ftp_export_elements
|
FROM ftp_export_elements
|
||||||
WHERE ftp_export_id = :ftp_export_id
|
WHERE ftp_export_id = :ftp_export_id
|
||||||
AND error = "0" AND done="1"';
|
AND error = "0" AND done="1"';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':ftp_export_id' => $id));
|
|
||||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$buffer = '#transfert finished ' . $date->format(DATE_ATOM) . "\n\n";
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
$filename = $row['filename'];
|
|
||||||
$folder = $row['folder'];
|
|
||||||
|
|
||||||
$root = $ftp_export['foldertocreate'];
|
|
||||||
|
|
||||||
$buffer .= $root . '/' . $folder . $filename . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmpfile = $registry->get('GV_RootPath') . 'tmp/tmpftpbuffer' . $date->format('U') . '.txt';
|
|
||||||
|
|
||||||
file_put_contents($tmpfile, $buffer);
|
|
||||||
|
|
||||||
$remotefile = $date->format('U') . '-transfert.log';
|
|
||||||
|
|
||||||
$ftp_client->chdir($ftp_export["destfolder"]);
|
|
||||||
|
|
||||||
$ftp_client->put($remotefile, $tmpfile);
|
|
||||||
|
|
||||||
unlink($tmpfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
$ftp_client->close();
|
|
||||||
unset($ftp_client);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$state .= $line = $e . "\n";
|
|
||||||
|
|
||||||
if ($this->debug)
|
|
||||||
echo $line;
|
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()
|
|
||||||
WHERE id = :export_id";
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $ftp_export['id']));
|
$stmt->execute(array(':ftp_export_id' => $id));
|
||||||
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
unset($ftp_client);
|
$buffer = '#transfert finished ' . $date->format(DATE_ATOM) . "\n\n";
|
||||||
}
|
|
||||||
$this->finalize($appbox, $id);
|
foreach ($rs as $row) {
|
||||||
phrasea_close_session($ses_id);
|
$filename = $row['filename'];
|
||||||
}
|
$folder = $row['folder'];
|
||||||
|
|
||||||
|
$root = $ftp_export['foldertocreate'];
|
||||||
|
|
||||||
|
$buffer .= $root . '/' . $folder . $filename . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmpfile = $registry->get('GV_RootPath') . 'tmp/tmpftpbuffer' . $date->format('U') . '.txt';
|
||||||
|
|
||||||
|
file_put_contents($tmpfile, $buffer);
|
||||||
|
|
||||||
|
$remotefile = $date->format('U') . '-transfert.log';
|
||||||
|
|
||||||
|
$ftp_client->chdir($ftp_export["destfolder"]);
|
||||||
|
|
||||||
|
$ftp_client->put($remotefile, $tmpfile);
|
||||||
|
|
||||||
|
unlink($tmpfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ftp_client->close();
|
||||||
|
unset($ftp_client);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$state .= $line = $e . "\n";
|
||||||
|
|
||||||
|
if ($this->debug)
|
||||||
|
echo $line;
|
||||||
|
|
||||||
|
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()
|
||||||
|
WHERE id = :export_id";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute(array(':export_id' => $ftp_export['id']));
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
unset($ftp_client);
|
||||||
|
}
|
||||||
|
$this->finalize($appbox, $id);
|
||||||
|
phrasea_close_session($ses_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function post_process_one_content(appbox $appbox, Array $row)
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function finalize(appbox $appbox, $id)
|
||||||
|
{
|
||||||
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
|
$sql = 'SELECT crash, nbretry FROM ftp_export
|
||||||
|
WHERE id = :export_id';
|
||||||
|
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute(array(':export_id' => $id));
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
if ($row && $row['crash'] >= $row['nbretry']) {
|
||||||
|
$this->send_mails($appbox, $id);
|
||||||
|
|
||||||
protected function post_process_one_content(appbox $appbox, Array $row)
|
|
||||||
{
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function finalize(appbox $appbox, $id)
|
$sql = 'SELECT count(id) as total, sum(error) as errors, sum(done) as done
|
||||||
{
|
|
||||||
$conn = $appbox->get_connection();
|
|
||||||
|
|
||||||
$sql = 'SELECT crash, nbretry FROM ftp_export
|
|
||||||
WHERE id = :export_id';
|
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':export_id' => $id));
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
if ($row && $row['crash'] >= $row['nbretry']) {
|
|
||||||
$this->send_mails($appbox, $id);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT count(id) as total, sum(error) as errors, sum(done) as done
|
|
||||||
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($row && $row['done'] == (int) $row['total']) {
|
if ($row && $row['done'] == (int) $row['total']) {
|
||||||
$this->send_mails($appbox, $id);
|
$this->send_mails($appbox, $id);
|
||||||
|
|
||||||
if ((int) $row['errors'] === 0) {
|
if ((int) $row['errors'] === 0) {
|
||||||
$sql = 'DELETE FROM ftp_export WHERE id = :export_id';
|
$sql = 'DELETE FROM ftp_export WHERE id = :export_id';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$sql = 'DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
$sql = 'DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
} else {
|
} else {
|
||||||
$sql = 'UPDATE ftp_export SET crash = nbretry';
|
$sql = 'UPDATE ftp_export SET crash = nbretry';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$sql = 'DELET FROM ftp_export_elements WHERE ftp_export_id = :export_id AND error="0"';
|
$sql = 'DELET FROM ftp_export_elements WHERE ftp_export_id = :export_id AND error="0"';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function send_mails(appbox $appbox, $id)
|
|
||||||
{
|
|
||||||
$conn = $appbox->get_connection();
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
|
|
||||||
$sql = 'SELECT filename, base_id, record_id, subdef, error, done
|
|
||||||
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
|
||||||
|
|
||||||
$transferts = array();
|
|
||||||
|
|
||||||
$transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes');
|
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':export_id' => $id));
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
if ($row['error'] == '0' && $row['done'] == '1') {
|
|
||||||
$transferts[] =
|
|
||||||
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
|
|
||||||
, $row["record_id"], $row["filename"]
|
|
||||||
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"]))
|
|
||||||
, phrasea::bas_names($row['base_id']), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
|
|
||||||
} else {
|
|
||||||
$transferts[] =
|
|
||||||
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
|
|
||||||
, $row["record_id"], $row["filename"]
|
|
||||||
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"])), phrasea::bas_names($row['base_id'])
|
|
||||||
, $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>';
|
|
||||||
$transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT addr, crash, nbretry, sendermail, mail, text_mail_sender, text_mail_receiver
|
|
||||||
FROM ftp_export WHERE id = :export_id';
|
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':export_id' => $id));
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
if ($row) {
|
|
||||||
if ($row['crash'] >= $row['nbretry'])
|
|
||||||
$connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant');
|
|
||||||
else
|
|
||||||
$connection_status = _('La connection vers le serveur distant est OK');
|
|
||||||
|
|
||||||
$text_mail_sender = $row['text_mail_sender'];
|
|
||||||
$text_mail_receiver = $row['text_mail_receiver'];
|
|
||||||
$mail = $row['mail'];
|
|
||||||
$sendermail = $row['sendermail'];
|
|
||||||
$ftp_server = $row['addr'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = "\n<br/>----------------------------------------<br/>\n";
|
|
||||||
$message = "<div>" . $connection_status . "</div>\n";
|
|
||||||
$message .= "<div>" . $transfert_status . "</div>\n";
|
|
||||||
$message .= "<div>" . _("task::ftp:Details des fichiers") . "</div>\n";
|
|
||||||
|
|
||||||
$message .= "<ul>";
|
|
||||||
$message .= implode("\n", $transferts);
|
|
||||||
$message .= "</ul>";
|
|
||||||
|
|
||||||
$sender_message = $text_mail_sender . $message;
|
|
||||||
$receiver_message = $text_mail_receiver . $message;
|
|
||||||
|
|
||||||
$subject = sprintf(
|
|
||||||
_('task::ftp:Status about your FTP transfert from %1$s to %2$s')
|
|
||||||
, $registry->get('GV_homeTitle'), $ftp_server
|
|
||||||
);
|
|
||||||
|
|
||||||
mail::ftp_sent($sendermail, $subject, $sender_message);
|
|
||||||
|
|
||||||
mail::ftp_receive($mail, $receiver_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
function logexport(Session_Handler $session, record_adapter $record, $obj, $ftpLog)
|
|
||||||
{
|
|
||||||
foreach ($obj as $oneObj) {
|
|
||||||
$session->get_logger($record->get_databox())
|
|
||||||
->log($record, Session_Logger::EVENT_EXPORTFTP, $ftpLog, '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function send_mails(appbox $appbox, $id)
|
||||||
|
{
|
||||||
|
$conn = $appbox->get_connection();
|
||||||
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
|
$sql = 'SELECT filename, base_id, record_id, subdef, error, done
|
||||||
|
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
||||||
|
|
||||||
|
$transferts = array();
|
||||||
|
|
||||||
|
$transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes');
|
||||||
|
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute(array(':export_id' => $id));
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($rs as $row) {
|
||||||
|
if ($row['error'] == '0' && $row['done'] == '1') {
|
||||||
|
$transferts[] =
|
||||||
|
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
|
||||||
|
, $row["record_id"], $row["filename"]
|
||||||
|
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"]))
|
||||||
|
, phrasea::bas_names($row['base_id']), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
|
||||||
|
} else {
|
||||||
|
$transferts[] =
|
||||||
|
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
|
||||||
|
, $row["record_id"], $row["filename"]
|
||||||
|
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"])), phrasea::bas_names($row['base_id'])
|
||||||
|
, $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>';
|
||||||
|
$transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT addr, crash, nbretry, sendermail, mail, text_mail_sender, text_mail_receiver
|
||||||
|
FROM ftp_export WHERE id = :export_id';
|
||||||
|
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute(array(':export_id' => $id));
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
if ($row) {
|
||||||
|
if ($row['crash'] >= $row['nbretry'])
|
||||||
|
$connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant');
|
||||||
|
else
|
||||||
|
$connection_status = _('La connection vers le serveur distant est OK');
|
||||||
|
|
||||||
|
$text_mail_sender = $row['text_mail_sender'];
|
||||||
|
$text_mail_receiver = $row['text_mail_receiver'];
|
||||||
|
$mail = $row['mail'];
|
||||||
|
$sendermail = $row['sendermail'];
|
||||||
|
$ftp_server = $row['addr'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = "\n<br/>----------------------------------------<br/>\n";
|
||||||
|
$message = "<div>" . $connection_status . "</div>\n";
|
||||||
|
$message .= "<div>" . $transfert_status . "</div>\n";
|
||||||
|
$message .= "<div>" . _("task::ftp:Details des fichiers") . "</div>\n";
|
||||||
|
|
||||||
|
$message .= "<ul>";
|
||||||
|
$message .= implode("\n", $transferts);
|
||||||
|
$message .= "</ul>";
|
||||||
|
|
||||||
|
$sender_message = $text_mail_sender . $message;
|
||||||
|
$receiver_message = $text_mail_receiver . $message;
|
||||||
|
|
||||||
|
$subject = sprintf(
|
||||||
|
_('task::ftp:Status about your FTP transfert from %1$s to %2$s')
|
||||||
|
, $registry->get('GV_homeTitle'), $ftp_server
|
||||||
|
);
|
||||||
|
|
||||||
|
mail::ftp_sent($sendermail, $subject, $sender_message);
|
||||||
|
|
||||||
|
mail::ftp_receive($mail, $receiver_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
function logexport(Session_Handler $session, record_adapter $record, $obj, $ftpLog)
|
||||||
|
{
|
||||||
|
foreach ($obj as $oneObj) {
|
||||||
|
$session->get_logger($record->get_databox())
|
||||||
|
->log($record, Session_Logger::EVENT_EXPORTFTP, $ftpLog, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -139,14 +139,14 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:proxy') ?>
|
<?php echo('task::ftp:proxy') ?>
|
||||||
<input type="text" name="proxy" style="width:400px;" onchange="chgxmltxt(this, 'proxy');"><br/>
|
<input type="text" name="proxy" style="width:400px;" onchange="chgxmltxt(this, 'proxy');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:proxy port') ?>
|
<?php echo('task::ftp:proxy port') ?>
|
||||||
<input type="text" name="proxyport" style="width:400px;" onchange="chgxmltxt(this, 'proxyport');"><br/>
|
<input type="text" name="proxyport" style="width:400px;" onchange="chgxmltxt(this, 'proxyport');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo('task::ftp:host') ?>
|
<?php echo('task::ftp:host') ?>
|
||||||
<input type="text" name="host" style="width:400px;" onchange="chgxmltxt(this, 'host');"><br/>
|
<input type="text" name="host" style="width:400px;" onchange="chgxmltxt(this, 'host');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:port') ?>
|
<?php echo('task::ftp:port') ?>
|
||||||
@@ -155,13 +155,13 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
<?php echo('task::ftp:user') ?>
|
<?php echo('task::ftp:user') ?>
|
||||||
<input type="text" name="user" style="width:400px;" onchange="chgxmltxt(this, 'user');"><br/>
|
<input type="text" name="user" style="width:400px;" onchange="chgxmltxt(this, 'user');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:password') ?>
|
<?php echo('task::ftp:password') ?>
|
||||||
<input type="password" name="password" style="width:400px;" onchange="chgxmltxt(this, 'password');"><br/>
|
<input type="password" name="password" style="width:400px;" onchange="chgxmltxt(this, 'password');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:chemin distant') ?>
|
<?php echo('task::ftp:chemin distant') ?>
|
||||||
<input type="text" name="ftppath" style="width:400px;" onchange="chgxmltxt(this, 'ftppath');"><br/>
|
<input type="text" name="ftppath" style="width:400px;" onchange="chgxmltxt(this, 'ftppath');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:localpath') ?>
|
<?php echo('task::ftp:localpath') ?>
|
||||||
<input type="text" name="localpath" style="width:400px;" onchange="chgxmltxt(this, 'localpath');"><br/>
|
<input type="text" name="localpath" style="width:400px;" onchange="chgxmltxt(this, 'localpath');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@@ -218,8 +218,9 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// si on doit changer le xml, on verifie qu'il est valide
|
// si on doit changer le xml, on verifie qu'il est valide
|
||||||
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"]))
|
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"])) {
|
||||||
return(false);
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "";
|
$sql = "";
|
||||||
$params = array(':task_id' => $taskid);
|
$params = array(':task_id' => $taskid);
|
||||||
|
@@ -399,16 +399,16 @@ class task_period_outofdate extends task_abstract
|
|||||||
$sbas_list = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
$sbas_list = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<?php echo _('task::outofdate:Base') ?> :
|
<?php echo _('task::outofdate:Base') ?> :
|
||||||
|
|
||||||
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
||||||
<option value="">...</option>
|
<option value="">...</option>
|
||||||
<?php
|
<?php
|
||||||
foreach ($sbas_list as $databox) {
|
foreach ($sbas_list as $databox) {
|
||||||
$selected = '';
|
$selected = '';
|
||||||
print("\t\t\t\t<option value=\"" . $databox->get_sbas_id() . "\" $selected>" . p4string::MakeString($databox->get_viewname(), "form") . "</option>\n");
|
print("\t\t\t\t<option value=\"" . $databox->get_sbas_id() . "\" $selected>" . p4string::MakeString($databox->get_viewname(), "form") . "</option>\n");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -416,9 +416,9 @@ class task_period_outofdate extends task_abstract
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
||||||
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
|
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<table id="OUTOFDATETAB" style="margin-right:10px; ">
|
<table id="OUTOFDATETAB" style="margin-right:10px; ">
|
||||||
@@ -427,7 +427,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%;">
|
<td style="width:20%;">
|
||||||
<?php echo _('task::outofdate:before') ?>
|
<?php echo _('task::outofdate:before') ?>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="2" style="width:20%; white-space:nowrap;">
|
<td colspan="2" style="width:20%; white-space:nowrap;">
|
||||||
<select style="width:100px" name="field1" id="field1" onchange="chgxmlpopup(this, 'field1');"></select>
|
<select style="width:100px" name="field1" id="field1" onchange="chgxmlpopup(this, 'field1');"></select>
|
||||||
@@ -439,7 +439,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
<input name="fieldDv1" id="fieldDv1" onchange="chgxmltxt(this, 'fieldDv1');" type="text" style="width:30px" value="0"></input> <?php echo _('admin::taskoutofdate: days ') ?>
|
<input name="fieldDv1" id="fieldDv1" onchange="chgxmltxt(this, 'fieldDv1');" type="text" style="width:30px" value="0"></input> <?php echo _('admin::taskoutofdate: days ') ?>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%; padding-left:20px; padding-right:20px;">
|
<td style="width:20%; padding-left:20px; padding-right:20px;">
|
||||||
<?php echo _('task::outofdate:between') ?>
|
<?php echo _('task::outofdate:between') ?>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="2" style="width:20%; white-space:nowrap;">
|
<td colspan="2" style="width:20%; white-space:nowrap;">
|
||||||
<select style="width:100px" name="field2" id="field2" onchange="chgxmlpopup(this, 'field2');"></select>
|
<select style="width:100px" name="field2" id="field2" onchange="chgxmlpopup(this, 'field2');"></select>
|
||||||
@@ -451,12 +451,12 @@ class task_period_outofdate extends task_abstract
|
|||||||
<input name="fieldDv2" id="fieldDv2" onchange="chgxmltxt(this, 'fieldDv2');" type="text" style="width:30px" value="0"></input> <?php echo _('admin::taskoutofdate: days ') ?>
|
<input name="fieldDv2" id="fieldDv2" onchange="chgxmltxt(this, 'fieldDv2');" type="text" style="width:30px" value="0"></input> <?php echo _('admin::taskoutofdate: days ') ?>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%;">
|
<td style="width:20%;">
|
||||||
<?php echo _('task::outofdate:after') ?>
|
<?php echo _('task::outofdate:after') ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="white-space:nowrap;">
|
<td style="white-space:nowrap;">
|
||||||
<?php echo _('task::outofdate:coll.') ?> :
|
<?php echo _('task::outofdate:coll.') ?> :
|
||||||
</td>
|
</td>
|
||||||
<td colspan="2" style="border-right:1px solid #000000">
|
<td colspan="2" style="border-right:1px solid #000000">
|
||||||
<select name="coll0" id="coll0" onchange="chgxmlpopup(this, 'coll0');"></select>
|
<select name="coll0" id="coll0" onchange="chgxmlpopup(this, 'coll0');"></select>
|
||||||
@@ -470,7 +470,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="white-space:nowrap;">
|
<td style="white-space:nowrap;">
|
||||||
<?php echo _('task::outofdate:status') ?> :<br/>
|
<?php echo _('task::outofdate:status') ?> :<br/>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="2" style="border-right:1px solid #000000">
|
<td colspan="2" style="border-right:1px solid #000000">
|
||||||
<select name="status0" id="status0" onchange="chgxmlpopup(this, 'status0');"></select>
|
<select name="status0" id="status0" onchange="chgxmlpopup(this, 'status0');"></select>
|
||||||
|
@@ -215,104 +215,104 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
||||||
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo sprintf(_("task::_common_:passer tous les %s records a l'etape suivante"), '<input type="text" name="flush" style="width:40px;" onchange="chgxmltxt(this, \'flush\');" value="">'); ?>
|
<?php echo sprintf(_("task::_common_:passer tous les %s records a l'etape suivante"), '<input type="text" name="flush" style="width:40px;" onchange="chgxmltxt(this, \'flush\');" value="">'); ?>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:relancer la tache tous les') ?>
|
<?php echo _('task::_common_:relancer la tache tous les') ?>
|
||||||
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
|
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
|
||||||
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>
|
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>
|
||||||
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
|
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
|
||||||
Mo
|
Mo
|
||||||
<br/>
|
<br/>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function flush_records_sbas()
|
protected function flush_records_sbas()
|
||||||
{
|
{
|
||||||
$sql = implode(', ', $this->recs_to_write);
|
$sql = implode(', ', $this->recs_to_write);
|
||||||
|
|
||||||
if ($sql != '') {
|
if ($sql != '') {
|
||||||
$this->log(sprintf(
|
$this->log(sprintf(
|
||||||
'setting %d record(s) to subdef meta writing'
|
'setting %d record(s) to subdef meta writing'
|
||||||
, count($this->recs_to_write)
|
, count($this->recs_to_write)
|
||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$connbas = connection::getPDOConnection($this->sbas_id);
|
$connbas = connection::getPDOConnection($this->sbas_id);
|
||||||
$sql = 'UPDATE record
|
$sql = 'UPDATE record
|
||||||
SET status=(status & ~0x03),
|
SET status=(status & ~0x03),
|
||||||
jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ')
|
jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ')
|
||||||
WHERE record_id IN (' . $sql . ')';
|
WHERE record_id IN (' . $sql . ')';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->recs_to_write = array();
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
$this->recs_to_write = array();
|
||||||
|
|
||||||
public function retrieve_sbas_content(databox $databox)
|
return $this;
|
||||||
{
|
}
|
||||||
$connbas = $databox->get_connection();
|
|
||||||
|
|
||||||
$sql = 'SELECT coll_id, record_id
|
public function retrieve_sbas_content(databox $databox)
|
||||||
|
{
|
||||||
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
|
$sql = 'SELECT coll_id, record_id
|
||||||
FROM record
|
FROM record
|
||||||
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
|
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
|
||||||
AND parent_record_id = 0
|
AND parent_record_id = 0
|
||||||
ORDER BY record_id DESC LIMIT 0, 20';
|
ORDER BY record_id DESC LIMIT 0, 20';
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return $rs;
|
return $rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process_one_content(databox $databox, Array $row)
|
||||||
|
{
|
||||||
|
$record_id = $row['record_id'];
|
||||||
|
$this->log(sprintf(
|
||||||
|
"Generate subdefs for : sbas_id %s / record %s "
|
||||||
|
, $this->sbas_id, $record_id));
|
||||||
|
$record = new record_adapter($this->sbas_id, $record_id);
|
||||||
|
|
||||||
|
$record->generate_subdefs($databox, null);
|
||||||
|
|
||||||
|
$this->recs_to_write[] = $record->get_record_id();
|
||||||
|
|
||||||
|
if (count($this->recs_to_write) >= $this->record_buffer_size) {
|
||||||
|
$this->flush_records_sbas();
|
||||||
}
|
}
|
||||||
|
unset($record);
|
||||||
|
|
||||||
public function process_one_content(databox $databox, Array $row)
|
return $this;
|
||||||
{
|
}
|
||||||
$record_id = $row['record_id'];
|
|
||||||
$this->log(sprintf(
|
|
||||||
"Generate subdefs for : sbas_id %s / record %s "
|
|
||||||
, $this->sbas_id, $record_id));
|
|
||||||
$record = new record_adapter($this->sbas_id, $record_id);
|
|
||||||
|
|
||||||
$record->generate_subdefs($databox, null);
|
protected function post_process_one_content(databox $databox, Array $row)
|
||||||
|
{
|
||||||
$this->recs_to_write[] = $record->get_record_id();
|
$connbas = $databox->get_connection();
|
||||||
|
$sql = 'UPDATE record
|
||||||
if (count($this->recs_to_write) >= $this->record_buffer_size) {
|
|
||||||
$this->flush_records_sbas();
|
|
||||||
}
|
|
||||||
unset($record);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function post_process_one_content(databox $databox, Array $row)
|
|
||||||
{
|
|
||||||
$connbas = $databox->get_connection();
|
|
||||||
$sql = 'UPDATE record
|
|
||||||
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
|
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
|
||||||
WHERE record_id=:record_id';
|
WHERE record_id=:record_id';
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $row['record_id']));
|
$stmt->execute(array(':record_id' => $row['record_id']));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -115,7 +115,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
parent.chgsbas(<?php echo $form ?>[pops[j].name]);
|
parent.chgsbas(<?php echo $form ?>[pops[j].name]);
|
||||||
}
|
}
|
||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
parent.calccmd();
|
parent.calccmd();
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
@@ -305,16 +305,16 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<?php echo _('task::outofdate:Base') ?> :
|
<?php echo _('task::outofdate:Base') ?> :
|
||||||
|
|
||||||
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
||||||
<option value="">...</option>
|
<option value="">...</option>
|
||||||
<?php
|
<?php
|
||||||
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
||||||
foreach ($sbas_ids as $databox) {
|
foreach ($sbas_ids as $databox) {
|
||||||
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
|
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -322,9 +322,9 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
||||||
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
|
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<table id="OUTOFDATETAB" style="margin-right:10px; ">
|
<table id="OUTOFDATETAB" style="margin-right:10px; ">
|
||||||
|
@@ -183,188 +183,188 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
||||||
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="checkbox" name="cleardoc" onchange="chgxmlck(this)">
|
<input type="checkbox" name="cleardoc" onchange="chgxmlck(this)">
|
||||||
<?php echo _('task::writemeta:effacer les metadatas non presentes dans la structure') ?>
|
<?php echo _('task::writemeta:effacer les metadatas non presentes dans la structure') ?>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:relancer la tache tous les') ?>
|
<?php echo _('task::_common_:relancer la tache tous les') ?>
|
||||||
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
|
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
|
||||||
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>
|
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>
|
||||||
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
|
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
|
||||||
Mo
|
Mo
|
||||||
<br/>
|
<br/>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
}
|
|
||||||
$out = ob_get_clean();
|
|
||||||
|
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
$out = ob_get_clean();
|
||||||
|
|
||||||
protected function retrieve_sbas_content(databox $databox)
|
return $out;
|
||||||
{
|
|
||||||
$connbas = $databox->get_connection();
|
|
||||||
$subdefgroups = $databox->get_subdef_structure();
|
|
||||||
$metasubdefs = array();
|
|
||||||
|
|
||||||
foreach ($subdefgroups as $type => $subdefs) {
|
|
||||||
foreach ($subdefs as $sub) {
|
|
||||||
$name = $sub->get_name();
|
|
||||||
if ($sub->meta_writeable())
|
|
||||||
$metasubdefs[$name . '_' . $type] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->metasubdefs = $metasubdefs;
|
|
||||||
|
|
||||||
$sql = 'SELECT record_id, coll_id, jeton
|
|
||||||
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
|
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
return $rs;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function format_value($type, $value)
|
|
||||||
{
|
|
||||||
if ($type == 'date') {
|
|
||||||
$value = str_replace(array("-", ":", "/", "."), array(" ", " ", " ", " "), $value);
|
|
||||||
$ip_date_yyyy = 0;
|
|
||||||
$ip_date_mm = 0;
|
|
||||||
$ip_date_dd = 0;
|
|
||||||
$ip_date_hh = 0;
|
|
||||||
$ip_date_nn = 0;
|
|
||||||
$ip_date_ss = 0;
|
|
||||||
switch (sscanf($value, "%d %d %d %d %d %d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd, $ip_date_hh, $ip_date_nn, $ip_date_ss)) {
|
|
||||||
case 1:
|
|
||||||
$value = sprintf("%04d:00:00", $ip_date_yyyy);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$value = sprintf("%04d:%02d:00", $ip_date_yyyy, $ip_date_mm);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
$value = sprintf("%04d:%02d:%02d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$value = '0000:00:00';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function process_one_content(databox $databox, Array $row)
|
|
||||||
{
|
|
||||||
$coll_id = $row['coll_id'];
|
|
||||||
$record_id = $row['record_id'];
|
|
||||||
$jeton = $row['jeton'];
|
|
||||||
|
|
||||||
$record = new record_adapter($this->sbas_id, $record_id);
|
|
||||||
|
|
||||||
$type = $record->get_type();
|
|
||||||
$subdefs = $record->get_subdefs();
|
|
||||||
|
|
||||||
$tsub = array();
|
|
||||||
|
|
||||||
foreach ($subdefs as $name => $subdef) {
|
|
||||||
$write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document');
|
|
||||||
$write_subdef = (($jeton & JETON_WRITE_META_SUBDEF) && isset($this->metasubdefs[$name . '_' . $type]));
|
|
||||||
|
|
||||||
if ($write_document || $write_subdef) {
|
|
||||||
$tsub[$name] = $subdef->get_pathfile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$registry = $databox->get_registry();
|
|
||||||
|
|
||||||
$fields = $record->get_caption()->get_fields();
|
|
||||||
|
|
||||||
$subCMD = '';
|
|
||||||
|
|
||||||
if ($record->get_uuid()) {
|
|
||||||
$subCMD .= ' -XMP-exif:ImageUniqueID=';
|
|
||||||
$subCMD .= escapeshellarg($record->get_uuid());
|
|
||||||
$subCMD .= ' -IPTC:UniqueDocumentID=';
|
|
||||||
$subCMD .= escapeshellarg($record->get_uuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
$meta = $field->get_databox_field();
|
|
||||||
|
|
||||||
/* @var $meta \databox_field */
|
|
||||||
|
|
||||||
if (trim($meta->get_metadata_source()) === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$multi = $meta->is_multi();
|
|
||||||
$type = $meta->get_type();
|
|
||||||
$datas = $field->get_values();
|
|
||||||
|
|
||||||
if ($multi) {
|
|
||||||
foreach ($datas as $value) {
|
|
||||||
$value = $this->format_value($type, $value->getValue());
|
|
||||||
|
|
||||||
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
|
|
||||||
$subCMD .= escapeshellarg($value) . ' ';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$value = array_pop($datas);
|
|
||||||
$datas = $this->format_value($type, $value->getValue());
|
|
||||||
|
|
||||||
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
|
|
||||||
$subCMD .= escapeshellarg($datas) . ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($tsub as $name => $file) {
|
|
||||||
$cmd = '';
|
|
||||||
if ($this->system == 'WINDOWS')
|
|
||||||
$cmd = 'start /B /LOW ';
|
|
||||||
$cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original ');
|
|
||||||
if ($name != 'document' || $this->clear_doc)
|
|
||||||
$cmd .= ' -all:all= ';
|
|
||||||
|
|
||||||
$cmd .= ' -codedcharacterset=utf8 ';
|
|
||||||
|
|
||||||
$cmd .= $subCMD . ' ' . escapeshellarg($file);
|
|
||||||
|
|
||||||
$this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name));
|
|
||||||
|
|
||||||
$s = trim(shell_exec($cmd));
|
|
||||||
|
|
||||||
$this->log("\t" . $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function flush_records_sbas()
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function post_process_one_content(databox $databox, Array $row)
|
|
||||||
{
|
|
||||||
$connbas = $databox->get_connection();
|
|
||||||
|
|
||||||
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . '
|
|
||||||
WHERE record_id = :record_id';
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute(array(':record_id' => $row['record_id']));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function retrieve_sbas_content(databox $databox)
|
||||||
|
{
|
||||||
|
$connbas = $databox->get_connection();
|
||||||
|
$subdefgroups = $databox->get_subdef_structure();
|
||||||
|
$metasubdefs = array();
|
||||||
|
|
||||||
|
foreach ($subdefgroups as $type => $subdefs) {
|
||||||
|
foreach ($subdefs as $sub) {
|
||||||
|
$name = $sub->get_name();
|
||||||
|
if ($sub->meta_writeable())
|
||||||
|
$metasubdefs[$name . '_' . $type] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->metasubdefs = $metasubdefs;
|
||||||
|
|
||||||
|
$sql = 'SELECT record_id, coll_id, jeton
|
||||||
|
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
|
||||||
|
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
return $rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function format_value($type, $value)
|
||||||
|
{
|
||||||
|
if ($type == 'date') {
|
||||||
|
$value = str_replace(array("-", ":", "/", "."), array(" ", " ", " ", " "), $value);
|
||||||
|
$ip_date_yyyy = 0;
|
||||||
|
$ip_date_mm = 0;
|
||||||
|
$ip_date_dd = 0;
|
||||||
|
$ip_date_hh = 0;
|
||||||
|
$ip_date_nn = 0;
|
||||||
|
$ip_date_ss = 0;
|
||||||
|
switch (sscanf($value, "%d %d %d %d %d %d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd, $ip_date_hh, $ip_date_nn, $ip_date_ss)) {
|
||||||
|
case 1:
|
||||||
|
$value = sprintf("%04d:00:00", $ip_date_yyyy);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$value = sprintf("%04d:%02d:00", $ip_date_yyyy, $ip_date_mm);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
$value = sprintf("%04d:%02d:%02d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$value = '0000:00:00';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function process_one_content(databox $databox, Array $row)
|
||||||
|
{
|
||||||
|
$coll_id = $row['coll_id'];
|
||||||
|
$record_id = $row['record_id'];
|
||||||
|
$jeton = $row['jeton'];
|
||||||
|
|
||||||
|
$record = new record_adapter($this->sbas_id, $record_id);
|
||||||
|
|
||||||
|
$type = $record->get_type();
|
||||||
|
$subdefs = $record->get_subdefs();
|
||||||
|
|
||||||
|
$tsub = array();
|
||||||
|
|
||||||
|
foreach ($subdefs as $name => $subdef) {
|
||||||
|
$write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document');
|
||||||
|
$write_subdef = (($jeton & JETON_WRITE_META_SUBDEF) && isset($this->metasubdefs[$name . '_' . $type]));
|
||||||
|
|
||||||
|
if ($write_document || $write_subdef) {
|
||||||
|
$tsub[$name] = $subdef->get_pathfile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$registry = $databox->get_registry();
|
||||||
|
|
||||||
|
$fields = $record->get_caption()->get_fields();
|
||||||
|
|
||||||
|
$subCMD = '';
|
||||||
|
|
||||||
|
if ($record->get_uuid()) {
|
||||||
|
$subCMD .= ' -XMP-exif:ImageUniqueID=';
|
||||||
|
$subCMD .= escapeshellarg($record->get_uuid());
|
||||||
|
$subCMD .= ' -IPTC:UniqueDocumentID=';
|
||||||
|
$subCMD .= escapeshellarg($record->get_uuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$meta = $field->get_databox_field();
|
||||||
|
|
||||||
|
/* @var $meta \databox_field */
|
||||||
|
|
||||||
|
if (trim($meta->get_metadata_source()) === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$multi = $meta->is_multi();
|
||||||
|
$type = $meta->get_type();
|
||||||
|
$datas = $field->get_values();
|
||||||
|
|
||||||
|
if ($multi) {
|
||||||
|
foreach ($datas as $value) {
|
||||||
|
$value = $this->format_value($type, $value->getValue());
|
||||||
|
|
||||||
|
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
|
||||||
|
$subCMD .= escapeshellarg($value) . ' ';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$value = array_pop($datas);
|
||||||
|
$datas = $this->format_value($type, $value->getValue());
|
||||||
|
|
||||||
|
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
|
||||||
|
$subCMD .= escapeshellarg($datas) . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tsub as $name => $file) {
|
||||||
|
$cmd = '';
|
||||||
|
if ($this->system == 'WINDOWS')
|
||||||
|
$cmd = 'start /B /LOW ';
|
||||||
|
$cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original ');
|
||||||
|
if ($name != 'document' || $this->clear_doc)
|
||||||
|
$cmd .= ' -all:all= ';
|
||||||
|
|
||||||
|
$cmd .= ' -codedcharacterset=utf8 ';
|
||||||
|
|
||||||
|
$cmd .= $subCMD . ' ' . escapeshellarg($file);
|
||||||
|
|
||||||
|
$this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name));
|
||||||
|
|
||||||
|
$s = trim(shell_exec($cmd));
|
||||||
|
|
||||||
|
$this->log("\t" . $s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function flush_records_sbas()
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function post_process_one_content(databox $databox, Array $row)
|
||||||
|
{
|
||||||
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
|
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . '
|
||||||
|
WHERE record_id = :record_id';
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute(array(':record_id' => $row['record_id']));
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -17,8 +17,9 @@ class uuid
|
|||||||
*/
|
*/
|
||||||
public static function generate_v3($namespace, $name)
|
public static function generate_v3($namespace, $name)
|
||||||
{
|
{
|
||||||
if ( ! self::is_valid($namespace))
|
if ( ! self::is_valid($namespace)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get hexadecimal components of namespace
|
// Get hexadecimal components of namespace
|
||||||
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
|
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
|
||||||
@@ -82,8 +83,9 @@ class uuid
|
|||||||
*/
|
*/
|
||||||
public static function generate_v5($namespace, $name)
|
public static function generate_v5($namespace, $name)
|
||||||
{
|
{
|
||||||
if ( ! self::is_valid($namespace))
|
if ( ! self::is_valid($namespace)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get hexadecimal components of namespace
|
// Get hexadecimal components of namespace
|
||||||
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
|
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
|
||||||
|
@@ -66,6 +66,7 @@ if ( ! is_null($parm['token'])) {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
?>
|
?>
|
||||||
@@ -95,6 +96,7 @@ if ( ! is_null($parm['token'])) {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -272,8 +272,9 @@ function doUserConf($conf, $param)
|
|||||||
|
|
||||||
return $new_conf;
|
return $new_conf;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return $conf;
|
return $conf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayListColumn($conf, $param, $twig)
|
function displayListColumn($conf, $param, $twig)
|
||||||
|
@@ -318,8 +318,9 @@ function doUserConf($conf, $param)
|
|||||||
|
|
||||||
return $new_conf;
|
return $new_conf;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return $conf;
|
return $conf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayListColumn($conf, $param, $twig)
|
function displayListColumn($conf, $param, $twig)
|
||||||
|
@@ -108,11 +108,17 @@ class patch_th_2_0_3
|
|||||||
function fixRejected(connection_pdo &$connbas, &$node, $rejected)
|
function fixRejected(connection_pdo &$connbas, &$node, $rejected)
|
||||||
{
|
{
|
||||||
global $debug;
|
global $debug;
|
||||||
if ($node->nodeType != XML_ELEMENT_NODE)
|
|
||||||
|
if ($node->nodeType != XML_ELEMENT_NODE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$id = $node->getAttribute("id");
|
$id = $node->getAttribute("id");
|
||||||
if (substr($id, 0, 1) == "R")
|
|
||||||
|
if (substr($id, 0, 1) == "R") {
|
||||||
$rejected = true;
|
$rejected = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($rejected) {
|
if ($rejected) {
|
||||||
$newid = "R" . substr($id, 1);
|
$newid = "R" . substr($id, 1);
|
||||||
if ($newid != $id) {
|
if ($newid != $id) {
|
||||||
|
@@ -111,11 +111,17 @@ class patch_th_2_0_4
|
|||||||
function fixRejected(connection_pdo &$connbas, &$node, $rejected)
|
function fixRejected(connection_pdo &$connbas, &$node, $rejected)
|
||||||
{
|
{
|
||||||
global $debug;
|
global $debug;
|
||||||
if ($node->nodeType != XML_ELEMENT_NODE)
|
|
||||||
|
if ($node->nodeType != XML_ELEMENT_NODE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$id = $node->getAttribute("id");
|
$id = $node->getAttribute("id");
|
||||||
if (substr($id, 0, 1) == "R")
|
|
||||||
|
if (substr($id, 0, 1) == "R") {
|
||||||
$rejected = true;
|
$rejected = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($rejected) {
|
if ($rejected) {
|
||||||
$newid = "R" . substr($id, 1);
|
$newid = "R" . substr($id, 1);
|
||||||
if ($newid != $id) {
|
if ($newid != $id) {
|
||||||
|
Reference in New Issue
Block a user