require_once '../../../config/config.inc.php'; require_once '../../../init.php'; // Include module main class require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php'; $module = new AiMultiDimensions(); $return = ''; // Parameters $allowed = explode(',', Configuration::get('AIMD_FILE_FORMAT')); $size = (int) Configuration::get('AIMD_FILE_SIZE') * 1024 * 1024; //die(print_r($_FILES)); //die('size : ' . $size . ' -> ' . (int) $_FILES['upl']['size']); $target = md5(time() . $_FILES['upl']['name']) . '_' . clean_string($_FILES['upl']['name']); if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION); if (!in_array(strtolower($extension), $allowed)) { $return = '{"status":"error : ' . $module->l('File extension not allowed') . '"}'; } else { if ((int) $_FILES['upl']['size'] > $size) { $return = '{"status":"error : ' . $module->l('File is too large') . '"}'; } else { if (@move_uploaded_file($_FILES['upl']['tmp_name'], 'files/' . $target)) { $return = '{"status":"success : ' . $target . '"}'; } else { $return = '{"status":"error : ' . $module->l('Upload file error') . '"}'; } } } } die($return); /** * \brief Clean a string (a file name)
} // Value are correct ? if (!isset($params['quantity']) && !isset($params['action'])) { if (isset($params['attr_2']) && (int) $params['attr_2'] < -1 || isset($params['attr_3']) && (int) $params['attr_3'] < -1 || (int) $params['value'] < -1) { $error = 3; } } } else { $params['action'] = Tools::getValue('action'); } // We quit with error message if ($error == 1) { die('ko'); } else { if ($error > 1) { die('Error->' . $module->l('Please choose correct values', 'ajax')); } } // Specific action if (isset($params['action'])) { switch ($params['action']) { case 'checkCart': $return = Db::getInstance()->getValue('SELECT aimd_dpq FROM ' . _DB_PREFIX_ . 'product WHERE id_product = ' . (int) $params['product']); break; case 'checkWeight': $weight = get_combinationWeight((int) $params['product'], (int) $params['combination']); $return = 'ok|' . str_replace('.', ',', number_format($weight, 2)); break; case 'copyFile': $order_id = (int) $params['order']; $product_id = (int) $params['product'];
* \copyright @ide-info since 2013 * \license Read the multi-language license file (license.pdf) * * \file includes/config.php * \brief Configuration file for ai_multidimensions module * * \package aimultidimensions * \version 1.9 */ // Dev mod $aimd_config_suffix = ''; $aimd_config_suffix = '-min'; $GLOBALS['aimd_config_suffix'] = $aimd_config_suffix; // Object for translations $module = new AiMultiDimensions(); // Entended parameters $config_entended = array(1 => array(0 => $module->l('None', 'config'), 1 => $module->l('Top', 'config'), 2 => $module->l('Bottom', 'config'), 3 => $module->l('Top & Bottom', 'config'), 4 => $module->l('Left', 'config'), 5 => $module->l('Right', 'config'), 6 => $module->l('Left & right', 'config'), 7 => $module->l('Perimeter', 'config'))); $GLOBALS['config_entended'] = $config_entended; // Formats // Rectangle must remains the first one // x = first dimension, y = second dimension, z = third dimension // format explanation : // array( // 'format' => $module->l('rectangle', 'config') : format is the name displayed in the list on link a product tab, it uses the translation mode // 'surface_formula' => 'x * y' : formula that is linked to this shape to calculate surface, x, y & z are the three dimensions and will be replaced by values input by the customer // 'perimeter_formula' => 'x * y' : formula that is linked to this shape to calculate perimeter, x, y & z are the three dimensions and will be replaced by values input by the customer // 'labels' => array('x' => '', 'y' => '', 'z' => '') : labels for this shape, if not empty, will replace the default labels // 'proportionnal display' => true) : if product calculation is set to proportionnal, display or not the other dimensions (0 -> false, 1 -> true) // Don't use mathematical functions or variables until they are common to PHP and JS $config_format = array(array('format' => $module->l('rectangle', 'config'), 'surface_formula' => 'x * y', 'perimeter_formula' => 'x * 2 + y * 2', 'labels' => array('x' => '', 'y' => '', 'z' => ''), 'proportionnal display' => 1), array('format' => $module->l('elipse', 'config'), 'surface_formula' => '(x / 2) * (y / 2) * 3.141592', 'perimeter_formula' => '(x / 2 + y / 2) * 3.141592', 'labels' => array('x' => $module->l('x diameter', 'config'), 'y' => $module->l('y diameter', 'config'), 'z' => ''), 'proportionnal display' => 0), array('format' => $module->l('cube', 'config'), 'surface_formula' => 'x * y * z', 'perimeter_formula' => '', 'labels' => array('x' => '', 'y' => '', 'z' => ''), 'proportionnal display' => 1)); $GLOBALS['config_format'] = $config_format;