
<?php
//This script will receive XFDF form data and store it in a folder for each user
//Check if usser is logged in and if is web user
$usuario=$modx->userLoggedIn();
if($usuario==true && $usuario['usertype']=='web') {
//We create an specific folder for the user if it is not created.
$id = $usuario['id'];
chdir('/home/MYSITE/xfdf/');
if (!is_dir($id)) mkdir($id);
chdir($id);
//Read XFDF Data
$XFDFData = file_get_contents('php://input');
$xfdf = new SimpleXMLElement($XFDFData);
//Create unique filename
$md5 = md5(mktime() . microtime());
//Save data as XML
$xfdf->asXML($md5 . '.xfdf');
//Output
echo 'Data saved';
//If not authorized...
} else {
echo 'Not authorized';
//$modx->sendForward(37);
}
?>//Save data as XML $xfdf->asXML($md5 . '.xfdf');
<?php
//This script will receive XFDF form data and store it in a folder for each user
//Check if usser is logged in and if is web user
$usuario=$modx->userLoggedIn();
if($usuario==true && $usuario['usertype']=='web') {
//We create an specific folder for the user if it is not created.
$id = $usuario['id'];
chdir('/home/MYSITE/xfdf/');
if (!is_dir($id)) mkdir($id);
chdir($id);
//Read XFDF Data
$XFDFData = file_get_contents('php://input');
$xfdf = new SimpleXMLElement($XFDFData);
//Check if user has been granted. This session variable is created in a plugin executed before this snippet.
if ($_SESSION['submitGranted'] && $_SESSION['submitGranted'] == 1) {
//Create unique filename.
$md5 = md5(mktime() . microtime());
//Save data as XML
$xfdf->asXML($md5 . '.xfdf');
$_SESSION['submitGranted'] = $md5 . '.xfdf';
}
//Output
echo 'Data saved';
//If not authorized...
} else {
echo 'Not authorized';
//$modx->sendForward(37);
}
?># For full documentation and other suggested options, please see
# http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
# including for unexpected logouts in multi-server/cloud environments
# and especially for the first three commented out rules
#php_flag register_globals Off
#AddDefaultCharset utf-8
#php_value date.timezone Europe/Moscow
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]
# Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
#RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# Exclude /assets and /manager directories and images from rewrite rules
RewriteRule ^(manager|assets)/*$ - [L]
RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# Reduce server overhead by enabling output compression if supported.
#php_flag zlib.output_compression On
#php_value zlib.output_compression_level 5
But we have more information. We declared a funtion in other snippet and had a redeclare error. It does mean that the snippet is beign executed in the page 3 times itself. It is like if we were calling: [[snippet]] [[snippet]] [[snippet]] instead of only [[snippet]]
if (!defined('SNIPPET_XFDF')) {
... code goes here ...
define('SNIPPET_XFDF', true);
}
We finally ignored and patched this in a bad wayBut we have more information. We declared a funtion in other snippet and had a redeclare error. It does mean that the snippet is beign executed in the page 3 times itself. It is like if we were calling: [[snippet]] [[snippet]] [[snippet]] instead of only [[snippet]]
So strange
Fatal error: Cannot redeclare newest() (previously declared in /home/diasan/public_html/manager/includes/document.parser.class.inc.php(770) : eval()’d code:29) in/home/diasan/public_html/manager/includes/document.parser.class.inc.php(770) : eval()’d code on line 31
Well one eloquent way of treating the symptom (without fully addressing the multiple-execution problem) is using something like so:
if (!defined('SNIPPET_XFDF')) { ... code goes here ... define('SNIPPET_XFDF', true); }