public function getAllDiscounts($codeName = false) { static $discounts = array(); if ($codeName && isset($discounts[$codeName])) { return $discounts[$codeName]; } elseif (isset($discounts['all'])) { return $discounts['all']; } $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'discount'); $sel->where('is_active')->equals(true); if ($codeName) { $sel->where('discount_type_id')->equals($this->getDiscountTypeId($codeName)); return $discounts[$codeName] = $sel->result(); } return $discounts['all'] = $sel->result(); }
public static function getList($discountTypeId = false) { $objectTypeId = self::getRuleType()->getId(); $sel = new selector('objects'); $sel->types('object-type')->id($objectTypeId); if ($discountTypeId) { $sel->where('rule_discount_types')->equals($discountTypeId); } return $sel->result(); }
public function onDispatchChanges(iUmiEventPoint $oEvent) { $sTemplate = "default"; try { list($sTemplateSubject, $sTemplateMessage) = def_module::loadTemplatesForMail("forum/mails/".$sTemplate, "mail_subject", "mail_message"); } catch (publicException $e) { return false; } $iTopicId = $oEvent->getParam("topic_id"); $iMessageId = $oEvent->getParam("message_id"); $message = umiHierarchy::getInstance()->getElement($iMessageId); $sel = new selector('objects'); $sel->types('object-type')->name("users", "user"); $sel->where('subscribed_pages')->equals($iTopicId); if (!$sel->length()) return false; $hierarchy = umiHierarchy::getInstance(); $block_arr = Array(); $sTemplateSubject = def_module::parseTemplateForMail($sTemplateSubject, $block_arr, $iMessageId); $sFromEmail = regedit::getInstance()->getVal("//settings/email_from"); $sFromFio = regedit::getInstance()->getVal("//settings/fio_from"); $oMail = new umiMail(); $oMail->setFrom($sFromEmail, $sFromFio); $oMail->setSubject($sTemplateSubject); foreach($sel->result() as $oUser) { $oMailUser = clone $oMail; $sUserMail = $oUser->getValue('e-mail'); $block_arr['h1'] = $message->getValue('h1'); $block_arr['message'] = $message->getValue('message'); $hierarchy->forceAbsolutePath(true); $block_arr['unsubscribe_link'] = $hierarchy->getPathById($iTopicId) . "?unsubscribe=" . base64_encode($iUserId); $sTemplateMessageUser = def_module::parseTemplateForMail($sTemplateMessage, $block_arr, $iMessageId); $oMailUser->setContent($sTemplateMessageUser); $hierarchy->forceAbsolutePath(false); if (umiMail::checkEmail($sUserMail)) { $sUserFio = $oUser->getValue('lname') . " ". $oUser->getValue('fname') . " " . $oUser->getValue('father_name'); $oMailUser->addRecipient($sUserMail, $sUserFio); $oMailUser->commit(); $oMailUser->send(); } else continue; } return true; }
public function list_files($element_id = false, $template = "default", $per_page = false, $ignore_paging = false) { if(!$template) $template = "default"; list($template_block, $template_line) = def_module::loadTemplates("filemanager/".$template, "list_files", "list_files_row"); $block_arr = Array(); $element_id = $this->analyzeRequiredPath($element_id); if(!$per_page) $per_page = $this->per_page; $curr_page = (int) getRequest('p'); if($ignore_paging) $curr_page = 0; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('filemanager', 'shared_file'); $sel->where('hierarchy')->page($element_id)->childs(100); $sel->limit($curr_page, $per_page); $result = $sel->result(); $total = $sel->length(); $lines = Array(); foreach($result as $element) { $line_arr = Array(); $next_element_id = $element->getId(); $line_arr['attribute:id'] = $element->getId(); $line_arr['attribute:name'] = $element->getName(); $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($next_element_id); $line_arr['attribute:downloads-count'] = $element->getValue('downloads_counter'); $line_arr['xlink:download-link'] = $this->pre_lang . "/filemanager/download/" . $next_element_id; $line_arr['xlink:href'] = "upage://" . $next_element_id; $line_arr['node:desc'] = $element->getValue("content"); $this->pushEditable("filemanager", "shared_file", $next_element_id); $lines[] = self::parseTemplate($template_line, $line_arr, $next_element_id); } $block_arr['nodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['per_page'] = $per_page; $block_arr['total'] = $total; return self::parseTemplate($template_block, $block_arr); }
public function export($v92ec19ffde05e15769b1bb3ee05ad745) { if (!count($v92ec19ffde05e15769b1bb3ee05ad745)) { $v8be74552df93e31bbdd6b36ed74bdb6a = new selector('pages'); $v8be74552df93e31bbdd6b36ed74bdb6a->where('hierarchy')->page(0)->childs(0); $v92ec19ffde05e15769b1bb3ee05ad745 = $v8be74552df93e31bbdd6b36ed74bdb6a->result(); } $vbbd738a112791dd1d0cb6bd0d61d878f = $this->getUmiDump($v92ec19ffde05e15769b1bb3ee05ad745, "commerceML2"); $vd0c75bac742760cf71fd76cd75d0c02a = './xsl/export/' . $this->type . '.xsl'; if (!is_file($vd0c75bac742760cf71fd76cd75d0c02a)) { throw new publicException("Can't load exporter {$vd0c75bac742760cf71fd76cd75d0c02a}"); } $v9a09b4dfda82e3e665e31092d1c3ec8d = new DOMDocument("1.0", "utf-8"); $v9a09b4dfda82e3e665e31092d1c3ec8d->formatOutput = XML_FORMAT_OUTPUT; $v9a09b4dfda82e3e665e31092d1c3ec8d->loadXML($vbbd738a112791dd1d0cb6bd0d61d878f); $v640eac53ad75db5c49a9ec86390d8530 = umiTemplater::create('XSLT', $vd0c75bac742760cf71fd76cd75d0c02a); return $v640eac53ad75db5c49a9ec86390d8530->parse($v9a09b4dfda82e3e665e31092d1c3ec8d); }
public function checkAllMessages() { $service = antiSpamService::get(); if (!$service) { return; } $sel = new selector('pages'); $sel->types->name('comments', 'comment'); $sel->types->name('forum', 'message'); $sel->where('is_spam')->isNull(); foreach ($sel->result() as $page) { $service->setNick(null); $service->setLink($page->link); $service->setContent($page->content); $page->is_spam = $service->isSpam() ? 2 : 1; $page->commit(); } }
public static final function getList($selfDeliveryOnly = false) { $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'delivery'); $regedit = regedit::getInstance(); if ((bool) $regedit->getVal('//modules/emarket/delivery-with-address')) { $types = array(); $typesSel = new selector('objects'); $typesSel->types('object-type')->guid('emarket-deliverytype'); $typesSel->where('class_name')->equals('self'); foreach ($typesSel as $typeId) { $types[] = $typeId->id; } if ($selfDeliveryOnly) { $sel->where('delivery_type_id')->equals($types); } else { $sel->where('delivery_type_id')->notequals($types); } } return $sel->result(); }
public function export($v92ec19ffde05e15769b1bb3ee05ad745) { $v8be74552df93e31bbdd6b36ed74bdb6a = new selector('pages'); $v8be74552df93e31bbdd6b36ed74bdb6a->types('hierarchy-type')->name('catalog', 'object'); if (count($v92ec19ffde05e15769b1bb3ee05ad745)) { foreach ($v92ec19ffde05e15769b1bb3ee05ad745 as $v9603a224b40d7b67210b78f2e390d00f) { $v8be74552df93e31bbdd6b36ed74bdb6a->where('hierarchy')->page($v9603a224b40d7b67210b78f2e390d00f->id)->childs(1000); } } $ved780287e302ec3b9fd3c5e78771919f = new xmlExporter("CommerceML2"); $ved780287e302ec3b9fd3c5e78771919f->addElements($v8be74552df93e31bbdd6b36ed74bdb6a->result()); $ved780287e302ec3b9fd3c5e78771919f->setIgnoreRelations(); $vbbd738a112791dd1d0cb6bd0d61d878f = $ved780287e302ec3b9fd3c5e78771919f->execute(); $vd0c75bac742760cf71fd76cd75d0c02a = './xsl/export/' . $this->type . '.xsl'; if (!is_file($vd0c75bac742760cf71fd76cd75d0c02a)) { throw new publicException("Can't load exporter {$vd0c75bac742760cf71fd76cd75d0c02a}"); } $v9a09b4dfda82e3e665e31092d1c3ec8d = new DOMDocument("1.0", "utf-8"); $v9a09b4dfda82e3e665e31092d1c3ec8d->formatOutput = XML_FORMAT_OUTPUT; $v9a09b4dfda82e3e665e31092d1c3ec8d->loadXML($vbbd738a112791dd1d0cb6bd0d61d878f->saveXML()); $v640eac53ad75db5c49a9ec86390d8530 = umiTemplater::create('XSLT', $vd0c75bac742760cf71fd76cd75d0c02a); return $v640eac53ad75db5c49a9ec86390d8530->parse($v9a09b4dfda82e3e665e31092d1c3ec8d); }
public function release_send() { $buffer = outputBuffer::current('HTTPOutputBuffer'); $buffer->charset('utf-8'); $buffer->contentType('text/xml'); $buffer->push('<?xml version="1.0" encoding="utf-8"?>'); $iDispId = (int) getRequest('param0'); $iReleaseId = $this->getNewReleaseInstanceId($iDispId); $arrPostData = getRequest("data_values"); $objectsColl = umiObjectsCollection::getinstance(); $controller = cmsController::getInstance(); $oDispatch = $objectsColl->getObject($iDispId); $oRelease = $objectsColl->getObject($iReleaseId); if (!$oDispatch instanceof umiObject || !$oRelease instanceof umiObject) { $buffer->push("<error>Не указан идентификатор рассылки</error>"); $buffer->end(); } if ($oRelease->getValue('status')) { $buffer->push("<error>Этот выпуск уже был отправлен</error>"); $buffer->end(); } $arrRecipients = array(); if (!getSession('umi_send_list_' . $iReleaseId)) { $sel = new selector('objects'); $sel->types("object-type")->name("dispatches", "subscriber"); $sel->where("subscriber_dispatches")->equals($iDispId); $sel->option('return')->value('id'); $sel->group("name"); foreach ($sel->result() as $recipient) { $arrRecipients[] = $recipient['id']; } $_SESSION['umi_send_list_' . $iReleaseId] = $arrRecipients; $_SESSION['umi_send_list_' . $iReleaseId . '_count'] = count($arrRecipients); } else { $arrRecipients = getSession('umi_send_list_' . $iReleaseId); } $delay = getSession('umi_send_list_' . $iReleaseId . '_delay'); $iTotal = (int) getSession('umi_send_list_' . $iReleaseId . '_count'); if ($delay and time() < $delay) { $iSended = $iTotal - count($arrRecipients); $sResult = <<<END <release dispatch="{$iDispId}"> \t<total>{$iTotal}</total> \t<sended>{$iSended}</sended> </release> END; $buffer->push($sResult); $buffer->end(); } $sHost = $controller->getCurrentDomain()->getHost(); $oMailer = new umiMail(); $arrMailBlocks = array(); $arrMailBlocks['header'] = $oDispatch->getName(); $arrMailBlocks['messages'] = ""; list($sReleaseFrm, $sMessageFrm) = def_module::loadTemplatesForMail("dispatches/release", "release_body", "release_message"); $sel = new selector('objects'); $sel->types("object-type")->name("dispatches", "message"); $sel->where("release_reference")->equals($iReleaseId); if ($sel->length()) { foreach ($sel->result() as $oNextMsg) { if ($oNextMsg instanceof umiObject) { $arrMsgBlocks = array(); $arrMsgBlocks['body'] = $oNextMsg->getValue('body'); $arrMsgBlocks['header'] = $oNextMsg->getValue('header'); $arrMailBlocks['messages'] .= def_module::parseTemplateForMail($sMessageFrm, $arrMsgBlocks, false, $oNextMsg->getId()); $oNextAttach = $oNextMsg->getValue('attach_file'); if ($oNextAttach instanceof umiFile && !$oNextAttach->getIsBroken()) { $oMailer->attachFile($oNextAttach); } } } } else { unset($_SESSION[$iDispId . '_new_templater']); $buffer->push("<error>В выпуске нет сообщений</error>"); $buffer->end(); } $oMailer->setFrom(regedit::getInstance()->getVal("//settings/email_from"), regedit::getInstance()->getVal("//settings/fio_from")); $oMailer->setSubject($arrMailBlocks['header']); $delay = 0; $max_messages = (int) mainConfiguration::getinstance()->get('modules', 'dispatches.max_messages_in_hour'); if ($max_messages && $iTotal >= $max_messages) { $delay = floor(3600 / $max_messages); } $aSended = array(); $iPacketSize = 5; //TODO: add to settings foreach ($arrRecipients as $recipient_id) { --$iPacketSize; $oNextMailer = clone $oMailer; $oNextSbs = new umiSubscriber($recipient_id); $sRecipientName = $oNextSbs->getValue('lname') . " " . $oNextSbs->getValue('fname') . " " . $oNextSbs->getValue('father_name'); $mail = $oNextSbs->getValue('email'); if (!strlen($mail)) { $mail = $oNextSbs->getName(); } $arrMailBlocks['unsubscribe_link'] = "http://" . $sHost . "/dispatches/unsubscribe/" . $oNextSbs->getId() . '/?email=' . $mail; $sMailBody = def_module::parseTemplateForMail($sReleaseFrm, $arrMailBlocks, false, $oNextSbs->getId()); $oNextMailer->setContent($sMailBody); $oNextMailer->addRecipient($mail, $sRecipientName); if (!(defined('CURRENT_VERSION_LINE') && CURRENT_VERSION_LINE == 'demo')) { $oNextMailer->commit(); $oNextMailer->send(); } $aSended[] = $recipient_id; //Unload temporary objects unset($oNextMailer); if ($iPacketSize === 0) { break; } if ($delay) { $_SESSION['umi_send_list_' . $iReleaseId . '_delay'] = $delay + time(); $_SESSION['umi_send_list_' . $iReleaseId] = array_diff($arrRecipients, $aSended); $iTotal = (int) getSession('umi_send_list_' . $iReleaseId . '_count'); $iSended = $iTotal - (count($arrRecipients) - count($aSended)); $sResult = <<<END <release dispatch="{$iDispId}"> \t<total>{$iTotal}</total> \t<sended>{$iSended}</sended> </release> END; $buffer->push($sResult); $buffer->end(); } } umiMail::clearFilesCache(); $_SESSION['umi_send_list_' . $iReleaseId] = array_diff($arrRecipients, $aSended); if (!count(getSession('umi_send_list_' . $iReleaseId))) { $oRelease->setValue('status', true); $oDate = new umiDate(time()); $oRelease->setValue('date', $oDate); $oRelease->setName($oDate->getFormattedDate('d-m-Y H:i')); $oRelease->commit(); $oDispatch->setValue('disp_last_release', $oDate); $oDispatch->commit(); } $iTotal = (int) getSession('umi_send_list_' . $iReleaseId . '_count'); $iSended = $iTotal - (count($arrRecipients) - count($aSended)); usleep(500000); $sResult = <<<END <release dispatch="{$iDispId}"> \t<total>{$iTotal}</total> \t<sended>{$iSended}</sended> </release> END; unset($_SESSION[$iDispId . '_new_templater']); $buffer->push($sResult); $buffer->end(); }
public function getAllObjects($category_id) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('catalog', 'object'); $sel->where('hierarchy')->page($category_id)->childs(8); return $sel->result(); }
public function export($v92ec19ffde05e15769b1bb3ee05ad745) { $v857a5246dff0c3c79e476b004684f6d3 = CURRENT_WORKING_DIR . "/sys-temp/export/"; $vb80bb7740288fda1f201890375a60c8f = getRequest('param0'); if (!is_dir($v857a5246dff0c3c79e476b004684f6d3)) { mkdir($v857a5246dff0c3c79e476b004684f6d3, 0777, true); } $v8e9e791281df5188f135edcc30eaa97e = $v857a5246dff0c3c79e476b004684f6d3 . $vb80bb7740288fda1f201890375a60c8f . "." . $this->getFileExt(); $v7c95caafbd5e4b5db3977617a0498de6 = $vb80bb7740288fda1f201890375a60c8f . "." . $this->getFileExt(); if (file_exists($v8e9e791281df5188f135edcc30eaa97e) && !file_exists($v8e9e791281df5188f135edcc30eaa97e . 'array')) { unlink($v8e9e791281df5188f135edcc30eaa97e); } $v2a05e4f9b3949ba2c0b7d413a0863c3f = array(); if (!file_exists($v8e9e791281df5188f135edcc30eaa97e . 'array')) { if (!count($v92ec19ffde05e15769b1bb3ee05ad745)) { $v8be74552df93e31bbdd6b36ed74bdb6a = new selector('pages'); $v8be74552df93e31bbdd6b36ed74bdb6a->where('hierarchy')->page(0)->childs(0); $v92ec19ffde05e15769b1bb3ee05ad745 = $v8be74552df93e31bbdd6b36ed74bdb6a->result; } foreach ($v92ec19ffde05e15769b1bb3ee05ad745 as $v8e2dcfd7e7e24b1ca76c1193f645902b) { if (!$v8e2dcfd7e7e24b1ca76c1193f645902b instanceof umiHierarchyElement) { $v8e2dcfd7e7e24b1ca76c1193f645902b = umiHierarchy::getInstance()->getElement($v8e2dcfd7e7e24b1ca76c1193f645902b, true, true); } if (!$v8e2dcfd7e7e24b1ca76c1193f645902b instanceof umiHierarchyElement) { continue; } $v7552cd149af7495ee7d8225974e50f80 = $v8e2dcfd7e7e24b1ca76c1193f645902b->getId(); $v2a05e4f9b3949ba2c0b7d413a0863c3f[$v7552cd149af7495ee7d8225974e50f80] = $v7552cd149af7495ee7d8225974e50f80; $vc9e9a848920877e76685b2e4e76de38d = umiHierarchy::getInstance()->getMaxNestingLevel($v7552cd149af7495ee7d8225974e50f80); if (!$vc9e9a848920877e76685b2e4e76de38d) { continue; } for ($v865c0c0b4ab0e063e5caa3387c1a8741 = 1; $v865c0c0b4ab0e063e5caa3387c1a8741 <= $vc9e9a848920877e76685b2e4e76de38d; $v865c0c0b4ab0e063e5caa3387c1a8741++) { $v8be74552df93e31bbdd6b36ed74bdb6a = new selector('pages'); $v8be74552df93e31bbdd6b36ed74bdb6a->option('return')->value('id'); $v8be74552df93e31bbdd6b36ed74bdb6a->where('hierarchy')->page($v7552cd149af7495ee7d8225974e50f80)->childs($v865c0c0b4ab0e063e5caa3387c1a8741); foreach ($v8be74552df93e31bbdd6b36ed74bdb6a->result() as $v9b207167e5381c47682c6b4f58a623fb) { $v2a05e4f9b3949ba2c0b7d413a0863c3f[$v9b207167e5381c47682c6b4f58a623fb['id']] = $v9b207167e5381c47682c6b4f58a623fb['id']; } } } } else { $v2a05e4f9b3949ba2c0b7d413a0863c3f = unserialize(file_get_contents($v8e9e791281df5188f135edcc30eaa97e . 'array')); } $v480d1b61a0432d1319f7504a3d7318dd = false; if (getRequest('as_file') !== '0') { $v480d1b61a0432d1319f7504a3d7318dd = (int) mainConfiguration::getInstance()->get("modules", "exchange.export.limit"); if ($v480d1b61a0432d1319f7504a3d7318dd <= 0) { $v480d1b61a0432d1319f7504a3d7318dd = 25; } } $ved780287e302ec3b9fd3c5e78771919f = new xmlExporter($v7c95caafbd5e4b5db3977617a0498de6, $v480d1b61a0432d1319f7504a3d7318dd); if (getRequest('as_file') !== '0') { $ved780287e302ec3b9fd3c5e78771919f->addElements(array_slice($v2a05e4f9b3949ba2c0b7d413a0863c3f, 0, $v480d1b61a0432d1319f7504a3d7318dd + 1)); } else { $ved780287e302ec3b9fd3c5e78771919f->addElements($v2a05e4f9b3949ba2c0b7d413a0863c3f); } $ved780287e302ec3b9fd3c5e78771919f->setIgnoreRelations(); $v9a09b4dfda82e3e665e31092d1c3ec8d = $ved780287e302ec3b9fd3c5e78771919f->execute(); $v10ae9fc7d453b0dd525d0edf2ede7961 = $this->getCSV($v9a09b4dfda82e3e665e31092d1c3ec8d, $v8e9e791281df5188f135edcc30eaa97e); $ve1260894f59eeae98c8440899de4df8d = fopen($v8e9e791281df5188f135edcc30eaa97e, 'a'); foreach ($v10ae9fc7d453b0dd525d0edf2ede7961 as $vd05b6ed7d2345020440df396d6da7f73) { $vb45cffe084dd3d20d928bee85e7b0f21 = "\"" . implode('";"', $vd05b6ed7d2345020440df396d6da7f73) . "\"\n"; if ($vb45cffe084dd3d20d928bee85e7b0f21 = @iconv('utf-8', 'windows-1251//IGNORE', $vb45cffe084dd3d20d928bee85e7b0f21)) { fputs($ve1260894f59eeae98c8440899de4df8d, $vb45cffe084dd3d20d928bee85e7b0f21); } } fclose($ve1260894f59eeae98c8440899de4df8d); $vaa8fb77e57d1ca18d593e909729871fe = $ved780287e302ec3b9fd3c5e78771919f->isCompleted(); if (getRequest('as_file') !== '0') { $vb0344c1ba7e309d30b65650c47a422c3 = $ved780287e302ec3b9fd3c5e78771919f->getExportedElements(); $v2a05e4f9b3949ba2c0b7d413a0863c3f = array_diff($v2a05e4f9b3949ba2c0b7d413a0863c3f, $vb0344c1ba7e309d30b65650c47a422c3); if (count($v2a05e4f9b3949ba2c0b7d413a0863c3f)) { $this->completed = false; file_put_contents($v8e9e791281df5188f135edcc30eaa97e . 'array', serialize($v2a05e4f9b3949ba2c0b7d413a0863c3f)); } else { if (file_exists($v8e9e791281df5188f135edcc30eaa97e . 'array')) { unlink($v8e9e791281df5188f135edcc30eaa97e . 'array'); } $this->completed = true; } } else { $this->completed = $vaa8fb77e57d1ca18d593e909729871fe; } if ($this->completed) { $v10ae9fc7d453b0dd525d0edf2ede7961 = unserialize(file_get_contents($v8e9e791281df5188f135edcc30eaa97e . ".tmp")); $ve1260894f59eeae98c8440899de4df8d = fopen($v8e9e791281df5188f135edcc30eaa97e . ".tmp", 'w'); foreach ($v10ae9fc7d453b0dd525d0edf2ede7961 as $vd05b6ed7d2345020440df396d6da7f73) { $vb45cffe084dd3d20d928bee85e7b0f21 = "\"" . implode('";"', $vd05b6ed7d2345020440df396d6da7f73) . "\"\n"; if ($vb45cffe084dd3d20d928bee85e7b0f21 = @iconv('utf-8', 'windows-1251//IGNORE', $vb45cffe084dd3d20d928bee85e7b0f21)) { fwrite($ve1260894f59eeae98c8440899de4df8d, $vb45cffe084dd3d20d928bee85e7b0f21); } } $vd11e7941c75eaca417c6af0d0f9d7d45 = fopen($v8e9e791281df5188f135edcc30eaa97e, 'r'); while ($vb45cffe084dd3d20d928bee85e7b0f21 = fgets($vd11e7941c75eaca417c6af0d0f9d7d45)) { if (substr_count($vb45cffe084dd3d20d928bee85e7b0f21, '"') % 2 != 0) { $v132ae73e31f76d8b94f87fe5ccfe28c9 = false; while (!feof($vd11e7941c75eaca417c6af0d0f9d7d45) && !$v132ae73e31f76d8b94f87fe5ccfe28c9) { $vb45cffe084dd3d20d928bee85e7b0f21 .= fgets($vd11e7941c75eaca417c6af0d0f9d7d45); if (substr_count($vb45cffe084dd3d20d928bee85e7b0f21, '"') % 2 == 0) { $v132ae73e31f76d8b94f87fe5ccfe28c9 = true; } } } fwrite($ve1260894f59eeae98c8440899de4df8d, $vb45cffe084dd3d20d928bee85e7b0f21); } fclose($ve1260894f59eeae98c8440899de4df8d); fclose($vd11e7941c75eaca417c6af0d0f9d7d45); unlink($v8e9e791281df5188f135edcc30eaa97e); rename($v8e9e791281df5188f135edcc30eaa97e . ".tmp", $v8e9e791281df5188f135edcc30eaa97e); } chmod($v8e9e791281df5188f135edcc30eaa97e, 0777); return false; }
public function getArrayToExport($elements) { $elementsToExport = array(); foreach ($elements as $element) { if (!$element instanceof umiHierarchyElement) { continue; } $sel = new selector('pages'); $sel->types('hierarchy-type')->name('catalog', 'object'); $sel->option('return')->value('id'); $sel->where('hierarchy')->page($element->getId())->childs(100); foreach ($sel->result() as $res) { $elementsToExport[] = $res['id']; } $elementsToExport[] = $element->getId(); } $elementsToExport = array_unique($elementsToExport); sort($elementsToExport); return $elementsToExport; }
public function getAddresses($iFormId = false) { $sel = new selector('objects'); $sel->types('object-type')->name('webforms', 'address'); $result = $sel->result(); $aBlock = array(); $aLines = array(); foreach ($result as $oObject) { $aLine = array(); $aLine['attribute:id'] = $oObject->getId(); if (in_array($iFormId, explode(',', $oObject->getValue('form_id')))) { $aLine['attribute:selected'] = 'selected'; } $aLine['node:text'] = $oObject->getName(); $aLines[] = self::parseTemplate('', $aLine); } $aBlock['attribute:input_name'] = "data[address]"; $aBlock['subnodes:items'] = $aLines; return self::parseTemplate('', $aBlock); }
public function frontendPanel() { $permissions = permissionsCollection::getInstance(); $cmsController = cmsController::getInstance(); $maxRecentPages = 5; $this->flushAsXml('frontendPanel'); $modules = array(); $modulesSortedPriorityList = $this->getSortedModulesList(); foreach ($modulesSortedPriorityList as $moduleInfo) { $modules[] = array('attribute:label' => $moduleInfo['label'], 'attribute:type' => $moduleInfo['type'], 'node:name' => $moduleInfo['name']); } $hierarchy = umiHierarchy::getInstance(); $key = md5(getServer('HTTP_REFERER')); $currentIds = is_array(getSession($key)) ? getSession($key) : array(); foreach ($currentIds as $i => $id) { $currentIds[$i] = $id[2]; } $currentIds = array_unique($currentIds); $current = array(); foreach ($currentIds as $id) { $current[] = $hierarchy->getElement($id); } $recent = new selector('pages'); $recent->where('is_deleted')->equals(0); $recent->where('is_active')->equals(1); $recent->where('lang')->equals(langsCollection::getInstance()->getList()); $recent->order('updatetime')->desc(); $recent->limit(0, $maxRecentPages); if (sizeof($currentIds) && $permissions->isAllowedModule($permissions->getUserId(), 'backup')) { $backup = $cmsController->getModule('backup'); $changelog = $backup->backup_panel($currentIds[0]); } else { $changelog = null; } $user = selector::get('object')->id($permissions->getUserId()); $referer = getRequest('referer') ? getRequest('referer') : getServer('HTTP_REFERER'); $tickets = new selector('objects'); $tickets->types('object-type')->name('content', 'ticket'); $tickets->where('url')->equals($referer); $tickets->limit(0, 100); $ticketsResult = array(); foreach ($tickets as $ticket) { $user = selector::get('object')->id($ticket->user_id); if (!$user) { continue; } $ticketsResult[] = array('attribute:id' => $ticket->id, 'author' => array('attribute:fname' => $user->fname, 'attribute:lname' => $user->lname, 'attribute:login' => $user->login), 'position' => array('attribute:x' => $ticket->x, 'attribute:y' => $ticket->y, 'attribute:width' => $ticket->width, 'attribute:height' => $ticket->height), 'message' => $ticket->message); } $result = array('user' => array('attribute:id' => $user->id, 'attribute:fname' => $user->fname, 'attribute:lname' => $user->lname, 'attribute:login' => $user->login), 'tickets' => array('nodes:ticket' => $ticketsResult), 'modules' => array('nodes:module' => $modules), 'documents' => array('editable' => array('nodes:page' => $current), 'recent' => array('nodes:page' => $recent->result()))); if (!$permissions->isAllowedMethod($permissions->getUserId(), 'content', 'tickets')) { unset($result['tickets']); } if ($changelog && sizeof($changelog['nodes:revision'])) { $result['changelog'] = $changelog; } $event = new umiEventPoint('eipFrontendPanelGet'); $event->setParam("id", getArrayKey($currentIds, 0)); $event->addRef("result", $result); $event->setMode('after'); $event->call(); return $result; }
/** * @desc */ private function placeComments($parentId, $templateString, umiHierarchy $hierarchy, $commentHType, &$total) { static $postHType = 0; if (!$postHType) { $postHType = umiHierarchyTypesCollection::getInstance()->getTypeByName('blogs20', 'post')->getId(); } $parent = $hierarchy->getElement($parentId, true); if (!$parent instanceof umiHierarchyElement) { throw new publicException("Unknown parent element for comments"); } $rootComments = $parent->getTypeId() == $postHType; $sel = new selector('pages'); $sel->where('hierarchy')->page($parentId)->childs(1); $sel->types('hierarchy-type')->id($commentHType); $sel->where('is_spam')->notequals(1); if ($rootComments) { $page = (int) getRequest('p'); $sel->limit($page * $this->comments_per_page, $this->comments_per_page); } $result = $sel->result(); $total = $sel->length(); $aLines = array(); foreach ($result as $oComment) { $commentId = $oComment->getId(); $temp = 0; $pubTime = $oComment->getValue('publish_time'); $aLineParam = array(); $aLineParam['attribute:cid'] = $commentId; $aLineParam['name'] = $oComment->getName(); $aLineParam['content'] = $this->prepareContent($oComment->getValue('content')); $aLineParam['author_id'] = $oComment->getValue('author_id'); $aLineParam['publish_time'] = $pubTime instanceof umiDate ? $pubTime->getFormattedDate('U') : time(); $aLineParam['subnodes:subcomments'] = $this->placeComments($commentId, $templateString, $hierarchy, $commentHType, $temp); $aLines[] = self::parseTemplate($templateString, $aLineParam, $commentId); } return $aLines; }
public function generateFeed($elementId, $xslPath, $typeId = null) { $this->errorSetErrorPage('/'); if ($elementId && (!umiHierarchy::getInstance()->isExists($elementId) || !umiHierarchy::getInstance()->getElement($elementId)->getIsActive())) { if (def_module::isXSLTResultMode()) { $result = array('error' => '%data_feed_nofeed%'); return def_module::parseTemplate('', $result); } else { return '%data_feed_nofeed%'; } } if ($typeId) { list($name, $ext) = explode('-', $typeId); $hierarchyType = umiHierarchyTypesCollection::getInstance()->getTypeByName($name, $ext); if ($hierarchyType) { $typeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($hierarchyType->getId()); } } elseif ($elementId) { $typeId = umiHierarchy::getInstance()->getDominantTypeId($elementId); } else { $typeId = umiObjectTypesCollection::getInstance()->getTypeIdByGUID('news-item'); } $type = umiObjectTypesCollection::getInstance()->getType($typeId); if ($type instanceof umiObjectType) { $module = $type->getModule(); $method = $type->getMethod(); } if (!isset($module) && !isset($method)) { if (def_module::isXSLTResultMode()) { $result = array('error' => '%data_feed_nofeed%'); return def_module::parseTemplate('', $result); } else { return '%data_feed_nofeed%'; } } if (!$this->checkIfFeedable($module, $method)) { if (def_module::isXSLTResultMode()) { $result = array('error' => '%data_feed_wrong%'); return def_module::parseTemplate('', $result); } else { return '%data_feed_wrong%'; } } $rss_per_page = (int) regedit::getInstance()->getVal("//modules/news/rss_per_page"); $rss_per_page = $rss_per_page > 0 ? $rss_per_page : 10; $sel = new selector('pages'); $sel->option('return')->value('id'); $sel->where('hierarchy')->page($elementId)->childs(100); $sel->types('hierarchy-type')->name($module, $method); if ($type->getFieldId('publish_time')) { $sel->order('publish_time')->desc(); } $sel->limit(0, $rss_per_page); $result = array(); foreach ($sel->result() as $res) { $result[] = $res['id']; } $exporter = new xmlExporter('rss'); $exporter->addElements($result); $exporter->setIgnoreRelations(); $umiDump = $exporter->execute(); $styleFile = CURRENT_WORKING_DIR . "/" . $xslPath; if (!is_file($styleFile)) { throw new publicException("Can't load exporter {$styleFile}"); } $doc = new DOMDocument("1.0", "utf-8"); $doc->formatOutput = XML_FORMAT_OUTPUT; $doc->loadXML($umiDump->saveXML()); if (!$elementId) { $elementId = umiHierarchy::getInstance()->getDefaultElementId(); } $element = umiHierarchy::getInstance()->getElement($elementId); $language = langsCollection::getInstance()->getLang($element->getLangId())->getPrefix(); $link = umiHierarchy::getInstance()->getPathById($elementId); $description = $element->getIsDefault() ? '' : $element->getName(); $templater = umiTemplater::create('XSLT', $styleFile); $templater->setAdditionalVariables(array('link' => $link, 'description' => $description, 'language' => $language)); $resultXml = $templater->parse($doc); $buffer = outputBuffer::current(); $buffer->contentType('text/xml'); $buffer->clear(); $buffer->push($resultXml); $buffer->end(); }
<?php require CURRENT_WORKING_DIR . '/libs/config.php'; $cmsController = cmsController::getInstance(); $config = mainConfiguration::getInstance(); $domain = $cmsController->getCurrentDomain(); $buffer = outputBuffer::current('HTTPOutputBuffer'); $buffer->contentType('text/plain'); $buffer->charset('utf-8'); $rules = ""; $sel = new selector('pages'); $sel->where('robots_deny')->equals(1); $sel->where('lang')->isnotnull(); foreach ($sel->result() as $element) { $rules .= "Disallow: " . $element->link . "\r\n"; } $rules .= "Disallow: /admin\r\n"; $rules .= "Disallow: /index.php\r\n"; $rules .= "Disallow: /emarket/addToCompare\r\n"; $rules .= "Disallow: /emarket/basket\r\n"; $rules .= "Disallow: /go_out.php\r\n"; $rules .= "Disallow: /search\r\n"; if (file_exists(CURRENT_WORKING_DIR . "/robots/" . $domain->getId() . ".robots.txt")) { $customRobots = file_get_contents(CURRENT_WORKING_DIR . "/robots/" . $domain->getId() . ".robots.txt"); if (strlen($customRobots)) { if (strpos($customRobots, "%disallow_umi_pages%") !== false) { $customRobots = str_replace("%disallow_umi_pages%", $rules, $customRobots); } $buffer->push($customRobots); $buffer->end(); exit;
public function widget() { $buffer = outputBuffer::current(); $buffer->contentType('text/javascript'); $buffer->option('generation-time', false); $buffer->clear(); $permissions = permissionsCollection::getInstance(); $objects = umiObjectsCollection::getInstance(); $controller = cmsController::getInstance(); $regedit = regedit::getInstance(); $host = "http://" . $controller->getCurrentDomain()->getHost(); $interval = $regedit->getVal("//modules/stat/request-time"); $interval = $interval > 0 ? $interval : 600; $regExp = "^" . str_replace('.', '\\\\.', $host) . "\/.*"; $showTips = (bool) $regedit->getVal("//modules/stat/tips"); $answer = <<<EOD { "version": 3, "update_interval": $interval, "update_url_regexps": [ "$regExp" ], "buttons": [ EOD; $userId = $permissions->getUserId(); $comma = false; if ($userId != $objects->getObjectIdByGUID('system-guest')) { //пользователи if ($regedit->getVal("//modules/stat/users-user") && $controller->getModule("users") && $permissions->isAllowedMethod($userId, "users", "users_list_all")) { $sel = new selector('objects'); $sel->types('object-type')->name('users', 'user'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-users-user') : ''; $answer .= self::getWidgetPart('users', $label, "{$host}/images/cms/admin/toolbar/users.png", "{$host}/admin/users/users_list_all/", $result, $comma); $comma = true; } //заказы if ($regedit->getVal("//modules/stat/emarket-order") && $controller->getModule("emarket") && $permissions->isAllowedMethod($userId, "emarket", "orders")) { $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->where('name')->isNull(false); $sel->where('name')->notequals('dummy'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-emarket-order') : ''; $answer .= self::getWidgetPart('orders', $label, "{$host}/images/cms/admin/toolbar/orders.png", "{$host}/admin/emarket/orders/", $result, $comma); $comma = true; } //сообщения обратной связи if ($regedit->getVal("//modules/stat/webforms-message") && $controller->getModule("webforms") && $permissions->isAllowedMethod($userId, "webforms", "messages")) { $sel = new selector('objects'); $sel->types('object-type')->name('webforms', 'form'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-webforms-message') : ''; $answer .= self::getWidgetPart('webforms_messages', $label, "{$host}/images/cms/admin/toolbar/messages.png", "{$host}/admin/webforms/messages/", $result, $comma); $comma = true; } //комментарии if ($regedit->getVal("//modules/stat/comments-comment") && $controller->getModule("comments") && $permissions->isAllowedMethod($userId, "comments", "view_comments")) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('comments', 'comment'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-comments-comment') : ''; $answer .= self::getWidgetPart('comments', $label, "{$host}/images/cms/admin/toolbar/comments.png", "{$host}/admin/comments/view_comments/", $result, $comma); $comma = true; } //голосования if ($regedit->getVal("//modules/stat/vote-poll_item") && $controller->getModule("vote") && $permissions->isAllowedMethod($userId, "vote", "lists")) { $sel = new selector('objects'); $sel->types('object-type')->name('vote', 'poll_item'); $polls = $sel->result(); $result = 0; foreach ($polls as $pollItem) { $result += (int) $pollItem->getValue('count'); } $label = $showTips ? getLabel('option-vote-poll_item') : ''; $answer .= self::getWidgetPart('votes', $label, "{$host}/images/cms/admin/toolbar/votes.png", "{$host}/admin/vote/lists/", $result, $comma); $comma = true; } if ($controller->getModule("blogs20")){ //посты блога if ($regedit->getVal("//modules/stat/blogs20-post") && $permissions->isAllowedMethod($userId, "blogs20", "posts")) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('blogs20', 'post'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-blogs20-post') : ''; $answer .= self::getWidgetPart('blogs_posts', $label, "{$host}/images/cms/admin/toolbar/blog_posts.png", "{$host}/admin/blogs20/posts/", $result, $comma); $comma = true; } //комментарии блога if ($regedit->getVal("//modules/stat/blogs20-comment") && $permissions->isAllowedMethod($userId, "blogs20", "comments")) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('blogs20', 'comment'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-blogs20-comment') : ''; $answer .= self::getWidgetPart('blogs_comments', $label, "{$host}/images/cms/admin/toolbar/blog_comments.png", "{$host}/admin/blogs20/comments/", $result, $comma); $comma = true; } } //вопросы if ($regedit->getVal("//modules/stat/faq-question") && $controller->getModule("faq") && $permissions->isAllowedMethod($userId, "faq", "projects_list")) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('faq', 'question'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-faq-question') : ''; $answer .= self::getWidgetPart('faq', $label, "{$host}/images/cms/admin/toolbar/questions.png", "{$host}/admin/faq/projects_list/", $result, $comma); $comma = true; } if ($controller->getModule("forum")){ //Топики в форуме if($regedit->getVal("//modules/stat/forum-topic") && $permissions->isAllowedMethod($userId, "forum", "lists")) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('forum', 'topic'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-forum-topic') : ''; $answer .= self::getWidgetPart('forums_topics', $label, "{$host}/images/cms/admin/toolbar/forum_topics.png", "{$host}/admin/forum/lists/", $result, $comma); $comma = true; } //Сообщения в форуме if($regedit->getVal("//modules/stat/forum-message") && $permissions->isAllowedMethod($userId, "forum", "last_messages")) { $sel = new selector('pages'); $sel->types('hierarchy-type')->name('forum', 'message'); $sel->option('return')->value('id'); $result = $sel->length(); $label = $showTips ? getLabel('option-forum-message') : ''; $answer .= self::getWidgetPart('forums_messages', $label, "{$host}/images/cms/admin/toolbar/forum_messages.png", "{$host}/admin/forum/last_messages/", $result, $comma); $comma = true; } } } else { $answer .= <<<EOD { "id": "auth", "appearance": { "type": "combined", "label": "Войти", "icon": "{$host}/images/cms/admin/toolbar/umi.png" }, "onclick": { "action": "openurl", "params": { "url": "{$host}/admin/" } } } EOD; } $answer .= "\n\t]\n}"; $buffer->push($answer); $buffer->end(); }
public function form_address_del($iFormId) { $sel = new selector('objects'); $sel->types('object-type')->name('webforms', 'address'); $sel->where('form_id')->like('%' . $iFormId . '%'); foreach ($sel->result() as $oAddress) { $aFormsId = explode(',', $oAddress->getValue('form_id')); if (in_array($iFormId, $aFormsId)) { $aFormsId = array_diff($aFormsId, array($iFormId)); $oAddress->setValue('form_id', implode(',', $aFormsId)); $oAddress->commit(); } } }
protected function sendNotification() { $daysLeft = regedit::getInstance()->getVal("//modules/banners/days-before-notification"); $daysLeft = $daysLeft * 24 * 3600; $viewsLeft = regedit::getInstance()->getVal("//modules/banners/clicks-before-notification"); $items = array(); $sel = new selector('objects'); $sel->types('object-type')->name('banners', 'banner'); foreach ($sel->result() as $banner) { $tillDate = toTimeStamp($banner->getValue('show_till_date')); $viewsCount = $banner->getValue('views_count'); $maxViews = $banner->getValue('max_views'); $days = false; $views = false; if ((int) $tillDate && time() + $daysLeft >= $tillDate) { $days = true; } if ((int) $maxViews && $viewsCount + $viewsLeft >= $maxViews) { $views = true; } if ($days || $views) { $bannerId = $banner->id; $bannerName = $banner->getName(); $domain = domainsCollection::getInstance()->getDefaultDomain(); $link = "http://" . $domain->getHost() . '/admin/banners/edit/' . $bannerId; list($templateLine) = def_module::loadTemplatesForMail("mail/banner_notification", "item"); $itemArr['link'] = $link; $itemArr['bannerName'] = $bannerName; if ($days) { $itemArr['tillDate'] = ' - срок показа истекает ' . $banner->getValue('show_till_date')->getFormattedDate() . '.'; } elseif ($views) { $itemArr['tillDate'] = ' - оставшееся количество показов: ' . ($maxViews - $viewsCount) . '.'; } else { $itemArr['tillDate'] = ''; } $items[] = def_module::parseTemplateForMail($templateLine, $itemArr, false, $bannerId); } } if (count($items)) { $blockArr = array(); list($subject, $template) = def_module::loadTemplatesForMail("mail/banner_notification", "subject", "body"); $mailMessage = new umiMail(); $from = regedit::getInstance()->getVal("//settings/email_from"); $mailMessage->setFrom($from); $emailTo = regedit::getInstance()->getVal("//settings/admin_email"); $mailMessage->addRecipient($emailTo); $mailMessage->setPriorityLevel("high"); $subject = def_module::parseTemplateForMail($subject, $blockArr); $mailMessage->setSubject($subject); $blockArr['header'] = $subject; $blockArr['+items'] = $items; $content = def_module::parseTemplateForMail($template, $blockArr); $mailMessage->setContent($content); $mailMessage->commit(); $mailMessage->send(); regedit::getInstance()->setVal("//modules/banners/last-check-date", time()); } }