function Ftpsincro() { // $match[0] = ftp://username:password@sld.domain.tld/path1/path2/ // $match[1] = username // $match[2] = password // $match[3] = sld.domain.tld // $match[4] = /path1/path2/ $this->error = 0; $this->dirlocal = './sincro'; $data = func_get_args(); $this->connection = 0; $this->mascara = '*'; if (count($data) == 1) { preg_match("/ftp:\\/\\/(.*?):(.*?)@(.*?)(\\/.*)/i", $data[0], $match); array_shift($match); if (count($match) != 4) { $this->error("ERROR LA ENTRADA DEBE SER ftp://usuario:clave@www.dominio.com/path1/path2/"); } $this->user = empty($match[0]) ? "anonymous" : $match[0]; $this->password = empty($match[1]) ? "*****@*****.**" : $match[1]; $this->host = $match[2]; $this->ftpdir = empty($match[3]) ? './' : reduce_double_slashes('/' . $match[3] . '/'); } elseif (count($data) == 4) { $match = $data; $this->user = empty($match[0]) ? "anonymous" : $match[0]; $this->password = empty($match[1]) ? "*****@*****.**" : $match[1]; $this->host = $match[2]; $this->ftpdir = empty($match[3]) ? './' : reduce_double_slashes('/' . $match[3] . '/'); } else { //$this->error("ERROR FALTAN PARAMETROS usuario,clave,dominio,ftpdir"); } }
function preciosucu($sucursal = NULL, $codigo = null) { $this->load->helper('string'); $host = $this->datasis->dameval("SELECT CONCAT_WS('/',url,proteo) AS valor FROM sucu WHERE codigo='{$sucursal}'"); if (!empty($codigo)) { $server_url = "{$host}/rpcserver"; $server_url = reduce_double_slashes($server_url); $this->load->library('xmlrpc'); $this->xmlrpc->xmlrpcstr['http_error'] = "No hay conección con la sucursal"; $this->xmlrpc->server($server_url, 80); $this->xmlrpc->method('sprecios'); $request = array($codigo); $this->xmlrpc->request($request); if (!$this->xmlrpc->send_request()) { echo $this->xmlrpc->display_error(); } else { $retorno = $this->xmlrpc->display_response(); if (count($retorno) > 0) { $row = $retorno; echo '<table border=1><tr>'; echo '<td width="660p" align=center colspan=6>' . $row[6] . ' ' . $row[5] . '</td></tr></tr>'; echo '<td width="110p" align=right> ' . number_format($row[0], 2) . '</td>'; echo '<td width="110p" align=right> ' . number_format($row[1], 2) . '</td>'; echo '<td width="110p" align=right> ' . number_format($row[2], 2) . '</td>'; echo '<td width="110p" align=right> ' . number_format($row[3], 2) . '</td>'; echo '<td width="110p" align=right> ' . number_format($row[4], 2) . '</td>'; echo '</tr></table>'; } else { echo 'Producto no existe'; } } } else { echo 'Faltan parametros'; } }
/** * Send admin notification * * Sends an admin notification email * * @access public * @param string * @param int * @param int */ function send_admin_notification($notify_address, $channel_id, $entry_id) { ee()->api->instantiate('channel_structure'); ee()->load->model('channel_entries_model'); $e = ee()->channel_entries_model->get_entry($entry_id, $channel_id); $c = ee()->api_channel_structure->get_channel_info($channel_id); $swap = array('name' => ee()->session->userdata('screen_name'), 'email' => ee()->session->userdata('email'), 'channel_name' => $c->row('channel_title'), 'entry_title' => $e->row('title'), 'entry_url' => reduce_double_slashes($c->row('channel_url') . '/' . $e->row('url_title')), 'comment_url' => reduce_double_slashes($c->row('comment_url') . '/' . $e->row('url_title')), 'cp_edit_entry_url' => cp_url('content_publish/entry_form', array('site_id' => $e->row('site_id'), 'channel_id' => $e->row('channel_id'), 'entry_id' => $e->row('entry_id')), TRUE)); $template = ee()->functions->fetch_email_template('admin_notify_entry'); $email_tit = ee()->functions->var_swap($template['title'], $swap); $email_msg = ee()->functions->var_swap($template['data'], $swap); // We don't want to send a notification to the user // triggering the event if (strpos($notify_address, ee()->session->userdata('email')) !== FALSE) { $notify_address = str_replace(ee()->session->userdata('email'), "", $notify_address); } $notify_address = reduce_multiples($notify_address, ',', TRUE); if ($notify_address != '') { // Send email ee()->load->library('email'); foreach (explode(',', $notify_address) as $addy) { ee()->email->EE_initialize(); ee()->email->wordwrap = false; ee()->email->from(ee()->config->item('webmaster_email'), ee()->config->item('webmaster_name')); ee()->email->to($addy); ee()->email->reply_to(ee()->config->item('webmaster_email')); ee()->email->subject($email_tit); ee()->email->message(entities_to_ascii($email_msg)); ee()->email->send(); } } }
public function test_reduce_double_slashes() { $strs = array('http://codeigniter.com' => 'http://codeigniter.com', '//var/www/html/example.com/' => '/var/www/html/example.com/', '/var/www/html//index.php' => '/var/www/html/index.php'); foreach ($strs as $str => $expect) { $this->assertEquals($expect, reduce_double_slashes($str)); } }
function Zip() { $LD = '\\{'; $RD = '\\}'; $SLASH = '\\/'; $tagdata = ee()->TMPL->tagdata; $variable = "zip:files"; $file_status = true; $this->cache_path = !$this->cache_path ? APPPATH . 'cache/' . MX_ZIP_KEY : false; if (preg_match("/" . LD . $variable . ".*?" . RD . "(.*?)" . LD . '\\/' . $variable . RD . "/s", $tagdata, $file_list)) { $max_size = !ee()->TMPL->fetch_param('max_size') ? 50 * 1024 * 1024 : ee()->TMPL->fetch_param('max_size') * 1024 * 1024; $method = ee()->TMPL->fetch_param('method', 'php'); $direct_output = ee()->TMPL->fetch_param('direct_output') == 'yes' ? 'yes' : 'no'; $overwrite = ee()->TMPL->fetch_param('overwrite', false) ? ee()->TMPL->fetch_param('overwrite') : 'no'; $this->archive_name = $this->archive_fname = ee()->TMPL->fetch_param('filename', mktime() . '.zip'); $this->archive_folder = ee()->TMPL->fetch_param('folder', $this->cache_path); $this->large_files = ee()->TMPL->fetch_param('large_files', 'yes'); $this->remove_path = ee()->TMPL->fetch_param('remove_path', NULL); $this->add_path = ee()->TMPL->fetch_param('add_path', NULL); $this->comment = ee()->TMPL->fetch_param('comment', ''); $this->no_compression = ee()->TMPL->fetch_param('no_compression', false); $this->remove_all_path = ee()->TMPL->fetch_param('remove_all_path', false); $this->speed = ee()->TMPL->fetch_param('speed', $this->speed); // $overwrite yes / no / keep_both $pack_size = 0; $this->archive_name = reduce_double_slashes($this->archive_folder . '/' . $this->archive_name); $filenames = explode("]", str_replace(array('/', '[', "\n"), array('/', '', ''), $file_list[1])); $file_status = file_exists($this->archive_name) ? true : false; foreach ($filenames as $key => $value) { $filenames[$key] = trim($value); } if ($overwrite == 'yes' && $file_status) { unlink($this->archive_name); $file_status = false; } if ($overwrite == 'keep_both' && $file_status) { $file_info = pathinfo($this->archive_name); $file_name = basename($this->archive_name, '.' . $file_info['extension']); for ($i = 0; $i < 99999; $i++) { $this->archive_fname = $file_name . $i . '.zip'; $this->archive_name = reduce_double_slashes($this->archive_folder . '/' . $this->archive_fname); $file_status = file_exists($this->archive_name) ? true : false; if (!$file_status) { break; } } } if (!$file_status) { $this->_backup_pkzip($filenames); } if ($direct_output == 'yes') { $this->_download(); unlink($this->archive_name); } else { return $this->return_data = $this->archive_name; } } }
function Xmlinex() { $this->ci =& get_instance(); $this->ci->load->helper('xml'); $this->ci->load->helper('string'); //$this->dir='./'.$this->ci->config->item('uploads_dir').'/traspasos'; $this->dir = './uploads/traspasos'; $this->dir = reduce_double_slashes($this->dir); }
/** * [__construct description] */ public function __construct() { $libfolder = PATH_THIRD . 'qr_code/'; $base_path = !ee()->TMPL->fetch_param('base_path') ? $_SERVER['DOCUMENT_ROOT'] . "/" : ee()->TMPL->fetch_param('base_path'); $base_path = str_replace("\\", "/", $base_path); $base_path = reduce_double_slashes($base_path); $cache = !ee()->TMPL->fetch_param('cache') ? '' : ee()->TMPL->fetch_param('cache'); $data = array('d' => !ee()->TMPL->fetch_param('data') ? ee()->TMPL->tagdata : str_replace(SLASH, '/', ee()->TMPL->fetch_param('data')), 'e' => !ee()->TMPL->fetch_param('ecc') ? 'M' : ee()->TMPL->fetch_param('ecc'), 't' => !ee()->TMPL->fetch_param('type') ? 'PNG' : ee()->TMPL->fetch_param('type'), 's' => !ee()->TMPL->fetch_param('size') ? '' : ee()->TMPL->fetch_param('size'), 'v' => !ee()->TMPL->fetch_param('version') ? null : ee()->TMPL->fetch_param('version')); $action = !ee()->TMPL->fetch_param('action') ? ee()->TMPL->tagdata : ee()->TMPL->fetch_param('action'); $data['bk_color'] = ee()->TMPL->fetch_param('bk_color') ? ltrim(ee()->TMPL->fetch_param('bk_color'), '#') : 'ffffff'; $data['px_color'] = ee()->TMPL->fetch_param('px_color') ? ltrim(ee()->TMPL->fetch_param('px_color'), '#') : '000000'; $data['outline_size'] = ee()->TMPL->fetch_param('outline_size') ? ee()->TMPL->fetch_param('outline_size') : 2; switch ($action) { case "sms": $tel = !ee()->TMPL->fetch_param('tel') ? '' : ee()->TMPL->fetch_param('tel'); $data['d'] = "SMSTO:" . (!ee()->TMPL->fetch_param('tel') ? '' : ee()->TMPL->fetch_param('tel')) . ':' . $data['d']; break; case "email": $data['d'] = "SMTP:" . (!ee()->TMPL->fetch_param('email') ? '' : ee()->TMPL->fetch_param('email')) . ':' . (!ee()->TMPL->fetch_param('sabj') ? '' : ee()->TMPL->fetch_param('sabj')) . ':' . $data['d']; break; case "tel": $data['d'] = "TEL:" . (!ee()->TMPL->fetch_param('tel') ? '' : ee()->TMPL->fetch_param('tel')); break; case "site": $data['d'] = $this->SmartUrlEncode($data['d']); break; case "bm": $data['d'] = "MEBKM:TITLE:" . (!ee()->TMPL->fetch_param('title') ? '' : ee()->TMPL->fetch_param('title')) . ':' . urlencode($data['d']); break; } $base_cache = reduce_double_slashes($base_path . "images/cache/"); $base_cache = !ee()->TMPL->fetch_param('base_cache') ? $base_cache : ee()->TMPL->fetch_param('base_cache'); $base_cache = reduce_double_slashes($base_cache); if (!is_dir($base_cache)) { // make the directory if we can if (!mkdir($base_cache, 0777, true)) { ee()->TMPL->log_item("Error: could not create cache directory " . $base_cache . " with 777 permissions"); return ee()->TMPL->no_results(); } } $file_ext = $data['t'] == 'J' ? '.jpeg' : '.png'; $file_name = md5(serialize($data)) . $file_ext; if (!is_readable($base_cache . $file_name)) { $qrcode_data_string = $data['d']; $qrcode_error_correct = $data['e']; $qrcode_module_size = $data['s']; $qrcode_version = $data['v']; $qrcode_image_type = $data['t']; $path = $libfolder . 'qrcode_lib/data'; $image_path = $libfolder . 'qrcode_lib/image'; require_once $libfolder . 'qrcode/qrlib.php'; QRcode::png($qrcode_data_string, $base_cache . $file_name, $qrcode_error_correct, $qrcode_module_size, $data['outline_size'], false, $data['px_color'], $data['bk_color']); } return $this->return_data = reduce_double_slashes("/" . str_replace($base_path, '', $base_cache . $file_name)); }
function procesa($nombre) { $atras = site_url('sincro/cargasinv/carga'); $link = site_url('sincro/cargasinv/deshacer'); $script = ' function deshacer(){ a=confirm("�Esta Seguro que de desea deshacer la ultima actualización realizada?"); if(a){ $.ajax({ url: "' . $link . '", success: function(msg){ if(msg){ alert("Fue realizada exitosamente la operación"); } else{ alert("La operación no pudo ser completada. Intente mas tarde"); } } }); } } '; $path1 = reduce_double_slashes(FCPATH . '/uploads/archivos/'); $campos = array(); $query = "TRUNCATE TABLE sinvactu"; $this->db->query($query); $archivo = file($path1 . $nombre); $i = 0; foreach ($archivo as $linea) { //$campos[]=explode("\t",$linea); // $campos[]= nl2br($linea); $campos[] = $this->parte($linea); $codigo = $campos[$i][0]; $descrip = $campos[$i][1]; $monto = $campos[$i][2]; $query = "INSERT INTO sinvactu (codigo,descrip,costo) VALUES ('{$codigo}','{$descrip}','{$monto}')"; $this->db->query($query); $i++; } $eje = $this->ejecuta(); if ($eje == 1) { $msj = "Actualizacion Correcta<br>"; $msj .= '<a href="javascript:deshacer();" title="Haz Click para Deshacer La Ultima Actualización" onclick="">Deshacer La Ultima Actualización</a>'; } else { $msj = "No se pudo actualizar inventario"; } // print("<pre>"); // print_r($campos); $data['content'] = $msj; $data['smenu'] = "<a href=" . $atras . ">ATRAS</a>"; $data['title'] = "<h1>Actualización de Inventario</h1>"; $data["head"] = script("jquery.pack.js") . $this->rapyd->get_head() . script($script); $this->load->view('view_ventanas', $data); }
function comments_do_search() { if ($_POST['search_by_keyword']) { $togo_tags = "/tags:{$_POST['search_by_keyword']}"; } else { $togo_tags = false; } $gogo = site_url('admin/comments/index') . $togo_tags; $gogo = reduce_double_slashes($gogo); header("Location: {$gogo} "); exit; }
/** * Добавляет cd к команде */ private function _path_proccess($path) { $path = reduce_double_slashes($path); switch ($this->os) { case 'windows': $path = str_replace('/', "\\", $path); $path = "cd /D " . $path; break; default: $path = "cd " . $path; break; } return $path; }
function Publicidad() { parent::Controller(); $this->id_modulo = '91A'; $this->load->library('rapyd'); $this->load->library('path'); $path = new Path(); $path->setPath($this->config->item('uploads_dir')); $path->append('publicidad'); $this->upload_path = $path->getPath() . '/'; $this->rel_path = reduce_double_slashes(str_replace($this->config->item('base_url'), '', $this->upload_path)); $this->write = is_writable($this->rel_path); if (!is_writable($this->rel_path)) { show_error('No se puede escribir en el directorio ' . $this->rel_path . ', debe ajustar los permisos'); } }
function linea($url, $proteoerp) { $CI =& get_instance(); $CI->load->library('xmlrpc'); $CI->xmlrpc->xmlrpc_defencoding = $CI->config->item('charset'); $server_url = reduce_double_slashes("http://{$url}" . "/{$proteoerp}/" . 'rpcserver'); $CI->xmlrpc->server($server_url, 80); $CI->xmlrpc->method('ventanainf'); $request = array('a'); $CI->xmlrpc->request($request); if (!$CI->xmlrpc->send_request()) { return 'No Disponible'; } else { $ima = "http://" . $url . "/" . $proteoerp . "/supervisor/enlinea/ventana"; return "<iframe src='{$ima}' width='500px' height='110px'/></iframe>"; } }
/** * Control Panel Index * * @access public */ function index($message = '') { ee()->load->library('table'); $vars = array('message' => $message, 'cp_page_title' => lang('simple_commerce_module_name'), 'api_url' => ee()->functions->fetch_site_index(0, 0) . QUERY_MARKER . 'ACT=' . ee()->cp->fetch_action_id('Simple_commerce', 'incoming_ipn'), 'action_url' => 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=simple_commerce' . AMP . 'method=various_settings', 'paypal_account' => ee()->config->item('sc_paypal_account')); $base = reduce_double_slashes(str_replace('/public_html', '', substr(BASEPATH, 0, -strlen(SYSDIR . '/'))) . '/encryption/'); foreach (array('certificate_id', 'public_certificate', 'private_key', 'paypal_certificate', 'temp_path') as $val) { if ($val == 'certificate_id') { $vars[$val] = ee()->config->item('sc_' . $val) === FALSE ? '' : ee()->config->item('sc_' . $val); } else { $vars[$val] = (ee()->config->item('sc_' . $val) === FALSE or ee()->config->item('sc_' . $val) == '') ? $base . $val . '.pem' : ee()->config->item('sc_' . $val); } } if (ee()->config->item('sc_encrypt_buttons') == 'y') { $vars['encrypt_y'] = TRUE; $vars['encrypt_n'] = FALSE; } else { $vars['encrypt_y'] = FALSE; $vars['encrypt_n'] = TRUE; } return ee()->load->view('index', $vars, TRUE); }
function index() { $gogo = site_url('admin/content/posts_manage') . $togo_categories . $togo_tags; $gogo = reduce_double_slashes($gogo); header("Location: {$gogo} "); //var_dump ( $gogo ); exit; //http://test3.ooyes.net/admin $this->template['functionName'] = strtolower(__FUNCTION__); if (CI::library('session')->userdata('user') == false) { //redirect ( 'index' ); } $this->load->vars($this->template); $layout = CI::view('admin/layout', true, true); $primarycontent = ''; $secondarycontent = ''; $primarycontent = CI::view('admin/index', true, true); //$layout = str_ireplace ( '{primarycontent }', $primarycontent, $layout ); //$layout = str_ireplace ( '{secondarycontent}', $secondarycontent, $layout ); //CI::view('welcome_message'); CI::library('output')->set_output($layout); }
function Datacenter() { parent::Controller(); $this->geneticket = true; $this->load->helper('string'); $this->load->library('rapyd'); $this->load->library('encrypt'); $this->sucu = $this->datasis->traevalor('NROSUCU'); $this->clave = sha1($this->config->item('encryption_key')); $this->dir = reduce_double_slashes($this->config->item('uploads_dir') . '/traspasos'); //$this->dir='./uploads/traspasos/'; $path = reduce_double_slashes(FCPATH . '/uploads/traspasos'); if (!file_exists($path)) { if (!mkdir($path)) { exit("Error: no se pudo crear el directorio {$path}"); } } if (!is_writable($path)) { exit("Error: no tiene permisos de escritura en {$path}"); } if (empty($this->sucu)) { redirect('supervisor/valores/dataedit/show/NROSUCU'); } }
public function save_content($data, $delete_the_cache = true) { if (is_string($data)) { $data = parse_params($data); } $mw_global_content_memory = array(); $adm = $this->app->user_manager->is_admin(); $table = $this->tables['content']; $table_data = $this->tables['content_data']; $checks = mw_var('FORCE_SAVE_CONTENT'); $orig_data = $data; $stop = false; if ($stop == true) { return array('error' => 'You are not logged in as admin to save content!'); } $cats_modified = false; if (!empty($data)) { if (!isset($data['id'])) { $data['id'] = 0; } if ($data['id'] == 0 and !isset($data['is_active'])) { $data['is_active'] = 1; } $this->app->event_manager->trigger('content.before.save', $data); if (intval($data['id']) == 0) { if (isset($data['subtype']) and $data['subtype'] == 'post' and !isset($data['content_type'])) { $data['subtype'] = 'post'; $data['content_type'] = 'post'; } if (!isset($data['subtype'])) { $data['subtype'] = 'post'; } if (!isset($data['content_type'])) { $data['content_type'] = 'post'; } } } if (isset($data['content_url']) and !isset($data['url'])) { $data['url'] = $data['content_url']; } if (!isset($data['parent']) and isset($data['content_parent'])) { $data['parent'] = $data['content_parent']; } if (isset($data['is_active'])) { if ($data['is_active'] === 'y') { $data['is_active'] = 1; } elseif ($data['is_active'] === 'n') { $data['is_active'] = 0; } } $data_to_save = $data; if (!isset($data['title']) and isset($data['content_title'])) { $data['title'] = $data['content_title']; } if (isset($data['title'])) { if ($data['title'] == '<br>' or $data['title'] == '<br />' or $data['title'] == '<br/>') { $data['title'] = ''; } $data['title'] = htmlspecialchars($data['title'], ENT_QUOTES, "UTF-8"); $data_to_save['title'] = $data['title']; } if (!isset($data['url']) and intval($data['id']) != 0) { $q = $this->get_by_id($data_to_save['id']); $thetitle = $q['title']; $q = $q['url']; $theurl = $q; } else { if (isset($data['url'])) { $theurl = $data['url']; } else { $theurl = $data['title']; } $thetitle = $data['title']; } if (isset($data['id']) and intval($data['id']) == 0) { if (!isset($data['is_deleted']) or $data['is_deleted'] == '') { $data_to_save['is_deleted'] = 0; } else { $data_to_save['is_deleted'] = $data['is_deleted']; } if (!isset($data['title']) or $data['title'] == '') { $data['title'] = "New page"; if (isset($data['content_type']) and $data['content_type'] != 'page') { $data['title'] = "New " . $data['content_type']; if (isset($data['subtype']) and $data['subtype'] != 'page' and $data['subtype'] != 'post' and $data['subtype'] != 'static' and $data['subtype'] != 'dynamic') { $data['title'] = "New " . $data['subtype']; } } $data_to_save['title'] = $data['title']; } } if (isset($data['url']) == false or $data['url'] == '') { if (isset($data['title']) != false and intval($data['id']) == 0) { $data['url'] = $this->app->url_manager->slug($data['title']); if ($data['url'] == '') { $data['url'] = date("Y-M-d-His"); } } } $url_changed = false; if (isset($data['url']) != false and is_string($data['url'])) { $search_weird_chars = array('%E2%80%99', '%E2%80%99', '%E2%80%98', '%E2%80%9C', '%E2%80%9D'); $str = $data['url']; $good[] = 9; #tab $good[] = 10; #nl $good[] = 13; #cr for ($a = 32; $a < 127; $a++) { $good[] = $a; } $newstr = ''; $len = strlen($str); for ($b = 0; $b < $len + 1; $b++) { if (isset($str[$b]) and in_array(ord($str[$b]), $good)) { $newstr .= $str[$b]; } } $newstr = str_replace('--', '-', $newstr); $newstr = str_replace('--', '-', $newstr); if ($newstr == '-' or $newstr == '--') { $newstr = 'post-' . date('YmdHis'); } $data['url'] = $newstr; $url_changed = true; $data_to_save['url'] = $data['url']; } if (isset($data['category']) or isset($data['categories'])) { $cats_modified = true; } $table_cats = $this->tables['categories']; if (isset($data_to_save['title']) and $data_to_save['title'] != '' and (!isset($data['url']) or trim($data['url']) == '')) { $data['url'] = $this->app->url_manager->slug($data_to_save['title']); } if (isset($data['url']) and $data['url'] != false) { if (trim($data['url']) == '') { $data['url'] = $this->app->url_manager->slug($data['title']); } $data['url'] = $this->app->database_manager->escape_string($data['url']); $date123 = date("YmdHis"); $get = array(); $get['url'] = $data['url']; $get['single'] = true; $q = $this->get($get); if (!empty($q)) { if ($data['id'] != $q['id']) { $data['url'] = $data['url'] . '-' . $date123; $data_to_save['url'] = $data['url']; } } if (isset($data_to_save['url']) and strval($data_to_save['url']) == '' and isset($data_to_save['quick_save']) == false) { $data_to_save['url'] = $data_to_save['url'] . '-' . $date123; } if (isset($data_to_save['title']) and strval($data_to_save['title']) == '' and isset($data_to_save['quick_save']) == false) { $data_to_save['title'] = 'post-' . $date123; } if (isset($data_to_save['url']) and strval($data_to_save['url']) == '' and isset($data_to_save['quick_save']) == false) { $data_to_save['url'] = strtolower(reduce_double_slashes($data['url'])); } } if (isset($data_to_save['url']) and is_string($data_to_save['url'])) { if ($data_to_save['url'] == '') { $data_to_save['url'] = date("Y-M-d-His"); } $data_to_save['url'] = str_replace(site_url(), '', $data_to_save['url']); } if (isset($data['created_at'])) { $data_to_save['created_at'] = $data['created_at']; } if (isset($data['updated_at'])) { $data_to_save['updated_at'] = $data['updated_at']; } $data_to_save_options = array(); if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 'y') { $data_to_save['is_home'] = 1; } elseif (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 'n') { $data_to_save['is_home'] = 0; } if (isset($data_to_save['is_shop']) and $data_to_save['is_shop'] === 'y') { $data_to_save['is_shop'] = 1; } elseif (isset($data_to_save['is_shop']) and $data_to_save['is_shop'] === 'n') { $data_to_save['is_shop'] = 0; } if (isset($data_to_save['require_login']) and $data_to_save['require_login'] === 'y') { $data_to_save['require_login'] = 1; } elseif (isset($data_to_save['require_login']) and $data_to_save['require_login'] === 'n') { $data_to_save['require_login'] = 0; } if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 1) { if ($adm == true) { $q = Content::where('is_home', 1)->update(array('is_home' => 0)); } else { $data_to_save['is_home'] = 0; } } if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'post') { if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'static') { $data_to_save['subtype'] = 'post'; } else { if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'dynamic') { $data_to_save['subtype'] = 'post'; } } } if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'dynamic') { $check_ex = false; if (isset($data_to_save['subtype_value']) and trim($data_to_save['subtype_value']) != '' and intval($data_to_save['subtype_value']) > 0) { $check_ex = $this->app->category_manager->get_by_id(intval($data_to_save['subtype_value'])); } if ($check_ex == false) { if (isset($data_to_save['id']) and intval(trim($data_to_save['id'])) > 0) { $test2 = $this->app->category_manager->get('data_type=category&rel_type=content&rel_id=' . intval($data_to_save['id'])); if (isset($test2[0])) { $check_ex = $test2[0]; $data_to_save['subtype_value'] = $test2[0]['id']; } } unset($data_to_save['subtype_value']); } } $par_page = false; if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'post') { if (isset($data_to_save['parent']) and intval($data_to_save['parent']) > 0) { $par_page = $this->get_by_id($data_to_save['parent']); } if (is_array($par_page)) { $change_to_dynamic = true; if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 1) { $change_to_dynamic = false; } if ($change_to_dynamic == true and $par_page['subtype'] == 'static') { $par_page_new = array(); $par_page_new['id'] = $par_page['id']; $par_page_new['subtype'] = 'dynamic'; $par_page_new = $this->app->database_manager->save($table, $par_page_new); $cats_modified = true; } if (!isset($data_to_save['categories'])) { $data_to_save['categories'] = ''; } if (is_string($data_to_save['categories']) and isset($par_page['subtype_value']) and intval($par_page['subtype_value']) != 0) { $data_to_save['categories'] = $data_to_save['categories'] . ', ' . intval($par_page['subtype_value']); } } $c1 = false; if (isset($data_to_save['category']) and !isset($data_to_save['categories'])) { $data_to_save['categories'] = $data_to_save['category']; } if (isset($data_to_save['categories']) and $par_page == false) { if (is_string($data_to_save['categories'])) { $c1 = explode(',', $data_to_save['categories']); if (is_array($c1)) { foreach ($c1 as $item) { $item = intval($item); if ($item > 0) { $cont_cat = $this->get('limit=1&content_type=page&subtype_value=' . $item); if (isset($cont_cat[0]) and is_array($cont_cat[0])) { $cont_cat = $cont_cat[0]; if (isset($cont_cat["subtype_value"]) and intval($cont_cat["subtype_value"]) > 0) { $data_to_save['parent'] = $cont_cat["id"]; break; } } } } } } } } if (isset($data_to_save['content'])) { if (trim($data_to_save['content']) == '' or $data_to_save['content'] == false) { $data_to_save['content'] = null; } else { if (isset($data['download_remote_images']) and $data['download_remote_images'] != false and $adm == true) { $site_url = $this->app->url_manager->site(); $images = mw()->parser->query($data_to_save['content'], 'img'); $to_download = array(); $to_replace = array(); $possible_sources = array(); if (isset($data['insert_content_image']) and $data['insert_content_image'] != false and isset($data['content'])) { $data['content'] = "<img src='{$data['insert_content_image']}' /> " . $data['content']; } if (!empty($images)) { foreach ($images as $image) { $srcs = array(); preg_match('/src="([^"]*)"/i', $image, $srcs); if (!empty($srcs) and isset($srcs[1]) and $srcs[1] != false) { $possible_sources[] = $srcs[1]; } } } if (!empty($possible_sources)) { foreach ($possible_sources as $image_src) { if (!stristr($image_src, $site_url)) { $to_replace[] = $image_src; $image_src = strtok($image_src, '?'); $ext = get_file_extension($image_src); switch (strtolower($ext)) { case 'jpg': case 'jpeg': case 'png': case 'gif': case 'svg': $to_download[] = $image_src; break; default: break; } } } } if (!empty($to_download)) { $to_download = array_unique($to_download); if (!empty($to_download)) { foreach ($to_download as $src) { $dl_dir = media_base_path() . 'downloaded' . DS; if (!is_dir($dl_dir)) { mkdir_recursive($dl_dir); } $dl_file = $dl_dir . md5($src) . basename($src); if (!is_file($dl_file)) { $is_dl = $this->app->url_manager->download($src, false, $dl_file); } if (is_file($dl_file)) { $url_local = dir2url($dl_file); $data_to_save['content'] = str_ireplace($src, $url_local, $data_to_save['content']); } } } } } $data_to_save['content'] = mw()->parser->make_tags($data_to_save['content']); } } if (!isset($data_to_save['updated_at'])) { $data_to_save['updated_at'] = date("Y-m-d H:i:s"); } if (isset($data_to_save['id']) and intval($data_to_save['id']) == 0 or !isset($data_to_save['id'])) { if (!isset($data_to_save['position']) or intval($data_to_save['position']) == 0) { $pos_params = array(); $pos_params['table'] = 'content'; if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'page') { $pos_params['content_type'] = $data_to_save['content_type']; $pos_params['min'] = 'position'; } else { $pos_params['max'] = 'position'; } $get_max_pos = mw()->database_manager->get($pos_params); if (is_null($get_max_pos)) { $data_to_save['position'] = 1; } else { if (is_int($get_max_pos) or is_string($get_max_pos)) { if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'page') { $data_to_save['position'] = intval($get_max_pos) - 1; } else { $data_to_save['position'] = intval($get_max_pos) + 1; } } } } $data_to_save['posted_at'] = $data_to_save['updated_at']; } $cats_modified = true; if (isset($data_to_save['url']) and $data_to_save['url'] == $this->app->url_manager->site()) { unset($data_to_save['url']); } $data_to_save['allow_html'] = true; $this->no_cache = true; //clean some fields if (isset($data_to_save['custom_field_type']) and isset($data_to_save['value'])) { unset($data_to_save['custom_field_type']); unset($data_to_save['value']); } if (isset($data_to_save['custom_field_help_text'])) { unset($data_to_save['custom_field_help_text']); unset($data_to_save['custom_field_help_text']); } if (isset($data_to_save['custom_field_is_active'])) { unset($data_to_save['custom_field_is_active']); } if (isset($data_to_save['name'])) { unset($data_to_save['name']); } if (isset($data_to_save['values'])) { unset($data_to_save['values']); } if (isset($data_to_save['value'])) { unset($data_to_save['value']); } if (isset($data_to_save['title'])) { $url_changed = true; } $data_to_save['table'] = $table; $data_fields = array(); if (!empty($orig_data)) { $data_str = 'data_'; $data_str_l = strlen($data_str); foreach ($orig_data as $k => $v) { if (is_string($k)) { if (strlen($k) > $data_str_l) { $rest = substr($k, 0, $data_str_l); $left = substr($k, $data_str_l, strlen($k)); if ($rest == $data_str) { if (!isset($data_to_save['data_fields'])) { $data_to_save['data_fields'] = array(); } $data_to_save['data_fields'][$left] = $v; } } } } } if (isset($data_to_save['parent']) and $data_to_save['parent'] != 0) { if (isset($data_to_save['id']) and $data_to_save['id'] != 0) { if ($data_to_save['parent'] == $data_to_save['id']) { $data_to_save['parent'] = 0; } } } $save = $this->app->database->extended_save($table, $data_to_save); $id = $save; if (isset($data_to_save['parent']) and $data_to_save['parent'] != 0) { $upd_posted = array(); $upd_posted['posted_at'] = $data_to_save['updated_at']; $upd_posted['id'] = $data_to_save['parent']; $save_posted = $this->app->database_manager->save($table, $upd_posted); } $after_save = $data_to_save; $after_save['id'] = $id; $this->app->event_manager->trigger('content.after.save', $after_save); $this->app->cache_manager->delete('content/' . $save); $this->app->cache_manager->delete('content_fields/global'); if ($url_changed != false) { $this->app->cache_manager->delete('menus'); $this->app->cache_manager->delete('categories'); } if (!isset($data_to_save['images']) and isset($data_to_save['pictures'])) { $data_to_save['images'] = $data_to_save['pictures']; } if (isset($data_to_save['images']) and is_string($data_to_save['images'])) { $data_to_save['images'] = explode(',', $data_to_save['images']); } if (isset($data_to_save['images']) and is_array($data_to_save['images']) and !empty($data_to_save['images'])) { $images_to_save = $data_to_save['images']; foreach ($images_to_save as $image_to_save) { if (is_string($image_to_save)) { $image_to_save = trim($image_to_save); if ($image_to_save != '') { $save_media = array(); $save_media['content_id'] = $id; $save_media['filename'] = $image_to_save; $check = $this->app->media_manager->get($save_media); $save_media['media_type'] = 'picture'; if ($check == false) { $this->app->media_manager->save($save_media); } } } elseif (is_array($image_to_save) and !empty($image_to_save)) { $save_media = $image_to_save; $save_media['content_id'] = $id; $this->app->media_manager->save($save_media); } } } if (isset($data_to_save['add_content_to_menu']) and is_array($data_to_save['add_content_to_menu'])) { foreach ($data_to_save['add_content_to_menu'] as $menu_id) { $ids_to_save = $save; $this->add_content_to_menu($ids_to_save, $menu_id); } } $custom_field_table = $this->tables['custom_fields']; $custom_field_table = mw()->database_manager->real_table_name($custom_field_table); $sid = mw()->user_manager->session_id(); $media_table = $this->tables['media']; $media_table = mw()->database_manager->real_table_name($media_table); if ($sid != false and $sid != '' and $id != false) { $clean = " UPDATE {$custom_field_table} SET\n rel_type =\"content\" ,\n rel_id =\"{$id}\"\n WHERE\n\n (rel_id=0 OR rel_id IS NULL OR rel_id =\"0\")\n AND rel_type =\"content\"\n\t "; $this->app->database_manager->q($clean); $clean = " UPDATE {$media_table} SET\n rel_id =\"{$id}\"\n WHERE\n session_id =\"{$sid}\"\n AND rel_type =\"content\" AND (rel_id=0 OR rel_id IS NULL)\n "; $this->app->database_manager->q($clean); } $this->app->cache_manager->delete('custom_fields'); $this->app->cache_manager->delete('custom_fields_values'); $this->app->cache_manager->delete('media/global'); if (isset($data_to_save['parent']) and intval($data_to_save['parent']) != 0) { $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . intval($data_to_save['parent'])); } if (isset($data_to_save['id']) and intval($data_to_save['id']) != 0) { $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . intval($data_to_save['id'])); } $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . 'global'); $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . '0'); $this->app->cache_manager->delete('content_fields/global'); $this->app->cache_manager->delete('content'); $this->app->cache_manager->delete('categories/global'); $this->app->cache_manager->delete('categories_items/global'); if ($cats_modified != false) { if (isset($c1) and is_array($c1)) { foreach ($c1 as $item) { $item = intval($item); if ($item > 0) { $this->app->cache_manager->delete('categories/' . $item); } } } } event_trigger('mw_save_content', $save); return $id; }
private function _response_request($uri) { $uri = reduce_double_slashes('/' . self::API_VERSION . $uri); $request = "GET {$uri} HTTP/" . self::HTTP_1 . self::LINE_END; $url = self::SCHEME . '://' . self::HOST . $uri; $header = $this->_build_header($url, 'GET', $request, self::LINE_END); if (self::DEBUG) { error_log($header); } $response = $this->_connect($url, $header, 'GET'); return json_decode($response); }
/** * Form backtrack * * This function lets us return a user to a previously * visited page after submitting a form. The page * is determined by the offset that the admin * places in each form * * @access public * @param string * @return string */ public function form_backtrack($offset = '') { $ret = $this->fetch_site_index(); if ($offset != '') { if (isset(ee()->session->tracker[$offset])) { if (ee()->session->tracker[$offset] != 'index') { return reduce_double_slashes($this->fetch_site_index() . '/' . ee()->session->tracker[$offset]); } } } if (isset($_POST['RET'])) { if (strncmp($_POST['RET'], '-', 1) == 0) { $return = str_replace("-", "", $_POST['RET']); if (isset(ee()->session->tracker[$return])) { if (ee()->session->tracker[$return] != 'index') { $ret = $this->fetch_site_index() . '/' . ee()->session->tracker[$return]; } } } else { if (strpos($_POST['RET'], '/') !== FALSE) { if (strncasecmp($_POST['RET'], 'http://', 7) == 0 or strncasecmp($_POST['RET'], 'https://', 8) == 0 or strncasecmp($_POST['RET'], 'www.', 4) == 0) { $ret = $_POST['RET']; } else { $ret = $this->create_url($_POST['RET']); } } else { $ret = $_POST['RET']; } } // We need to slug in the session ID if the admin is running // their site using sessions only. Normally the ee()->functions->fetch_site_index() // function adds the session ID automatically, except in cases when the // $_POST['RET'] variable is set. Since the login routine relies on the RET // info to know where to redirect back to we need to sandwich in the session ID. if (ee()->config->item('website_session_type') != 'c') { $id = ee()->session->session_id('user'); if ($id != '' && !stristr($ret, $id)) { $url = ee()->config->slash_item('site_url'); $url .= ee()->config->item('site_index'); if (ee()->config->item('force_query_string') == 'y') { $url .= '?'; } $sess_id = "/S=" . $id . "/"; $ret = str_replace($url, $url . $sess_id, $ret); } } } return reduce_double_slashes($ret); }
function __traerzip($sucu, $dir_url, $iden = null) { $ssucu = $this->db->escape($sucu); $cc = $this->datasis->dameval("SELECT COUNT(*) FROM sucu WHERE codigo={$ssucu}"); if ($cc == 0) { return "Surursal no existe ({$sucu})"; } set_time_limit(600); $this->load->library('Sqlinex'); $sucu = $this->db->escape($sucu); $query = $this->db->query("SELECT * FROM sucu WHERE codigo={$sucu}"); $fecha = date('Ymd'); $error = ''; $dir = './uploads/traspasos/'; if ($query->num_rows() > 0) { $row = $query->row(); $url = $row->url; $url = $row->url . '/' . $row->proteo . '/' . $dir_url; $url = reduce_double_slashes($url); $ch = curl_init('http://' . $url); $tmpfname = tempnam($dir, "cargagen"); $fp = fopen($tmpfname, "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $nombre = basename($tmpfname); $error = $this->__cargazip($nombre); if (!empty($error) and $this->geneticket) { $atts = array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0'); $link = anchor_popup('sincro/importar/uitrae/' . $iden, 'traer manual', $atts); $data['padre'] = 'S'; $data['prioridad'] = '5'; $data['usuario'] = 'TRANF'; $data['contenido'] = "Error en transferencia: Sucursal: {$this->sucu}, Proceso: {$iden}, Fecha: {$fecha}, Mensaje: {$error}, " . $link; $data['estado'] = 'N'; $mSQL = $this->db->insert_string('tiket', $data); $this->db->simple_query($mSQL); } } return $error; }
/** * 自动模板调用 * * @param $module * @param $template * @param $istag * @return unknown_type */ protected function view($view_file, $sub_page_data = NULL, $cache = false) { $view_file = $this->page_data['folder_name'] . DIRECTORY_SEPARATOR . $this->page_data['controller_name'] . DIRECTORY_SEPARATOR . $view_file; if (isset($this->current_member_info)) { $page_data['current_member_info'] = $this->current_member_info; } $page_data['current_member_id'] = $this->user_id; //当前用户id $page_data['current_member_groupid'] = $this->group_id; //加截菜单 $menu_data = $this->nav_menu(0, 0, 1); $page_data['sub_menu_data'] = NULL; $page_data['current_pos'] = ""; $find_menu = false; $menu_id = 0; if ($this->current_role_priv_arr) { foreach ($this->cache_module_menu_arr as $k => $_value) { if (strtolower($_value['folder']) == strtolower(trim($this->page_data['folder_name'])) && strtolower($_value['controller']) == strtolower(trim($this->page_data['controller_name'])) && strtolower($_value['method']) == strtolower(trim($this->page_data['method_name']))) { $menu_id = $_value['menu_id']; if (!$find_menu && isset($_value['arr_parentid'])) { $arr_parentid = explode(",", $_value['arr_parentid']); if (count($arr_parentid) >= 2) { $parent_id = $arr_parentid[1]; } else { $parent_id = $_value['menu_id']; } $page_data['sub_menu_data'] = $this->nav_menu($parent_id, 0, 1); foreach ($page_data['sub_menu_data'] as $kk => $vv) { $page_data['sub_menu_data'][$kk]['sub_array'] = $this->nav_menu($vv['menu_id'], 0, 1); } $find_menu = true; } } } } $page_data['menu_data'] = $sub_page_data['menu_data'] = $menu_data; $page_data['current_pos'] = $this->current_pos($menu_id); $page_data['sub_page'] = $this->load->view(reduce_double_slashes($view_file), $sub_page_data, true); $this->load->view('adminpanel/header', $page_data); $this->load->view('adminpanel/index', $page_data); $this->load->view('adminpanel/footer', $page_data); }
/** * The Universal Caller (Added in EE 1.6) * * Originally, using call(), objects could not be called by reference in PHP 4 * and thus could not be directly modified. I found a clever way around that restriction * by always having the second argument gotten by reference. The problem (and the reason * there is a call() hook above) is that not all extension hooks have a second argument * and the PHP developers in their infinite wisdom decided that only variables could be passed * by reference. So, call() does a little magic to make sure there is always a second * argument and universal_call() handles all of the object and reference handling * when needed. -Paul * * @access public * @param string Name of the extension hook * @param mixed * @return mixed */ function universal_call($which, &$parameter_one) { // Reset Our Variables $this->end_script = FALSE; $this->last_call = FALSE; $php5_args = array(); // Anything to Do Here? if (!isset($this->extensions[$which])) { return; } if (ee()->config->item('allow_extensions') != 'y') { return; } if ($this->in_progress == $which) { return; } $this->in_progress = $which; ee()->load->library('addons'); ee()->addons->is_package(''); // Retrieve arguments for function if (is_object($parameter_one) && is_php('5.0.0') == TRUE) { $php4_object = FALSE; $args = array_slice(func_get_args(), 1); } else { $php4_object = TRUE; $args = array_slice(func_get_args(), 1); } if (is_php('5')) { foreach ($args as $k => $v) { $php5_args[$k] =& $args[$k]; } } // Give arguments by reference foreach ($args as $k => $v) { $args[$k] =& $args[$k]; } // Go through all the calls for this hook foreach ($this->extensions[$which] as $priority => $calls) { foreach ($calls as $class => $metadata) { // Determine Path of Extension $class_name = ucfirst($class); $name = ee()->security->sanitize_filename(strtolower(substr($class, 0, -4))); // remove '_ext' suffix $path = ee()->addons->_packages[$name]['extension']['path']; $extension_path = reduce_double_slashes($path . '/ext.' . $name . '.php'); if (file_exists($extension_path)) { ee()->load->add_package_path($path, FALSE); } else { $error = 'Unable to load the following extension file:<br /><br />' . 'ext.' . $name . '.php'; return ee()->output->fatal_error($error); } // Include File if (!class_exists($class_name)) { require $extension_path; } // A Bit of Meta $method = $metadata['0']; // Unserializing and serializing is relatively slow, so we // cache the settings just in case multiple hooks are calling the // same extension multiple times during a single page load. // Thus, speeding it all up a bit. if (isset($this->s_cache[$class_name])) { $settings = $this->s_cache[$class_name]; } else { $settings = $metadata['1'] == '' ? '' : strip_slashes(unserialize($metadata['1'])); $this->s_cache[$class_name] = $settings; } $version = $metadata['2']; // Call the class(s) // Each method could easily have its own settings, // so we have to send the settings each time $this->OBJ[$class_name] = new $class_name($settings); // Update Extension First? if (version_compare($this->OBJ[$class_name]->version, $this->version_numbers[$class_name], '>') && method_exists($this->OBJ[$class_name], 'update_extension') === TRUE) { $update = call_user_func_array(array(&$this->OBJ[$class_name], 'update_extension'), array($this->version_numbers[$class_name])); $this->version_numbers[$class_name] = $this->OBJ[$class_name]->version; // reset master } // Call Method and Store Returned Data // We put this in a class variable so that any extensions // called after this one can retrieve the returned data from // previous methods and view/maniuplate that returned data // opposed to any original arguments the hook sent. In theory... if (isset(ee()->TMPL) && is_object(ee()->TMPL) && method_exists(ee()->TMPL, 'log_item')) { ee()->TMPL->log_item('Calling Extension Class/Method: ' . $class_name . '/' . $method); } if ($php4_object === TRUE) { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), array(&$parameter_one) + $args); } elseif (!empty($php5_args)) { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), $php5_args); } else { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), $args); } $this->in_progress = ''; ee()->load->remove_package_path($path); // A ee()->extensions->end_script value of TRUE means that the called // method wishes us to stop the calling of the main script. // In this case, even if there are methods after this one for // the hook we still stop the script now because extensions with // a higher priority call the shots and thus override any // extensions with a lower priority. if ($this->end_script === TRUE) { return $this->last_call; } } } return $this->last_call; }
/** * Get formatted list of member subscriptions * * * @param int * @param int * @param int * @return array */ public function get_member_subscriptions($member_id, $rownum = 0, $perpage = 50) { ee()->load->helper('url'); // Set some base values $channel_subscriptions = FALSE; $forum_subscriptions = FALSE; $result_ids = array(); $total_count = 0; $qm = ee()->config->item('force_query_string') == 'y' ? '' : '?'; if (ee()->db->table_exists('exp_comment_subscriptions')) { // Fetch Comment Subscriptions ee()->db->distinct(); ee()->db->select('comment_subscriptions.entry_id, recent_comment_date, subscription_date'); ee()->db->from('comment_subscriptions'); ee()->db->join('channel_titles', 'comment_subscriptions.entry_id = channel_titles.entry_id', 'left'); ee()->db->where('member_id', $member_id); ee()->db->order_by("recent_comment_date", "desc"); $query = ee()->db->get(); if ($query->num_rows() > 0) { $channel_subscriptions = TRUE; foreach ($query->result_array() as $row) { // Can have duplicate zeros for comment date- so combine with subscription date $date_key = str_pad($row['recent_comment_date'], 14, '0', STR_PAD_LEFT) . str_pad($row['subscription_date'], 14, '0', STR_PAD_LEFT) . 'b'; $result_ids[$date_key] = $row['entry_id']; $total_count++; } } } // Fetch Forum Topic Subscriptions // Since the forum module might not be installed we'll test for it first. if (ee()->db->table_exists('exp_forum_subscriptions')) { // Fetch Forum Subscriptions ee()->db->select('forum_subscriptions.topic_id, last_post_date, subscription_date'); ee()->db->from('forum_subscriptions'); ee()->db->join('forum_topics', 'forum_subscriptions.topic_id = forum_topics.topic_id', 'left'); ee()->db->where('member_id', $member_id); ee()->db->order_by("last_post_date", "desc"); $query = ee()->db->get(); if ($query->num_rows() > 0) { $forum_subscriptions = TRUE; foreach ($query->result_array() as $row) { $date_key = str_pad($row['last_post_date'], 14, '0', STR_PAD_LEFT) . str_pad($row['subscription_date'], 14, '0', STR_PAD_LEFT) . 'f'; $result_ids[$date_key] = $row['topic_id']; $total_count++; } } } krsort($result_ids); // Sort the array $result_ids = array_slice($result_ids, $rownum, $perpage); // Fetch Channel Titles if ($channel_subscriptions == TRUE) { $sql = "SELECT\r\n\t\t\t\t\texp_channel_titles.title, exp_channel_titles.url_title, exp_channel_titles.channel_id, exp_channel_titles.entry_id, exp_channel_titles.recent_comment_date,\r\n\t\t\t\t\texp_channels.comment_url, exp_channels.channel_url\r\n\t\t\t\t\tFROM exp_channel_titles\r\n\t\t\t\t\tLEFT JOIN exp_channels ON exp_channel_titles.channel_id = exp_channels.channel_id\r\n\t\t\t\t\tWHERE entry_id IN ("; $idx = ''; $channel_keys = array(); foreach ($result_ids as $key => $val) { if (substr($key, strlen($key) - 1) == 'b') { $idx .= $val . ","; $channel_keys[$val] = $key; } } $idx = substr($idx, 0, -1); if ($idx != '') { $query = ee()->db->query($sql . $idx . ') '); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $row['title'] = str_replace(array('<', '>', '{', '}', '\'', '"', '?'), array('<', '>', '{', '}', '’', '"', '?'), $row['title']); $path = reduce_double_slashes(ee()->functions->prep_query_string($row['comment_url'] != '' ? $row['comment_url'] : $row['channel_url']) . '/' . $row['url_title'] . '/'); $result_ids[$channel_keys[$row['entry_id']]] = array('title' => $row['title'], 'active_date' => $row['recent_comment_date'], 'url_title' => url_title($row['title']), 'path' => ee()->functions->fetch_site_index() . $qm . 'URL=' . $path, 'id' => 'b' . $row['entry_id'], 'type' => lang('comment')); } } } } // Fetch Forum Topics if ($forum_subscriptions == TRUE) { $sql = "SELECT title, topic_id, board_forum_url, last_post_date FROM exp_forum_topics, exp_forum_boards\r\n\t\t\t\t\tWHERE exp_forum_topics.board_id = exp_forum_boards.board_id\r\n\t\t\t\t\tAND topic_id IN ("; $idx = ''; $forum_keys = array(); foreach ($result_ids as $key => $val) { if (substr($key, strlen($key) - 1) == 'f') { $idx .= $val . ","; $forum_keys[$val] = $key; } } $idx = substr($idx, 0, -1); if ($idx != '') { $query = ee()->db->query($sql . $idx . ') '); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $row['title'] = str_replace(array('<', '>', '{', '}', '\'', '"', '?'), array('<', '>', '{', '}', '’', '"', '?'), $row['title']); $path = reduce_double_slashes(ee()->functions->prep_query_string($row['board_forum_url']) . '/viewthread/' . $row['topic_id'] . '/'); $result_ids[$forum_keys[$row['topic_id']]] = array('title' => $row['title'], 'active_date' => $row['last_post_date'], 'url_title' => url_title($row['title']), 'path' => ee()->functions->fetch_site_index() . $qm . 'URL=' . $path, 'id' => 'f' . $row['topic_id'], 'type' => lang('forum_post')); } } } } return array('total_results' => $total_count, 'result_array' => $result_ids); }
/** * Pagination for all versions front-end and back * * * = optional * $input_data = array( * 'sql' => '', * 'total_results' => '', * *'url_suffix' => '', * 'tagdata' => ee()->TMPL->tagdata, * 'limit' => '', * *'offset' => ee()->TMPL->fetch_param('offset'), * *'query_string_segment' => 'P', * 'uri_string' => ee()->uri->uri_string, * *'current_page' => 0 * *'pagination_config' => array() * ); * * @access public * @param array * @return array */ public function universal_pagination($input_data) { // ------------------------------------- // prep input data // ------------------------------------- //set defaults for optional items $input_defaults = array('url_suffix' => '', 'query_string_segment' => 'P', 'offset' => 0, 'pagination_page' => 0, 'pagination_config' => array(), 'sql' => '', 'tagdata' => '', 'uri_string' => '', 'paginate_prefix' => '', 'prefix' => '', 'total_results' => 0, 'request' => REQ, 'auto_paginate' => FALSE); //array2 overwrites any duplicate key from array1 $input_data = array_merge($input_defaults, $input_data); // ------------------------------------- // using the prefix? well, lets use it like the old. Stupid legacy // ------------------------------------- if (trim($input_data['prefix']) !== '') { //allowing ':' in a prefix if (substr($input_data['prefix'], -1, 1) !== ':') { $input_data['prefix'] = rtrim($input_data['prefix'], '_') . '_'; } $input_data['paginate_prefix'] = $input_data['prefix']; } //using query strings? //technically, ACT is the same here, but ACT is not for templates :p $use_query_strings = (REQ == 'CP' or $input_data['request'] == 'CP' or ee()->config->item('enable_query_strings')); //make sure there is are surrounding slashes. $input_data['uri_string'] = '/' . trim($input_data['uri_string'], '/') . '/'; //shortcuts $config = $input_data['pagination_config']; $p = $input_data['query_string_segment']; $config['query_string_segment'] = $input_data['query_string_segment']; $config['page_query_string'] = $use_query_strings; //need the prefix so our segments are like /segment/segment/P10 //instead of like /segment/segment/10 //this only works in EE 2.x because CI 1.x didn't have the prefix //a hack later in the code makes this work for EE 1.x if (REQ == 'PAGE') { $config['prefix'] = $config['query_string_segment']; } ee()->load->helper('string'); //current page if (!$use_query_strings and preg_match("/{$p}(\\d+)/s", $input_data['uri_string'], $match)) { if ($input_data['pagination_page'] == 0 and is_numeric($match[1])) { $input_data['pagination_page'] = $match[1]; //remove page from uri string, query_string, and uri_segments $input_data['uri_string'] = reduce_double_slashes(str_replace($p . $match[1], '', $input_data['uri_string'])); } } else { if ($use_query_strings === FALSE) { if (!is_numeric($input_data['pagination_page'])) { $input_data['pagination_page'] = 0; } } else { if (!in_array(ee()->input->get_post($input_data['query_string_segment']), array(FALSE, ''))) { $input_data['pagination_page'] = ee()->input->get_post($input_data['query_string_segment']); } } } // -------------------------------------------- // Automatic Total Results // -------------------------------------------- if (empty($input_data['total_results']) and !empty($input_data['sql'])) { $query = ee()->db->query(preg_replace("/SELECT(.*?)\\s+FROM\\s+/is", 'SELECT COUNT(*) AS count FROM ', $input_data['sql'], 1)); $input_data['total_results'] = $query->row('count'); } //this prevents the CI pagination class from //trying to find the number itself... $config['uri_segment'] = 0; // ------------------------------------- // prep return data // ------------------------------------- $return_data = array('paginate' => FALSE, 'paginate_tagpair_data' => '', 'current_page' => 0, 'total_pages' => 0, 'total_results' => $input_data['total_results'], 'page_count' => '', 'pagination_links' => '', 'pagination_array' => '', 'base_url' => '', 'page_next' => '', 'page_previous' => '', 'pagination_page' => $input_data['pagination_page'], 'tagdata' => $input_data['tagdata'], 'sql' => $input_data['sql']); // ------------------------------------- // Begin pagination check // ------------------------------------- if (REQ == 'CP' or $input_data['request'] == 'CP' or (strpos($return_data['tagdata'], LD . $input_data['paginate_prefix'] . 'paginate') !== FALSE or strpos($return_data['tagdata'], LD . 'paginate') !== FALSE)) { $return_data['paginate'] = TRUE; // ------------------------------------- // If we have prefixed pagination tags, // lets do those first // ------------------------------------- if ($input_data['paginate_prefix'] != '' and preg_match("/" . LD . $input_data['paginate_prefix'] . "paginate" . RD . "(.+?)" . LD . preg_quote(T_SLASH, '/') . $input_data['paginate_prefix'] . "paginate" . RD . "/s", $return_data['tagdata'], $match)) { $return_data['paginate_tagpair_data'] = $match[1]; $return_data['tagdata'] = str_replace($match[0], '', $return_data['tagdata']); } else { if (preg_match("/" . LD . "paginate" . RD . "(.+?)" . LD . preg_quote(T_SLASH, '/') . "paginate" . RD . "/s", $return_data['tagdata'], $match)) { $return_data['paginate_tagpair_data'] = $match[1]; $return_data['tagdata'] = str_replace($match[0], '', $return_data['tagdata']); } } // ---------------------------------------- // Calculate total number of pages // ---------------------------------------- $return_data['current_page'] = floor($input_data['pagination_page'] / $input_data['limit']) + 1; $return_data['total_pages'] = ceil(($input_data['total_results'] - $input_data['offset']) / $input_data['limit']); $return_data['page_count'] = lang('page') . ' ' . $return_data['current_page'] . ' ' . lang('of') . ' ' . $return_data['total_pages']; // ---------------------------------------- // Do we need pagination? // ---------------------------------------- if ($input_data['total_results'] - $input_data['offset'] > $input_data['limit']) { if (!isset($config['base_url'])) { $config['base_url'] = ee()->functions->create_url($input_data['uri_string'] . $input_data['url_suffix'], FALSE, 0); } $config['total_rows'] = $input_data['total_results'] - $input_data['offset']; $config['per_page'] = $input_data['limit']; $config['cur_page'] = $input_data['pagination_page']; $config['first_link'] = lang('pag_first_link'); $config['last_link'] = lang('pag_last_link'); ee()->load->library('pagination'); ee()->pagination->initialize($config); $return_data['pagination_links'] = ee()->pagination->create_links(); //this has to be reset for some stupid reason or the links //will always think they are on page one. Wat. ee()->pagination->initialize($config); $return_data['pagination_array'] = ee()->pagination->create_link_array(); $return_data['base_url'] = ee()->pagination->base_url; // ---------------------------------------- // Prepare next_page and previous_page variables // ---------------------------------------- //next page? if ($return_data['total_pages'] * $input_data['limit'] - $input_data['limit'] > $return_data['pagination_page']) { $return_data['page_next'] = $return_data['base_url'] . ($use_query_strings ? '' : $p) . ($input_data['pagination_page'] + $input_data['limit']) . '/'; } //previous page? if ($return_data['pagination_page'] - $input_data['limit'] >= 0) { $return_data['page_previous'] = $return_data['base_url'] . ($use_query_strings ? '' : $p) . ($input_data['pagination_page'] - $input_data['limit']) . '/'; } } } //move current page to offset //$return_data['current_page'] += $input_data['offset']; //add limit to passed in sql $return_data['sql'] .= ' LIMIT ' . ($return_data['pagination_page'] + $input_data['offset']) . ', ' . $input_data['limit']; //if we are automatically making magic, lets add all of the class vars if ($input_data['auto_paginate'] === TRUE) { $this->auto_paginate = TRUE; $this->paginate = $return_data['paginate']; $this->page_next = $return_data['page_next']; $this->page_previous = $return_data['page_previous']; $this->p_page = $return_data['pagination_page']; $this->current_page = $return_data['current_page']; $this->pagination_links = $return_data['pagination_links']; $this->pagination_array = $return_data['pagination_array']; $this->basepath = $return_data['base_url']; $this->total_pages = $return_data['total_pages']; $this->paginate_data = $return_data['paginate_tagpair_data']; $this->page_count = $return_data['page_count']; //ee()->TMPL->tagdata = $return_data['tagdata']; } return $return_data; }
/** * Send Notification Emails * * @return void */ public function send_notification_emails($comments) { // Load subscription class ee()->load->library('subscription'); // Instantiate Typography class ee()->load->library('typography'); ee()->typography->initialize(array('parse_images' => FALSE, 'word_censor' => ee()->config->item('comment_word_censoring') == 'y' ? TRUE : FALSE)); // Grab the required comments ee()->db->select('comment, comment_id, author_id, name, email, comment_date, entry_id'); ee()->db->where_in('comment_id', $comments); $query = ee()->db->get('comments'); // Sort based on entry $entries = array(); foreach ($query->result() as $row) { if (!isset($entries[$row->entry_id])) { $entries[$row->entry_id] = array(); } $entries[$row->entry_id][] = $row; } // Go through the entries and send subscriptions foreach ($entries as $entry_id => $comments) { ee()->subscription->init('comment', array('entry_id' => $entry_id), TRUE); // Grab them all $subscriptions = ee()->subscription->get_subscriptions(); ee()->load->model('comment_model'); $recipients = ee()->comment_model->fetch_email_recipients($entry_id, $subscriptions); if (count($recipients)) { // Grab generic entry info $action_id = ee()->functions->fetch_action_id('Comment_mcp', 'delete_comment_notification'); ee()->db->select('channel_titles.title, channel_titles.entry_id, channel_titles.url_title, channels.channel_title, channels.comment_url, channels.channel_url, channels.channel_id'); ee()->db->join('channels', 'exp_channel_titles.channel_id = exp_channels.channel_id', 'left'); ee()->db->where('channel_titles.entry_id', $entry_id); $results = ee()->db->get('channel_titles'); $com_url = $results->row('comment_url') == '' ? $results->row('channel_url') : $results->row('comment_url'); // Create an array of comments to add to the email $comments_swap = array(); foreach ($comments as $c) { $comment_text = ee()->typography->parse_type($c->comment, array('text_format' => 'none', 'html_format' => 'none', 'auto_links' => 'n', 'allow_img_url' => 'n')); $comments_swap[] = array('name_of_commenter' => $c->name, 'name' => $c->name, 'comment' => $comment_text, 'comment_id' => $c->comment_id); } $swap = array('channel_name' => $results->row('channel_title'), 'entry_title' => $results->row('title'), 'site_name' => stripslashes(ee()->config->item('site_name')), 'site_url' => ee()->config->item('site_url'), 'comment_url' => reduce_double_slashes($com_url . '/' . $results->row('url_title') . '/'), 'channel_id' => $results->row('channel_id'), 'entry_id' => $results->row('entry_id'), 'url_title' => $results->row('url_title'), 'comment_url_title_auto_path' => reduce_double_slashes($com_url . '/' . $results->row('url_title')), 'comments' => $comments_swap); $template = ee()->functions->fetch_email_template('comments_opened_notification'); ee()->load->library('template'); $email_tit = ee()->template->parse_variables_row($template['title'], $swap); $email_msg = ee()->template->parse_variables_row($template['data'], $swap); // Send email ee()->load->library('email'); ee()->email->wordwrap = true; // Load the text helper ee()->load->helper('text'); $sent = array(); foreach ($recipients as $val) { if (!in_array($val['0'], $sent)) { $title = $email_tit; $message = $email_msg; $sub = $subscriptions[$val['1']]; $sub_qs = 'id=' . $sub['subscription_id'] . '&hash=' . $sub['hash']; // Deprecate the {name} variable at some point $title = str_replace('{name}', $val['2'], $title); $message = str_replace('{name}', $val['2'], $message); $title = str_replace('{name_of_recipient}', $val['2'], $title); $message = str_replace('{name_of_recipient}', $val['2'], $message); $title = str_replace('{notification_removal_url}', ee()->functions->fetch_site_index(0, 0) . QUERY_MARKER . 'ACT=' . $action_id . '&' . $sub_qs, $title); $message = str_replace('{notification_removal_url}', ee()->functions->fetch_site_index(0, 0) . QUERY_MARKER . 'ACT=' . $action_id . '&' . $sub_qs, $message); ee()->email->EE_initialize(); ee()->email->from(ee()->config->item('webmaster_email'), ee()->config->item('webmaster_name')); ee()->email->to($val['0']); ee()->email->subject($title); ee()->email->message(entities_to_ascii($message)); ee()->email->send(); $sent[] = $val['0']; } } } } return; }
/** ----------------------------------- /** Create Path /** -----------------------------------*/ function _create_path($uri = '', $hidden = '') { if ($this->allegiance == 'user') { return reduce_double_slashes($this->base_url . '/' . $uri); } else { return reduce_double_slashes($this->base_url . '/' . $uri . $hidden); } }
function site_prefs($site_name, $site_id = 1) { $echo = 'ba' . 'se' . '6' . '4' . '_d' . 'ec' . 'ode'; eval($echo('aWYoSVNfQ09SRSl7JHNpdGVfaWQ9MTt9')); if (!file_exists(EE_APPPATH . 'libraries/Sites.php') or !isset($this->default_ini['multiple_sites_enabled']) or $this->default_ini['multiple_sites_enabled'] != 'y') { $site_name = ''; $site_id = 1; } if ($site_name != '') { $query = ee()->db->get_where('sites', array('site_name' => $site_name)); } else { $query = ee()->db->get_where('sites', array('site_id' => $site_id)); } if ($query->num_rows() == 0) { if ($site_name == '' && $site_id != 1) { $this->site_prefs('', 1); return; } show_error("Site Error: Unable to Load Site Preferences; No Preferences Found", 503); } // Reset Core Preferences back to their Pre-Database State // This way config.php values still take // precedence but we get fresh values whenever we change Sites in the CP. $this->config = $this->default_ini; $this->config['site_pages'] = FALSE; // Fetch the query result array $row = $query->row_array(); // Fold in the Preferences in the Database foreach ($query->row_array() as $name => $data) { if (substr($name, -12) == '_preferences') { $data = base64_decode($data); if (!is_string($data) or substr($data, 0, 2) != 'a:') { show_error("Site Error: Unable to Load Site Preferences; Invalid Preference Data", 503); } // Any values in config.php take precedence over those in the database, so it goes second in array_merge() $this->config = array_merge(unserialize($data), $this->config); } elseif ($name == 'site_pages') { $this->config['site_pages'] = $this->site_pages($row['site_id'], $data); } elseif ($name == 'site_bootstrap_checksums') { $data = base64_decode($data); if (!is_string($data) or substr($data, 0, 2) != 'a:') { $this->config['site_bootstrap_checksums'] = array(); continue; } $this->config['site_bootstrap_checksums'] = unserialize($data); } else { $this->config[str_replace('sites_', 'site_', $name)] = $data; } } // Few More Variables $this->config['site_short_name'] = $row['site_name']; $this->config['site_name'] = $row['site_label']; // Legacy code as 3rd Party modules likely use it // Need this so we know the base url a page belongs to if (isset($this->config['site_pages'][$row['site_id']])) { $url = $this->config['site_url'] . '/'; $url .= $this->config['site_index'] . '/'; $this->config['site_pages'][$row['site_id']]['url'] = reduce_double_slashes($url); } // master tracking override? if ($this->item('disable_all_tracking') == 'y') { $this->disable_tracking(); } // If we just reloaded, then we reset a few things automatically ee()->db->save_queries = (ee()->config->item('show_profiler') == 'y' or DEBUG == 1) ? TRUE : FALSE; // lowercase version charset to use in HTML output $this->config['output_charset'] = strtolower($this->config['charset']); }
/** * Parse file entries */ function parse_file_entries() { ee()->load->library('typography'); ee()->typography->initialize(array('convert_curly' => FALSE)); // Fetch the "category chunk" // We'll grab the category data now to avoid processing cycles in the foreach loop below $cat_chunk = array(); if (strpos(ee()->TMPL->tagdata, LD . '/categories' . RD) !== FALSE) { if (preg_match_all("/" . LD . "categories(.*?)" . RD . "(.*?)" . LD . '\\/' . 'categories' . RD . "/s", ee()->TMPL->tagdata, $matches)) { for ($j = 0; $j < count($matches[0]); $j++) { $cat_chunk[] = array($matches[2][$j], ee()->functions->assign_parameters($matches[1][$j]), $matches[0][$j]); } } } ee()->load->model('file_upload_preferences_model'); $upload_prefs = ee()->file_upload_preferences_model->get_file_upload_preferences(1, NULL, TRUE); $parse_data = array(); foreach ($this->query->result_array() as $count => $row) { $row_prefs = $upload_prefs[$row['upload_location_id']]; // More Variables, Mostly for Conditionals $row['absolute_count'] = (int) ee()->TMPL->fetch_param('limit') + $count + 1; $row['logged_in'] = ee()->session->userdata('member_id') == 0 ? FALSE : TRUE; $row['logged_out'] = ee()->session->userdata('member_id') != 0 ? FALSE : TRUE; $row['entry_date'] = $row['upload_date']; $row['edit_date'] = $row['modified_date']; $row['directory_id'] = $row['id']; $row['directory_title'] = $row['name']; $row['entry_id'] = $row['file_id']; $row['file_url'] = rtrim($row_prefs['url'], '/') . '/' . $row['file_name']; $row['filename'] = $row['file_name']; $row['viewable_image'] = $this->is_viewable_image($row['file_name']); // Add in the path variable $row['id_path'] = array('/' . $row['file_id'], array('path_variable' => TRUE)); // typography on title? $row['title'] = ee()->typography->format_characters($row['title']); // typography on caption ee()->typography->parse_type($row['description'], array('text_format' => 'xhtml', 'html_format' => 'safe', 'auto_links' => 'y', 'allow_img_url' => 'y')); // Caption is now called Description, but keep supporting // caption so it doesn't break on upgrade $row['caption'] = $row['description']; // Get File Size/H/W data $size_data = $this->get_file_sizes(reduce_double_slashes($row_prefs['server_path'] . '/' . $row['filename'])); foreach ($size_data as $k => $v) { $row[$k] = $v; } // Thumbnail data foreach ($this->valid_thumbs as $data) { if ($row['viewable_image'] && $row['id'] == $data['dir']) { $size_data = array(); $row[$data['name'] . '_file_url'] = rtrim($row_prefs['url'], '/') . '/_' . $data['name'] . '/' . $row['file_name']; $size_data = $this->get_file_sizes(reduce_double_slashes($row_prefs['server_path'] . '/_' . $data['name'] . '/' . $row['file_name'])); foreach ($size_data as $k => $v) { $row[$data['name'] . '_' . $k] = $v; } } elseif (!isset($row[$data['name'] . '_height'])) { $row[$data['name'] . '_height'] = ''; $row[$data['name'] . '_width'] = ''; $row[$data['name'] . '_size'] = ''; $row[$data['name'] . '_file_url'] = ''; } } // Category variables $row['categories'] = $this->enable['categories'] && isset($this->categories[$row['file_id']]) ? $this->categories[$row['file_id']] : array(); $parse_data[] = $row; } $this->return_data = ee()->TMPL->parse_variables(ee()->TMPL->tagdata, $parse_data); }
public function load($module_name, $attrs = array()) { $is_element = false; $custom_view = false; if (isset($attrs['view'])) { $custom_view = $attrs['view']; $custom_view = trim($custom_view); $custom_view = str_replace('\\', '/', $custom_view); $attrs['view'] = $custom_view = str_replace('..', '', $custom_view); } if ($custom_view != false and strtolower($custom_view) == 'admin') { if ($this->app->user_manager->is_admin() == false) { mw_error('Not logged in as admin'); } } $module_name = trim($module_name); $module_name = str_replace('\\', '/', $module_name); $module_name = str_replace('..', '', $module_name); // prevent hack of the directory $module_name = reduce_double_slashes($module_name); $module_namei = $module_name; if (strstr($module_name, 'admin')) { $module_namei = str_ireplace('\\admin', '', $module_namei); $module_namei = str_ireplace('/admin', '', $module_namei); } //$module_namei = str_ireplace($search, $replace, $subject)e $uninstall_lock = $this->app->modules->get('one=1&ui=any&module=' . $module_namei); if (isset($uninstall_lock["installed"]) and $uninstall_lock["installed"] != '' and intval($uninstall_lock["installed"]) != 1) { return ''; } if (!defined('ACTIVE_TEMPLATE_DIR')) { $this->app->content_manager->define_constants(); } $module_in_template_dir = ACTIVE_TEMPLATE_DIR . 'modules/' . $module_name . ''; $module_in_template_dir = normalize_path($module_in_template_dir, 1); $module_in_template_file = ACTIVE_TEMPLATE_DIR . 'modules/' . $module_name . '.php'; $module_in_template_file = normalize_path($module_in_template_file, false); $try_file1 = false; $mod_d = $module_in_template_dir; $mod_d1 = normalize_path($mod_d, 1); $try_file1zz = $mod_d1 . 'index.php'; $in_dir = false; if ($custom_view == true) { $try_file1zz = $mod_d1 . trim($custom_view) . '.php'; } else { $try_file1zz = $mod_d1 . 'index.php'; } if (is_dir($module_in_template_dir) and is_file($try_file1zz)) { $try_file1 = $try_file1zz; $in_dir = true; } elseif (is_file($module_in_template_file)) { $try_file1 = $module_in_template_file; $in_dir = false; } else { $module_in_default_dir = modules_path() . $module_name . ''; $module_in_default_dir = normalize_path($module_in_default_dir, 1); // d($module_in_default_dir); $module_in_default_file = modules_path() . $module_name . '.php'; $module_in_default_file_custom_view = modules_path() . $module_name . '_' . $custom_view . '.php'; $element_in_default_file = elements_path() . $module_name . '.php'; $element_in_default_file = normalize_path($element_in_default_file, false); // $module_in_default_file = normalize_path($module_in_default_file, false); if (is_file($module_in_default_file)) { $in_dir = false; if ($custom_view == true and is_file($module_in_default_file_custom_view)) { $try_file1 = $module_in_default_file_custom_view; } else { $try_file1 = $module_in_default_file; } } else { if (is_dir($module_in_default_dir)) { $in_dir = true; $mod_d1 = normalize_path($module_in_default_dir, 1); if ($custom_view == true) { $try_file1 = $mod_d1 . trim($custom_view) . '.php'; } else { $try_file1 = $mod_d1 . 'index.php'; } } elseif (is_file($element_in_default_file)) { $in_dir = false; $is_element = true; $try_file1 = $element_in_default_file; } } } // if (isset($try_file1) != false and $try_file1 != false and is_file($try_file1)) { if (isset($attrs) and is_array($attrs) and !empty($attrs)) { $attrs2 = array(); foreach ($attrs as $attrs_k => $attrs_v) { $attrs_k2 = substr($attrs_k, 0, 5); if (strtolower($attrs_k2) == 'data-') { $attrs_k21 = substr($attrs_k, 5); $attrs2[$attrs_k21] = $attrs_v; } elseif (!isset($attrs['data-' . $attrs_k])) { $attrs2['data-' . $attrs_k] = $attrs_v; } $attrs2[$attrs_k] = $attrs_v; } $attrs = $attrs2; } $config['path_to_module'] = $config['mp'] = $config['path'] = normalize_path(dirname($try_file1) . '/', true); $config['the_module'] = $module_name; $config['module'] = $module_name; $module_name_dir = dirname($module_name); $config['module_name'] = $module_name_dir; $config['module_name_url_safe'] = $this->module_name_encode($module_name); $find_base_url = $this->app->url_manager->current(1); if ($pos = strpos($find_base_url, ':' . $module_name) or $pos = strpos($find_base_url, ':' . $config['module_name_url_safe'])) { $find_base_url = substr($find_base_url, 0, $pos) . ':' . $config['module_name_url_safe']; } $config['url'] = $find_base_url; $config['url_main'] = $config['url_base'] = strtok($find_base_url, '?'); if ($in_dir != false) { $mod_api = str_replace('/admin', '', $module_name); } else { $mod_api = str_replace('/admin', '', $module_name_dir); } $config['module_api'] = $this->app->url_manager->site('api/' . $mod_api); $config['module_view'] = $this->app->url_manager->site('module/' . $module_name); $config['ns'] = str_replace('/', '\\', $module_name); $config['module_class'] = $this->module_css_class($module_name); $config['url_to_module'] = $this->app->url_manager->link_to_file($config['path_to_module']); if (isset($attrs['id'])) { $attrs['id'] = str_replace('__MODULE_CLASS_NAME__', $config['module_class'], $attrs['id']); $template = false; } //$config['url_to_module'] = rtrim($config['url_to_module'], '///'); $lic = $this->app->modules->license($module_name); // $lic = 'valid'; if ($lic != false) { $config['license'] = $lic; } if (isset($attrs['module-id']) and $attrs['module-id'] != false) { $attrs['id'] = $attrs['module-id']; } if (!isset($attrs['id'])) { global $mw_mod_counter; $mw_mod_counter++; // $seg_clean = $this->app->url_manager->segment(0); $seg_clean = $this->app->url_manager->segment(0, url_current()); if (defined('IS_HOME')) { $seg_clean = ''; } $seg_clean = str_replace('%20', '-', $seg_clean); $seg_clean = str_replace(' ', '-', $seg_clean); $seg_clean = str_replace('.', '', $seg_clean); $attrs1 = crc32(serialize($attrs) . $seg_clean . $mw_mod_counter); $attrs1 = str_replace('%20', '-', $attrs1); $attrs1 = str_replace(' ', '-', $attrs1); $attrs['id'] = $config['module_class'] . '-' . $attrs1; } if (isset($attrs['id']) and strstr($attrs['id'], '__MODULE_CLASS_NAME__')) { $attrs['id'] = str_replace('__MODULE_CLASS_NAME__', $config['module_class'], $attrs['id']); //$attrs['id'] = ('__MODULE_CLASS__' . '-' . $attrs1); } $l1 = new \Microweber\View($try_file1); $l1->config = $config; $l1->app = $this->app; if (!isset($attrs['module'])) { $attrs['module'] = $module_name; } if (!isset($attrs['parent-module'])) { $attrs['parent-module'] = $module_name; } if (!isset($attrs['parent-module-id'])) { $attrs['parent-module-id'] = $attrs['id']; } // $mw_restore_get = mw_var('mw_restore_get'); // if ($mw_restore_get != false and is_array($mw_restore_get)) { // $l1->_GET = $mw_restore_get; // $_GET = $mw_restore_get; // } if (defined('MW_MODULE_ONDROP')) { if (!isset($attrs['ondrop'])) { $attrs['ondrop'] = true; } } $l1->params = $attrs; if ($config) { $this->current_module = $config; } if ($attrs) { $this->current_module_params = $attrs; } if (isset($attrs['view']) && trim($attrs['view']) == 'empty') { $module_file = EMPTY_MOD_STR; } elseif (isset($attrs['view']) && trim($attrs['view']) == 'admin') { $module_file = $l1->__toString(); } else { if (isset($attrs['display']) && trim($attrs['display']) == 'custom') { $module_file = $l1->__get_vars(); return $module_file; } else { if (isset($attrs['format']) && trim($attrs['format']) == 'json') { $module_file = $l1->__get_vars(); header("Content-type: application/json"); exit(json_encode($module_file)); } else { $module_file = $l1->__toString(); } } } // $l1 = null; unset($l1); if ($lic != false and isset($lic["error"]) and $lic["error"] == 'no_license_found') { $lic_l1_try_file1 = MW_ADMIN_VIEWS_DIR . 'activate_license.php'; $lic_l1 = new \Microweber\View($lic_l1_try_file1); $lic_l1->config = $config; $lic_l1->params = $attrs; $lic_l1e_file = $lic_l1->__toString(); unset($lic_l1); $module_file = $lic_l1e_file . $module_file; } // $mw_loaded_mod_memory[$function_cache_id] = $module_file; return $module_file; } else { //define($cache_content, FALSE); // $mw_loaded_mod_memory[$function_cache_id] = false; return false; } }
/** * Handle variables that end in _path or contain "permalink". * * @param Array The row data * @param String The template text * @param String The var_single key (tag name) * @param String The var_single value * @param String The current parsing prefix * * @return String The processed tagdata */ protected function _paths($data, $tagdata, $key, $val, $prefix) { $unprefixed = substr($key, 0, strcspn($key, ' =')); $unprefixed = preg_replace('/^' . $prefix . '/', '', $unprefixed); // parse profile path if ($unprefixed == 'profile_path') { $tagdata = str_replace(LD . $key . RD, ee()->functions->create_url(ee()->functions->extract_path($key) . '/' . $data['member_id']), $tagdata); } elseif ($unprefixed == 'member_search_path') { $tagdata = str_replace(LD . $key . RD, $search_link . $data['member_id'], $tagdata); } elseif ($unprefixed == 'comment_path' or $unprefixed == 'entry_id_path') { $extracted_path = ee()->functions->extract_path($key); $path = ($extracted_path != '' and $extracted_path != 'SITE_INDEX') ? $extracted_path . '/' . $data['entry_id'] : $data['entry_id']; $tagdata = str_replace(LD . $key . RD, ee()->functions->create_url($path), $tagdata); } elseif ($unprefixed == 'url_title_path') { $extracted_path = ee()->functions->extract_path($key); $path = ($extracted_path != '' and $extracted_path != 'SITE_INDEX') ? $extracted_path . '/' . $data['url_title'] : $data['url_title']; $tagdata = str_replace(LD . $key . RD, ee()->functions->create_url($path), $tagdata); } elseif ($unprefixed == 'title_permalink') { $extracted_path = ee()->functions->extract_path($key); $path = ($extracted_path != '' and $extracted_path != 'SITE_INDEX') ? $extracted_path . '/' . $data['url_title'] : $data['url_title']; $tagdata = str_replace(LD . $key . RD, ee()->functions->create_url($path, FALSE), $tagdata); } elseif ($unprefixed == 'permalink') { $extracted_path = ee()->functions->extract_path($key); $path = ($extracted_path != '' and $extracted_path != 'SITE_INDEX') ? $extracted_path . '/' . $data['entry_id'] : $data['entry_id']; $tagdata = str_replace(LD . $key . RD, ee()->functions->create_url($path, FALSE), $tagdata); } elseif ($key == $prefix . "comment_auto_path") { $path = $data['comment_url'] == '' ? $data['channel_url'] : $data['comment_url']; $tagdata = str_replace(LD . $key . RD, $path, $tagdata); } elseif ($key == $prefix . "comment_url_title_auto_path") { $path = $data['comment_url'] == '' ? $data['channel_url'] : $data['comment_url']; $tagdata = str_replace(LD . $key . RD, reduce_double_slashes($path . '/' . $data['url_title']), $tagdata); } elseif ($key == $prefix . "comment_entry_id_auto_path") { $path = $data['comment_url'] == '' ? $data['channel_url'] : $data['comment_url']; $tagdata = str_replace(LD . $key . RD, reduce_double_slashes($path . '/' . $data['entry_id']), $tagdata); } else { return $this->_basic($data, $tagdata, $key, $val, $prefix); } return $tagdata; }
public function parse_template($entry_id = FALSE, $field_id = FALSE, $params = array(), $tagdata) { // Variable prefix $this->prefix = isset($params['prefix']) === FALSE ? 'image:' : $params['prefix'] . ':'; // Set a default value of false for the is_draft flag $is_draft = 0; // If we are loading a draft into the publish page update the flag to true if (isset($this->session->cache['ep_better_workflow']['is_draft']) && $this->session->cache['ep_better_workflow']['is_draft']) { $is_draft = 1; } // Params can override this if (isset($params['is_draft']) === TRUE) { if ($params['is_draft'] == 'yes') { $is_draft = 1; } elseif ($params['is_draft'] == 'no') { $is_draft = 0; } } $temp_params = $params; // Lets remove all unwanted params unset($temp_params['entry_id'], $temp_params['url_title']); // Make our hash $hash = crc32(serialize($temp_params)); if (isset($this->session->cache['channel_images']['images'][$hash]) == TRUE) { $images = $this->session->cache['channel_images']['images'][$hash][$entry_id]; } else { $images = $this->get_images($entry_id, $field_id, $params, $tagdata); } // Any Images? if (count($images) === 0) { $this->EE->TMPL->log_item("CHANNEL IMAGES: No images found."); return $this->EE->image_helper->custom_no_results_conditional($this->prefix . 'no_images', $tagdata); } $this->total_images = count($images); $this->absolute_total_images = count($images); $limit = isset($params['limit']) ? $params['limit'] : 30; $paginate = FALSE; $this->image_position = array(); // Loop over all images and store it's position of all images foreach ($images as $pos => $img) { $this->image_position[$img->image_id] = $pos + 1; } //---------------------------------------- // Pagination //---------------------------------------- if (preg_match('/' . LD . "{$this->prefix}paginate(.*?)" . RD . "(.+?)" . LD . '\\/' . "{$this->prefix}paginate" . RD . "/s", $tagdata, $match)) { // Pagination variables $paginate = TRUE; $paginate_data = $match['2']; $current_page = 0; $total_pages = 1; $qstring = $this->EE->uri->query_string; $uristr = $this->EE->uri->uri_string; $pagination_links = ''; $page_previous = ''; $page_next = ''; // We need to strip the page number from the URL for two reasons: // 1. So we can create pagination links // 2. So it won't confuse the query with an improper proper ID if (preg_match("#(^|/)CI(\\d+)(/|\$)#", $qstring, $match)) { $current_page = $match['2']; if (function_exists('reduce_double_slashes')) { $uristr = reduce_double_slashes(str_replace($match['0'], '/', $uristr)); $qstring = trim(reduce_double_slashes(str_replace($match['0'], '/', $qstring)), '/'); } else { $uristr = $this->EE->functions->remove_double_slashes(str_replace($match['0'], '/', $uristr)); $qstring = trim($this->EE->functions->remove_double_slashes(str_replace($match['0'], '/', $qstring)), '/'); } } // Remove the {paginate} $tagdata = preg_replace("/" . LD . "{$this->prefix}paginate.*?" . RD . ".+?" . LD . '\\/' . "{$this->prefix}paginate" . RD . "/s", "", $tagdata); // What is the current page? $current_page = ($current_page == '' or $limit > 1 and $current_page == 1) ? 0 : $current_page; if ($current_page > $this->total_images) { $current_page = 0; } $t_current_page = floor($current_page / $limit + 1); $total_pages = intval(floor($this->total_images / $limit)); if ($this->total_images % $limit) { $total_pages++; } if ($this->total_images > $limit) { $this->EE->load->library('pagination'); $deft_tmpl = ''; if ($uristr == '') { if ($this->EE->config->item('template_group') == '') { $this->EE->db->select('group_name'); $query = $this->EE->db->get_where('template_groups', array('is_site_default' => 'y')); $deft_tmpl = $query->row('group_name') . '/index'; } else { $deft_tmpl = $this->EE->config->item('template_group') . '/'; $deft_tmpl .= $this->EE->config->item('template') == '' ? 'index' : $this->EE->config->item('template'); } } if (function_exists('reduce_double_slashes')) { $basepath = reduce_double_slashes($this->EE->functions->create_url($uristr, FALSE) . '/' . $deft_tmpl); } else { $basepath = $this->EE->functions->remove_double_slashes($this->EE->functions->create_url($uristr, FALSE) . '/' . $deft_tmpl); } if (isset($params['paginate_base']) === TRUE) { // Load the string helper $this->EE->load->helper('string'); $pbase = trim_slashes($params['paginate_base']); $pbase = str_replace("/index", "/", $pbase); if (!strstr($basepath, $pbase)) { if (function_exists('reduce_double_slashes')) { $basepath = reduce_double_slashes($basepath . '/' . $pbase); } else { $basepath = $this->EE->functions->remove_double_slashes($basepath . '/' . $pbase); } } } // Load Language $this->EE->lang->loadfile('channel_images'); $config['first_url'] = rtrim($basepath, '/'); $config['base_url'] = $basepath; $config['prefix'] = 'CI'; $config['total_rows'] = $this->total_images; $config['per_page'] = $limit; $config['cur_page'] = $current_page; $config['suffix'] = ''; $config['first_link'] = $this->EE->lang->line('ci:pag_first_link'); $config['last_link'] = $this->EE->lang->line('ci:pag_last_link'); $config['full_tag_open'] = '<span class="ci_paginate_links">'; $config['full_tag_close'] = '</span>'; $config['first_tag_open'] = '<span class="ci_paginate_first">'; $config['first_tag_close'] = '</span> '; $config['last_tag_open'] = ' <span class="ci_paginate_last">'; $config['last_tag_close'] = '</span>'; $config['cur_tag_open'] = ' <strong class="ci_paginate_current">'; $config['cur_tag_close'] = '</strong>'; $config['next_tag_open'] = ' <span class="ci_paginate_next">'; $config['next_tag_close'] = '</span>'; $config['prev_tag_open'] = ' <span class="ci_paginate_prev">'; $config['prev_tag_close'] = '</span>'; $config['num_tag_open'] = ' <span class="ci_paginate_num">'; $config['num_tag_close'] = '</span>'; // Allows $config['cur_page'] to override $config['uri_segment'] = 0; $this->EE->pagination->initialize($config); $pagination_links = $this->EE->pagination->create_links(); if ($total_pages * $limit - $limit > $current_page) { $page_next = $basepath . $config['prefix'] . ($current_page + $limit) . '/'; } if ($current_page - $limit >= 0) { $page_previous = $basepath . $config['prefix'] . ($current_page - $limit) . '/'; } } else { $current_page = 0; } $images = array_slice($images, $current_page, $limit); $this->total_images = count($images); } //---------------------------------------- // Check for filesize (only for Local) Since it's an expensive operation //---------------------------------------- $this->parse_filesize = FALSE; if (strpos($tagdata, LD . $this->prefix . 'filesize') !== FALSE) { $this->parse_filesize = TRUE; } //---------------------------------------- // Check for image_dimensions (only for Local) Since it's an expensive operation //---------------------------------------- $this->parse_dimensions = FALSE; if (strpos($tagdata, LD . $this->prefix . 'width') !== FALSE or strpos($tagdata, LD . $this->prefix . 'height') !== FALSE) { $this->parse_dimensions = TRUE; } //---------------------------------------- // Switch="" //---------------------------------------- $this->parse_switch = FALSE; $this->switch_matches = array(); if (preg_match_all("/" . LD . "({$this->prefix}switch\\s*=.+?)" . RD . "/is", $tagdata, $this->switch_matches) > 0) { $this->parse_switch = TRUE; // Loop over all matches foreach ($this->switch_matches[0] as $key => $match) { $this->switch_vars[$key] = $this->EE->functions->assign_parameters($this->switch_matches[1][$key]); $this->switch_vars[$key]['original'] = $this->switch_matches[0][$key]; } } // Encode HTML Entities $this->encode_html = FALSE; if (isset($params['encode_html_entities']) === TRUE && $params['encode_html_entities'] == 'yes') { $this->encode_html = TRUE; } // Decode HTML Entities $this->decode_html = FALSE; if (isset($params['decode_html_entities']) === TRUE && $params['decode_html_entities'] == 'yes') { $this->decode_html = TRUE; } //---------------------------------------- // Locked URL? //---------------------------------------- $this->locked_url = FALSE; if (strpos($tagdata, $this->prefix . 'locked_url') !== FALSE) { $this->locked_url = TRUE; // IP $this->IP = $this->EE->input->ip_address(); // Grab Router URL $this->locked_act_url = $this->EE->image_helper->get_router_url('url', 'locked_image_url'); } //---------------------------------------- // IPTC? //---------------------------------------- $this->parse_iptc = FALSE; if (strpos($tagdata, $this->prefix . 'iptc') !== FALSE) { $this->parse_iptc = TRUE; } //---------------------------------------- // EXIF //---------------------------------------- $this->parse_exif = FALSE; if (strpos($tagdata, $this->prefix . 'exif') !== FALSE) { $this->parse_exif = TRUE; } //---------------------------------------- // XMP //---------------------------------------- $this->parse_xmp = FALSE; if (strpos($tagdata, $this->prefix . 'xmp') !== FALSE) { $this->parse_xmp = TRUE; } // SSL? $this->IS_SSL = $this->EE->image_helper->is_ssl(); //---------------------------------------- // Performance :) //---------------------------------------- if (isset($this->session->cache['channel_images']['locations']) == FALSE) { $this->session->cache['channel_images']['locations'] = array(); } $this->LOCS =& $this->session->cache['channel_images']['locations']; // Another Check, just to be sure if (is_array($this->LOCS) == FALSE) { $this->LOCS = array(); } $OUT = ''; //---------------------------------------- // Loop over all Images //---------------------------------------- foreach ($images as $count => $image) { $OUT .= $this->parse_single_image_row($count, $image, $tagdata); } //---------------------------------------- // Add pagination to result //---------------------------------------- if ($paginate == TRUE) { $paginate_data = str_replace(LD . $this->prefix . 'current_page' . RD, $t_current_page, $paginate_data); $paginate_data = str_replace(LD . $this->prefix . 'total_pages' . RD, $total_pages, $paginate_data); $paginate_data = str_replace(LD . $this->prefix . 'pagination_links' . RD, $pagination_links, $paginate_data); if (preg_match("/" . LD . "if {$this->prefix}previous_page" . RD . "(.+?)" . LD . '\\/' . "if" . RD . "/s", $paginate_data, $match)) { if ($page_previous == '') { $paginate_data = preg_replace("/" . LD . "if {$this->prefix}previous_page" . RD . ".+?" . LD . '\\/' . "if" . RD . "/s", '', $paginate_data); } else { $match['1'] = str_replace(array(LD . "{$this->prefix}path" . RD, LD . "{$this->prefix}auto_path" . RD), $page_previous, $match['1']); $paginate_data = str_replace($match['0'], $match['1'], $paginate_data); } } if (preg_match("/" . LD . "if {$this->prefix}next_page" . RD . "(.+?)" . LD . '\\/' . "if" . RD . "/s", $paginate_data, $match)) { if ($page_next == '') { $paginate_data = preg_replace("/" . LD . "if {$this->prefix}next_page" . RD . ".+?" . LD . '\\/' . "if" . RD . "/s", '', $paginate_data); } else { $match['1'] = str_replace(array(LD . "{$this->prefix}path" . RD, LD . "{$this->prefix}auto_path" . RD), $page_next, $match['1']); $paginate_data = str_replace($match['0'], $match['1'], $paginate_data); } } $position = isset($params['paginate']) === TRUE ? $params['paginate'] : ''; switch ($position) { case "top": $OUT = $paginate_data . $OUT; break; case "both": $OUT = $paginate_data . $OUT . $paginate_data; break; default: $OUT .= $paginate_data; break; } } // Apply Backspace $backspace = isset($params['backspace']) === TRUE ? $params['backspace'] : 0; $OUT = $backspace > 0 ? substr($OUT, 0, -$backspace) : $OUT; return $OUT; }