<?php global $form, $listid, $groups; if (preg_match("/\\/includes\\//", $PHP_SELF)) { die("You can't access this file directly!"); } $form = clean_word($form); $listid = clean_int($listid); ?> <script type="text/javascript"> <!-- <![CDATA[ function OkButton () { var parentlist = window.opener.document.<?php echo $form; ?> .elements[<?php echo $listid; ?> ]; var thislist = document.forms[0].elements[0]; var found = ""; // select/deselect all elements for ( i = 0; i < parentlist.length; i++ ) { var state = false; for ( j = 0; j < thislist.length; j++ ) { if ( thislist.options[j].value == parentlist.options[i].value ) { state = thislist.options[i].selected; found += " " + thislist.options[j].value;
} else { $thismonth = date("m"); $thisyear = date("Y"); } $next = mktime(3, 0, 0, $thismonth + 1, 1, $thisyear); $nextyear = date("Y", $next); $nextmonth = date("m", $next); $nextdate = date("Ym", $next) . "01"; $prev = mktime(3, 0, 0, $thismonth - 1, 1, $thisyear); $prevyear = date("Y", $prev); $prevmonth = date("m", $prev); $prevdate = date("Ym", $prev) . "01"; // Sanitize get variables $fday = clean_word($fday); $fmonth = clean_word($fmonth); $fyear = clean_word($fyear); ?> <div style="text-align:center;"> <table class="minical"> <tr> <td><a title="<?php etranslate("Previous"); ?> " href="datesel.php?form=<?php echo $form; ?> &fday=<?php echo $fday; ?> &fmonth=<?php
function parseContentBodyItems($original_content, $title) { $original_content = clean_word($original_content); $original_content = $original_content; $rem = false; $original_content = str_replace($rem, ' ', $original_content); $rem = ' '; $original_content = str_ireplace($rem, ' ', $original_content); $original_content = str_ireplace('class=mcevisualaid>', ' ', $original_content); // $original_content = html_entity_decode($original_content); $site_url = site_url(); $original_content = str_ireplace($site_url, '{SITEURL}', $original_content); $content_item = $original_content; $possible_filename = CI::model('core')->url_title($title, 'dash', true); $possible_filename = string_cyr2lat($possible_filename); $possible_filename = $possible_filename . '-' . date("Ymdhis") . rand(1, 99); $possible_filename = str_ireplace('&', '_', $possible_filename); $possible_filename = str_ireplace(';', '_', $possible_filename); $possible_filename = str_ireplace('`', '_', $possible_filename); $possible_filename = str_ireplace('"', '_', $possible_filename); $possible_filename = str_ireplace("'", '_', $possible_filename); $possible_filename = str_ireplace("%", '_', $possible_filename); $possible_filename = str_ireplace("*", '_', $possible_filename); $possible_filename = str_ireplace("#", '_', $possible_filename); $possible_filename = str_ireplace("@", '_', $possible_filename); $possible_filename = str_ireplace("!", '_', $possible_filename); $possible_filename = str_ireplace('$', '_', $possible_filename); $possible_filename = str_ireplace('/', '_', $possible_filename); $possible_filename = str_ireplace('\\', '_', $possible_filename); $possible_filename = str_ireplace('[', '_', $possible_filename); $possible_filename = str_ireplace(']', '_', $possible_filename); $possible_filename = str_ireplace('â€â"¢', '_', $possible_filename); if (strval($original_content) == '') { return false; } $input = $content_item; $regexp = "<img\\s[^>]*src=(\"??)([^\" >]*?)\\1[^>]*"; $images = array(); if (preg_match_all("/{$regexp}/siU", $input, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { # $match[2] = link address # $match[3] = link text $images[] = $match[2]; } } $dir = MEDIAFILES . 'downloaded/'; if (is_dir($dir) == false) { @mkdir($dir); } @touch($dir . 'index.html'); //mkdir $media_url = MEDIA_URL; if (!empty($images)) { foreach ($images as $image) { if (stristr($image, '.jpg') == true or stristr($image, '.png') == true or stristr($image, '.gif') == true or stristr($image, '.bmp') == true or stristr($image, '.jpeg') == true) { $orig_image = $image; if (stristr($image, '{MEDIAURL}' == false)) { if (stristr($image, $media_url) == true) { } else { if (CI::model('core')->url_IsFile($image) == true) { $to_get = $image; } else { $image = 'http://maksoft.net/' . $image; if (CI::model('core')->url_IsFile($image) == true) { $to_get = $image; } } if (CI::model('core')->url_IsFile($image) == true) { if (stristr($image, $media_url) == false) { //print 'file: ' . $image; $parts = explode('/', $image); $currentFile = $parts[count($parts) - 1]; $orig_file = $currentFile; $ext = substr($image, strrpos($image, '.') + 1); //$to_save = //exit($ext); $orig_file_clean = strip_punctuation($orig_file); $orig_file_clean = str_replace('.', '_', $orig_file_clean); $orig_file_clean = str_replace('.', '_', $orig_file_clean); $orig_file_clean = str_replace('.', '_', $orig_file_clean); $orig_file_clean = str_replace('=', '_', $orig_file_clean); $orig_file_clean = str_replace('?', '_', $orig_file_clean); $orig_file_clean = str_ireplace('&', '_', $orig_file_clean); $orig_file_clean = str_ireplace(';', '_', $orig_file_clean); $orig_file_clean = str_ireplace('`', '_', $orig_file_clean); $orig_file_clean = str_ireplace('"', '_', $orig_file_clean); $orig_file_clean = str_ireplace("'", '_', $orig_file_clean); $orig_file_clean = str_ireplace("%", '_', $orig_file_clean); $orig_file_clean = str_ireplace("*", '_', $orig_file_clean); $orig_file_clean = str_ireplace("#", '_', $orig_file_clean); $orig_file_clean = str_ireplace("@", '_', $orig_file_clean); $orig_file_clean = str_ireplace("!", '_', $orig_file_clean); $orig_file_clean = str_ireplace('$', '_', $orig_file_clean); $orig_file_clean = str_ireplace('/', '_', $orig_file_clean); $orig_file_clean = str_ireplace('\\', '_', $orig_file_clean); $orig_file_clean = str_ireplace('[', '_', $orig_file_clean); $orig_file_clean = str_ireplace(']', '_', $orig_file_clean); $orig_file_clean = str_ireplace('â€â"¢', '_', $orig_file_clean); $orig_file_clean = $orig_file_clean . '.' . $ext; if (is_file($dir . $possible_filename) == false) { $currentFile = $possible_filename . '-' . $orig_file_clean; } else { if (is_file($dir . $currentFile) == true) { $currentFile = $possible_filename . '_' . $orig_file_clean; } if (is_file($dir . $currentFile) == true) { $currentFile = $possible_filename . '_' . date("Ymdhis") . '_' . $orig_file_clean; } if (is_file($dir . $currentFile) == true) { $currentFile = date("Ymdhis") . '_' . $orig_file_clean; } } //get /* var_dump ( $image ); print "<hr>"; var_dump ( $dir . $currentFile ); print "<hr>"; print "<hr>";*/ //CI::model('core')->url_getPageToFile ( $image, $dir . $currentFile ); CurlTool::downloadFile($image, $dir . $currentFile, false); $the_new_image = '{MEDIAURL}' . 'downloaded/' . $currentFile; // $content_item = str_ireplace ( $image, $the_new_image, $content_item ); $content_item = str_ireplace($orig_image, $the_new_image, $content_item); $content_item = str_ireplace($media_url, '{MEDIAURL}', $content_item); } } else { //print 'no file: ' . $image; } } } } } } // var_dump ( $content_item ); //exit (); return $content_item; }
function save_field() { $id = is_admin(); if ($id == false) { exit('Error: not logged in as admin.'); } if ($_POST) { $the_field_data_all = $_POST; } else { exit('Error: no POST?'); } $is_no_save = url_param('peview', true); //p($is_no_save); $ref_page = $_SERVER['HTTP_REFERER']; if ($ref_page != '') { //$page_id = $ref_page->page->id; //$the_ref_page = get_page ( $page_id ); $ref_page = $the_ref_page = get_ref_page(); //p($ref_page); $page_id = $ref_page['id']; } $json_print = array(); foreach ($the_field_data_all as $the_field_data) { if (!empty($the_field_data)) { $save_global = false; if ($the_field_data['attributes']) { //$the_field_data ['attributes'] = json_decode($the_field_data ['attributes']); //var_dump($the_field_data ['attributes']); } if (intval($the_field_data['attributes']['page']) != 0) { $page_id = intval($the_field_data['attributes']['page']); $content_id = $page_id; $the_ref_page = get_page($page_id); } if (intval($the_field_data['attributes']['post']) != 0) { $post_id = intval($the_field_data['attributes']['post']); $content_id = $post_id; $the_ref_post = get_post($post_id); } if (intval($the_field_data['attributes']['category']) != 0) { $category_id = intval($the_field_data['attributes']['category']); } $page_element_id = false; if (strval($the_field_data['attributes']['id']) != '') { $page_element_id = $the_field_data['attributes']['id']; } if ($the_field_data['attributes']['global'] != false) { $save_global = true; } if ($the_field_data['attributes']['rel'] == 'global') { $save_global = true; } if ($the_field_data['attributes']['rel'] == 'post') { if ($ref_page != '') { $save_global = false; $ref_post = $the_ref_post = get_ref_post(); //p ( $ref_post ); $post_id = $ref_post['id']; $page_id = $ref_page['id']; $content_id = $post_id; } } if ($the_field_data['attributes']['rel'] == 'page') { // p ( $_SERVER ); if ($ref_page != '') { $save_global = false; $ref_page = $the_ref_page = get_ref_page(); $page_id = $ref_page['id']; $content_id = $page_id; } } if ($the_field_data['attributes']['rel'] == 'PAGE_ID') { // p ( $_SERVER ); if ($ref_page != '') { $save_global = false; $ref_page = $the_ref_page = get_ref_page(); $page_id = $ref_page['id']; $content_id = $page_id; } } if ($the_field_data['attributes']['rel'] == 'POST_ID') { // p ( $_SERVER ); if ($ref_page != '') { $save_global = false; $ref_page = $the_ref_page = get_ref_page(); $page_id = $ref_page['id']; $content_id = $page_id; } } if ($category_id == false and $page_id == false and $post_id == false and $save_global == false) { print 'Error: plase specify integer value for at least one of those attributes - page, post or category'; } else { $some_mods = array(); if ($the_field_data['attributes']['field'] != '') { if ($the_field_data['html'] != '') { $field = trim($the_field_data['attributes']['field']); $html_to_save = $the_field_data['html']; $html_to_save = str_replace('MICROWEBER', 'microweber', $html_to_save); //$html_to_save = str_replace ( '<div><br></div>', '<br>', $html_to_save ); //$html_to_save = str_replace ( '<div><br /></div>', '<br />', $html_to_save ); //$html_to_save = str_replace ( '<div></div>', '<br />', $html_to_save ); $content = $html_to_save; $html_to_save = $content; if (strstr($content, 'mw_params_encoded') == true) { $tags1 = extract_tags($content, 'div', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8'); // p($tags); $matches = $tags1; if (!empty($matches)) { // foreach ($matches as $m) { // if ($m['tag_name'] == 'div') { $attr = $m['attributes']; if (strval($attr['module_id']) == '') { $attr['module_id'] = 'module_' . rand() . rand() . rand() . rand(); } if ($attr['module_id'] != '') { $mw_params_encoded = $attr; $mod_id = $attr['module_id']; $tag1 = "<microweber "; foreach ($mw_params_encoded as $k => $v) { $skip_key = false; if ($k == 'edit') { $v = 'edit_tag'; } if ($k == 'onmouseup') { $v = ''; $skip_key = true; } if ($k == 'class') { $v = ''; $skip_key = true; } if ($skip_key == false) { if (strtolower(trim($k)) != 'save' and strtolower(trim($k)) != 'submit') { $tag1 = $tag1 . "{$k}=\"{$v}\" "; } } $tag1 = $tag1 . "module=\"{$attr['mw_params_module']}\" "; } $tag1 .= " />"; $some_mods[$mod_id] = $tag1; } } } } /*$doc = new DOMDocument (); $doc->preserveWhiteSpace = true; $doc->loadHTML ( $content ); $xpath = new DOMXpath ( $doc ); foreach ( $xpath->query ( '//div[@mw_params_encoded]' ) as $a ) { // $clunker_vars = get_object_vars($a->nodeValue); // we pass the object, not th //echo "Found {$a->previousSibling->previousSibling->nodeValue}," . " by {$a->previousSibling->nodeValue}\n"; $mw_params_encoded = $a->getAttribute ( 'mw_params_encoded' ); $mod_id = $a->getAttribute ( 'module_id' ); $mw_params_encoded = base64_decode ( $mw_params_encoded ); $mw_params_encoded = unserialize ( $mw_params_encoded ); //$c1 = $a->nodeValue; $c1 = domNodeContent ( $a, 1 ); if (! empty ( $mw_params_encoded )) { $tag1 = "<microweber "; foreach ( $mw_params_encoded as $k => $v ) { if ($k == 'edit') { $v = 'edit_tag'; } if ((strtolower ( trim ( $k ) ) != 'save') and (strtolower ( trim ( $k ) ) != 'submit')) { $tag1 = $tag1 . "{$k}=\"{$v}\" "; } } $tag1 .= " />"; $some_mods [$mod_id] = $tag1; //p ( $tag1 ); // p ( $c1 ); //$c1 = trim ( $c1 ); //$content = trim ( $content ); //$content123 = explode ( $c1, $content ); //$content = str_ireplace ( $c1, $tag1, $content ); // p($content123); } }*/ // //$parsed = get_string_between ( $content, "mw_params_encoded=\"", '"' ); // } //p($some_mods,1); $html_to_save = $content; foreach ($some_mods as $some_mod_k => $some_mod_v) { //$t1 = extact_tag_by_attr ( 'module_id', $some_mod_k, $content, 'div' ); //p ( $t1 ); $content = preg_replace("#<div[^>]*id=\"{$some_mod_k}\".*?</div>#si", $some_mod_v, $content); } if ($is_no_save != true) { $pattern = "/mw_last_hover=\"[0-9]*\"/"; $pattern = "/mw_last_hover=\"[0-9]*\"/i"; $content = preg_replace($pattern, "", $content); $pattern = "/mw_last_hover=\"\"/"; $content = preg_replace($pattern, "", $content); $pattern = "/mw_tag_edit=\"[0-9]*\"/i"; $content = preg_replace($pattern, "", $content); $pattern = "/mw_tag_edit=\"\"/"; $content = preg_replace($pattern, "", $content); } //$content = preg_replace ( "#<div[^>]*id=\"{$some_mod_k}\".*?</div>#si", $some_mod_v, $content ); $html_to_save = $content; // p ( $content,1 ); if (strstr($content, '<div') == true) { $relations = array(); $tags = extract_tags($content, 'div', $selfclosing = false, $return_the_entire_tag = true, $charset = 'UTF-8'); $matches = $tags; if (!empty($matches)) { // foreach ($matches as $m) { // // p ( ($m) ); if ($m['tag_name'] == 'div') { $replaced = false; $attr = $m['attributes']; if ($attr['mw_params_encoded']) { $decode_params = $attr['mw_params_encoded']; //$decode_params = base64_decode ( $decode_params ); $decode_params = 'edit_tag'; //p ( $decode_params ); //p ( $attr, 1 ); //print 1111111111111111111111111111111111111111111111111111111; } foreach ($some_mods as $some_mod_k => $some_mod_v) { //p(($m)); // p($some_mod_v); if (stristr($content, $some_mod_k)) { //p ( $content ); //$content = str_ireplace ( $m ['full_tag'], $some_mod_v, $content ); //p ( $content, 1 ); } } //p ( $content, 1 ); if ($attr['class'] == 'module') { // p($attr); if ($attr['base64_array'] != '') { $base64_array = base64_decode($attr['base64_array']); $base64_array = unserialize($base64_array); if (!empty($base64_array)) { $tag1 = "<microweber "; foreach ($base64_array as $k => $v) { if (strtolower(trim($k)) != 'save' and strtolower(trim($k)) != 'submit') { $tag1 = $tag1 . "{$k}=\"{$v}\" "; } } $tag1 .= " />"; $to_save[] = $tag1; $content = str_ireplace($m['full_tag'], $tag1, $content); $replaced = true; //p($base64_array); } } if ($replaced == false) { if ($attr['edit'] != '') { $tag = $attr['edit']; $tag = 'edit_tag'; //$tag = base64_decode ( $tag ); //p ( $tag ); if (strstr($tag, 'module_id=') == false) { $tag = str_replace('/>', ' module_id="module_' . date('Ymdhis') . rand() . '" />', $tag); } $to_save[] = $tag; if ($tag != false) { $content = str_ireplace($m['full_tag'], $tag, $content); } } } } } } $html_to_save = $content; } } $html_to_save = str_ireplace('class="ui-droppable"', '', $html_to_save); $html_to_save = str_ireplace('<div><div></div><div><div></div>', '<br />', $html_to_save); //$html_to_save = str_ireplace ( 'class="ui-droppable"', '', $html_to_save ); //$html_to_save =utfString( $html_to_save ); //$html_to_save = htmlspecialchars ( $html_to_save, ENT_QUOTES ); //$html_to_save = html_entity_decode ( $html_to_save ); //p($html_to_save); // p($content,1); $html_to_save = clean_word($html_to_save); if ($save_global == false) { if ($content_id) { if ($page_id) { $for_histroy = $the_ref_page; if ($post_id) { $for_histroy = $the_ref_post; } if (stristr($field, 'custom_field_')) { $field123 = str_ireplace('custom_field_', '', $field); $old = $for_histroy['custom_fields'][$field123]; } else { $old = $for_histroy[$field]; } $history_to_save = array(); $history_to_save['table'] = 'table_content'; $history_to_save['id'] = $content_id; $history_to_save['value'] = $old; $history_to_save['field'] = $field; //p ( $history_to_save ); if ($is_no_save != true) { CI::model('core')->saveHistory($history_to_save); } } $to_save = array(); $to_save['id'] = $content_id; $to_save['quick_save'] = true; $to_save['page_element_id'] = $page_element_id; $to_save['page_element_content'] = CI::model('template')->parseMicrwoberTags($html_to_save, $options = false); $to_save[$field] = $html_to_save; //print "<h2>For content $content_id</h2>"; //p ( $to_save ); //p ( $html_to_save, 1 ); $json_print[] = $to_save; if ($is_no_save != true) { $saved = CI::model('content')->saveContent($to_save); // p($to_save); //p($content_id); //p($page_id); // p ( $html_to_save ,1); } //print ($html_to_save) ; $html_to_save = CI::model('template')->parseMicrwoberTags($html_to_save, $options = false); } else { if ($category_id) { print __FILE__ . __LINE__ . ' category is not implemented not rady yet'; } } } else { $field_content = CI::model('core')->optionsGetByKey($the_field_data['attributes']['field'], $return_full = true, $orderby = false); $to_save = $field_content; $to_save['option_key'] = $the_field_data['attributes']['field']; $to_save['option_value'] = $html_to_save; $to_save['option_key2'] = 'editable_region'; $to_save['page_element_id'] = $page_element_id; $to_save['page_element_content'] = CI::model('template')->parseMicrwoberTags($html_to_save, $options = false); //print "<h2>Global</h2>"; if ($is_no_save != true) { $to_save = CI::model('core')->optionsSave($to_save); } $json_print[] = $to_save; $history_to_save = array(); $history_to_save['table'] = 'global'; // $history_to_save ['id'] = 'global'; $history_to_save['value'] = $field_content['option_value']; $history_to_save['field'] = $field; if ($is_no_save != true) { CI::model('core')->saveHistory($history_to_save); } $html_to_save = CI::model('template')->parseMicrwoberTags($html_to_save, $options = false); // $json_print[] = array ($the_field_data ['attributes'] ['id'] => $html_to_save ); // print ($html_to_save) ; // print ($to_save) ; //p ( $field_content ); //optionsSave($data) } } } else { // print ('Error: plase specify a "field" attribute') ; // p($the_field_data); } } } } // p($_POST); /* if (! empty ( $_POST )) { foreach ( $_POST as $k => $v ) { // $v2 = array (); foreach ( $v as $v1_k => $v1_v ) { $html = CI::model ( 'template' )->parseMicrwoberTags ( $v1_v, $options = false ); $v2 [$v1_k] = ( $html ); } $json_print [$k] = $v2; } } */ header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); $json_print = json_encode($json_print); print $json_print; CI::model('core')->cleanCacheGroup('global/blocks'); exit; }
<?php global $color; if (preg_match("/\\/includes\\//", $PHP_SELF)) { die("You can't access this file directly!"); } $color = clean_word($color); ?> <script type="text/javascript"> <!-- <![CDATA[ function sendColor ( color ) { var thisInput = window.opener.document.prefform.<?php echo $color; ?> ; thisInput.value = color; if (thisInput.onkeyup) { // This updates the color swatch for this color input. It relies on the // <input>s of the prefform having onkeyup="updateColor(this);" as an // attribute thisInput.onkeyup(); } window.close (); } //]]> --> </script>