function main($query, $type, $reversed, $key) { $line = get_bus_line($key); if (count($line) == 0) { write_error($GLOBALS['ERR_NOT_BUS']); } else { if ($type == 'text') { write_text($query, $reversed, $line); } elseif ($type == 'json') { write_json($query, $reversed, $line); } else { write_error($GLOBALS['ERR_PARAMS_TYPE']); } } }
function save_site($text, $file, $Data) { //Регулярка для Unicode preg_match_all('/[\\pL\\pN\\pP]+/u', $text, $matches); foreach ($matches[0] as $v) { $array[] = mb_strtolower($v, 'UTF-8'); } if (count($Data) != 0) { foreach ($Data as $value) { $Sites[] = strtolower($value[0]); } $deleted_sites = array_unique(array_diff($Sites, $array)); $add_sites = array_unique(array_diff($array, $Sites)); foreach ($deleted_sites as $key => $value) { unset($Data[$key]); } foreach ($add_sites as $value) { $Data[] = array($value); } } else { foreach ($array as $value) { $Data[] = array($value); } } if (count($deleted_sites) != 0) { $temp = $Data; $Data = null; foreach ($temp as $value) { $Data[] = $value; } unset($temp); } //Ассоциативный массив json_encode() кодирует как объект stdClass-а(ключ-значение)??????????????? $text = json_encode($Data); write_text($text, $file); return $Data; }
function dup_text( $dc1, $dc2, $text_id ) { $text = read_text( $dc1, $text_id ); $id = write_text( $dc2, $text ); return $id; }
$source_pic = request_var('avatarfile', ''); $source_pic_full = $source_pic . '.gif'; $text_content = stripslashes(request_var('text_content', '', true)); $text_size = request_var('text_size', 10); $text_font = request_var('text_font', 'denmark.ttf'); $text_font = $fonts_path . $text_font; $text_color = request_var('text_color', '#ffffff'); $text_position = request_var('text_position', 0); $avatars_array = array('ip.gif', 'a69_02.gif', 'agreen.gif', 'aphro_lite.gif', 'aphrodite.gif', 'blue.gif', 'darkblue.gif', 'firefox.gif', 'gray.gif', 'green.gif', 'opera.gif', 'pink.gif', 'purple.gif', 'red.gif', 'sblue.gif', 'av01.gif', 'av02.gif', 'av03.gif', 'av04.gif', 'av05.gif', 'av06.gif', 'av07.gif', 'av08.gif', 'av09.gif', 'av10.gif', 'av11.gif', 'av12.gif', 'av13.gif', 'av14.gif', 'av15.gif', 'av16.gif', 'av17.gif'); if (in_array($source_pic_full, $avatars_array)) { $source_pic = $generator_template_path . $source_pic_full; } else { $num = mt_rand(1, sizeof($avatars_array)); $source_pic = $generator_template_path . $avatars_array[$num]; } write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size, $text_color, $text_position); //write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size, '#FFFFAA', $text_position); /** * Write text on images */ function write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size = 10, $text_color = '#FFFFFF', $text_position = '0') { $temp_pic = imagecreatefromgif($source_pic); list($image_width, $image_height) = getimagesize($source_pic); /* $temp_pic_empty = imagecreatetruecolor ($image_width, $image_height); imagealphablending($temp_pic_empty, false); imagecopyresampled($temp_pic_empty, $temp_pic, 0, 0, 0, 0, $image_width, $image_height, $image_width, $image_height); imagesavealpha($temp_pic_empty, true); //imagepng($im_re, 'small_redfade.png'); $temp_pic2 = imagecreatefrompng($source_pic);