if (is_object($loggedUser)) { $userdiagram = $delegate->userdiagramGetByIds($loggedUser->id, $diagram->id); //is he allocated to this diagram? if (is_object($userdiagram)) { $display = true; } } } //END GUARDIAN: check display $type = $_REQUEST['type']; $nowIsNow = now(); //store time switch ($type) { case 'png': //load PNG data $pngData = $delegate->diagramdataGetByDiagramIdAndType($diagram->id, Diagramdata::TYPE_PNG); #print_r($pngData); $convertion = false; //flag to request a new convertion if (!is_object($pngData)) { //no PNG file present (at least in DB) $convertion = true; } else { //PNG exists but is old if ($pngData->lastUpdate < $diagram->lastUpdate) { $convertion = true; } } #print "Conversion needed: $convertion"; #exit(); $svgPath = getStorageFolder() . '/' . $diagram->id . '.svg';
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ require_once dirname(__FILE__) . '/common/delegate.php'; if (!isset($_SESSION)) { session_start(); } if (!is_numeric($_REQUEST['diagramId'])) { echo 'No diagram Id'; exit; } $delegate = new Delegate(); $diagram = $delegate->diagramGetById($_REQUEST['diagramId']); $diagramdata = $delegate->diagramdataGetByDiagramIdAndType($_REQUEST['diagramId'], Diagramdata::TYPE_CSV); $links = array(); if ($diagramdata->fileSize > 0) { $fh = fopen(getStorageFolder() . '/' . $diagramdata->diagramId . '.csv', 'r'); $data = fread($fh, $diagramdata->fileSize); fclose($fh); $csvLines = explode("\n", $data); foreach ($csvLines as $csvLine) { $shards = explode(',', $csvLine); $links[] = $shards; } } //check if diagram is public if (!is_object($diagram)) { print "No diagram found"; exit;
function load() { if (!is_numeric($_REQUEST['diagramId'])) { print "Wrong diagram id : " . $_REQUEST['diagramId']; exit; } $d = new Delegate(); $diagram = $d->diagramGetById($_REQUEST['diagramId']); $allow = false; if ($diagram->public) { $allow = true; } else { //no public so only logged users can see it if (!is_numeric($_SESSION['userId'])) { print "Wrong user id"; exit; } $userdiagram = $d->userdiagramGetByIds($_SESSION['userId'], $_REQUEST['diagramId']); if (is_object($userdiagram) && is_numeric($userdiagram->userId)) { $allow = true; } else { print 'Error: no right over that diagram'; exit; } } if ($allow) { $diagramdata = $d->diagramdataGetByDiagramIdAndType($_REQUEST['diagramId'], Diagramdata::TYPE_DIA); $diaFile = getStorageFolder() . '/' . $_REQUEST['diagramId'] . '.dia'; /**When switching from Linux to Windows some files might get corrupt so we will use file_get_contents*/ // $fh = fopen($diaFile, 'r'); // $data = fread($fh, $diagramdata->fileSize); // fclose($fh); $data = file_get_contents($diaFile); print $data; } }