/**
  * Create new topic
  *
  */
 public function actionPostAjaxCreateMessage()
 {
     $title = trim(getPostParam('title'));
     $type = getPostParam('type');
     $to = getPostParam('to');
     $message = trim(str_replace(array('<p></p>', '<p><br /></p>'), '', getPostParam('message', '')));
     // Make sure we have a title
     if (!$title || empty($title)) {
         echoJson(array('error' => at('Sorry, You must submit a title.')));
     }
     // Make sure We have a message
     if (!$message || empty($message)) {
         echoJson(array('error' => at('Sorry, You must submit a message.')));
     }
     // Check to make sure we've selected at least one participant
     if (!$to || !count($to)) {
         echoJson(array('error' => at('Sorry, You must select at least one participant.')));
     }
     // Make sure we didn't select more partiticpants then we need to
     if (getParam('personal_message_max_participants') && count($to) > getParam('personal_message_max_participants')) {
         echoJson(array('error' => at('Sorry, You have selected too many participants.')));
     }
     // Add the new topic
     $model = new PersonalMessageTopic();
     $model->title = $title;
     $model->type = $type;
     $model->to = $to;
     $model->message = $message;
     if (!$model->save()) {
         echoJson(array('error' => at('Sorry, We could not save the personal message.')));
     }
     // Display Success
     $html = at('Thank You! Your message was sent!');
     $footer = $this->renderPartial('_pm_ajax_sent_footer', array(), true);
     $title = at('Personal Message Sent!');
     echoJson(array('html' => $html, 'footer' => $footer, 'title' => $title));
 }
 /**
  * Import language
  */
 public function actionImport()
 {
     // Check access
     checkAccessThrowException('op_language_import_language');
     $file = CUploadedFile::getInstanceByName('file');
     $update = getPostParam('update', 0);
     // Did we upload anything?
     if (!$file || !$file->getTempName()) {
         ferror(at('File was not uploaded properly.'));
         $this->redirect(array('language/index'));
     }
     // Make sure it's an xml file
     if ($file->getType() != 'text/xml') {
         ferror(at('You must upload an XML file.'));
         $this->redirect(array('language/index'));
     }
     // Make file has contents
     if (!$file->getSize()) {
         ferror(at('File Uploaded is empty.'));
         $this->redirect(array('language/index'));
     }
     // Grab data from file
     $xml = new ClassXML();
     $xml->loadXML(file_get_contents($file->getTempName()));
     // Check to see if it has language details
     foreach ($xml->fetchElements('language_row') as $lang) {
         // Grab first language
         $langData = $xml->fetchElementsFromRecord($lang);
         break;
     }
     // Make sure we have data
     if (!count($langData)) {
         ferror(at('Could not locate language data.'));
         $this->redirect(array('language/index'));
     }
     // See if language data missing the name and short form
     if (!isset($langData['name']) || !isset($langData['abbr'])) {
         ferror(at('Language data missing name or abbreviation.'));
         $this->redirect(array('language/index'));
     }
     $langName = $langData['name'];
     $langAbbr = $langData['abbr'];
     $langId = null;
     // Check if that language exists
     $langModel = Language::model()->find('abbr=:abbr', array(':abbr' => $langAbbr));
     // If we have the model then set the id
     if ($langModel) {
         $langId = $langModel->id;
     }
     // Grab the strings
     $stringsToImport = array();
     foreach ($xml->fetchElements('message_row') as $string) {
         // Grab first language
         $stringData = $xml->fetchElementsFromRecord($string);
         $stringsToImport[] = $stringData;
     }
     // Make sure we have strings
     if (!count($stringsToImport)) {
         ferror(at('Could not locate any strings to import.'));
         $this->redirect(array('language/index'));
     }
     // Do we need to create a new language?
     if (!$langModel) {
         // Create new language
         $newLang = new Language();
         $newLang->name = $langName;
         $newLang->abbr = $langAbbr;
         if (!$newLang->save()) {
             ferror(at('Could not save the new language.'));
             $this->redirect(array('language/index'));
         }
         $langId = $newLang->id;
     }
     $imported = 0;
     $updated = 0;
     $skipped = 0;
     // Run each string and check if the one exists in the current language if it does and we have the update then update
     // otherwise skip
     foreach ($stringsToImport as $r) {
         // Get orig id if exists if not create orig
         $orig = SourceMessage::model()->find('category=:category AND message=:message', array(':category' => $r['category'], ':message' => $r['orig']));
         if ($orig) {
             // It exists so we have the original message id
             $origId = $orig->id;
         } else {
             // It does not exists create and get newly created id
             $newSource = new SourceMessage();
             $newSource->category = $r['category'];
             $newSource->message = $r['orig'];
             $newSource->save(false);
             $origId = $newSource->id;
         }
         // Now that we have the original id check if we need to update or create
         $exists = Message::model()->find('id=:id AND language_id=:lang', array(':id' => $origId, ':lang' => $langId));
         if ($exists) {
             if ($update) {
                 // Exists and update
                 $exists->translation = $r['translation'];
                 $exists->update();
                 $updated++;
             } else {
                 // Exists do not update
                 $skipped++;
             }
         } else {
             // Does not exist create
             $newMessage = new Message();
             $newMessage->id = $origId;
             $newMessage->language = $langAbbr;
             $newMessage->language_id = $langId;
             $newMessage->translation = $r['translation'];
             $newMessage->save(false);
             $imported++;
         }
     }
     // Log and save flash message
     if ($langModel) {
         alog(at("Update Language '{name}'", array('{name}' => $langName)));
         fok(at('Language Updated. {i} Strings Imported, {u} Strings Updated, {s} Strings Skipped.', array('{i}' => $imported, '{u}' => $updated, '{s}' => $skipped)));
     } else {
         alog(at("Imported New Language '{name}'", array('{name}' => $langName)));
         fok(at("New Language Created '{name}'. <b>{i}</b> Strings Imported, <b>{u}</b> Strings Updated, <b>{s}</b> Strings Skipped.", array('{name}' => $langName, '{i}' => $imported, '{u}' => $updated, '{s}' => $skipped)));
     }
     $this->redirect(array('language/index'));
 }
Exemple #3
0
define('DS', DIRECTORY_SEPARATOR);
define('BILL_SYSTEM_OPTIONS_TABLE', 'system_options');
# путь к платёжным системам
$pathToPS = '.' . DS . 'res' . DS . 'paysystems' . DS;
# вспомогательные ф-ии
include_once $pathToPS . 'helper' . DS . 'functions.php';
# файл-конфиг соединения с БД
$configFilePath = './app/etc/config.xml';
# необходимо задать в обработчиках ПС
$title = 'ISP - пополнение счёта';
$response = 'Error! Платёжная система не выбрана!';
# получаем необходимые данные для оплаты
# данные абонента
$user = getUserDataFromPOST();
# сумма платежа
$amount = round(getPostParam('amount', 100), 2);
/*
# для отладки
$amount = 10;
$amount = round($amount, 2);
$user['uid'] = 1;
$user['email'] = '*****@*****.**';
*/
if (isset($_GET['system']) and !empty($_GET['system'])) {
    $file = 'default.php';
    $systemName = $_GET['system'];
    # получаем сис. опции и проверяем, включены ли системы
    # соединение с БД
    $LINK = connectToDB($configFilePath);
    if (!$LINK->ping()) {
        die('Connection with DB lost.');
 /**
  * set file content
  */
 public function actionAjaxSetThemeFileContent()
 {
     // Init
     $fileId = getPostParam('fileId');
     $content = getPostParam('content');
     // Access check
     if (!checkAccess('op_theme_file_edit')) {
         echoJson(array('error' => at('Sorry, You are not allowed to edit theme files.')));
     }
     // Check to make sure the theme file exists
     $themeFile = ThemeFile::model()->with(array('theme'))->findByPk($fileId);
     if (!$themeFile) {
         echoJson(array('error' => at('Sorry, We could not located that file.')));
     }
     // Update theme content
     $themeFile->content = $content;
     $themeFile->update();
     // Log
     alog(at("Updated Theme '{name}', File {file}", array('{name}' => $themeFile->theme->name, '{file}' => $themeFile->file_location)));
     // Sync theme to save changes
     $themeFile->theme->syncTheme();
     echoJson(array('html' => at('Theme File Saved!')));
 }