<?php // For IE to support headers if chat is installed on different domain header('P3P: CP="NOI ADM DEV COM NAV OUR STP"'); try { $docShare = erLhcoreClassModelDocShare::fetch((int) $Params['user_parameters']['doc_id']); } catch (Exception $e) { erLhcoreClassModule::redirect(); exit; } if ($docShare->active == 0) { erLhcoreClassModule::redirect(); exit; } $tpl = erLhcoreClassTemplate::getInstance('lhdocshare/view.tpl.php'); $tpl->set('docshare', $docShare); $Result['content'] = $tpl->fetch(); $Result['pagelayout'] = 'docsharewidget'; $Result['dynamic_height'] = true; $Result['dynamic_height_append'] = 10; $Result['dynamic_height_message'] = 'lhc_sizing_doc_embed_' . $docShare->id; $Result['pagelayout_css_append'] = 'embed-widget';
<?php /** * php cron.php -s site_admin -c cron/docshare * * Run every 10 minits or so. On this cron depends documents conversion * * */ foreach (erLhcoreClassModelDocShare::getList(array('filter' => array('converted' => 0))) as $doc) { echo "Converting - ", $doc->name, " | ", $doc->id, "\n"; erLhcoreClassDocShare::makeConversion($doc, true); } echo "Finished conversion\n";
<?php $tpl = erLhcoreClassTemplate::getInstance('lhdocshare/list.tpl.php'); $pages = new lhPaginator(); $pages->serverURL = erLhcoreClassDesign::baseurl('docshare/list'); $pages->items_total = erLhcoreClassModelDocShare::getCount(); $pages->setItemsPerPage(10); $pages->paginate(); $items = array(); if ($pages->items_total > 0) { $items = erLhcoreClassModelDocShare::getList(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id DESC')); } $tpl->set('items', $items); $tpl->set('pages', $pages); $Result['content'] = $tpl->fetch(); $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('docshare/index'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('docshare/index', 'Documents sharer')), array('url' => erLhcoreClassDesign::baseurl('docshare/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('docshare/list', 'Documents list')));
public static function convertPDFToPNG(erLhcoreClassModelDocShare &$fileObject) { $pdfFile = $fileObject->pdf_file_path_server; if ($fileObject->pdf_file != '' && file_exists($pdfFile)) { try { $config = erConfigClassLhConfig::getInstance(); $objectData = erLhcoreClassModelChatConfig::fetch('doc_sharer'); $dataDocSharer = (array) $objectData->data; erLhcoreClassFileUpload::mkdirRecursive($fileObject->pdftoimg_path, true, $dataDocSharer['http_user_name'], $dataDocSharer['http_user_group_name']); $ocrParsed = true; // Prepare to run ImageMagick command $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')); $appendCommand = ''; if ($dataDocSharer['pdftoppm_limit'] > 0) { $appendCommand .= ' -l ' . $dataDocSharer['pdftoppm_limit']; } $command = $dataDocSharer['pdftoppm_path'] . $appendCommand . ' -png -r 200 ' . escapeshellarg($pdfFile) . ' ' . $fileObject->pdftoimg_path . $fileObject->id; // Open color_indexer process $imageProcess = proc_open($command, $descriptors, $pipes); // Close STDIN pipe fclose($pipes[0]); $errorString = ''; $outputString = ''; // Read STDERR do { $errorString .= rtrim(fgets($pipes[2], 1024), "\n"); } while (!feof($pipes[2])); // Wait for process to terminate and store return value $status = proc_get_status($imageProcess); while ($status['running'] !== false) { // Sleep 1/100 second to wait for convert to exit usleep(10000); $status = proc_get_status($imageProcess); } $return = proc_close($imageProcess); $data = ezcBaseFile::findRecursive($fileObject->pdftoimg_path, array("@{$fileObject->id}-.*\\.png@"), array()); $contentPages = array(); $pagesCount = 0; foreach ($data as $key => $file) { $pagesCount++; $parts = explode('-', $file); array_pop($parts); $parts[] = '-' . $pagesCount . '.png'; $newName = implode('', $parts); rename($file, $newName); $file = $newName; chown($file, $dataDocSharer['http_user_name']); chgrp($file, $dataDocSharer['http_user_group_name']); chmod($file, 0664); } $fileObject->pdf_to_img_converted = 1; $fileObject->pages_pdf_count = $pagesCount; $fileObject->saveThis(); } catch (Exception $e) { throw $e; } } }