function generate_realty() { echo 'в функции generate_realty до include<br>'; include_once 'modules/kXML/add_functions.php'; echo 'в функции generate_realty после include<br>'; $ids = explode(",", $_POST['records']); add2log($_REQUEST['module'], $_REQUEST['name'], "start update xml [" . count($ids) . " objects processed]"); if (isset($_POST['custom_generate']) && $_POST['custom_generate'] == '1') { echo 'Зашел - ' . $_POST['custom_generate'] . '<br>'; $path = "custom/kXML/custom_generate/{$_REQUEST['module']}/{$_REQUEST['name']}"; echo $path . '<br>'; //exit(); if (file_exists($path)) { include_once $path; $name_this = str_replace('.php', '', $_POST['name']); $name_this = 'generate_xml_' . $name_this; foreach ($ids as $id) { $name_this($id); } } echo "\n Обработано объектов: " . count($ids); return false; } $first_line = true; //$bean=loadBean($_POST['module']); $n_ = ' '; $encoding = 'UTF-8'; $search = array(); $elements = array(); $elements_h = array(); $path = $_POST['module']; if (!file_exists("custom/kXML/xml/" . $path)) { mkdir("custom/kXML/xml/" . $path); } $path .= "/" . $_POST['name']; $f = fopen("custom/kXML/templates/{$path}", "r"); while (!feof($f)) { $line = fgets($f); if ($line && ($line[0] != '#' && $line[0] != '/' && $line[0] != '*' && $line[0] != ';')) { $element = explode(' ; ', $line); if ($first_line) { if (isset($element[3])) { $encoding = str_replace($n_, '', $element[3]); unset($element[3]); } $search = $element; $first_line = false; } else { if ($element[3][0] == '1') { $elements_h[$element[0]][$element[1]] = trim($element[2]); } else { $elements[$element[0]][$element[1]] = trim($element[2]); } } } } fclose($f); gen_xml($elements, $elements_h, $path, $search, $encoding); }
if (!$from_pos) { $from_pos = strpos($search_query, 'from '); } if (!$where_pos) { $where_pos = strpos($search_query, 'where '); } if (!$order_pos) { $order_pos = strpos($search_query, 'order '); } $from_pos += 4; $query_parts['search_from'] = substr($search_query, $from_pos, $where_pos - $from_pos); $query_parts['search_where'] = substr($search_query, $where_pos, $order_pos - $where_pos); return $query_parts; } $ids = explode(",", $_POST['records']); add2log($_REQUEST['module'], $_REQUEST['name'], "start update xml [" . count($ids) . " objects processed]"); if (isset($_POST['custom_generate']) && $_POST['custom_generate'] == '1') { $path = "custom/kXML/custom_generate/{$_REQUEST['module']}/{$_REQUEST['name']}"; if (file_exists($path)) { $name_this = str_replace('.php', '', $_REQUEST['name']); $name_this = 'generate_xml_' . $name_this; include_once $path; foreach ($ids as $id) { generate_xml($id); } } //echo "Объявления добавлены в файл выбранной Вами доски. \n Обработано объектов: ".count($ids); echo "Объявления добавлены в файл выбранной Вами доски."; return false; } $first_line = true;
if (file_exists($path)) { if (unlink($path)) { echo "Файл успешно удален"; add2log($_REQUEST['path'], $_REQUEST['record'], "delete xml"); } else { echo "Error: can't delete the file!"; } } else { echo "Error: can't access to file!"; } break; case 'delete_tpl': include_once 'modules/kXML/add_functions.php'; $path = "{$_REQUEST['path']}/{$_REQUEST['record']}"; if (file_exists($path)) { add2log($_REQUEST['path'], $_REQUEST['record'], "delete template"); } else { echo "Error: can't access to file!"; } break; default: echo "Error: bad request!"; break; } function count_elements($path) { $f = fopen("custom/kXML/templates/{$path}", "r"); $line = fgets($f); $search = explode(' ; ', $line); $search[0] = trim($search[0]); fclose($f);
<?php include 'functions.php'; $error_code = "777"; $error_msg = "Boeing!"; $name = "Mon rapport"; $lang = "fr_FR"; // Here, mode is based on the file extension. "foo.html" becomes "org.makcorp.ueasy.modes.Html". It can be done otherwise $point = strrpos($argv[2], '.'); $extensionFirstLetter = strtoupper(substr($argv[2], $point + 1, 1)); $extensionLastLetters = strtolower(substr($argv[2], $point + 2, strlen($argv[2]))); $modename = "org.makcorp.ueasy.modes.{$extensionFirstLetter}{$extensionLastLetters}"; add2log("Opening " . $argv[2] . " as {$modename} ..."); $css = join("", file("../cms/test.css")); // Early Experimentation for Spip // If it is a spip document, get it in the mysql database if ("{$extensionFirstLetter}{$extensionLastLetters}" == "Spip") { $id_article = substr($argv[2], 0, $point); add2log("Opening Spip article: {$id_article}\n"); $link = mysql_connect("localhost", "root", ""); // Ooh, bad ! mysql_select_db("spip"); $res0 = mysql_query("select * from spip_articles where id_article={$id_article};", $link); $article = mysql_fetch_array($res0); } else { $data = join("", file("data-" . $argv[2])); } // Reply to the server echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<methodResponse>\n\t<params>\n\t\t<param><value><int>{$error_code}</int></value></param>\n\t\t<param><value><string>{$error_msg}</string></value></param>\n\t\t<param><value><string><![CDATA[{$name}]]></string></value></param>\n\t\t<param><value><string>{$modename}</string></value></param>\n\t\t<param><value><string>{$lang}</string></value></param>\n\t\t<param><value><string><![CDATA[TO BE OVERWRITTEN BY SERVER]]></string></value></param>\n\t\t<param><value><string><![CDATA[{$css}]]></string></value></param>\n\t\t<param><value><string><![CDATA[{$data}]]></string></value></param>\n\t</params>\n</methodResponse>"; add2log("... open " . $argv[2] . " as {$modename}");