function get_random_colors($how_many) { $colors = array(); for ($k = 0; $k < $how_many; $k++) { $colors[] = '#' . random_color(); } return $colors; }
function get_LatestPosts($LatestPosts) { echo '<section class="aside-today"> <h2 class="aside-today__title">最近更新<span>+' . $LatestPosts . '</span></h2> <ul class="aside-today__list"> '; ?> <?php query_posts('showposts=' . $LatestPosts); ?> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <li> <div class="topic"><span><a href="<?php the_permalink(); ?> "><img style="margin-bottom: 5px;" alt="<?php the_title(); ?> " src="<?php echo mmimg(get_the_ID()); ?> " ></a><?php $category = get_the_category(); if ($category[0]) { echo '<a class="' . random_color() . '" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a> / '; echo $category[0]->slug; } ?> </span></div> <h1><a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php the_title(); ?> </a></h1> </li> <?php } } wp_reset_query(); echo ' </ul> </section>'; }
function generateCloud($arr, $min_size, $max_size) { // Obtenemos maximos y minimos $min_n = 0; $max_n = 0; foreach ($arr as $desc) { $min_n = $min_n > $desc['N'] ? $desc['N'] : $min_n; $max_n = $max_n < $desc['N'] ? $desc['N'] : $max_n; } // Una vez obtenemos calculamos la proporcion $prop = ($max_size - $min_size) / ($max_n - $min_n); echo "\n\t<div id='nube'>\n\t<div id='etiquetas'>\n\t"; // A escribir! $i = 0; $script = "var item,x;\n"; foreach ($arr as $desc) { $id = "desc{$i}"; echo "<span style='font-size:" . ($min_size + round($desc['N'] * $prop, 2)) . "px;color:" . random_color() . ";' id='{$id}'>" . $desc['descriptor'] . "</span>"; // Intercambia ancho y alto if (!rand(0, 4) && !ae_detect_opera()) { if (ae_detect_ie()) { $script .= "item = document.getElementById('{$id}');\n"; $script .= "x = item.clientWidth;\n"; $script .= "if (x<=70) {\n"; $script .= "document.getElementById('{$id}').className += 'vertical';\n"; $script .= "}\n"; } else { $script .= "item = document.getElementById('{$id}');\n"; $script .= "x = item.clientWidth;\n"; $script .= "if (x<=70) {\n"; $script .= "item.style.width=item.clientHeight;\n"; $script .= "item.style.height=x;\n"; $script .= "document.getElementById('{$id}').className += 'vertical';\n"; $script .= "item.style.marginLeft=item.style.width;\n"; $script .= "item.style.width=0;\n"; $script .= "item.style.whiteSpace='nowrap';\n"; $script .= "}\n"; } } $i++; } /*$script .= "x = document.getElementById('nube').offsetWidth;\n"; $script .= "for (var i=0;i<$i;i++){\n"; $script .= "item=document.getElementById('desc'+i);\n"; $script .= "while (item.clientWidth>x){\n"; $script .= "item.style.fontSize=parseInt(item.style.fontSize.replace('px',''))-1;}}\n";*/ echo "\n\t<div style='clear:both'></div>\n\t</div>\n\t</div>\n\t"; echo "<script type='text/javascript'>\n{$script}</script>\n"; }
$color = imagecolorallocate($image, $r, $g, $b); imageline($image, 0, $i, $lx, $i, $color); } } // generate Text if ($debug) { echo "\n<br>-Captcha-Debug: Fill forground with chars and shadows: (" . $chars . ")"; } for ($i = 0, $x = intval(rand($minsize, $maxsize)); $i < $chars; $i++) { $text = $string[$i]; $angle = intval(rand($maxrotation * -1, $maxrotation)); $size = intval(rand($minsize, $maxsize)); $y = intval(rand((int) ($size * 1.5), (int) ($ly - $size / 7))); list($r, $g, $b) = random_color(0, 127); $color = imagecolorallocate($image, $r, $g, $b); list($r, $g, $b) = random_color(0, 127); $shadow = imagecolorallocate($image, $r + 127, $g + 127, $b + 127); $TTF_file = change_TTF(); imagettftext($image, $size, $angle, $x + (int) ($size / 15), $y, $shadow, $TTF_file, $text); imagettftext($image, $size, $angle, $x, $y - (int) ($size / 15), $color, $TTF_file, $text); $x += (int) ($size + $minsize / 5); } $ip = $DB->escape($_SERVER['REMOTE_ADDR'], 1); $DB->query("DELETE FROM {$CONF['sql_prefix']}_sessions WHERE data LIKE '{$ip}|%'", __FILE__, __LINE__); $data = "{$ip}|" . sha1(')F*RJ@FHR^%X' . $string . '(*Ht3h7f9&^F' . $ip); require_once "{$CONF['path']}/sources/misc/session.php"; $session = new session(); $session->create('captcha', $data); header('Pragma: no-cache'); header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); header('Content-type: image/jpeg');
// http://php.net/manual/timezones.php $your_id = ""; //your id $bot_token = ""; // bot page access token // parse api response $result_parse = file_get_contents("http://api.vk.com/method/wall.search?owner_id={$owner_id}&count=1&query={$query}"); $result_parse = json_decode($result_parse); $result_parse = $result_parse->response; // get unixtime from api response for ($i = 0; $i < count($result_parse); $i++) { $dateunix = $result_parse[$i]->date; } // convert unix time $dt = new DateTime("@{$dateunix}"); $dt->setTimeZone(new DateTimeZone('' . $date_timezone)); $date = $dt->format('' . $date_format); // hex generator for antifloodcontrol function random_color_part() { return str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT); } function random_color() { return random_color_part() . random_color_part() . random_color_part(); } $hex = random_color(); // message body: "(msg_body) (date) [antifloodcontrol: (random hex)]" $msq = "{$msg_body}{$date}%20%5Bantifloodcontrol:%20{$hex}%20%5D"; // send message file_get_contents("https://api.vk.com/method/messages.send?access_token={$bot_token}&user_id={$your_id}&message={$msq}");
public function getChunksToSize($node, $maxSize, &$chunks, &$currentColor = 'pink') { if (!isset($node->chunk)) { $node->setInnerChunks($node); } if (str_word_count($node->chunk) > $maxSize && $node->hasChildren()) { foreach (array_reverse($node->children) as $nodeChild) { $nodeChild->getChunksToSize($nodeChild, $maxSize, $chunks, $currentColor); } } else { if (count($chunks) > 0) { $lastChunk = array_pop($chunks); //combine one-word chunks and non alphanumerical chunks with to bigger chunks if (str_word_count($node->chunk) <= 1 || strlen(preg_replace("/[^a-zA-Z0-9]/i", "", $lastChunk)) == 0 || is_numeric(preg_replace("/[^a-zA-Z0-9]/i", "", $lastChunk)) || is_numeric($node->chunk)) { // oh, no!! the chunk is veeery small ): Can we add it to the next logical bigger chunk? $chunks[] = $node->chunk . " " . $lastChunk; $node->chunkColor = $currentColor; $this->_setChildrenColor($node, $currentColor); } else { $chunks[] = $lastChunk; $chunks[] = $node->chunk; $currentColor = '#' . random_color(); $node->chunkColor = $currentColor; $this->_setChildrenColor($node, $currentColor); } } else { $chunks[] = $node->chunk; $currentColor = '#' . random_color(); $node->chunkColor = $currentColor; $this->_setChildrenColor($node, $currentColor); } } return $chunks; }
the_title(); ?> </h2> </section> <section class="category-topic cf"> <?php $args = array('orderby' => 'name', 'order' => 'ASC', 'exclude' => '85,20'); $categories = get_categories($args); foreach ($categories as $category) { ?> <div class="category-topic__topics"> <div class="category-topic__title cf"> <div class="topic left"><span><a href="#" class="<?php echo random_color(); ?> "><?php echo $category->cat_name; ?> </a> / <?php echo $category->slug; ?> </span></div> <div class="viewall right"><a href="<?php echo get_category_link($category->term_id); ?> ">查看更多</a></div> </div> <ul class="category-topic__list"> <?php
smoker = '{$_REQUEST[smoker]}', college = '{$_REQUEST[college]}', subject = '{$_REQUEST[subject]}', course = '{$_REQUEST[mycourse]}', academic_year = '{$_REQUEST[academic_year]}', arrival = '$arriv', departure = '$depar', deposit = '{$_REQUEST[deposit]}', color = '{$_REQUEST[color]}' WHERE resident_id = $resident_id"; //ver("q",$q); mysql_query($q); } else { $today=date("Y-m-d H:m:s"); $q="INSERT INTO residents (name, surname, address_line1, address_line2, postal_code, city, county, country_id, nationality, r, telephone, mobile, email, date_of_birth, marital_status, smoker, college, subject, course, academic_year, arrival, departure, color, application_date) VALUES ('{$_REQUEST[name]}', '{$_REQUEST[surname]}', '{$_REQUEST[address_line1]}', '{$_REQUEST[address_line2]}', '{$_REQUEST[postal_code]}', '{$_REQUEST[city]}', '{$_REQUEST[county]}', '{$_REQUEST[country_id]}', '{$_REQUEST[nationality]}', '{$_REQUEST[r]}', '{$_REQUEST[telephone]}', '{$_REQUEST[mobile]}', '{$_REQUEST[email]}', '$date_of_birth', '{$_REQUEST[marital_status]}', '{$_REQUEST[smoker]}', '{$_REQUEST[college]}', '{$_REQUEST[subject]}', '{$_REQUEST[mycourse]}', '{$_REQUEST[academic_year]}', '$arriv', '$depar', '".random_color()."', '$today')"; //ver("q",$q); mysql_query($q); $resident_id=mysql_insert_id(); } } if ($_REQUEST[operation]=="refresh") { // Check valid numbers before update. $error=0; foreach ($_REQUEST as $key => $value) { if (substr($key,0,2) == "ra" && substr($key,2) == $_REQUEST["booking_id"]) { $ra=$value; $error_ra="input"; if (!is_numeric($ra)) { $error=1; $error_ra="class=input_error"; } }
echo "<script>document.location='admin.php?pagetoload=residents_list.php';</script>"; } elseif ($request[operation] == "change_status") { $q = "UPDATE bookings SET status='{$request[status]}' WHERE booking_id={$request[booking_id]}"; //ver("q",$q); mysql_query($q); } elseif ($request[operation] == "save") { $date_of_birth = $request[year] . "-" . $request[month] . "-" . $request[day]; $arriv = change_format_date($request[arrival]); $depar = change_format_date($request[departure]); if ($resident_id) { $q = "UPDATE residents SET\r\n\t\tname = '{$request[name]}',\r\n\t\tsurname = '{$request[surname]}',\r\n\t\taddress_line1 = '{$request[address_line1]}',\r\n\t\taddress_line2 = '{$request[address_line2]}',\r\n\t\tpostal_code = '{$request[postal_code]}',\r\n\t\tcity = '{$request[city]}',\r\n\t\tcounty = '{$request[county]}',\r\n\t\tcountry_id = '{$request[country_id]}',\r\n\t\tnationality = '{$request[nationality]}',\r\n\t\tr = '{$request[r]}',\r\n\t\ttelephone = '{$request[telephone]}',\r\n\t\tmobile = '{$request[mobile]}',\r\n\t\temail = '{$request[email]}',\r\n\t\tdate_of_birth = '{$date_of_birth}',\r\n\t\tmarital_status = '{$request[marital_status]}',\r\n\t\tsmoker = '{$request[smoker]}',\r\n\t\tcollege = '{$request[college]}',\r\n\t\tsubject = '{$request[subject]}',\r\n\t\tcourse = '{$request[mycourse]}',\r\n\t\tacademic_year = '{$request[academic_year]}',\r\n\t\tarrival = '{$arriv}',\r\n\t\tdeparture = '{$depar}',\r\n\t\tdeposit = '{$request[deposit]}',\r\n\t\tcolor = '{$request[color]}'\r\n\t\tWHERE resident_id = {$resident_id}"; //ver("q",$q); mysql_query($q); } else { $today = date("Y-m-d H:m:s"); $q = "INSERT INTO residents (name, surname, address_line1, address_line2, postal_code, city, county, country_id, nationality, r, telephone, mobile, email, date_of_birth, marital_status, smoker, college, subject, course, academic_year, arrival, departure, color, application_date)\r\n\t\tVALUES ('{$request[name]}', '{$request[surname]}', '{$request[address_line1]}', '{$request[address_line2]}', '{$request[postal_code]}', '{$request[city]}', '{$request[county]}', '{$request[country_id]}', '{$request[nationality]}', '{$request[r]}', '{$request[telephone]}', '{$request[mobile]}', '{$request[email]}', '{$date_of_birth}', '{$request[marital_status]}', '{$request[smoker]}', '{$request[college]}', '{$request[subject]}', '{$request[mycourse]}', '{$request[academic_year]}', '{$arriv}', '{$depar}', '" . random_color() . "', '{$today}')"; //ver("q",$q); mysql_query($q); $resident_id = mysql_insert_id(); } } if ($request[operation] == "refresh") { // Check valid numbers before update. $error = 0; foreach ($request as $key => $value) { if (substr($key, 0, 2) == "ra" && substr($key, 2) == $request["booking_id"]) { $ra = $value; $error_ra = "input"; if (!is_numeric($ra)) { $error = 1; $error_ra = "class=input_error";
foreach ($cpu as $c) { if ($c['HOUR'] == date('H', $current)) { $data_day[$current]['cpu' . $inst['id']] = round($c['average'] / 10); } } foreach ($ram as $r) { if ($r['HOUR'] == date('H', $current)) { $data_day[$current]['ram' . $inst['id']] = round($r['average']); } } $current = $next; } } $content = "\n\t<div id=\"chart1\"></div>\n\t<br />\n\t<div id=\"chart2\"></div>\n\t<br /><br />\n\t<script>\n\t\t\$(function()\n\t\t{\t\t\n\t\t\tvar dataSourceDay = ["; foreach ($data_day as $key => $value) { $content .= "\n\t\t\t{ hour: '" . date($lang['dateformathour'], $key) . "', "; foreach ($app['branches'][$_SESSION['DATA'][$app['id']]['branch']]['instances'] as $i) { $content .= " memory{$i['id']}: " . $value['ram' . $i['id']] . ", cpu{$i['id']}: " . $value['cpu' . $i['id']] . ", "; } $content .= "}, "; } $content .= "\n\t\t\t];\n\t\t\t\n\t\t\t\$(\"#chart1\").dxChart({\n\t\t\t\tdataSource: dataSourceDay,\n\t\t\t\tcommonSeriesSettings: {\n\t\t\t\t\targumentField: \"hour\",\n\t\t\t\t\tpoint: {\n\t\t\t\t\t\tvisible: false\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tseries: [\n"; foreach ($app['branches'][$_SESSION['DATA'][$app['id']]['branch']]['instances'] as $i) { $content .= "\n\t\t\t\t\t{ valueField: \"cpu{$i['id']}\", name: \"{$app['name']}-{$_SESSION['DATA'][$app['id']]['branch']}-{$i['id']} ({$lang['cpu']})\", type: 'spline', 'color': '#" . random_color() . "' },\n\t"; } $content .= "\n\t\t\t\t],\n\t\t\t\tvalueAxis: {\n\t\t\t\t\tlabel: {\n\t\t\t\t\t\tcustomizeText: function() {\n\t\t\t\t\t\t\treturn this.valueText + '%'\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\targumentAxis:{\n\t\t\t\t\tgrid:{\n\t\t\t\t\t\tvisible: true\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\ttooltip:{\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tfont: { size: 15 }\n\t\t\t\t},\n\t\t\t\ttitle: {\n\t\t\t\t\ttext: '{$lang['chart1_title']}',\n\t\t\t\t\tfont: { size: 15 }\n\t\t\t\t},\n\t\t\t\tlegend: {\n\t\t\t\t\tverticalAlignment: \"bottom\",\n\t\t\t\t\thorizontalAlignment: \"center\"\n\t\t\t\t},\n\t\t\t\tsize: {\n\t\t\t\t\twidth: 1100,\n\t\t\t\t\theight: 300\n\t\t\t\t},\n\t\t\t\tcommonPaneSettings: {\n\t\t\t\t\tborder:{\n\t\t\t\t\t\tvisible: true,\n\t\t\t\t\t\tright: false\n\t\t\t\t\t} \n\t\t\t\t}\n\t\t\t});\n\n\t\t\t\$(\"#chart2\").dxChart({\n\t\t\t\tdataSource: dataSourceDay,\n\t\t\t\tcommonSeriesSettings: {\n\t\t\t\t\targumentField: \"hour\"\n\t\t\t\t},\n\t\t\t\tseries: [\n"; foreach ($app['branches'][$_SESSION['DATA'][$app['id']]['branch']]['instances'] as $i) { $content .= "\t\t\t\t\t{ valueField: \"memory{$i['id']}\", name: \"{$app['name']}-{$_SESSION['DATA'][$app['id']]['branch']}-{$i['id']} ({$lang['memory']})\", type: 'bar', 'color': '#" . random_color() . "' },\n\t"; } $content .= "\n\t\t\t\t],\n\t\t\t\tvalueAxis: {\n\t\t\t\t\tlabel: {\n\t\t\t\t\t\tcustomizeText: function() {\n\t\t\t\t\t\t\treturn this.valueText + 'M'\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\targumentAxis:{\n\t\t\t\t\tgrid:{\n\t\t\t\t\t\tvisible: true\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\ttooltip:{\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tfont: { size: 15 }\n\t\t\t\t},\n\t\t\t\ttitle: {\n\t\t\t\t\ttext: '{$lang['chart2_title']}',\n\t\t\t\t\tfont: { size: 15 }\n\t\t\t\t},\n\t\t\t\tlegend: {\n\t\t\t\t\tverticalAlignment: \"bottom\",\n\t\t\t\t\thorizontalAlignment: \"center\"\n\t\t\t\t},\n\t\t\t\tsize: {\n\t\t\t\t\twidth: 1100,\n\t\t\t\t\theight: 300\n\t\t\t\t},\n\t\t\t\tcommonPaneSettings: {\n\t\t\t\t\tborder:{\n\t\t\t\t\t\tvisible: true,\n\t\t\t\t\t\tright: false\n\t\t\t\t\t} \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t</script>\n"; echo $content;
<?php require "config.php"; header("Access-Control-Allow-Origin: *"); header('Content-type: application/json'); $sql = "Select * from tbl_voting"; $res = mysqli_query($conn, $sql); $rows = mysqli_num_rows($res); function random_color_part() { return str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT); } function random_color() { return random_color_part() . random_color_part() . random_color_part(); } $sql = "Select * from tbl_votes"; $res = mysqli_query($conn, $sql); while ($data = mysqli_fetch_array($res)) { $string = $data[0]; $pieces = explode(' ', $string); $last_word = array_pop($pieces); $result[] = array('value' => $data[1] / $rows * 100, 'color' => '#' . random_color(), 'label' => $last_word, 'VOTES' => $data[1], 'TOTAL' => $rows); } echo json_encode($result);
<?php //ver_array("REQUEST", $request); //ver_array("SESSION", $_SESSION); $request = filter_input_array(INPUT_POST); if ($request[operation] == "book") { $arrival = change_format_date($request[date_from]); $departure = change_format_date($request[date_to]); $number_rooms = 0; $color = random_color(); $q = "INSERT INTO groups (name,color,arrival,departure) VALUES ('{$request[group_name]}', '{$color}' , '{$arrival}', '{$departure}')"; $r = mysql_query($q); $group_id = mysql_insert_id(); foreach ($request as $key => $value) { //ver("",$key); if (substr($key, 0, 4) == "room") { $room_id = substr($key, 4); $number_rooms++; $nr = $number_rooms; if ($nr < 10) { $nr = "0" . $nr; } $today = date("Y-m-d H:m:s"); $q1 = "INSERT INTO residents (name,color, arrival, departure, application_date, status) " . "VALUES ('{$request[group_name]} {$nr}', '{$color}', '{$arrival}', '{$departure}', '{$today}', 'accepted')"; mysql_query($q1); $resident_id = mysql_insert_id(); $q2 = "INSERT INTO bookings (arrival, planned_departure, departure, room_id, resident_id, status, booking_date, group_id) " . "VALUES ('{$arrival}', '{$departure}', '{$departure}', '{$room_id}', {$resident_id}, 'accepted', '{$today}', {$group_id})"; mysql_query($q2); $q3 = "INSERT INTO residents_groups (group_id, resident_id) VALUES ('{$group_id}', '{$resident_id}')"; mysql_query($q3); }
function llistatCercaEspais($RET, $ESPAIS, $DATA) { ?> <div class="REQUADRE"> <div class="titol">Llistat d'espais</div> <?php // MOSTREM PER CADA DIA DE LA SETMANA, QUÈ HI HA A CADA HORA. //Agafem el dia inicial... $Di = date('N', $DATA); //1 -dll, 2dm, 3dc, 4dj $dies_mes = cal_days_in_month(CAL_GREGORIAN, date('m', $DATA), date('Y', $DATA)); $DIES = array(1 => array('T' => 'Dl', 'D' => array()), 2 => array('T' => 'Dm', 'D' => array()), 3 => array('T' => 'Dc', 'D' => array()), 4 => array('T' => 'Dj', 'D' => array()), 5 => array('T' => 'Dv', 'D' => array()), 6 => array('T' => 'Ds', 'D' => array()), 7 => array('T' => 'Dg', 'D' => array())); $TAULA = array(9 => array('T' => '9:00', 'D' => $DIES), 10 => array('T' => '10:00', 'D' => $DIES), 11 => array('T' => '11:00', 'D' => $DIES), 12 => array('T' => '12:00', 'D' => $DIES), 13 => array('T' => '13:00', 'D' => $DIES), 14 => array('T' => '14:00', 'D' => $DIES), 15 => array('T' => '15:00', 'D' => $DIES), 16 => array('T' => '16:00', 'D' => $DIES), 17 => array('T' => '17:00', 'D' => $DIES), 18 => array('T' => '18:00', 'D' => $DIES), 19 => array('T' => '19:00', 'D' => $DIES), 20 => array('T' => '20:00', 'D' => $DIES), 21 => array('T' => '21:00', 'D' => $DIES), 22 => array('T' => '22:00', 'D' => $DIES), 23 => array('T' => '23:00', 'D' => $DIES), 24 => array('T' => '24:00', 'D' => $DIES)); $COLORS = array(); foreach ($ESPAIS as $idE => $Text) { $COLORS[$idE] = random_color(); } //Mostrem 7 dies... dels quals hi ha activitats per hores echo "<table id='taula_calendari'>"; //Per cada setmana del mes... for ($setmana = 0; $setmana <= ceil($dies_mes / 8); $setmana++) { //Posem els títols dels dies i hores echo "<tr><th>Hores</th>"; for ($i = 1; $i < 8; $i++) { $DM = $setmana * 7 + $i - $Di + 1; if ($DM > $dies_mes) { echo "<th>" . $DIES[$i]['T'] . "<br />()</th>"; } elseif ($DM < 1) { echo "<th>" . $DIES[$i]['T'] . "<br />()</th>"; } else { echo "<th>" . $DIES[$i]['T'] . '<br />(' . $DM . ')</th>'; } } echo "</tr>"; foreach ($TAULA as $K => $D) { echo '<tr>'; $begin = true; echo '<td>' . $D['T'] . '</td>'; $begin = false; //Cada cop que entrem, fem una nova setmana for ($dia = $setmana * 7 + 1; $dia < $setmana * 7 + 8; $dia++) { //Definim el dia del mes $DM = $dia - $Di + 1; $DMT = date('Y-m-d', mktime(0, 0, 0, date('m', $DATA), $DM, date('Y', $DATA))); if ($DM < 1 || $DM > $dies_mes) { echo "<td> </td>"; } else { echo '<td>'; foreach ($RET[$DMT] as $Hi => $D) { foreach ($D as $idE => $D) { if ($K >= $Hi && $K < $D['HF']) { echo '<div style="float:left; background-color: ' . $COLORS[$idE] . '; vertical-align: text-middle; text-align:center; height:20px; width:20px;"><a href="' . url_for('gestio/gActivitats?accio=ACTIVITAT&IDA=' . $D['idA']) . '" class="tt2">' . $idE . '<span class="tt2">' . $D['Espai'] . '<br />' . $D['NomA'] . '</span></a></div>'; } } } echo '</td>'; } } echo '</tr>'; } } echo "</table>"; ?> <div style="clear:both;"></div> </div> <?php }
<?php function random_color() { $rgb = array('a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); $color = '#'; //this is what we'll return! for ($i = 0; $i < 6; $i++) { $x = rand(0, 15); $color = $color . $rgb[$x]; } return $color; } ?> h1 { color: <?php echo "" . random_color(); ?> ; } p { color: <?php echo "" . random_color(); ?> ; }
public function __get_content() { $isRedBall = TRUE; $ballNumber = $this->ballNumber; if ($this->ballNumber > 100) { $isRedBall = FALSE; $ballNumber = $this->ballNumber - 100; } $ball_name = $isRedBall ? "红球" . $ballNumber : "蓝球" . $ballNumber; $data = array('ball_name' => $ball_name); //月份 $counterArray = array(); for ($month = 1; $month <= 12; $month++) { $counterArray[$month] = 0; } foreach ($this->drawResults as $drawResult) { if ($isRedBall) { if ($drawResult->redBall1 == $ballNumber || $drawResult->redBall2 == $ballNumber || $drawResult->redBall3 == $ballNumber || $drawResult->redBall4 == $ballNumber || $drawResult->redBall5 == $ballNumber || $drawResult->redBall6 == $ballNumber) { $counterArray[$drawResult->month]++; } } else { if ($drawResult->blueBall) { $counterArray[$drawResult->month]++; } } } $counters = ''; $colors = ''; for ($month = 1; $month <= 12; $month++) { if ($month != 1) { $counters .= ','; $colors .= ','; } $counters .= $counterArray[$month]; $colors .= "'" . random_color(0, 128, 0, 128, 0, 128) . "'"; } $dataChart1 = array('chart_name_1' => '月份分布', 'counters_1' => $counters, 'colors_1' => $colors); $data = array_merge($data, $dataChart1); //日 $days = ''; for ($day = 1; $day <= 31; $day++) { if ($day != 1) { $days .= ','; } $days .= $day; } $counterArray = array(); $dcArray = array(); for ($day = 1; $day <= 31; $day++) { $dcArray[$day] = 0; $counterArray[$day] = 0; } foreach ($this->drawResults as $drawResult) { $dcArray[$drawResult->dayOfMonth]++; if ($isRedBall) { if ($drawResult->redBall1 == $ballNumber || $drawResult->redBall2 == $ballNumber || $drawResult->redBall3 == $ballNumber || $drawResult->redBall4 == $ballNumber || $drawResult->redBall5 == $ballNumber || $drawResult->redBall6 == $ballNumber) { $counterArray[$drawResult->dayOfMonth]++; } } else { if ($drawResult->blueBall == $ballNumber) { $counterArray[$drawResult->dayOfMonth]++; } } } $counters = ''; $proportions = ''; for ($d = 1; $d <= 31; $d++) { if ($d != 1) { $counters .= ','; $proportions .= ','; } $counters .= $counterArray[$d]; $proportions .= 100.0 * $counterArray[$d] / $dcArray[$d]; } $dataChart2 = array('chart_name_2' => '日期分布', 'days' => $days, 'counters_2' => $counters, 'proportion_2' => $proportions); $data = array_merge($data, $dataChart2); //解析模板 return $this->parser->parse('balldetail_content', $data, TRUE); }