function ftp_processfiles($dowhat, $conn_id, $directory, $list, $options, $result, $divelevel) { // -------------- // This function does something with files (get size, find string, ...) // The $list contains both directories and files. The files are simply processed; the // directories are parsed recursively. // // $list[$i]["dirorfile"] contains d or - which indicates if the entry is a directory or a file // $list[$i]["dirfilename"] contains the name of the entry // $list[$i]["size"] contains the size of the entry // // OPTIONS: // if ($dowhat == "calculatesize") then // $options = array() doesn't contain anything // if ($dowhat == "findstring") then // $options["string"] a string // $options["case_sensitive"] blank or yes // $options["filename"] a filename with possible wildcard character * (it should match this preg_match regular expression: "/^[a-zA-Z0-9_ *-]*$/") // $options["size_from"], $options["size_to"] a number (in Bytes) // $options["modified_from"], $options["modified_to"] unix timestamps of the modification dates // // RESULT: // if ($dowhat == "calculatesize") then // $result["size"] // $result["skipped"] // if ($dowhat == "findstring") then // $result[$k]["directory"] contains the directory // $result[$k]["dirfilename"] contains the filename // $result[$k]["line"] contains the line nr // // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_result; // ------------------------------------------------------------------------- // Initialization // ------------------------------------------------------------------------- if ($divelevel == 0) { } // ------------------------------------------------------------------------- // For all directories // ------------------------------------------------------------------------- for ($i = 1; $i <= $list["stats"]["directories"]["total_number"]; $i = $i + 1) { $currentdirectory = glueDirectories($directory, $list["directories"][$i]["dirfilename"]); // Check if the directory contains a banned keyword if ($list["directories"][$i]["selectable"] != "ok") { continue; } // Get a new list $newlist = ftp_getlist($conn_id, $currentdirectory); if ($net2ftp_result["success"] == false) { return false; } // Call the function recursively $newdivelevel = $divelevel + 1; $result = ftp_processfiles($dowhat, $conn_id, $currentdirectory, $newlist, $options, $result, $newdivelevel); if ($net2ftp_result["success"] == false) { return false; } } // end for list_directories // ------------------------------------------------------------------------- // Process the files // ------------------------------------------------------------------------- for ($i = 1; $i <= $list["stats"]["files"]["total_number"]; $i = $i + 1) { // ------------------------------- // Calculate size // ------------------------------- if ($dowhat == "calculatesize") { // Check if the size information is entered // Check also if the size is numeric if (isset($list["files"][$i]["size"]) && is_numeric($list["files"][$i]["size"])) { $result["size"] = $result["size"] + $list["files"][$i]["size"]; } else { $result["skipped"] = $result["skipped"] + 1; } } elseif ($dowhat == "findstring") { // Check that the file is smaller than the maximum file size that can be processed with net2ftp if ($list["files"][$i]["selectable"] != "ok") { continue; } // Check that the file is within the limits indicated on the selection screen if ($list["files"][$i]["size"] < $options["size_from"] || $list["files"][$i]["size"] > $options["size_to"]) { // echo "File $i skipped"; continue; } // Check modification date (if that data is returned by the FTP server in the correct format) $mtime_file = strtotime($list["files"][$i]["mtime"]); // If strtotime cannot interprete the data returned by the FTP server it returns -1 if ($mtime_file != -1 && ($mtime_file < $options["modified_from"] || $mtime_file > $options["modified_to"])) { continue; } // Check the filename $pattern = "/^" . $options["filename"] . "\$/i"; // i at the end is for a case-insensitive match if (preg_match($pattern, $list["files"][$i]["dirfilename"]) == 0) { continue; } // Read the file $text = ftp_readfile("", $directory, $list["files"][$i]["dirfilename"]); // If the file could not be read correctly, continue to the next one if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); continue; } elseif ($text == "") { continue; } // Split the file in an array, each element of the array containing one line of the file $text_lines = explode_lines($text); // For each line, check if the string occurs for ($line = 0; $line < sizeof($text_lines); $line++) { // STRSTR AND STRISTR if ($options["case_sensitive"] == "yes") { $found = strstr($text_lines[$line], $options["string"]); } else { $found = stristr($text_lines[$line], $options["string"]); } if ($found != false) { $tempresult["directory"] = $directory; $tempresult["directory_html"] = htmlEncode2($directory); $tempresult["directory_js"] = javascriptEncode2($directory); $tempresult["dirfilename"] = $list["files"][$i]["dirfilename"]; $tempresult["dirfilename_html"] = $list["files"][$i]["dirfilename_html"]; $tempresult["dirfilename_js"] = $list["files"][$i]["dirfilename_js"]; $tempresult["line"] = $line + 1; // $text_lines[0] contains the line 1, etc... array_push($result, $tempresult); } } // end for } // end if findstring } // end for list_files return $result; }
function parse_dvdempire_video_data($search_attributes_r, $s_item_type, $buffer) { //<title>DVD Empire - Item - Rambo III: Ultimate Edition / DVD-Video</title> if (preg_match("!<title>DVD Empire - Item - (.*)/[\\s]*DVD-Video<\\/title>!m", $buffer, $regs)) { $this->addItemAttribute('title', str_replace("\"", "", html_entity_decode(strip_tags($regs[1]), ENT_COMPAT, get_opendb_config_var('themes', 'charset') == 'utf-8' ? 'UTF-8' : 'ISO-8859-1'))); } //<title>Buy Just Friends DVD @ DVD Empire </title> if (preg_match("!<title>Buy (.*) DVD @ DVD Empire <\\/title>!", $buffer, $matches)) { $this->addItemAttribute('title', $matches[1]); } if (preg_match("/Region ([0-9]+)/i", $buffer, $regs)) { $this->addItemAttribute('dvd_region', $regs[1]); } else { $this->addItemAttribute('dvd_region', '1'); // otherwise assume US region } $product_info = get_page_block('Product Information', $buffer); $this->addItemAttribute('dvd_extras', preg_replace(array("'[\n|\r]+'", "'[\t ]+'"), array("\n", " "), html_entity_decode(strip_tags(str_replace("<br>", "\n", parse_page_block('Features', $product_info))), ENT_COMPAT, get_opendb_config_var('themes', 'charset') == 'utf-8' ? 'UTF-8' : 'ISO-8859-1'))); $this->addItemAttribute('vid_format', 'NTSC'); // An American site, so most likely NTSC $video = parse_page_block('Video', $product_info); if (strlen($video) > 0) { if (strpos($video, 'Anamorphic') !== FALSE) { $this->addItemAttribute('anamorphic', 'Y'); } $ratio_list_r = array('1.33', '1.66', '1.78', '1.85', '2.35', '2.78'); while (list(, $ratio) = @each($ratio_list_r)) { if (preg_match('/' . $ratio . ':1/', $video)) { $this->addItemAttribute('ratio', $ratio); } } } $audio = parse_page_block('Audio', $product_info); if (strlen($audio) > 0) { $audio_r = explode_lines(strip_tags(preg_replace("/<br>/i", "\n", $audio))); if (is_not_empty_array($audio_r)) { //ENGLISH: Dolby Digital 5.1 [CC] for ($i = 0; $i < count($audio_r); $i++) { if (preg_match("/([A-Z]+): ([^\$]+)\$/Ui", $audio_r[$i], $matches)) { if (ends_with($matches[2], "[CC]")) { $audio_format = trim(substr($matches[2], 0, -5)); } else { $audio_format = trim($matches[2]); } $this->addItemAttribute('audiotrk', $matches[0]); $this->addItemAttribute('audio_lang', $matches[1]); $this->addItemAttribute('audio_format', $audio_format); } } } } $subtitles = parse_page_block('Subtitles', $product_info); if (strpos($subtitles, 'None') === FALSE) { $this->addItemAttribute('subtitles', trim_explode(",", $subtitles)); } if (preg_match("/<b>Packaging:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('dvd_packge', $regs[1]); } if (preg_match("/<b>Disc:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('dvd_disc', $regs[1]); } if (preg_match("/<b>Number of Discs:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $no_discs = trim($regs[1]); // fixed if (strlen($no_discs) > 0) { $this->addItemAttribute('no_discs', $no_discs); } } if (preg_match("/<b>Item Code:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('item_code', $regs[1]); } if (preg_match("/<b>Chapters:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('dvd_chptrs', $regs[1]); } if (preg_match("/<b>UPC Code:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('upc_id', $regs[1]); } if (preg_match("/<b>Studio:<\\/b> <a href=\\'.*?\\'>(.*?)<\\/a><br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('studio', $regs[1]); } if (preg_match("/<b>Production Year:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('year', $regs[1]); } if (preg_match("/<b>Release Date:<\\/b> (.*?)<br \\/>/i", $product_info, $regs)) { $this->addItemAttribute('rel_date', $regs[1]); } if (preg_match("/<b>DVD Year:<\\/b>(.*?)<br>/i", $product_info, $regs)) { $this->addItemAttribute('dvd_rel_dt', $regs[1]); } if (preg_match("/<b>Length:<\\/b>[\\s]([0-9]*)/i", $product_info, $regs)) { $this->addItemAttribute('run_time', $regs[1]); } if (preg_match("/<b>Rating:<\\/b>(.*?)<br \\/>/i", $product_info, $regs)) { $age_rating = trim($regs[1]); if (strlen($age_rating) > 0) { $this->addItemAttribute('age_rating', $age_rating); } } //<b>Cast & Crew</b> $film_info = get_page_block('Cast & Crew', $buffer); if (strlen($film_info) > 0) { $this->addItemAttribute('actors', parse_film_info_block('Actors', $film_info)); $this->addItemAttribute('director', parse_film_info_block('Directors', $film_info)); $this->addItemAttribute('producers', parse_film_info_block('Producers', $film_info)); $this->addItemAttribute('writers', parse_film_info_block('Writers', $film_info)); $this->addItemAttribute('creators', parse_film_info_block('Creators', $film_info)); } $index = strpos($buffer, "<b>Reviews</b>"); if ($index !== FALSE) { $index += strlen("<b>Reviews</b>"); $reviews = get_page_block('Reviews', substr($buffer, $index)); if (strlen($reviews) > 0) { // <b>Overall Rating:</b> <img src="/Graphics/Running/v4_rating0.gif" border='0' vspace='0' hspace='1'><img src="/Graphics/Running/v4_rating0.gif" border='0' vspace='0' hspace='1'><img src="/Graphics/Running/v4_rating0.gif" border='0' vspace='0' hspace='1'><img src="/Graphics/Running/v4_rating0.gif" border='0' vspace='0' hspace='1'><img src="/Graphics/Running/v4_rating1.gif" border='0' vspace='0' hspace='1'><span class='fontsmall'> <b>4.45</b> out of <b>5</b>, including <b>41</b> reviews<br> } } // ---------------------------- // Now the Cover images // ---------------------------- //http://images2.dvdempire.com/gen/movies/3073.jpg if (preg_match('!<img src=[\'|"](http://\\w*?\\.dvdempire\\.org/products/[0-9]*/' . $search_attributes_r['dvdempr_id'] . '\\.jpg)[\'|"]!', $buffer, $regs)) { $this->addItemAttribute('thumbimg', $regs[1]); } // Now we need to get the cover images $buffer = $this->fetchURI('http://www.dvdempire.com/Exec/v4_item.asp?item_id=' . $search_attributes_r['dvdempr_id'] . '&tab=5'); if (strlen($buffer) > 0) { //<img src="http://images2.dvdempire.com/gen/movies/3073h.jpg" valign="top" align="middle" border="0" hspace="0" vspace="0"> if (preg_match('!<img src=[\'|"](http://\\w*?\\.dvdempire\\.org/products/[0-9]*/' . $search_attributes_r['dvdempr_id'] . 'h\\.jpg)[\'|"]!', $buffer, $regs)) { $this->addItemAttribute('imageurl', $regs[1]); $this->addItemAttribute('imageurlf', $regs[1]); } } $buffer = $this->fetchURI('http://www.dvdempire.com/Exec/v4_item.asp?item_id=' . $search_attributes_r['dvdempr_id'] . '&tab=5&back=1'); if (strlen($buffer) > 0) { if (preg_match('!<img src=[\'|"](http://\\w*?\\.dvdempire\\.org/products/[0-9]*/' . $search_attributes_r['dvdempr_id'] . 'bh\\.jpg)[\'|"]!', $buffer, $regs)) { $this->addItemAttribute('imageurlb', $regs[1]); } } }
for ($i = 0; $i < sizeof($languagesArray); $i++) { // ------------------------------------ // Send status // ------------------------------------ echo "Language {$i} - " . $languagesArray[$i] . "<br />\n"; flush(); // ------------------------------------ // Read the English file and get the lines // ------------------------------------ $en_string = local_readfile($directory_old . "en" . $extension); $en_lines = explode_lines($en_string); // ------------------------------------ // Read the old translated file // ------------------------------------ $translated_old_string = local_readfile($directory_old . $languagesArray[$i] . $extension); $translated_old_lines = explode_lines($translated_old_string); // $en_lines contains: // [694] => $net2ftp_messages["Zip"] = "Zip"; // [695] => $net2ftp_messages["Size"] = "Size"; // [696] => $net2ftp_messages["Search"] = "Search"; // ------------------------------------ // Initialize the translated string // ------------------------------------ $translated_new_string = ""; $translated_new_lines = array(); // ------------------------------------------------------------------------- // SUBLOOP: for all lines // ------------------------------------------------------------------------- for ($j = 1; $j < sizeof($en_lines); $j++) { // ------------------------------------ // Send status
function get_item_display_field($item_r, $item_attribute_type_r, $value = NULL, $dowrap = TRUE, $prompt_mask = NULL) { if ($item_attribute_type_r['display_type'] == 'hidden') { return ''; } else { if ($item_attribute_type_r['display_type'] == 'fileviewer') { $format_mask = ifempty($item_attribute_type_r['display_type_arg1'], '%value%'); $width = ifempty($item_attribute_type_r['display_type_arg2'], '400'); $height = ifempty($item_attribute_type_r['display_type_arg3'], '300'); $target = ifempty($item_attribute_type_r['display_type_arg4'], '_blank'); if (is_array($value)) { $values = $value; } else { $values[] = $value; } if (count($values) > 0) { $display_value_r = array(); while (list(, $value) = each($values)) { $value = trim($value); $value_format_mask = $format_mask; if (strpos($value_format_mask, '%img%') !== FALSE) { $file_type_r = fetch_file_type_r(fetch_file_type_for_extension(get_file_ext($value))); if (strlen($file_type_r['image']) > 0 && ($image_src = theme_image_src($file_type_r['image'])) !== FALSE) { $img = '<img src="' . $image_src . '" title="' . $value . '">'; } else { $img = ''; } $value_format_mask = str_replace('%img%', $img, $value_format_mask); } if (strpos($value_format_mask, '%value%') !== FALSE) { $value_format_mask = str_replace('%value%', $value, $value_format_mask); } $file_r = file_cache_get_image_r($value, 'display'); $url = $file_r['fullsize']['url']; $display_value_r[] = "<a href=\"" . $value . "\" onclick=\"fileviewer('{$url}' ,'" . ($width + 20) . "', '" . ($height + 25) . "', '" . $target . "'); return false;\" title=\"" . $item_attribute_type_r['prompt'] . "\" class=\"popuplink\">{$value_format_mask}</a>"; } $field = format_multivalue_block($display_value_r, 'fileviewer'); if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { return ''; } } else { if ($item_attribute_type_r['display_type'] == 'datetime') { if (is_array($value)) { $values = $value; } else { $values[] = $value; } if (count($values) > 0) { $display_value_r = array(); while (list(, $value) = each($values)) { $value = trim($value); $timestamp = get_timestamp_for_datetime($value, 'YYYYMMDDHH24MISS'); if ($timestamp !== FALSE) { if (strlen($item_attribute_type_r['display_type_arg1']) == 0) { $item_attribute_type_r['display_type_arg1'] = 'DD/MM/YYYY'; } $datetime = get_localised_timestamp($item_attribute_type_r['display_type_arg1'], $timestamp); if ($datetime !== FALSE) { $display_value_r[] = $datetime; } else { $display_value_r[] = $value; } } else { $display_value_r[] = $value; } } $field = format_multivalue_block($display_value_r, 'datetime'); if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { return ''; } } else { if ($item_attribute_type_r['display_type'] == 'format_mins') { if (is_array($value)) { $values = $value; } else { $values[] = $value; } if (count($values) > 0) { $display_value_r = array(); while (list(, $value) = each($values)) { $value = trim($value); if (is_numeric($value)) { // Ensure we have a mask to work with. $display_mask = $item_attribute_type_r['display_type_arg1']; if (strlen($display_mask) == 0) { $display_mask = '%h %H %m %M'; } $hrs = floor($value / 60); // hours $mins = $value % 60; // minutes // Process display_mask and remove any bits that are not needed because the hour/minute is zero. if ($mins == 0 && $hrs > 0) { // only get rid of minutes if $hrs is a value. $index = strpos($display_mask, '%H'); if ($index !== FALSE) { $display_mask = substr($display_mask, 0, $index + 2); } else { $index = strpos($display_mask, '%m'); if ($index != FALSE) { $display_mask = substr($display_mask, 0, $index); } //include the %H } } else { if ($hrs == 0) { $index = strpos($display_mask, '%m'); if ($index != FALSE) { $display_mask = substr($display_mask, $index); } //include the %H } } // Unfortunately we need to do $mins>0 and $hrs>0 if's twice, because otherwise once we // replace the %h and %H the test for $mins>0 would not be able to cut the display_mask, // based on the %h/%H... if ($hrs > 0) { // Now do all replacements. $display_mask = str_replace('%h', $hrs, $display_mask); if ($hrs != 1) { $display_mask = str_replace('%H', get_opendb_lang_var('hours'), $display_mask); } else { $display_mask = str_replace('%H', get_opendb_lang_var('hour'), $display_mask); } } if ($mins >= 0 || $hrs === 0 && $mins === 0) { // Now do minute replacements only. $display_mask = str_replace('%m', $mins, $display_mask); if ($mins != 1) { $display_mask = str_replace('%M', get_opendb_lang_var('minutes'), $display_mask); } else { $display_mask = str_replace('%M', get_opendb_lang_var('minute'), $display_mask); } } $display_value_r[] = $display_mask; } else { // what else can we do here?! $display_value_r[] = $value; } } $field = format_multivalue_block($display_value_r, 'format_mins'); if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { return ''; } } else { if ($item_attribute_type_r['display_type'] == 'star_rating') { // arg[0] = rating range if (is_array($value)) { $values = $value; } else { $values[] = $value; } if (count($values) > 0) { $display_value_r = array(); while (list(, $value) = each($values)) { $value = trim($value); // no point unless numeric if (is_numeric($value)) { $total_count = $item_attribute_type_r['display_type_arg1']; if (is_numeric($total_count)) { $display_value = ''; $j = $value; for ($i = 0; $i < $total_count; ++$i) { if ($j >= 0.75) { $display_value .= theme_image('rs.gif'); } else { if ($j >= 0.25) { $display_value .= theme_image('rgs.gif'); } else { $display_value .= theme_image('gs.gif'); } } $j = $j - 1; } $ratingmask = $item_attribute_type_r['display_type_arg2']; if (strlen($ratingmask) > 0) { $ratingmask = str_replace('%value%', $value, $ratingmask); $ratingmask = str_replace('%maxrange%', $total_count, $ratingmask); $display_value = str_replace('%starrating%', $display_value, $ratingmask); } if ($item_attribute_type_r['listing_link_ind'] == 'Y') { $display_value = format_listing_link($value, $display_value, $item_attribute_type_r, NULL); } } $display_value_r[] = $display_value; } } $field = format_multivalue_block($display_value_r, 'starrating'); if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { return ''; // nothing to do! } } else { if (!is_array($value) && $item_attribute_type_r['display_type'] == 'display' && ifempty($item_attribute_type_r['display_type_arg1'], '%value%') == '%value%') { // Support newline formatting by default. $value = nl2br(trim($value)); if ($item_attribute_type_r['listing_link_ind'] == 'Y') { $field = format_listing_links($value, $item_attribute_type_r, 'exact'); } else { $field = $value; } if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { if ($item_attribute_type_r['display_type'] == 'list') { //list(list_type [,delimiter]) if (is_array($value)) { $values = $value; $attr_match = 'exact'; } else { $value = trim($value); if (strlen($item_attribute_type_r['display_type_arg2']) == 0) { // Use newline! $values = explode_lines($value); $attr_match = 'partial'; } else { $values = explode($item_attribute_type_r['display_type_arg2'], $value); if (strlen(trim($item_attribute_type_r['display_type_arg2'])) === 0) { $attr_match = 'word'; } else { $attr_match = 'partial'; } } } $field = format_list_from_array($values, $item_attribute_type_r, $item_attribute_type_r['listing_link_ind'] == 'Y' ? $attr_match : FALSE); if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { if ($item_attribute_type_r['display_type'] == 'category' || $item_attribute_type_r['display_type'] == 'display') { $field = ''; if (is_array($value)) { $value_array = $value; } else { $value_array[] = $value; } $attribute_value_rs = array(); if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y') { $results = fetch_value_match_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], $value_array, get_lookup_order_by($item_attribute_type_r['display_type_arg1']), 'asc'); if ($results) { while ($lookup_r = db_fetch_assoc($results)) { $lookup_key = array_search2($lookup_r['value'], $value_array, TRUE); if ($lookup_key !== FALSE) { // Remove the matched element array_splice($value_array, $lookup_key, 1); $attribute_value_rs[] = array(value => $lookup_r['value'], display => $lookup_r['display'], img => $lookup_r['img']); } } db_free_result($results); } } // where extra items that do not have a matching lookup value. if (is_not_empty_array($value_array)) { reset($value_array); while (list(, $value) = each($value_array)) { if (strlen(trim($value)) > 0) { // In case there are extra spaces $attribute_value_rs[] = array(value => $value, display => $value); } } } if (is_not_empty_array($attribute_value_rs)) { $field = format_lookup_display_block($item_attribute_type_r, $attribute_value_rs); if (strlen($field) > 0) { if ($dowrap) { return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask); } else { return $field; } } else { return NULL; } } } else { if ($item_attribute_type_r['display_type'] == 'review') { $total_count = fetch_attribute_type_cnt('S_RATING'); if (is_numeric($total_count)) { $value = trim($value); if (!is_numeric($value)) { $value = 0; } $field = ''; $j = $value; for ($i = 0; $i < $total_count; ++$i) { if ($j >= 0.75) { $field .= theme_image('rs.gif'); } else { if ($j >= 0.25) { $field .= theme_image('rgs.gif'); } else { $field .= theme_image('gs.gif'); } } $j = $j - 1; } // If a mask is defined, format the display value. if (strlen($item_attribute_type_r['display_type_arg1']) > 0) { $lookup_r = fetch_attribute_type_lookup_r('S_RATING', $value); if (is_not_empty_array($lookup_r)) { $field .= format_display_value($item_attribute_type_r['display_type_arg1'], $lookup_r['img'], $lookup_r['value'], $lookup_r['display']); } } return $field; // this is only used in a few places. } } } } } } } } } } //else -- no display type match. if ($dowrap) { return format_field($item_attribute_type_r['prompt'], nl2br($value), $prompt_mask); } else { return nl2br($value); } }
function get_function_info($line) { if (empty($line) || $line == '} ') { $function_info = array('function' => ''); $function_info['args_in'] = ''; $function_info['args_out'] = ''; $function_info['list_args_in'] = array(); $function_info['list_args_out'] = array(); $function_info['mc_count'] = 1; return $function_info; } $list = array('function[[:space:]]+()&?[[:space:]]*([^\\(=]*)[[:space:]]*\\([[:space:]]*([^\\)]*)', 'function[[:space:]]+([^=]*)=[[:space:]]+&?[[:space:]]*([^\\(]*)[[:space:]]*\\([[:space:]]*([^\\)]*)'); $ancora = 1; $i = 0; while ($ancora) { $pat = $list[$i]; // echo "$i - $pat<br>"; $function_info = array(); $temp = preg_match('/' . addcslashes($pat, '/') . '/', $line, $temp_function_info); $function_info['args_out'] = $temp_function_info[1]; $function_info['function'] = $temp_function_info[2]; $function_info['args_in'] = $temp_function_info[3]; $i = $i + 1; $ancora = empty($function_info['function']) && $i < count($list); } if (!array_key_exists('args_out', $function_info)) { $function_info['args_out'] = ''; } if (!array_key_exists('function', $function_info)) { $function_info['function'] = ''; } if (!array_key_exists('args_in', $function_info)) { $function_info['args_in'] = ''; } if (empty($function_info['function'])) { stampa('Problema nel parsing della funzione:'); var_dump($function_info); die($line); } $flag_keep_sep = 0; if (!empty($function_info['args_out'])) { $function_info['list_args_out'] = explode_lines(array($function_info['args_out']), array(',', ' '), array()); } else { $function_info['list_args_out'] = array(); } if (!empty($function_info['args_in'])) { // drop "&" for referenced arguments $function_info['args_in'] = preg_replace('/&/', '', $function_info['args_in']); // drop default values ("... $a=NULL ..." --> "... $a ..." ) $function_info['args_in'] = preg_replace('/=[[:space:]]*[^[:space:]]+[[:space:]]*/', ' ', $function_info['args_in']); // split input arguments $function_info['list_args_in'] = explode_lines(array($function_info['args_in']), array(',', ' '), array()); } else { $function_info['list_args_in'] = array(); } $function_info['mc_count'] = 1; return $function_info; }