redmine

Don't remember

[submodule "genpdf/lib/3dparty/Inflect"]
path = genpdf/lib/3dparty/Inflect
url = https://github.com/mephi-ut/Inflect
... ...
... ... @@ -5,8 +5,11 @@ require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/SimpleXMLElement.php"
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/User.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/Issue.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/Attachment.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/Membership.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Client.php";
require_once "lib/3rdparty/Inflect/Inflect.php";
require_once "config.php";
/*
... ... @@ -83,6 +86,23 @@ Array
)
*/
$dont_inflect_patterns = array(
'/^нач./',
'/^зам./',
'/^заф./',
'/^нач./',
'/^./',
'/^спец./',
);
$inflect_cut_patterns = array(
'/^(.*)[иы]й[ ]/',
);
$inflect_ignore_ending_patterns = array(
'[ ].*',
);
function _tempdir_cleanup($dir) {
# system('rm -rf "'.$dir.'"');
}
... ... @@ -122,127 +142,55 @@ function body_parse($body) {
return $body;
}
$custom_fields = NULL;
$custom_fields_keys = array();
switch ($_GET['file']) {
case 'request/vpn':
$project_id = 1;
$memo_subject = 'Запрос на учётную запись к vpn.mephi.ru';
break;
case 'request/vpn-private-net':
$project_id = 1;
$memo_subject = 'Запрос на доступ к VLAN через vpn.mephi.ru';
break;
case 'request/nix-hosting':
$project_id = 102;
$memo_subject = 'Заявка на предоставление nix-хостинга';
break;
case 'request/win-hosting':
$project_id = 1;
$memo_subject = 'Заявка на предоставление win-хостинга';
break;
case 'request/voip-softphone':
$project_id = 18;
$memo_subject = 'Заявка на создание учётной записи к softphone';
break;
case 'request/voip3':
$project_id = 124;
$memo_subject = 'Заявка на доступ к систему «Биллинг» IP-телефонии';
break;
case 'request/cps':
$project_id = 109;
// $project_id = 1;
$memo_subject = 'Заявка на доступ к системе учёта рабочего времени';
break;
case 'request/hpc':
// $project_id = NULL; //38;
$project_id = 38;
$memo_subject = 'Запрос на учётную запись к HPC-кластерам';
$custom_fields_keys = array(2 => 'hdd-amount', 3 => 'cpu-amount', 4 => 'subdivision', 5 => 'scientific-director', 6 => 'ram-amount', 7 => 'preffered-login', 8 => 'ic-bandwidth', 16 => 'contact-email');
break;
case 'request/vacation':
$project_id = 118;
$memo_subject = 'Заявление на отпуск';
switch($_GET['vacation-type']) {
case 'main':
$_GET['vacation-type'] = 'ежегодный основной оплачиваемый отпуск';
$_GET['of-vacation'] = 'ежегодного основного оплачиваемого отпуска';
break;
case 'educational':
$_GET['vacation-type'] = 'учебный отпуск';
$_GET['of-vacation'] = 'учебного отпуска';
break;
case 'free':
$_GET['vacation-type'] = 'отпуск без сохранения заработной платы';
$_GET['of-vacation'] = 'отпуска без сохранения заработной платы';
break;
case 'parental':
$_GET['vacation-type'] = 'отпуск по уходу за ребёнком до достижения им возраста трёх лет';
$_GET['of-vacation'] = 'отпуска по уходу за ребёнком до достижения им возраста трёх лет';
break;
}
$time_from = strtotime($_GET['days-from']);
$time_to = strtotime($_GET['days-to']);
$time_diff = $time_from - $time_to;
$days_diff = floor(($time_diff / (3600*24)) + 0.5);
$_GET['days-count'] = ($days_diff + 1);
break;
case 'request/voip-transfer-equipment':
$project_id = 1;//18;
$memo_subject = 'Заявка на передачу телефонных аппаратов в ОСП';
break;
default:
die('unknown memo-type');
}
switch ($_GET['file']) {
case 'request/voip3':
case 'request/cps':
if (empty($_GET['subdiv-code'])) {
if (!empty($_SERVER['HTTP_REFERER'])) {
header('Location: '.$_SERVER['HTTP_REFERER'].'?errmsg='.urlencode('Не указан код подразделения'));
exit(0);
} else
die('"subdiv-code" is not set');
}
$subdivs = json_decode(file_get_contents('https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='.$_GET['subdiv-code']));
$subdiv = $subdivs->result->s0;
$_GET['subdiv-name'] = $subdiv->name;
break;
function error($str) {
die($str);
header('Location: '.$_GET['callback_url'].'?errmsg='.urlencode($str));
error_log($str);
exit(0);
}
foreach($custom_fields_keys as $id => $key)
$custom_fields[] = array('id' => $id, 'value' => empty($_GET[$key]) ? '0' : $_GET[$key]);
$tempdir = tempdir();
if ($tempdir === FALSE)
die('Cannot create temporary directory');
//DE base64 subdivs
if (isset($_GET['signer-subdivs'])){
$_GET['signer-subdivs'] = base64_decode($_GET['signer-subdivs']);
}
$inflect = new Inflect();
//This cycle for situation when we could not receive enought info from node_common
foreach (array('signer', 'contact', 'user') as $key) {
if (!empty($_GET[$key.'-e_id'])) {
$e_id = $_GET[$key.'-e_id'];
$employees = json_decode(file_get_contents("http://cps.mephi.ru/?cmd=getemployeeinfo&e_id=". urlencode($e_id) ));
$employee = ((array)$employees);
$employee = reset($employee);
} else
if (!empty($_GET[$key.'-login'])) {
$login = $_GET[$key.'-login'];
$employees = json_decode(file_get_contents("http://cps.mephi.ru/?cmd=getemployeeinfo&username=".urlencode($login) ));
$employee = ((array)$employees);
$employee = reset($employee);
} else
continue;
$appointments = array();
foreach($employee->WORKPOSITIONS as $workposition) {
$appointments[] = preg_replace('/ [0-9]*.[0-9]$/', '', $workposition->name).' '.mb_strtoupper($workposition->subdivision->shortname);
}
exec('cp -a /var/www/ut.mephi.ru/ut-tex/mephimemo "'.$tempdir.'/"');
chdir($tempdir.'/mephimemo');
file_put_contents("request.get", print_r($_GET, true));
$fullname = $employee->fullname;
$name = mb_substr($employee->firstname, 0, 1).'.'.mb_substr($employee->middlename, 0, 1).'. '. $employee->lastname;
$appointment = join(', ',$appointments);
#ob_start();
#print_r($_GET);
#$_GET_print_r = ob_get_clean();
$text = '';
$_GET[$key.'-fullname'] = $fullname;
$_GET[$key.'-name'] = $name;
$_GET[$key.'-appointment'] = $appointment;
$redmine_admin = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD);
}
/*
if (empty($_GET['date-end']))
$_GET['date-end'] = (date('Y')+1).'-12-31';
*/
foreach (array('fullname' => 40, 'phonenumber' => 20, 'email' => 30, 'appointment' => 40, 'pgp-id' => 12) as $key => $space) {
if (empty($_GET['signer-'.$key]))
$_GET['signer-'.$key] = str_pad('', $space, '_');
... ... @@ -254,6 +202,51 @@ foreach (array('fullname' => 40, 'phonenumber' => 20, 'email' => 30, 'appointmen
$_GET['contact-'.$key] = $_GET['user-'.$key];
}
foreach (array('signer', 'contact', 'user') as $key) {
if (empty($_GET[$key.'-name']))
$_GET[$key.'-name'] = $_GET[$key.'-fullname'];
foreach (array('of', 'to') as $case => $key_prefix) {
if (empty($_GET[$key_prefix.'-'.$key.'-fullname']))
$_GET[$key_prefix.'-'.$key.'-fullname'] = $inflect->getInflectName($_GET[$key.'-fullname'], $case);
if (empty($_GET[$key_prefix.'-'.$key.'-appointment'])) {
foreach ($dont_inflect_patterns as &$dont_inflect_pattern) {
if (preg_match($dont_inflect_pattern, $_GET[$key.'-appointment'])) {
$_GET[$key_prefix.'-'.$key.'-appointment'] = $_GET[$key.'-appointment'];
continue 2;
}
}
// working with appointments
$appointments = split(', ', $_GET[$key.'-appointment']);
foreach ($appointments as &$appointment) {
$matches = NULL;
$ignored_ending = '';
$appointment = preg_replace($inflect_cut_patterns, '', $appointment);
foreach($inflect_ignore_ending_patterns as $inflect_ignore_ending_pattern) {
if (preg_match('/'.$inflect_ignore_ending_pattern.'$/u', $appointment, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches as &$match) {
$ignored_ending .= $match[0];
$appointment = mb_substr($appointment, 0, -mb_strlen($match[0]));
}
}
}
$appointment = $inflect->getInflectNoun($appointment, $case);
$appointment .= $ignored_ending;
$_GET[$key_prefix.'-'.$key.'-appointment'] = $appointment;
}
$_GET[$key_prefix.'-'.$key.'-appointment'] = join(', ', $appointments);
}
}
}
foreach (array('work-date-end' => 'Срок окончания работ') as $key => $descr) {
$_GET[$key.'-descr'] = $descr.': '.
(
... ... @@ -273,9 +266,41 @@ foreach ($_GET as $key => &$value) {
if (substr($key, -12) == "-other-value")
if ($_GET[substr($key, 0, strlen($key)-12)] == "other")
$_GET[substr($key, 0, strlen($key)-12)] = $value;
$value = str_replace('_', '\_', $value);
$value = str_replace(array('\\', '_'), array('{\textbackslash}', '\_'), $value);
}
foreach (array('videocheck', 'confcheck', 'webtrans', 'telebridge', 'otherconf', 'record1', 'record2', 'record3') as $key ) {
if (isset($_GET[$key]))
$_GET[$key] = 'Да';
//govnocode 2.0
else{
/*
// if ($_GET['video-type'] == 'Нет')
// die('Ошибка: не выбран флажок видеосъемки');
if (isset($_GET['usermount1']) || isset($__GET['record1']))
die('Ошибка: не выбран флажок видеоконференции');
if (isset($_GET['record2']))
die('Ошибка: не выбран флажок вебтрансляции');
if (isset($_GET['usermount2']) || isset($_GET['record3']))
die('Ошибка: не выбран флажок проведения телемоста');
if (isset($_GET['otherconftext']))
die('Ошибка: не выбран флажок "Другое"');
*/
$_GET[$key] = 'Нет';
}
}
//Jim's simple diagnostics
//print_r($_GET);die();
$redmine_admin = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD);
$me = NULL;
if (isset($_GET['user-serialized'])) {
$user_drupal_serialized = base64_decode($_GET['user-serialized']);
$hash = $_GET['user-signature'];
... ... @@ -307,93 +332,329 @@ if (isset($_GET['user-serialized'])) {
// file_put_contents("/tmp/user", print_r($user_redmine)); die();
$redmine = new Redmine\Client('https://redmine.ut.mephi.ru', $api_key);
} else
$redmine = &$redmine_admin;
$body_template = file_get_contents('template/'.$_GET['file'].'.tex');
$body = body_parse($body_template);
switch ($_GET['file']) {
case 'request/vacation':
$header = '\mmheader{Начальнику отдела кадров НИЯУ МИФИ}{}';
break;
case 'request/voip-transfer-equipment':
$header = '\mmfullheader{'.$_GET['subdiv-name'].'}{Начальнику управления информатизации}{Романову Н.Н.}';
break;
default:
$header = '\mmheader{Начальнику управления информатизации}{Н. Н. Романову}';
$me = $redmine->api('user')->getCurrentUser()['user'];
} else {
die('Not authed');
$redmine = &$redmine_admin;
}
file_put_contents('header.tex', $header);
file_put_contents('body.tex', $body);
file_put_contents('footer.tex', '\mmfooter{'.$_GET['signer-appointment'].'}{'.$_GET{'signer-fullname'}.'}');
file_put_contents('responsible.tex', '\mmresponsibleskip');
if (!is_null($project_id)) {
file_put_contents('urlqr.tex', '');
exec('make');
exec('pdftotext memo.pdf');
$text = file_get_contents('memo.txt');
unlink('memo.pdf');
$custom_fields = NULL;
$issue_props =
array(
'project_id' => $project_id,
'subject' => $memo_subject,
'description' => $text,
);
$custom_fields_keys = array();
$files = split(',', $_GET['file']);
$pdfs = array();
foreach ($files as $file) {
switch ($file) {
case 'request/vpn':
$project_id = 1;
$memo_subject = 'Запрос на учётную запись к vpn.mephi.ru';
break;
case 'request/vpn-private-net':
$project_id = 1;
$memo_subject = 'Запрос на доступ к VLAN через vpn.mephi.ru';
break;
case 'request/nix-hosting':
$project_id = 102;
$memo_subject = 'Заявка на предоставление nix-хостинга';
$custom_fields_keys = array (4 => 'signer-subdivs', 85=> 'domainnames');
break;
case 'request/win-hosting':
$project_id = 1;
$memo_subject = 'Заявка на предоставление win-хостинга';
break;
case 'request/voip-softphone':
$project_id = 18;
$memo_subject = 'Заявка на создание учётной записи к softphone';
break;
case 'request/voip3':
$project_id = 124;
$memo_subject = 'Заявка на доступ к систему «Биллинг» IP-телефонии';
break;
case 'request/cps':
$project_id = 109;
// $project_id = 1;
$memo_subject = 'Заявка на доступ к системе учёта рабочего времени';
break;
case 'request/hpc':
// $project_id = NULL; //38;
$project_id = 38;
$memo_subject = 'Запрос на учётную запись к HPC-кластерам';
if (!is_null($custom_fields))
$issue_props['custom_fields'] = $custom_fields;
$custom_fields_keys = array(2 => 'hdd-amount', 3 => 'cpu-amount', 4 => 'subdivision', 5 => 'scientific-director', 6 => 'ram-amount', 7 => 'preffered-login', 8 => 'ic-bandwidth', 16 => 'contact-email');
break;
case 'request/vacation':
$project_id = 118;
// $project_id = 1;
$memo_subject = 'Заявление на отпуск';
switch($_GET['vacation-type']) {
case 'main':
$_GET['vacation-type'] = 'ежегодный основной оплачиваемый отпуск';
$_GET['of-vacation'] = 'ежегодного основного оплачиваемого отпуска';
break;
case 'educational':
$_GET['vacation-type'] = 'учебный отпуск';
$_GET['of-vacation'] = 'учебного отпуска';
break;
case 'free':
$_GET['vacation-type'] = 'отпуск без сохранения заработной платы';
$_GET['of-vacation'] = 'отпуска без сохранения заработной платы';
break;
case 'parental':
$_GET['vacation-type'] = 'отпуск по уходу за ребёнком до достижения им возраста трёх лет';
$_GET['of-vacation'] = 'отпуска по уходу за ребёнком до достижения им возраста трёх лет';
break;
}
$time_from = strtotime($_GET['days-from']);
$time_to = strtotime($_GET['days-to']);
$time_diff = $time_to - $time_from;
$days_diff = floor(($time_diff / (3600*24)) + 0.5);
$_GET['days-count'] = ($days_diff + 1);
$issue = $redmine->api('issue')->create($issue_props);
break;
case 'request/temporary-acting':
if (!isset($_GET['user-e_id']))
continue 2;
$issue_id = $issue->id;
} else {
$issue_id = $_GET['issue-id'];
}
if (substr($_GET['of-user-fullname'], 0, 2) == '\_')
$_GET['of-user-fullname'] = '\\\\'."\n".$_GET['of-user-fullname'];
break;
case 'request/voip-transfer-equipment':
$project_id = 1;//18;
$memo_subject = 'Заявка на передачу телефонных аппаратов в ОСП';
break;
case 'request/video':
$project_id = 1;
$memo_subject = 'Заявка на сопровождение мероприятия видеосъемкой, проведение видеоконференции и веб-трансляции';
break;
// die ('working on that');
case 'request/php':
$project_id = 12871;
$memo_subject = 'Заявка на предоставление PHP хостинга';
break;
default:
die('unknown memo-type');
file_put_contents('urlqr.tex', '\mmredmineurlqr{'.$issue_id.'}');
if (isset($user_redmine['user']['id']))
$redmine_admin->api('issue')->addWatcher($issue_id, $user_redmine['user']['id']);
switch ($_GET['file']) {
case 'request/cps':
case 'request/voip3':
case 'request/voip-softphone':
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_NNROMANOV);
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_DYOKUNEV);
break;
case 'request/voip-transfer-equipment':
case 'request/vacation':
break;
default:
file_put_contents('responsible.tex', '\mmresponsible{'.$_GET['contact-fullname'].'}{'.$_GET{'contact-phonenumber'}.'}{'.$_GET['contact-email'].'}');
}
}
if (!is_null($me))
$redmine_admin->api('membership')->create($project_id, array('user_id' => $me['id'], 'role_ids' => array(ROLE_CUSTOMER)));
switch ($file) {
case 'request/voip3':
case 'request/cps':
case 'request/php':
if (empty($_GET['subdiv-code'])) {
if (!empty($_SERVER['HTTP_REFERER'])) {
header('Location: '.$_SERVER['HTTP_REFERER'].'?errmsg='.urlencode('Не указан код подразделения'));
exit(0);
} else
die('"subdiv-code" is not set');
}
$subdivs = json_decode(file_get_contents('https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='.$_GET['subdiv-code']));
$subdiv = $subdivs->result->s0;
$_GET['subdiv-name'] = $subdiv->name;
break;
case 'request/video':
if (empty($_GET['subdiv-code'])) {
if (!empty($_SERVER['HTTP_REFERER'])) {
header('Location: '.$_SERVER['HTTP_REFERER'].'?errmsg='.urlencode('Не указан код подразделения'));
exit(0);
} else
die('"subdiv-code" is not set');
}
$subdivs = json_decode(file_get_contents('https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='.$_GET['subdiv-code']));
$subdiv = $subdivs->result->s0;
$_GET['subdiv-name'] = $subdiv->name;
break;
}
exec('make');
$pdf_content = file_get_contents('memo.pdf');
foreach($custom_fields_keys as $id => $key)
$custom_fields[] = array('id' => $id, 'value' => empty($_GET[$key]) ? '0' : $_GET[$key]);
$pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) );
$redmine_admin->api('issue')->attach(
$issue_id,
array(
'token' => $pdf_upload->upload->token,
'filename' => 'sluzhebnaya_zapiska.pdf',
'description' => 'Служебная записка',
'content_type'=> 'application/pdf'
)
);
$tempdir = tempdir();
if ($tempdir === FALSE)
die('Cannot create temporary directory');
exec('cp -a /var/www/ut.mephi.ru/ut-tex/mephimemo "'.$tempdir.'/"');
chdir($tempdir.'/mephimemo');
file_put_contents("request.get", print_r($_GET, true));
#ob_start();
#print_r($_GET);
#$_GET_print_r = ob_get_clean();
$text = '';
/*
if (empty($_GET['date-end']))
$_GET['date-end'] = (date('Y')+1).'-12-31';
*/
$body_template = file_get_contents('template/'.$file.'.tex');
$body = body_parse($body_template);
switch ($file) {
case 'request/vacation':
$header = '\mmheaderstatement{Начальнику отдела кадров НИЯУ МИФИ}{}';
$footer = '';
break;
case 'request/temporary-acting':
$header = '\mmheadermemo{\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_}{\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_}';
$footer = '
\mmfooter{'.$_GET['signer-appointment'].'}{'.$_GET{'signer-name'}.'}{}{}
\\
\mmfooter{'.$_GET['user-appointment'].'}{'.$_GET{'user-name'}.'}{}{Согласен:}
';
break;
case 'request/voip-transfer-equipment':
$header = '\mmfullheader{'.$_GET['subdiv-name'].'}{Начальнику управления информатизации}{Романову Н.Н.}';
break;
case 'request/video';
$header = '\mmfullheader{Утверждаю}{Начальник управления информатизации}{/Романов Н.Н./}';
break;
default:
$header = '\mmheader{Начальнику управления информатизации}{Н. Н. Романову}';
$footer = '\mmfooter{'.$_GET['signer-appointment'].'}{'.$_GET{'signer-name'}.'}{}{}';
}
file_put_contents('header.tex', $header);
file_put_contents('body.tex', $body);
file_put_contents('footer.tex', $footer);
file_put_contents('responsible.tex', '\mmresponsibleskip');
if (empty($issue_id)) {
if (!is_null($project_id)) {
file_put_contents('urlqr.tex', '');
exec('make');
exec('pdftotext memo.pdf');
$text = file_get_contents('memo.txt');
unlink('memo.pdf');
//insert switch here
switch($file) {
case 'request/php':
$issue_props =
array(
'assigned_to_id' => USERID_KVMARTINOV,
'project_id' => $project_id,
'subject' => $memo_subject,
'description' => $text,
);
break;
default:
$issue_props =
array(
'assigned_to_id' => USERID_DYOKUNEV,
'project_id' => $project_id,
'subject' => $memo_subject,
'description' => $text,
);
}
if (!is_null($custom_fields))
$issue_props['custom_fields'] = $custom_fields;
// print_r ($issue_props);
error_log(base64_encode(serialize($issue_props)));
$result = $redmine->api('issue')->create($issue_props);
$issue = json_decode($result);
$issue = $issue->issue;
error_log(base64_encode(serialize($issue)));
error_log('issue: '.$issue->id);
if (empty($issue->id))
error('Wrong parameters: '.$result);
$issue_id = $issue->id;
} else {
$issue_id = $_GET['issue-id'];
}
}
file_put_contents('urlqr.tex', '\mmredmineurlqr{'.$issue_id.'}');
if (isset($user_redmine['user']['id']))
$redmine_admin->api('issue')->addWatcher($issue_id, $user_redmine['user']['id']);
switch ($file) {
case 'request/hpc':
file_put_contents('responsible.tex', '\mmresponsible{'.$_GET['contact-name'].'}{'.$_GET{'contact-phonenumber'}.'}{'.$_GET['contact-email'].'}');
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_AAANIKEEV);
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_BIRCOPH);
case 'request/cps':
case 'request/voip3':
case 'request/voip-softphone':
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_NNROMANOV);
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_DYOKUNEV);
break;
case 'request/voip-transfer-equipment':
case 'request/vacation':
case 'request/temporary-acting':
break;
default:
file_put_contents('responsible.tex', '\mmresponsible{'.$_GET['contact-name'].'}{'.$_GET{'contact-phonenumber'}.'}{'.$_GET['contact-email'].'}');
}
exec('make');
$pdf_content = file_get_contents('memo.pdf');
$pdf_upload = json_decode( $redmine_admin->api('attachment')->upload($pdf_content) );
$redmine_admin->api('issue')->attach(
$issue_id,
array(
'token' => $pdf_upload->upload->token,
'filename' => 'sluzhebnaya_zapiska.pdf',
'description' => 'Служебная записка',
'content_type'=> 'application/pdf'
)
);
if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) {
system('convert -density 400 memo.pdf memo.png');
system('convert -density 400 memo.png memo_png.pdf');
$pdfs_path[] = getcwd().'/memo_png.pdf';
$pdf_content = file_get_contents('memo_png.pdf');
} else
$pdfs_path[] = getcwd().'/memo.pdf';
$pdfs_content[] = $pdf_content;
}
$count = count($pdfs_path);
if ($count == 0) {
exit(0);
}
header('Content-type: application/pdf');
if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) {
system('convert -density 200 memo.pdf memo.png');
system('convert -density 200 memo.png memo_png.pdf');
print file_get_contents('memo_png.pdf');
} else {
print $pdf_content;
if ($count == 1) {
print $pdfs_content[0];
exit(0);
}
if ($count > 1) {
$tempdir = tempdir();
chdir($tempdir);
system('pdfunite '.join(' ', $pdfs_path).' memo_unite.pdf');
print file_get_contents('memo_unite.pdf');
exit(0);
}
?>
... ...
Inflect @ c1aa9da6
Subproject commit c1aa9da69af1be2977cc941cbb2fd47a22cf02e2
... ...
... ... @@ -15,11 +15,13 @@
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{xunicode}
\usepackage{setspace}
%\usepackage{parskip}
\usepackage{pst-barcode}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{polyglossia}
\setmainfont{DejaVu Serif}
\newfontfamily\cyrillicfont{Times New Roman}
\setmainfont{Times New Roman}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
\setdefaultlanguage[spelling=modern]{russian}
... ... @@ -29,17 +31,26 @@
\usepackage{textcomp} % allow ligatures and special symbols
\usepackage[none]{hyphenat}
\usepackage{soul}
\pagestyle{empty}