public static function recibir_archivo($archivo_zip)
 {
     //define('READ_LEN', 4096);
     file_put_contents(BASEPATH . "../application/temp/temp_archivos_xml/recibido.zip", $archivo_zip);
     $mensaje_error = array('mensaje' => 'Error al transferir el archivo');
     $zip2 = new ZipArchive();
     if (!file_exists(BASEPATH . '../application/temp/temp_archivos_xml/recibido.zip')) {
         return $mensaje_error;
     }
     if ($zip2->open(BASEPATH . '../application/temp/temp_archivos_xml/recibido.zip') === TRUE) {
         $zip2->extractTo(BASEPATH . '../application/temp/temp_archivos_xml/');
         $zip2->close();
         if (file_exists(BASEPATH . '../application/temp/archivos_xml/export_horario.xml')) {
             if (!Helper_File::files_identical(BASEPATH . '../application/temp/temp_archivos_xml/export_horario.xml', BASEPATH . '../application/temp/archivos_xml/export_horario.xml', array(2))) {
                 $mensaje = Business_Web_Service_Xml::procesar_archivo(BASEPATH . '../application/temp/archivos_xml/export_horario.xml');
                 return array('mensaje' => $mensaje);
             } else {
                 return array('mensaje' => 'El archivo tiene el mismo contenido');
             }
         } else {
             $contents = file_get_contents(BASEPATH . "../application/temp/temp_archivos_xml/export_horario.xml");
             file_put_contents(BASEPATH . "../application/temp/archivos_xml/export_horario.xml", $contents);
             $mensaje = Business_Web_Service_Xml::procesar_archivo(BASEPATH . '../application/temp/archivos_xml/export_horario.xml');
             return array('mensaje' => $mensaje);
         }
     } else {
         return $mensaje_error;
     }
 }
Ejemplo n.º 2
0
 function getList($path, $depth = null)
 {
     $dir = $this->basePath . '/' . $path;
     $list = Helper_File::tree($dir, $depth, array('.svn'));
     Helper_Array::unsetByValuer($list, array('_meta.txt'));
     Helper_Array::unsetByKey($list, array('_inc'));
     return $list;
 }
Ejemplo n.º 3
0
 static function deleteOldImage($controller, $name, $sizes, $dir)
 {
     if (isset($controller->files)) {
         $root = $controller->files->file_root;
         foreach ($sizes as $size) {
             $controller->files->deleteFile("{$root}/{$dir}/" . Helper_File::addSuffix(Helper_File::getFileName($name), $size['suffix']));
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * sets Error in many possible ways
  * @param str $type my custom type(category) of error
  * @param  str $emessage
  * @param  str $edata (just some additional data if needed)
  * @param  str $ecode (just some additional code of error  if needed)
  * @return bool
  */
 public static function setError($errorType, $emessage, $edata = '', $ecode = '')
 {
     if (!is_string($edata)) {
         $edata = Helper_File::getDump($edata, true);
     }
     $message = "\r\t" . '[' . date('Y-m-d H:i:s O') . '] ' . $ecode . ' ' . $errorType . ' ' . $emessage . ' {{' . $edata . '}} ' . "\n";
     //WRITE to file
     self::setLog($errorType, $message);
     //ECHO to screen
     print $message;
     //SEND email
     Helper_Email::sendEmail(self::EMAIL_ADMIN, $errorType . ": " . date('Y-m-d H:i:s O'), $message);
     return false;
 }
Ejemplo n.º 5
0
 function _getImageName($item)
 {
     $suffix = '_tn';
     if (isset($this->thumbnailSuffix)) {
         $suffix = $this->thumbnailSuffix;
     }
     $imageName = '';
     if ($item['image']) {
         $imageName = Helper_File::addSuffix($item['image'], $suffix);
     }
     if (!empty($item['options']['_image_url'])) {
         $imageName = $item['options']['_image_url'];
     }
     return $imageName;
 }
function smarty_modifier_cc_file_add_suffix($string, $suff = '')
{
    return Helper_File::addSuffix($string, $suff);
}
Ejemplo n.º 7
0
    static function renderFormRow($options, $lang = "en")
    {
        $_name = "";
        $_sanitized_name = "";
        $_label = "";
        $_type = "text";
        $_attribute = "";
        $_value = "";
        $_value_empty = "";
        $_html_input = "";
        $_html = "";
        $_options = array();
        $_selected = "";
        if (!empty($options['name'])) {
            $_name = $options['name'];
        }
        if (!empty($options['name'])) {
            $_sanitized_name = preg_replace("/[^a-zA-Z0-9\\-_]+/", "", $options['name']);
        }
        if (!empty($options['label'])) {
            $_label = $options['label'];
        }
        if (!empty($options['type'])) {
            $_type = $options['type'];
        }
        if (!empty($options['attribute'])) {
            $_attribute = $options['attribute'];
        }
        if (!empty($options['value'])) {
            $_value = $options['value'];
        }
        if (!empty($options['value_empty'])) {
            $_value_empty = $options['value_empty'];
        }
        if (!empty($options['options'])) {
            $_options = $options['options'];
        }
        if (!empty($options['selected'])) {
            $_selected = $options['selected'];
        }
        $_required = "";
        if (strpos($_attribute, 'required') !== false) {
            $_required .= "<span class='required'>*</span>";
        }
        if ($_type == "text" || $_type == "email" || $_type == "tel" || $_type == "password") {
            $_html_input .= "<input id='input_{$_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>";
            $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-label'>\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n                <div class='sirclo-form-input'>\n                    {$_html_input}\n                </div>\n            </div>";
        } else {
            if ($_type == "textarea") {
                $_html_input .= "<textarea name='{$_name}' {$_attribute}></textarea>";
                $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-label'>\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n                <div class='sirclo-form-input'>\n                    {$_html_input}\n                </div>\n            </div>";
            } else {
                if ($_type == "file") {
                    $_html_input .= "<input id='input_{$_name}' type='file' name='{$_name}' {$_attribute}>";
                    $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-label'>\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n                <div class='sirclo-form-input'>\n                    {$_html_input}\n                </div>\n            </div>";
                } else {
                    if ($_type == "country") {
                        $_countries = Helper_Paypal::getPaypalCountriesAssoc();
                        $_html_input_option = "<option value=\"\">-- Select Country --</option>";
                        foreach ($_countries as $_country_key => $_country_value) {
                            if (!empty($_value) && $_value == $_country_key) {
                                $_html_input_option .= "<option value='{$_country_key}' selected='selected'>{$_country_value}</option>";
                            } else {
                                $_html_input_option .= "<option value='{$_country_key}'>{$_country_value}</option>";
                            }
                        }
                        $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>";
                        $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-label'>\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n                <div class='sirclo-form-input'>\n                    {$_html_input}\n                </div>\n            </div>";
                    } else {
                        if ($_type == "salutation") {
                            if ($lang == "id") {
                                $_salutations = array('' => '-- Harap Dipilih --', 'Mr' => 'Tuan', 'Mrs' => 'Nyonya', 'Miss' => 'Nona', 'Dr' => 'Dr');
                            } else {
                                $_salutations = array('' => '-- Please Select --', 'Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr');
                            }
                            $_html_input_option = "";
                            foreach ($_salutations as $_salutation_key => $_salutation_value) {
                                if (!empty($_value) && $_value == $_salutation_value) {
                                    $_html_input_option .= "<option value='{$_salutation_key}' selected='selected'>{$_salutation_value}</option>";
                                } else {
                                    $_html_input_option .= "<option value='{$_salutation_key}'>{$_salutation_value}</option>";
                                }
                            }
                            $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>";
                            $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-label'>\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n                <div class='sirclo-form-input'>\n                    {$_html_input}\n                </div>\n            </div>";
                        } else {
                            if ($_type == "checkbox") {
                                $_html_input .= "<input name='{$_name}' {$_attribute} type='checkbox'>";
                                $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-input checkbox'>\n                    {$_html_input}\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n            </div>";
                            } else {
                                if ($_type == "radio") {
                                    $_html_input = "";
                                    if (!empty($_value)) {
                                        foreach ($_value as $_v) {
                                            $_html_image = '';
                                            if (!empty($_v['image'])) {
                                                $_html_image = '<br/><img src="' . Helper_File::addSuffix($_v['image'], '_ori') . '"/>';
                                            }
                                            if (isset($_selected) && $_v['value'] == $_selected) {
                                                $_html_input .= "<div class='radio'><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . " checked='checked'>" . $_v['title'] . $_html_image . "</div>\n";
                                            } else {
                                                $_html_input .= "<div class='radio'><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . ">" . $_v['title'] . $_html_image . "</div>\n";
                                            }
                                        }
                                    } else {
                                        if (!empty($_value_empty)) {
                                            $_html_input .= "<span class='value-empty'>{$_value_empty}</span>";
                                        }
                                    }
                                    $_html .= <<<EOD
<div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>
<div class='sirclo-form-input radio'>
{$_html_input}</div>
</div>

EOD;
                                } else {
                                    if ($_type == "checkbox_multiple") {
                                        $_html_input = "";
                                        if (!empty($_value)) {
                                            foreach ($_value as $_v) {
                                                if (!empty($_selected) && in_array($_v['value'], $_selected)) {
                                                    $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . " checked='checked'>" . $_v['title'] . "</div>";
                                                } else {
                                                    $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . ">" . $_v['title'] . "</div>";
                                                }
                                            }
                                        } else {
                                            if (!empty($_value_empty)) {
                                                $_html_input .= "<span class='value-empty'>{$_value_empty}</span>";
                                            }
                                        }
                                        $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-input checkbox-multiple'>\n                    {$_html_input}\n                </div>\n            </div>";
                                    } else {
                                        if ($_type == "subheader") {
                                            $_html .= "<h3 class='{$_sanitized_name}'>" . $_value . "</h3>";
                                        } else {
                                            if ($_type == "hidden") {
                                                $_html .= "<input id='input_{$_sanitized_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>";
                                            } else {
                                                if ($_type == "div") {
                                                    $_html .= "<div {$_attribute}>";
                                                } else {
                                                    if ($_type == "div_close") {
                                                        $_html .= "</div>";
                                                    } else {
                                                        if ($_type == "submit") {
                                                            if ($lang == "id") {
                                                                $_html_input .= "<div class='sirclo-form-row notice'><span class='required'>*</span> wajib diisi.</div>";
                                                            } else {
                                                                $_html_input .= "<div class='sirclo-form-row notice'>Fields marked with <span class='required'>*</span> are required.</div>";
                                                            }
                                                            $_html_input .= "<input type='submit' value='{$_value}' {$_attribute}>";
                                                            $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                {$_html_input}\n            </div>";
                                                        } else {
                                                            if ($_type == 'dropdown') {
                                                                $_attrs = array();
                                                                if ($_required) {
                                                                    $_attrs['required'] = 'required';
                                                                }
                                                                $_html_input .= Helper_Xml::xmlSelect($_name, $_options, $_value, $_attrs);
                                                                $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                <div class='sirclo-form-label'>\n                    <label for='{$_name}'>\n                        {$_label}\n                        {$_required}\n                    </label>\n                </div>\n                <div class='sirclo-form-input'>\n                    {$_html_input}\n                </div>\n            </div>";
                                                            } else {
                                                                if ($_type == "plain_text") {
                                                                    $_html_input .= "<p>{$_value}</p>";
                                                                    $_html .= "\n            <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n                {$_html_input}\n            </div>";
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return $_html;
    }
Ejemplo n.º 8
0
 static function bannerToArr($controller, $obj)
 {
     $prefix = '_med';
     if ($controller->getKrcoConfigVersion() >= 1) {
         $prefix = '';
     }
     $image = Helper_File::addSuffix($obj->getImage(), $prefix);
     $youtubeId = Helper_String::extractYoutubeId($obj->getYoutubeLink());
     $arr = array('title' => $obj->getTitle($controller->lang), 'description' => self::markdownMark($obj->getDescription($controller->lang)), 'image' => $controller->composeResource("/content/banners/" . rawurlencode($image)), 'link' => $obj->getLink(), 'youtube_id' => $youtubeId, 'cta_text' => $obj->getButtonText());
     return $arr;
 }
Ejemplo n.º 9
0
 private function loadFile()
 {
     $texto = '';
     $dir = $this->input->post('path');
     $root = BASEPATH . "../application/logs" . (empty($dir) ? '/' : "/{$dir}");
     $path = $root;
     $resAjax = new Response_Ajax();
     if (file_exists($path) && $dir != '.' && $dir != '..' && !is_dir($path)) {
         $fp = fopen($path, 'r');
         //leemos el archivo
         $texto = fread($fp, filesize($path));
         $name = basename($path);
         $size = filesize($path);
         /*bytes*/
         $size_file = Helper_File::round_size($size, 2);
         //transformamos los saltos de linea en etiquetas <br>
         //$texto = nl2br($texto);
         /*$search  = array("\r\n", "\r", "\n", " ");
           $replace = array("<br/>", "<br/>", "<br/>", "&nbsp;");
           $texto = str_replace($search, $replace, $texto);*/
         $resAjax->isSuccess(TRUE);
         $resAjax->message('');
     } else {
         $resAjax->isSuccess(FALSE);
         $resAjax->message('Error de Archivo');
     }
     $resAjax->form('file', array('text' => print_r($texto, TRUE), 'name' => $name, 'path' => $dir, 'size' => $size_file));
     echo $resAjax->toJsonEncode();
 }