Example #1
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     $node_data = $Node->nodeDetail($this->GET['id']);
     require_once 'models/common/common_file.php';
     $File = new common_file();
     if (is_numeric($this->GET['id'])) {
         $files = $File->listFiles($this->GET['id']);
     }
     if (is_array($files)) {
         foreach ($files as $file) {
             $this->tpl->assign('FILE', $file);
             $this->tpl->parse('content.item');
         }
     }
     $this->tpl->assign('NODE', $node_data);
     /**
      * display title
      */
     if ($node_data['display_title']) {
         if ($node_data['link_to_node_id'] > 0) {
             $this->tpl->parse('content.title_link');
         } else {
             $this->tpl->parse('content.title');
         }
     }
     return true;
 }
Example #2
0
 /**
  * post action
  */
 function post()
 {
     parent::post();
     //only for including of configuration
     require_once 'models/common/common_email.php';
     $EmailForm = new common_email();
     $this->tpl->assign('EMAIL_FORM_CONF', $EmailForm->conf);
     require_once 'models/common/common_file.php';
     $File = new common_file();
     $directory = "templates/component/_contact_form/";
     $this->tpl->assign('DIRECTORY', $directory);
     $templates = $File->getFlatArrayFromFsJoin($directory);
     $templates = array_reverse($templates);
     if (is_array($templates)) {
         foreach ($templates as $template) {
             $template['name'] = str_replace('.html', '', $template['name']);
             if ($template['name'] == $this->node_data['component']['node_controller']) {
                 $template['selected'] = "selected='selected'";
             } else {
                 $template['selected'] = '';
             }
             $template['title'] = $templates_info[$this->GET['node_group']][$template['name']]['title'];
             if ($template['title'] == '') {
                 $template['title'] = $template['name'];
             }
             $this->tpl->assign('LAYOUT_TEMPLATE', $template);
             $this->tpl->parse('content.templateitem');
         }
     }
     $this->tpl->assign("SPAM_PROTECTION", array('captcha_image' => $this->node_data['component']['spam_protection'] == 'captcha_image' ? 'selected="selected"' : '', 'captcha_text_js' => $this->node_data['component']['spam_protection'] == 'captcha_text_js' ? 'selected="selected"' : ''));
 }
Example #3
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/common/common_file.php';
     $File = new common_file();
     if ($this->GET['file_path_encoded']) {
         $file_path = $File->decode_file_path($this->GET['file_path_encoded']);
         $info = $File->getFileInfo($file_path, true);
         $this->tpl->assign("ITEM", $info);
     }
     return true;
 }
Example #4
0
 /**
  * displayLocalImageGalleryTemplates
  */
 function displayLocalImageGalleryTemplates()
 {
     $File = new common_file();
     $templates = $File->getFlatArrayFromFs(ONXSHOP_PROJECT_DIR . 'templates/component/image_gallery');
     if (is_array($templates)) {
         foreach ($templates as $file) {
             if (substr($file['title'], -5) == ".html") {
                 $name = substr($file['title'], 0, -5);
                 $this->tpl->assign("ITEM", array("name" => $file['title'], "value" => $name, "selected" => $name == $this->node_data['component']['template'] ? 'selected="selected"' : ''));
                 $this->tpl->parse("content.local_templates.item");
             }
         }
         $this->tpl->parse("content.local_templates");
     }
 }
Example #5
0
 /**
  * main action
  */
 public function mainAction()
 {
     //msg($file_path);
     require_once 'models/common/common_file.php';
     $File = new common_file();
     $file_path = $File->decode_file_path($this->GET['file_path_encoded']);
     if ($file_path) {
         //msg($file_path);
         //TODO: safer to do another check for file_path string in node.content
         if ($File->deleteFile($file_path)) {
             msg("Deleted " . str_replace('var/files/', '', $file_path));
             $this->tpl->parse('content.deleted');
         }
     }
     return true;
 }
Example #6
0
 /**
  * get md array for node directory
  */
 function getList($publish = 1)
 {
     require_once 'models/common/common_file.php';
     $File = new common_file();
     //getting list of templates, joing project and onxshop node dir
     $list = $File->getFlatArrayFromFsJoin("templates/node/");
     //remove .html, .php
     foreach ($list as $k => $item) {
         $list[$k]['name'] = preg_replace('/\\.html$/', '', $list[$k]['name']);
         $list[$k]['name'] = preg_replace('/\\.php$/', '', $list[$k]['name']);
         $list[$k]['id'] = preg_replace('/\\.html$/', '', $list[$k]['id']);
         $list[$k]['id'] = preg_replace('/\\.php$/', '', $list[$k]['id']);
         $list[$k]['parent'] = preg_replace('/\\.html$/', '', $list[$k]['parent']);
         $list[$k]['parent'] = preg_replace('/\\.php$/', '', $list[$k]['parent']);
     }
     return $list;
 }
Example #7
0
 /**
  * post action
  */
 function post()
 {
     parent::post();
     //only for including of configuration
     require_once 'models/common/common_email.php';
     $EmailForm = new common_email();
     $this->tpl->assign('EMAIL_FORM_CONF', $EmailForm->conf);
     require_once 'models/common/common_file.php';
     $File = new common_file();
     /**
      * contact form template directory name
      */
     $directory = "templates/component/contact_form/";
     $this->tpl->assign('DIRECTORY', $directory);
     // show warning if old _contact_form directory is found
     $old_directory = 'templates/component/_contact_form/';
     if (file_exists(ONXSHOP_PROJECT_DIR . $old_directory)) {
         msg("Found deprecated folder name in your installation. Please contact your developers and ask them to rename {$old_directory} to {$directory}", 'error');
     }
     /**
      * list templates
      */
     $templates = $File->getFlatArrayFromFsJoin($directory);
     $templates = array_reverse($templates);
     if (is_array($templates)) {
         foreach ($templates as $template) {
             $template['name'] = str_replace('.html', '', $template['name']);
             if ($template['name'] == $this->node_data['component']['node_controller']) {
                 $template['selected'] = "selected='selected'";
             } else {
                 $template['selected'] = '';
             }
             $template['title'] = $templates_info[$this->GET['node_group']][$template['name']]['title'];
             if ($template['title'] == '') {
                 $template['title'] = $template['name'];
             }
             $this->tpl->assign('LAYOUT_TEMPLATE', $template);
             $this->tpl->parse('content.templateitem');
         }
     }
     $this->tpl->assign("SPAM_PROTECTION", array('captcha_image' => $this->node_data['component']['spam_protection'] == 'captcha_image' ? 'selected="selected"' : '', 'captcha_text_js' => $this->node_data['component']['spam_protection'] == 'captcha_text_js' ? 'selected="selected"' : ''));
 }
 /**
  * getListForDirectories
  */
 public function getListForDirectories($directories)
 {
     if (!is_array($directories)) {
         return false;
     }
     /**
      * pass find param
      */
     switch ($this->GET['type']) {
         case 'd':
             $find_param = '-type d';
             break;
         default:
             $find_param = '';
             break;
     }
     /**
      * get list
      */
     require_once 'models/common/common_file.php';
     $File = new common_file();
     $list = array();
     foreach ($directories as $directory_prefix) {
         $directory = $directory_prefix . $this->GET['directory'];
         if (file_exists($directory) && is_dir($directory)) {
             $list_single = $File->getTree($directory, $find_param);
         } else {
             $list_single = array();
         }
         $list = array_merge($list, $list_single);
     }
     if (is_array($list)) {
         return $list;
     } else {
         return false;
     }
 }
Example #9
0
 /**
  * send
  * internal function
  * 
  * @return boolean
  * send status
  */
 function send()
 {
     $email_data = $this->_format($this->template);
     $this->set('subject', $email_data['title']);
     require_once 'Zend/Mail.php';
     $mail = new Zend_Mail('utf-8');
     $mail->addHeader('X-MailGenerator', ONXSHOP_VERSION);
     $mail->setFrom($this->get('email_from'), $this->get('name_from'));
     $mail->addTo($this->get('email_recipient'), $this->get('name_recipient'));
     $mail->setSubject($this->get('subject'));
     //send BCC of all emails to specified address
     if ($this->conf['mail_bcc_address']) {
         $mail->addBcc($this->conf['mail_bcc_address'], $this->conf['mail_bcc_name']);
     }
     if ($this->conf['smtp_server_address']) {
         msg("use SMTP " . $this->conf['smtp_server_address'], 'ok', 2);
         require_once 'Zend/Mail/Transport/Smtp.php';
         if ($this->conf['smtp_server_username'] && $this->conf['smtp_server_password']) {
             msg('using SMTP auth', 'ok', 2);
             $config = array('auth' => 'login', 'username' => $this->conf['smtp_server_username'], 'password' => $this->conf['smtp_server_password']);
         } else {
             $config = array();
             msg("Not using SMTP auth", 'ok', 2);
         }
         $transport = new Zend_Mail_Transport_Smtp($this->conf['smtp_server_address'], $config);
         Zend_Mail::setDefaultTransport($transport);
     } else {
         msg('use internal mail()', 'ok', 2);
     }
     /**
      * attachment(s) via upload
      */
     if (count($_FILES) > 0) {
         foreach ($_FILES as $key => $file) {
             if (is_uploaded_file($file['tmp_name'])) {
                 /**
                  * file
                  */
                 require_once 'models/common/common_file.php';
                 //getSingleUpload could be static method
                 $CommonFile = new common_file();
                 $upload = $CommonFile->getSingleUpload($file, 'var/tmp/');
                 /**
                  * array indicated the same file name already exists in the var/tmp/ folder
                  * we can ignore it, as the previous attachement was overwritten
                  * FIXME: could be a problem when more users submit the same filename in the same time
                  * perhaps saving file with PHP session id or not saving in var/tmp would help
                  */
                 if (is_array($upload)) {
                     $attachment_saved_file = ONXSHOP_PROJECT_DIR . $upload['temp_file'];
                 } else {
                     $attachment_saved_file = ONXSHOP_PROJECT_DIR . $upload;
                 }
                 /**
                  * check if file exists and than add to email as attachemnt
                  */
                 if (file_exists($attachment_saved_file)) {
                     $attachment_info = $CommonFile->getFileInfo($attachment_saved_file);
                     $Attachment = $mail->createAttachment(file_get_contents($attachment_saved_file));
                     $Attachment->filename = $attachment_info['filename'];
                 }
             }
         }
     }
     /**
      * attachments
      * quick hack to add attachment functionality, curently used only in gift_voucher_generate
      */
     if (is_array($GLOBALS['onxshop_atachments']) && count($GLOBALS['onxshop_atachments']) > 0) {
         foreach ($GLOBALS['onxshop_atachments'] as $file) {
             if (file_exists($file)) {
                 require_once 'models/common/common_file.php';
                 $CommonFile = new common_file();
                 $attachment_info = $CommonFile->getFileInfo($file);
                 $Attachment = $mail->createAttachment(file_get_contents($file));
                 $Attachment->filename = $attachment_info['filename'];
             }
         }
     }
     /**
      * content alternative text
      */
     $mail->setBodyText($email_data['content']['txt']);
     $mail->setBodyHtml($email_data['content']['html']);
     /**
      * send
      */
     if (!$mail->send()) {
         msg('The email was not sent! Some problem with email sending.', 'error');
         return false;
     } else {
         msg("The email to {$this->email_recipient} has been sent successfully.", 'ok', 2);
         return true;
     }
 }
Example #10
0
/**
 * onxshop_flush_cache
 *
 * @return Boolean
 */
function onxshop_flush_cache()
{
    /**
     * clean cache using Zend_Cache method
     */
    $registry = Zend_Registry::getInstance();
    $db_cache_clear_status = $registry['onxshop_db_cache']->clean(Zend_Cache::CLEANING_MODE_ALL);
    if (ONXSHOP_DB_QUERY_CACHE_BACKEND !== ONXSHOP_PAGE_CACHE_BACKEND) {
        $page_cache_clear_status = $registry['onxshop_page_cache']->clean(Zend_Cache::CLEANING_MODE_ALL);
    } else {
        $page_cache_clear_status = true;
    }
    /**
     * remove all files in cache directory
     */
    require_once 'models/common/common_file.php';
    $File = new common_file();
    if ($File->rm(ONXSHOP_PROJECT_DIR . "var/cache/*")) {
        $file_clear_status = true;
    } else {
        $file_clear_status = false;
    }
    /**
     * return true only if all cache was cleared
     */
    if ($db_cache_clear_status && $page_cache_clear_status && $file_clear_status) {
        return true;
    } else {
        return false;
    }
}
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/common/common_file.php';
     $File = new common_file();
     /**
      * Setting input variables
      * 
      */
     if ($this->GET['directory']) {
         $base_folder = $this->GET['directory'];
     } else {
         $base_folder = 'var/files/';
     }
     if ($this->GET['open']) {
         $open_folder = $this->GET['open'];
     } else {
         if ($_POST['open']) {
             $open_folder = $_POST['open'];
         } else {
             if ($_SESSION['server_browser_last_open_folder'] != '') {
                 $open_folder = urlencode($_SESSION['server_browser_last_open_folder']);
             } else {
                 $open_folder = "";
             }
         }
     }
     $multiupload = $this->GET['multiupload'] == 'true';
     /**
      * Store opened folder to session
      */
     $_SESSION['server_browser_last_open_folder'] = urldecode($open_folder);
     /**
      * Setting base paths
      * 
      */
     $base_folder_full = ONXSHOP_PROJECT_DIR . $base_folder;
     $fullpath = $base_folder_full . urldecode($open_folder);
     $pathinfo = pathinfo($fullpath);
     $actual_folder = $pathinfo['dirname'] . '/';
     $actual_file = $pathinfo['basename'];
     if (is_dir($actual_folder . $actual_file)) {
         $actual_folder = $actual_folder . $actual_file . '/';
         $actual_file = '';
     }
     $relative_folder_path = str_replace($base_folder_full, '', $actual_folder);
     /**
      * Cleaning
      *
      */
     //stolen from common_uri_mapping
     if (function_exists("recode_string")) {
         $new_folder = recode_string("utf-8..flat", trim($_POST['new_folder']));
     } else {
         $new_folder = iconv("UTF-8", "ASCII//IGNORE", trim($_POST['new_folder']));
     }
     //$new_folder = strtolower($new_folder);
     $new_folder = preg_replace("/\\s/", "-", $new_folder);
     $new_folder = preg_replace("/&[^([a-zA-Z;)]/", 'and-', $new_folder);
     $new_folder = preg_replace("/[^\\w-\\/]/", '', $new_folder);
     $new_folder = preg_replace("/\\-{2,}/", '-', $new_folder);
     /**
      * Create a new folder
      */
     if ($new_folder != '' && $_POST['create']) {
         $new_folder_full = $actual_folder . $new_folder;
         if (!mkdir($new_folder_full)) {
             msg("Cannot create folder {$new_folder} in {$actual_folder}", 'error');
         }
     }
     /**
      * Delete file
      */
     if ($this->GET['delete_file']) {
         $File->deleteFile($this->GET['delete_file']);
         return true;
     }
     /**
      * Confirm overwrite
      */
     if ($_POST['overwrite'] == 'overwrite') {
         if ($File->overwriteFile($_POST['filename'], $_POST['save_dir'], $_POST['temp_file'])) {
             if ($multiupload) {
                 $this->jsonResponse("success");
             }
             msg('File has been overwritten');
         } else {
             msg("Can't overwrite file", 'error');
         }
     }
     //input
     $normal_formated_files = $_FILES;
     foreach ($normal_formated_files as $file_item) {
         if (is_uploaded_file($file_item['tmp_name'])) {
             $save_dir = $base_folder . $relative_folder_path;
             $upload = $File->getSingleUpload($file_item, $save_dir);
             /**
              * when array is returned by getSingleUpload, it's an existing file is in place
              */
             if (is_array($upload)) {
                 $this->tpl->assign("OVERWRITE_FILE", $upload);
                 if ($multiupload) {
                     $this->jsonResponse("file_exists", $upload);
                 }
                 $this->tpl->parse("content.confirm_overwrite");
                 $overwrite_show = 1;
             } else {
                 if ($upload) {
                     if ($multiupload) {
                         $this->jsonResponse("success");
                     }
                     msg("Uploaded {$file_item['name']}");
                 }
             }
         }
     }
     /**
      * prepare folder head string
      */
     $folder_head = str_replace('/', ' / ', $relative_folder_path);
     $folder_head = '/ ' . $folder_head;
     /**
      * Assign template variables
      * 
      */
     $this->tpl->assign('BASE', $base_folder);
     $this->tpl->assign('FOLDER_HEAD', $folder_head);
     $this->tpl->assign('FOLDER', $relative_folder_path);
     $this->tpl->assign('MAX_FILE_SIZE', round($File->convertBytes(ini_get('upload_max_filesize')) / 1048576));
     $this->tpl->assign('MAX_FILES', ini_get('max_file_uploads'));
     /**
      * allow to upload only in non-root folder
      */
     if ($relative_folder_path || ONXSHOP_MEDIA_LIBRARY_ROOT_UPLOAD) {
         $this->tpl->parse('content.add_new.upload_file');
     } else {
         $this->tpl->parse('content.add_new.upload_instruction');
     }
     //hide upload when overwrite?
     if ($overwrite_show == 0) {
         $this->tpl->parse("content.add_new");
     }
     /**
      * Get File List
      * 
      */
     //list content od folder
     $list = $File->getFlatArrayFromFs($actual_folder, '-type f -maxdepth 1');
     //FIND2GLOB PATCH: $list = $File->getFlatArrayFromFs($actual_folder, 'f', false);
     if (is_array($list) && count($list) > 0) {
         foreach ($list as $l) {
             $l['file_path'] = $actual_folder . $l['name'];
             $l['file_path_encoded'] = $File->encode_file_path($actual_folder . $l['name']);
             $l['file_path_encoded_relative'] = $File->encode_file_path($base_folder . $relative_folder_path . $l['name']);
             $this->tpl->assign("ITEM", $l);
             $relations_list = $File->getRelations($base_folder . $relative_folder_path . $l['name']);
             if ($relations_list['count'] == 0) {
                 $this->tpl->parse('content.list.item.delete');
             } else {
                 $this->tpl->assign("FILE_USAGE", $relations_list['count']);
                 $this->tpl->parse('content.list.item.usage');
                 //$_Onxshop_Request = new Onxshop_Request("bo/component/file_usage~file_path_encoded_relative={$l['file_path_encoded_relative']}~");
                 //$this->tpl->assign("FILE_USAGE", $_Onxshop_Request->getContent());
             }
             //if (preg_match('/^image\/.*/', $l['mime-type']))
             $this->tpl->parse('content.list.item.thumbnail');
             switch ($this->GET['type']) {
                 case 'add_to_node':
                 case 'RTE':
                 case 'add_to_product':
                 case 'add_to_product_variety':
                 case 'add_to_recipe':
                 case 'add_to_store':
                 case 'add_to_survey':
                 case 'add_to_taxonomy':
                 case 'CSS':
                 case 'file':
                     $this->tpl->parse('content.list.item.add_to_node');
                     break;
                 case 'database_import':
                     $this->tpl->parse('content.list.item.database_import');
                     break;
             }
             $this->tpl->parse('content.list.item');
         }
         $this->tpl->parse('content.list');
     } else {
         // contains no files, check if there aren't some folders, otherwise allow delete
         $list = $File->getFlatArrayFromFs($actual_folder, '-type d -maxdepth 1');
         //FIND2GLOB PATCH: $list = $File->getFlatArrayFromFs($actual_folder, 'd', false);
         if (count($list) == 0) {
             $this->tpl->parse('content.empty');
         }
     }
     return true;
 }
Example #12
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/common/common_file.php';
     $File = new common_file();
     /**
      * Setting base paths
      * 
      */
     $file_path_encoded_relative = $File->decode_file_path($this->GET['file_path_encoded_relative']);
     /**
      * Assign template variables
      * 
      */
     $this->tpl->assign('BASE', $base_folder);
     $this->tpl->assign('FOLDER_HEAD', str_replace('/', '/ ', $relative_folder_path));
     $this->tpl->assign('FOLDER', $relative_folder_path);
     $this->tpl->assign('MAX_FILE_SIZE', ini_get('upload_max_filesize'));
     /**
      * Get File List
      * 
      */
     $relations_list = $File->getRelations($file_path_encoded_relative);
     if ($relations_list['count'] == 0) {
         $this->tpl->parse('content.delete');
     } else {
         if (count($relations_list['file']) > 0) {
             $this->displayNodeInfo($relations_list['file']);
         }
         if (count($relations_list['node']) > 0) {
             $this->displayNodeInfo($relations_list['node']);
         }
         if (count($relations_list['product']) > 0) {
             foreach ($relations_list['product'] as $image_detail) {
                 $this->tpl->assign('IMAGE_DETAIL', $image_detail);
                 $this->tpl->parse('content.usage.product');
             }
         }
         if (count($relations_list['product_variety']) > 0) {
             foreach ($relations_list['product_variety'] as $image_detail) {
                 $this->tpl->assign('IMAGE_DETAIL', $image_detail);
                 $this->tpl->parse('content.usage.product_variety');
             }
         }
         if (count($relations_list['taxonomy']) > 0) {
             foreach ($relations_list['taxonomy'] as $image_detail) {
                 $this->tpl->assign('IMAGE_DETAIL', $image_detail);
                 $this->tpl->parse('content.usage.taxonomy');
             }
         }
         if (count($relations_list['recipe']) > 0) {
             foreach ($relations_list['recipe'] as $image_detail) {
                 $this->tpl->assign('IMAGE_DETAIL', $image_detail);
                 $this->tpl->parse('content.usage.recipe');
             }
         }
         if (count($relations_list['store']) > 0) {
             foreach ($relations_list['store'] as $image_detail) {
                 $this->tpl->assign('IMAGE_DETAIL', $image_detail);
                 $this->tpl->parse('content.usage.store');
             }
         }
         if (count($relations_list['survey']) > 0) {
             foreach ($relations_list['survey'] as $image_detail) {
                 $this->tpl->assign('IMAGE_DETAIL', $image_detail);
                 $this->tpl->parse('content.usage.survey');
             }
         }
         $this->tpl->parse('content.usage');
     }
     return true;
 }
Example #13
0
 /**
  * Find where the file is used
  *
  * @param string $file
  * file src
  * 
  * @return array
  * file using places list
  */
 function getRelations($file)
 {
     require_once 'models/common/common_file.php';
     $CommonFile = new common_file();
     $file_list['file'] = $CommonFile->getFileLink($file);
     require_once 'models/common/common_image.php';
     $CommonImage = new common_image();
     $file_list['node'] = $CommonImage->getFileLink($file);
     require_once 'models/ecommerce/ecommerce_product_image.php';
     $ProductImage = new ecommerce_product_image();
     $file_list['product'] = $ProductImage->getFileLink($file);
     require_once 'models/ecommerce/ecommerce_product_variety_image.php';
     $ProductVarietyImage = new ecommerce_product_variety_image();
     $file_list['product_variety'] = $ProductVarietyImage->getFileLink($file);
     require_once 'models/common/common_taxonomy_label_image.php';
     $TaxonomyImage = new common_taxonomy_label_image();
     $file_list['taxonomy'] = $TaxonomyImage->getFileLink($file);
     require_once 'models/ecommerce/ecommerce_recipe_image.php';
     $RecipeImage = new ecommerce_recipe_image();
     $file_list['recipe'] = $RecipeImage->getFileLink($file);
     require_once 'models/ecommerce/ecommerce_store_image.php';
     $StoreImage = new ecommerce_store_image();
     $file_list['store'] = $StoreImage->getFileLink($file);
     require_once 'models/education/education_survey_image.php';
     $SurveyImage = new education_survey_image();
     $file_list['survey'] = $SurveyImage->getFileLink($file);
     $file_list['count'] = count($file_list['file']) + count($file_list['node']) + count($file_list['product']) + count($file_list['product_variety']) + count($file_list['taxonomy']) + count($file_list['recipe']) + count($file_list['store']) + count($file_list['survey']);
     return $file_list;
 }
 /**
  * getFilename
  */
 public function getFilenameToSave($file_name, $survey_entry_id, $question_id, $answer_id)
 {
     if (!$file_name) {
         return false;
     }
     if (!is_numeric($survey_entry_id)) {
         return false;
     }
     if (!is_numeric($question_id)) {
         return false;
     }
     if (!is_numeric($answer_id)) {
         return false;
     }
     require_once 'models/common/common_file.php';
     $file_name = common_file::nameToSafe($file_name);
     $file_name = "{$survey_entry_id}-{$question_id}-{$answer_id}-" . $file_name;
     return $file_name;
 }
Example #15
0
 /**
  * getFileInfo
  */
 private function getFileInfo($filename)
 {
     if (!$filename) {
         return false;
     }
     $file_path = ONXSHOP_PROJECT_DIR . 'var/backup/' . $filename;
     if (!file_exists($file_path) && !is_file($file_path)) {
         return false;
     }
     require_once 'models/common/common_file.php';
     $file_info = common_file::getFileInfo($file_path);
     return $file_info;
 }
Example #16
0
 /**
  * main action
  */
 public function mainAction()
 {
     set_time_limit(0);
     require_once 'models/common/common_file.php';
     $File = new common_file();
     $tool = $this->GET['tool'];
     switch ($tool) {
         case 'uri':
             require_once 'models/common/common_uri_mapping.php';
             $CommonURIMapping = new common_uri_mapping();
             $CommonURIMapping->generateAndSaveURITable();
             msg("Nice URLs has been completely generated");
             break;
         case 'flush_thumb':
             if ($File->rm(ONXSHOP_PROJECT_DIR . "var/thumbnails/*")) {
                 msg("All image thumbnails have been deleted");
             } else {
                 "Flushing thumbnails failed";
             }
             break;
         case 'flush_tmp':
             if ($File->rm(ONXSHOP_PROJECT_DIR . "var/tmp/*")) {
                 msg("Temp directory has been cleaned");
             } else {
                 "Flushing temp dir failed";
             }
             break;
         case 'flush_cache':
             if (onxshop_flush_cache()) {
                 msg("Cache has been refreshed");
             } else {
                 msg("Flushing cache failed");
             }
             break;
         case 'flush_api_cache':
             if (is_numeric($GLOBALS['onxshop_conf']['common_configuration']['api_data_version'])) {
                 $current_api_data_version = $GLOBALS['onxshop_conf']['common_configuration']['api_data_version'];
             } else {
                 $current_api_data_version = 1;
             }
             $api_data_version = $current_api_data_version + 1;
             $Configuration = new common_configuration();
             if ($Configuration->saveConfig('common_configuration', 'api_data_version', $api_data_version)) {
                 msg("Data version of API has increased to {$api_data_version}");
                 if (onxshop_flush_cache()) {
                     msg("Cache has been refreshed");
                 } else {
                     msg("Flushing cache failed");
                 }
             }
             break;
         case 'find_hard_links':
             require_once 'models/common/common_node.php';
             $Node = new common_node();
             $hard_links = $Node->findHardLinks();
             foreach ($hard_links as $hard_link) {
                 $this->tpl->assign('ITEM', $hard_link);
                 $this->tpl->parse('content.hard_links.item');
             }
             $this->tpl->parse('content.hard_links');
             break;
         case 'delete_orphaned_baskets':
             require_once 'models/ecommerce/ecommerce_basket.php';
             $Basket = new ecommerce_basket();
             if ($Basket->deleteOrphanedAnonymouseBaskets()) {
                 msg('Deleted orphaned baskets older than two weeks');
             }
             break;
         case 'backup':
             $_Onxshop = new Onxshop_Request("bo/component/backup");
             $this->tpl->assign('SUB_CONTENT', $_Onxshop->getContent());
             break;
         default:
             $this->tpl->parse('content.menu');
             break;
     }
     return true;
 }