/** * @param int $color1 * @param int $color2 * @param float $factor * @return int */ function interpolate($color1, $color2, $factor) { $r = (red($color2) - red($color1)) * $factor + red($color1); $g = (green($color2) - green($color1)) * $factor + green($color1); $b = (blue($color2) - blue($color1)) * $factor + blue($color1); return color($r, $g, $b); }
function mandel($params) { $image_x = 4 * $params['w']; $image_y = 4 * $params['h']; $image = imagecreatetruecolor($image_x, $image_y); imagefilledrectangle($image, 0, 0, $image_x, $image_y, 0xffffff); $f = imagecolorallocate($image, $params['r'], $params['g'], $params['b']); $color = color($params, $image); for ($x = 0; $x < $image_x; $x++) { for ($y = 0; $y < $image_y; $y++) { $c_r = $x / $params['w'] + -2; $c_i = $y / $params['h'] + -2; $z_r = 0; $z_i = 0; $i = 0; while ($z_r * $z_r + $z_i * $z_i < 4 and $i < $params['n']) { $mod = sqrt($z_r * $z_r + $z_i * $z_i); $arg = atan2($z_i, $z_r); $z_r = pow($mod, $params['k']) * cos($params['k'] * $arg) + $c_r; $z_i = pow($mod, $params['k']) * sin($params['k'] * $arg) + $c_i; $i++; } if ($i == $params['n']) { imagesetpixel($image, $x, $y, $f); } else { imagesetpixel($image, $x, $y, $color[$i]); } } } return send_image($image); }
require_once dirname(__DIR__) . '/vendor/autoload.php'; class Kolor extends Colors\Color { function __invoke($string = null) { $obj = new Colors\Color($string); return $obj; } } $c = new Kolor(); $c = new Colors\Color(); function color($string) { return new Colors\Color($string); } echo color('Hello World!')->red()->white() . color("some other text 1 ")->green() . color("some other text 2 ")->blue() . color("some other text 3 ")->yellow() . color("some other text 4 ")->white() . PHP_EOL; exit; print "we r here \n"; print $c->red("this is red") . "\n"; print $c->bold($c->red("this is red and bold")) . "\n"; print $c("also this is red and bold")->red->bold . "\n"; $c("this is some text"); var_dump($c); print "===============================================================\n"; $c("this is some text")->red(); var_dump($c); print "===============================================================\n"; $c("different text"); var_dump($c); print "===============================================================\n"; $c("different text")->blue();
function getColor($current, $max) { $color = color($current, $max); return $color; }
/** * Makes an active TD segment with an onclick/onmouseover */ function makeTD($name, $description, $color, $imgname = null) { $result = "<TD><A onmouseout=\"window.status=''\""; $result .= " onmouseover=\"window.status='{$description}'\""; $result .= " onclick=\"alert('{$name}: {$description}')\">"; if (isset($imgname)) { $result .= makeIMG($imgname, "{$name}: {$description}"); } else { $result .= color($name, $color); } $result .= "</A></TD>\n"; return $result; }
/** * @param $message */ function important($message) { echo color($message, 'green') . "\n"; }
use yii\helpers\Url; ?> <?php foreach ($menuSub as $sub) { ?> <tr id="menu-<?php echo $sub->id; ?> "> <td> <?php echo icon($sub->father_id2, $sub->father_id3); ?> <span class="<?php echo color($sub->father_id2, $sub->father_id3); ?> "><?php echo name($sub->father_id2, $sub->father_id3); ?> </span> </td> <td> <span class="label label-default"><?php echo $sub->name; ?> </span> </td> <td><i class="<?php echo $sub->icon; ?>
$spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['bonus_healing'] . ' ' . $character->stats['spell_bonus_healing'] . '</span>') . '\')">' . $_LANGUAGE->text['bonus_healing'] . ':</span></td><td class="stats_right">' . $character->stats['spell_bonus_healing'] . '</td></tr>'; $spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['hit_rating'] . ' ' . $character->stats['spell_hit_rating'] . '</span>') . '\')">' . $_LANGUAGE->text['hit_rating'] . ':</span></td><td class="stats_right">' . $character->stats['spell_hit_rating'] . '</td></tr>'; $tmp = array('arcane', 'fire', 'frost', 'nature', 'shadow'); $tip = '<span class="description">'; foreach ($tmp as $tt) { $tip .= '<img alt="" width="15" height="15" src="' . $_DOMAIN . 'images/res-' . $tt . '.gif"> ' . $_LANGUAGE->text[$tt] . ' ' . $character->stats['spell_crit_' . $tt] . '%<br>'; } $tip .= '</span>'; $spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['crit_rating'] . ' ' . $character->stats['spell_crit_rating'] . '</span><br>' . $tip) . '\')">' . $_LANGUAGE->text['crit_chance'] . ':</span></td><td class="stats_right">' . $character->stats['spell_crit'] . '%</td></tr>'; $spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['mana_regen'] . ' ' . $character->stats['mana_regen'] . '</span><br><span class="description">' . $character->stats['mana_regen'] . ' ' . $_LANGUAGE->text['mana_regen_p_5_s_w_n_t'] . '</span>') . '\')">' . $_LANGUAGE->text['mana_regen'] . ':</span></td><td class="stats_right">' . $character->stats['mana_regen'] . '</td></tr>'; // Defense $defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['armor'] . ' ' . $character->stats['armor_base'] . ' + ' . color($character->stats['armor_bonus'], 0) . '</span><br><span class="description">' . $_LANGUAGE->text['reduces'] . ' ' . $_LANGUAGE->text['ps_damage_taken'] . ' ' . $_LANGUAGE->text['by'] . ' ' . $character->stats['armor_mod'] . '%</span>') . '\')"> ' . $_LANGUAGE->text['armor'] . ':</span></td><td class="stats_right">' . color($character->stats['armor_bonus'], $character->stats['armor_base']) . '</td></tr>'; $defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['dodge'] . ' ' . $character->stats['dodge'] . '%</span>') . '\')">' . $_LANGUAGE->text['dodge'] . ':</span></td><td class="stats_right">' . $character->stats['dodge'] . '%</td></tr>'; $defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['parry'] . ' ' . $character->stats['parry'] . '%</span>') . '\')">' . $_LANGUAGE->text['parry'] . ':</span></td><td class="stats_right">' . $character->stats['parry'] . '%</td></tr>'; $defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();" onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['block'] . ' ' . $character->stats['block'] . '%</span>') . '\')">' . $_LANGUAGE->text['block'] . ':</span></td><td class="stats_right">' . $character->stats['block'] . '%</td></tr>'; $tp->assign('base_stats', $base_stats); $tp->assign('melee', $melee); $tp->assign('ranged', $ranged); $tp->assign('spell', $spell); $tp->assign('defense', $defense); $_LANGUAGE->translate($tp); $tp->display();
public function testAppliesStyleDirectlyToText() { $actual = color()->apply('blue', 'foo'); $expected = (string) color('foo')->blue; $this->assertSame($expected, $actual); $actual = color()->white('some white text'); $expected = (string) color('some white text')->white(); $this->assertSame($expected, $actual); }
<ul class="stat-boxes"> <?php $i = 0; foreach ($summary_data as $name => $value) { ?> <li style="color: <?php echo color($i); ?> !important;" class="popover-visits"> <div class="left peity_bar_good"><h4><?php echo lang('reports_' . $name); ?> </h4></div> <div class="right"> <strong style="color: <?php echo color($i); ?> !important;"><?php echo str_replace(' ', ' ', to_currency($value)); ?> </strong> </div> </li> <?php $i++; } ?> </ul> </div>
function letters_list($data = '') { $output = ' <table bgcolor="' . COLOR_TABLE_GENERAL . '"> '; $output .= ' <tr>'; // letters // total 32-95 $offset = 32; $col = -1; $color = 0; $dishes_letters = letters_list_creator(); for ($i = 17; $i <= 92 - $offset; $i++) { $letter = chr($i + $offset); if ($letter == "'") { $letter = "\\'"; } if ($letter == '%') { continue; } $bgcolor = COLOR_TABLE_GENERAL; //RTG: if there is some dishes begginnig with this letter if (in_array($letter, $dishes_letters, false)) { $letter = htmlentities($letter); $link = 'orders.php?command=dish_list&data[letter]=' . $letter; if (isset($data['quantity']) && $data['quantity']) { $link .= '&data[quantity]=' . $data['quantity']; } if (isset($data['priority']) && $data['priority']) { $link .= '&data[priority]=' . $data['priority']; } $bgcolor = color($color++); $output .= ' <td bgcolor="' . $bgcolor . '" onclick="redir(\'' . $link . '\');return(false);"> <a href="' . $link . '"> <strong>' . $letter . '</strong> </a> </td>'; $col++; } else { continue; $output .= ' <td bgcolor="' . $bgcolor . '"> </td>'; } if (($col + 1) % 6 == 0) { $color++; $output .= ' </tr> <tr>'; } } $output .= ' </tr>'; $output .= ' </tbody> </table>'; return $output; }
<?php while (comments()) { ?> <?php // Insert default the name if not specified $name = comment_name(); if (empty($name)) { $name = 'Anonymous'; } ?> <article id="comment<?php echo comment_id(); ?> " class="anchor-comment"> <div class="anchor-comment__avatar mdl-color--<?php echo color($name); ?> "> <?php echo strtoupper(substr($name, 0, 1)); ?> </div> <header class="anchor-comment__author"> <h5 class="anchor-comment__author-name"><?php echo $name; ?> </h5> <h6 class="anchor-comment__author-time"> <time><?php echo relative_time(comment_time()); ?>
/** * 处理提交的数据 */ private function filter_data() { $name = isset($this->input['name']) ? trim(urldecode($this->input['name'])) : ''; $description = isset($this->input['description']) ? trim(urldecode($this->input['description'])) : ''; $isupdate = isset($this->input['isupdate']) ? intval($this->input['isupdate']) : 1; $creditshigher = isset($this->input['creditshigher']) ? intval($this->input['creditshigher']) : '0'; $starnum = isset($this->input['starnum']) ? intval($this->input['starnum']) : 0; $usernamecolor = isset($this->input['usernamecolor']) ? trim(urldecode($this->input['usernamecolor'])) : '#000000'; $enable = isset($this->input['enable']) ? intval($this->input['enable']) : '1'; //前台是否启用 if (empty($name)) { $this->errorOutput('用户组名称不能为空'); } if ($this->input['showcredit']) { if (empty($this->input['credits_rules_diy'])) { $this->errorOutput('如无需自定义规则,请<积分规则>选择否!'); } } if (!empty($usernamecolor)) { $_march = '/[^a-zA-Z]/is'; if (!preg_match($_march, $usernamecolor)) { $usernamecolor = color($usernamecolor); } $colorarr = str_split($usernamecolor); if (count($colorarr) > 7) { $this->errorOutput('十六进制色值不合法,大于7位'); } if ($colorarr[0] != '#') { $this->errorOutput('十六进制色值不合法,开头应该是以#'); } unset($colorarr[0]); foreach ($colorarr as $val) { if ($val >= 'A' && $val <= 'F' || $val >= '0' && $val <= '9' || $val >= 'a' && $val <= 'f') { continue; } else { $this->errorOutput('十六进制色值不合法,参考:#FF0000'); } } } $data = array('name' => $name, 'description' => $description, 'isupdate' => $isupdate, 'starnum' => $starnum, 'usernamecolor' => $usernamecolor, 'enable' => $enable); if (empty($isupdate)) { $data['creditshigher'] = $creditshigher; } if ($_FILES['icon']) { $img['Filedata'] = $_FILES['icon']; if (!$this->settings['App_material']) { $this->errorOutput('图片服务器未安装!'); } $material_pic = new material(); $img_info = $material_pic->addMaterial($img); $img_data = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']); $data['icon'] = maybe_serialize($img_data); } elseif ($this->input['icondel']) { $data['icon'] = ''; } return $data; }
$actions = ['rock', 'paper', 'scissors']; $results = ['rock' => ['rock' => 0, 'paper' => -1, 'scissors' => 1], 'paper' => ['rock' => 1, 'paper' => 0, 'scissors' => -1], 'scissors' => ['rock' => -1, 'paper' => 1, 'scissors' => 0]]; $resultText = [-1 => color('red') . 'You lose!', 0 => color('purple') . "It's a tie!", 1 => color('green') . 'You win!']; while ($c = fread(STDIN, 10)) { $c = strtolower(trim($c)); if (in_array($c, $actions)) { $cpu = $actions[mt_rand(0, 2)]; echo "The CPU chose {$cpu}\n"; $result = $results[$c][$cpu]; if ($result === 1) { $wins++; } else { if ($result === -1) { $losses++; } } echo $resultText[$result] . color() . " ({$wins} - {$losses})\n"; if ($wins > 2 || $losses > 2) { if ($wins > $losses) { echo color('lightgreen') . "You won!!\n" . color(); } else { echo color('lightred') . "You lost...\n" . color(); } break; } else { echo "Choose a new action.\n"; } } else { echo color('red') . "Wrong action!\n" . color(); } }
function color($a = NULL) { return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a); } function formatLabel($value) { return sprintf("%.2f", $value); } $graph = new Graph(150, 100); $graph->setAntiAliasing(TRUE); $group = new PlotGroup(); $group->setXAxisZero(FALSE); $group->setBackgroundColor(new Color(197, 180, 210, 80)); $group->setPadding(25, 10, 10, 20); $group->axis->left->setLabelNumber(2); $group->axis->left->setLabelPrecision(1); // Display two lines for ($n = 0; $n < 2; $n++) { $x = array(); for ($i = 0; $i < 10; $i++) { $x[] = cos($i * M_PI / 5) / ($n + 1); } $plot = new LinePlot($x); $plot->setColor(color(10)); // Random line color $plot->setFillColor(color(90)); // Random background color $group->add($plot); } $graph->add($group); $graph->draw();
</div> <div class="row"> <div id="report_summary" class="repors-summarys"> <ul class="stat-boxes"> <?php $i = 0; foreach ($summary_data as $name => $value) { ?> <li class="popover-visits"> <?php echo "<div class='left peity_bar_good'><h5 style='" . color($i) . " !important;'>" . lang('reports_' . $name) . '</h5></div>'; ?> <?php echo "<div class='right'><strong style='" . color($i) . " !important;'>" . to_currency($value) . '</strong></div>'; ?> </li> <?php $i++; } ?> </ul> </div> </div> <div id="chart_wrapper"> <div id="chart"></div>
function console_log() { $messages = array_filter(func_get_args()); $db_line = color(str_repeat('=', 80), 'N') . "\n"; $line = color(str_repeat('-', 80), 'w') . "\n"; echo "\n" . $db_line . color(' Success!', 'C') . color(" - ", 'R') . color(array_shift($messages), 'W') . "\n" . $db_line; $messages = implode("", array_map(function ($message) { return color(' ' . $message, 'w') . "\n"; }, $messages)); echo $messages ? $messages . $db_line : ''; echo "\n"; exit; }
} $main_content .= '<br>Essa enquete começou em ' . date("d/m/Y H:i.", $POLL['start']) . '<br>'; $main_content .= 'Essa enquete irá terminar em ' . date("d/m/Y H:i.", $POLL['end']) . '<br>'; $main_content .= '<br>Total de votos: <b>' . $POLL['votes_all'] . '</b><br><br>'; } else { $main_content .= '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=4 WIDTH=100%><TR BGCOLOR=' . $config['site']['vdarkborder'] . '><TD COLSPAN=3 CLASS=white><B>Resultado</B></TD></TR>'; $main_content .= '<TR BGCOLOR="' . $dark . '"><td COLSPAN=3><b>' . $POLL['question'] . '</b></td></tr>'; $ANSWERS_show = $SQL->query('SELECT * FROM ' . $SQL->tableName('z_polls_answers') . ' where `poll_id` = ' . $_REQUEST['id'] . ' order by `answer_id`'); $i = 1; foreach ($ANSWERS_show as $answer) { if (is_int($i / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } $main_content .= '<TR BGCOLOR="' . $bgcolor . '"><td width=60%>' . $answer['answer'] . '</td><td width=50%>' . $answer['votes'] . '(' . color($percent[$i], $color[0], $color[1], $color[2], $color[3]) . ') <img src="bar.php?long=' . (int) $percent[$i] . '"></td></tr>'; $i++; } $main_content .= '</table><br><br>'; $main_content .= '<br>Essa enquete começou em ' . date("d/m/Y H:i.", $POLL['start']) . '<br>'; $main_content .= 'Essa enquete terminou em ' . date("d/m/Y H:i.", $POLL['end']) . '<br>'; $main_content .= '<br>Total de votos: <b>' . $POLL['votes_all'] . '</b><br><br>'; } $showed = true; $main_content .= '<div class=\'hr1\'></div><a href="index.php?subtopic=' . $link . '"><font size="2"><b><center>Voltar para lista de enquetes</center></b></font></a>'; } } } if ($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] != "true") { $main_content .= '<br><a href="?subtopic=' . $link . '&control=true"><b><center>[Painel de Controle]</center></b></a><br><br>'; }
function show_receipt($id) { if (!$id) { return 1; } $table = 'account_mgmt_main'; $query = "SELECT * FROM {$table} WHERE `id`='{$id}'"; $res = mysql_db_query($_SESSION['common_db'], $query); $row = mysql_fetch_array($res); if ($row['annulled']) { switch ($row['type']) { case 4: echo ucphr('RECEIPT_ANNULLED_OK') . ".<br>\n"; break; case 3: echo ucphr('INVOICE_ANNULLED_OK') . ".<br>\n"; break; case 5: echo ucphr('BILL_ANNULLED_OK') . ".<br>\n"; break; } echo GLOBALMSG_RECORD_DELETE_OK_FROM_LOG_MANY_2 . ".<br><br>"; echo "<form name=\"form1\" action=\"receipt.php\" method=\"post\">\n"; echo "<input type=\"hidden\" name=\"command\" value=\"delete\">\n"; echo "<input type=\"hidden\" name=\"delete[" . $id . "]\" value=\"1\">\n"; echo "<input type=\"submit\" value=\"" . GLOBALMSG_RECORD_DELETE . "\">"; echo "</form>\n"; return 0; } $table = 'account_log'; $query = "SELECT * FROM {$table} WHERE `payment`='{$id}'"; $res = mysql_db_query($_SESSION['common_db'], $query); if (!mysql_num_rows($res)) { return 2; } echo "<table bgcolor=\"" . color(-1) . "\">\n"; echo "<thead ><tr>\n\t<td>" . ucfirst(phr('QUANTITY')) . "</a></td>\n\t<td>" . ucfirst(phr('DESCRIPTION')) . "</td>\n\t<td>" . ucfirst(phr('AMOUNT')) . "</td>\n\t</tr></thead>\n\t<tbody>\n"; $i = 0; while ($row = mysql_fetch_array($res)) { if ($row['operation'] == 1) { $ingred = new ingredient($row['ingredient']); $description = " " . ucphr('PLUS') . " " . $ingred->name($_SESSION['language']); unset($ingred); } elseif ($row['operation'] == -1) { $ingred = new ingredient($row['ingredient']); $description = " " . ucphr('MINUS') . " " . $ingred->name($_SESSION['language']); unset($ingred); } else { $dish = new dish($row['dish']); $description = $dish->name($_SESSION['language']); unset($dish); } $total += $row['price']; $color = color($i); echo '<tr bgcolor="', $color, '"> <td>', $row['quantity'], '</td> <td>', $description, '</td> <td align="right">', $row['price'], '</td> </tr> '; $i++; } echo '<tr bgcolor="', color(-1), '"> <td></td> <td>' . ucfirst(phr('TOTAL')) . '</td> <td align="right">', sprintf("%0.2f", $total), '</td> </tr> '; echo "</tbody></table>"; echo "<form name=\"form1\" action=\"receipt.php\" method=\"post\">\n"; echo "<input type=\"hidden\" name=\"command\" value=\"delete\">\n"; echo "<input type=\"hidden\" name=\"delete[" . $id . "]\" value=\"1\">\n"; echo "<input type=\"submit\" value=\"" . GLOBALMSG_RECORD_DELETE . "\">"; echo "</form>\n"; echo "<form name=\"form1\" action=\"receipt.php\" method=\"post\">\n"; echo "<input type=\"hidden\" name=\"command\" value=\"annul\">\n"; echo "<input type=\"hidden\" name=\"annul[" . $id . "]\" value=\"1\">\n"; echo "<input type=\"submit\" value=\"" . ucphr('ANNULL') . "\">"; echo "</form>\n"; }
$group->axis->bottom->title->setPadding(1, 0, 0, 0); $group->axis->top->title->set("Axis des X : Treize plus douze"); $group->axis->top->title->setBackgroundColor(new Color(240, 200, 197, 25)); $group->axis->top->title->setPadding(1, 0, 0, 0); $count = mt_rand(2, 4); for ($n = 0; $n < $count; $n++) { $x = array(); for ($i = 0; $i < 10; $i++) { $x[] = round(cos($i * M_PI / 10) * mt_rand(-20, 100)); } $plot = new LinePlot($x); $plot->setColor(color()); $plot->setFillColor(color(90)); $plot->setXAxis(mt_rand(0, 1) ? PLOT_BOTTOM : PLOT_TOP); $plot->setYAxis(mt_rand(0, 1) ? PLOT_LEFT : PLOT_RIGHT); $plot->label->set($x); $plot->label->setColor(color(0)); if ($n % 2 === 0) { $plot->label->setBackgroundColor(new Color(mt_rand(220, 240), mt_rand(220, 240), mt_rand(220, 240), mt_rand(15, 35))); } $plot->label->setPadding(1, 0, 0, 0); $group->add($plot); $group->legend->add($plot, str_repeat("#" . ($n + 1), mt_rand(1, 2)), $n % 2 ? LEGEND_LINE : LEGEND_BACKGROUND); } $group->legend->setColumns(2); $group->legend->border->hide(); $group->legend->setSpace(20); $group->legend->setBackgroundColor(new Color(245, 255, 255)); $group->setPadding(NULL, 130, NULL, NULL); $graph->add($group); $graph->draw();
} if (year($ano) == 1) { $band = 1; echo "<script>alert('Año no valido: {$ano}')</script>"; } if (tipoV($tipo_v) == 1) { $band = 1; $tipo_v = utf8_encode($tipo_v); echo "<script>alert('Tipo de vehículo no valido: {$tipo_v}')</script>"; } } else { $band = 1; echo "<script>alert(' Llenar toda la información antes de continuar')</script>"; } if ($color != "") { if (color($color) == 1) { $color = utf8_encode($color); $band = 1; echo "<script>alert('Color no valido: {$color}')</script>"; } } if ($codigoAnterior != "") { if ($band == 0) { $consulta = " \tSELECT * \n\t\t\t\t\t\t\t\tFROM planta_vehicular\n\t\t\t\t\t\t\t\tWHERE codigoAnterior = '{$codigoAnterior}' \n\t\t\t\t\t\t\t\t\tAND codigoNuevoV != '{$codigoNuevo}' "; $ejecutar = mysql_query($consulta) or die(mysql_error()); $filas = mysql_num_rows($ejecutar); if (codigoAnterior($codigoAnterior) == 1) { $band = 1; echo "<script>alert('Código Anterior no valido: {$codigoAnterior}')</script>"; } if ($filas != 0) {
include_once(CACTI_BASE_PATH . "/include/top_header.php"); color_edit(); include_once(CACTI_BASE_PATH . "/include/bottom_footer.php"); break; default: if (isset($_REQUEST["export_x"])) { export_colors(); }elseif (isset($_REQUEST["import_x"])) { include_once(CACTI_BASE_PATH . "/include/top_header.php"); import_colors(); include_once(CACTI_BASE_PATH . "/include/bottom_footer.php"); }else{ include_once(CACTI_BASE_PATH . "/include/top_header.php"); color(); include_once(CACTI_BASE_PATH . "/include/bottom_footer.php"); } break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { if (isset($_POST["save_component_color"])) { $save["id"] = $_POST["id"]; $save["hex"] = form_input_validate($_POST["hex"], "hex", "^[a-fA-F0-9]+$", false, 3); if (!is_error_message()) {
function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '') { /** * Function to create a random color * Note: We aren't using this outside this function so we will sit it inside * @auteur mastercode.nl * @param $type string Mode for the color * @return int **/ function color($type) { switch ($type) { case "bg": $color = rand(224, 255); break; case "text": $color = rand(0, 127); break; case "grid": $color = rand(200, 224); break; default: $color = rand(0, 255); break; } return $color; } $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_size' => '', 'font_path' => '', 'show_grid' => true, 'skew' => true, 'expiration' => 7200); foreach ($defaults as $key => $val) { if (!is_array($data)) { if (!isset(${$key}) or ${$key} == '') { ${$key} = $val; } } else { ${$key} = !isset($data[$key]) ? $val : $data[$key]; } } if ($img_path == '' or $img_url == '') { return FALSE; } if (!@is_dir($img_path)) { return FALSE; } if (!is_really_writable($img_path)) { return FALSE; } if (!extension_loaded('gd')) { return FALSE; } // ----------------------------------- // Select random Font from folder // ----------------------------------- if (is_dir($font_path)) { $handle = opendir($font_path); while (($file = @readdir($handle)) !== false) { if (!in_array($file, array('.', '..')) && substr($file, strlen($file) - 4, 4) == '.ttf') { $fonts[] = $file; } } $font_file = $font_path . DIRECTORY_SEPARATOR . $fonts[array_rand($fonts)]; } else { $font_file = $font_path; } // ----------------------------------- // Remove old images // ----------------------------------- list($usec, $sec) = explode(" ", microtime()); $now = (double) $usec + (double) $sec; $current_dir = @opendir($img_path); while ($filename = @readdir($current_dir)) { if ($filename != "." and $filename != ".." and $filename != "index.html") { $name = str_replace(".png", "", $filename); if ($name + $expiration < $now) { @unlink($img_path . $filename); } } } @closedir($current_dir); // ----------------------------------- // Do we have a "word" yet? // ----------------------------------- if ($word == '') { // No Zero (for user clarity); $pool = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $str = ''; for ($i = 0; $i < 6; $i++) { $str .= substr($pool, mt_rand(0, strlen($pool) - 1), 1); } $word = strtoupper($str); } // ----------------------------------- // Length of Word // ----------------------------------- $length = strlen($word); // ----------------------------------- // Create image // ----------------------------------- $im = ImageCreateTruecolor($img_width, $img_height); // ----------------------------------- // Assign colors // ----------------------------------- $bg_color = imagecolorallocate($im, color('bg'), color('bg'), color('bg')); $border_color = imagecolorallocate($im, 153, 102, 102); $text_color = imagecolorallocate($im, color('text'), color('text'), color('text')); $grid_color[] = imagecolorallocate($im, color('grid'), color('grid'), color('grid')); $grid_color[] = $grid_color[0] + 150; $grid_color[] = $grid_color[0] + 180; $grid_color[] = $grid_color[0] + 210; $shadow_color = imagecolorallocate($im, 255, 240, 240); // ----------------------------------- // Create the rectangle // ----------------------------------- ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color); if ($show_grid == TRUE) { // X grid $grid = rand(20, 25); for ($x = 0; $x < $img_width; $x += mt_rand($grid - 2, $grid + 2)) { $current_colour = $grid_color[array_rand($grid_color)]; imagedashedline($im, mt_rand($x - 3, $x + 3), mt_rand(0, 4), mt_rand($x - 3, $x + 3), mt_rand($img_height - 5, $img_height), $current_colour); } // Y grid for ($y = 0; $y < $img_height; $y += mt_rand($grid - 2, $grid + 2)) { $current_colour = $grid_color[array_rand($grid_color)]; imageline($im, mt_rand(0, 4), mt_rand($y - 3, $y), mt_rand($img_width - 5, $img_width), mt_rand($y - 3, $y), $current_colour); } } // ----------------------------------- // Write the text // ----------------------------------- $use_font = ($font_file != '' and file_exists($font_file) and function_exists('imagettftext')) ? TRUE : FALSE; if ($use_font == FALSE) { $font_size = 5; $x = rand(2, $img_width / ($length / 3)); // y isnt used here } else { // Make font proportional to the image size $font_size = !empty($font_size) ? $font_size : mt_rand(18, 25); $x = rand(4, $img_width - ($font_size + ($font_size >> 1)) * $length); // y isnt used here } for ($i = 0; $i < strlen($word); $i++) { if ($use_font == FALSE) { $y = rand(0, $img_height / 2); imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color); $x += $font_size * 2; } else { $letter = substr($word, $i, 1); $less_rotate = array('c', 'N', 'U', 'Z', '7', '6', '9'); //letters that we don't want rotated too much... $angle = $skew == TRUE ? in_array($letter, $less_rotate) ? rand(-5, 5) : rand(-15, 15) : 0; $y = $img_height / 2 + ($font_size >> 1) + ($skew == TRUE ? rand(-9, 9) : 0); $x += $font_size >> 2; imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_file, $letter); $x += $font_size + ($font_size >> 2); } } // ----------------------------------- // Create the border // ----------------------------------- imagerectangle($im, 0, 0, $img_width - 1, $img_height - 1, $border_color); // ----------------------------------- // Generate the image // ----------------------------------- $img_name = $now . '.png'; ImagePNG($im, $img_path . $img_name); $img = "<img src=\"{$img_url}{$img_name}\" width=\"{$img_width}\" height=\"{$img_height}\" style=\"border:0;\" alt=\" \" />"; ImageDestroy($im); return array('word' => $word, 'time' => $now, 'image' => $img); }
} echo sprintf("\r" . ' ➜ ' . color('過濾需要刪除檔案', 'g') . color('(' . ($i + 1) . ')', 'g') . " - % 3d%% ", ceil(++$i * 100 / $c)); return true; }); echo sprintf("\r" . ' ➜ ' . color('過濾需要刪除檔案', 'g') . color('(' . count($delete_files) . ')', 'g') . " - % 3d%% ", 100); echo '- ' . color('過濾需要刪除檔案成功!', 'C') . "\n"; echo str_repeat('-', 80) . "\n"; // // ======================================================================== // // ======================================================================== // // ======================================================================== echo sprintf("\r" . ' ➜ ' . color('刪除 S3 上需要刪除的檔案(' . ($c = count($delete_files)) . ')', 'g')); $i = 0; echo '- ' . (array_filter(array_map(function ($file) use($bucket, &$i, $c) { echo sprintf("\r" . ' ➜ ' . color('刪除 S3 上需要刪除的檔案(' . $c . ')', 'g') . " - % 3d%% ", ceil(++$i * 100 / $c)); return !S3::deleteObject($bucket, $file['name']); try { return !S3::deleteObject($bucket, $file['name']); } catch (Exception $e) { return true; } }, $delete_files)) ? color('刪除 S3 上需要刪除的檔案失敗!', 'r') : color('刪除 S3 上需要刪除的檔案成功!', 'C')) . "\n"; echo str_repeat('-', 80) . "\n"; // // ======================================================================== // // ======================================================================== // // ======================================================================== echo ' ' . color('◎ 執行結束 ◎', 'P') . "\n"; echo str_repeat('=', 80) . "\n"; echo "\n"; echo " " . color('➜', 'R') . " " . color('您的網址是', 'G') . ":" . color(PROTOCOL . $bucket . '/' . NAME . '/', 'W') . "\n\n"; echo str_repeat('=', 80) . "\n"; echo "\n";
case 'controller': $results = create_controller($temp_path, $name, $action); break; case 'model': $params = params($action, array('-p', '-f', '-pic', '-file')); $images = array_merge($images = isset($params['-p']) ? $params['-p'] : array(), isset($params['-pic']) ? $params['-pic'] : array()); $files = array_merge($files = isset($params['-f']) ? $params['-f'] : array(), isset($params['-file']) ? $params['-file'] : array()); $results = create_model($temp_path, $name, $images, $files); break; case 'migration': $results = create_migration($temp_path, $name, $action); break; case 'cell': $results = create_cell($temp_path, $name, array_merge(array($action), $argv)); break; case 'demo': include 'functions/demo.php'; $results = create_demo(); break; case 'search': $results = create_search($temp_path, $name); break; default: return console_error('指令錯誤!', '只接受 controller、model、migration、cell、demo、search 指令。'); } $results = array_map(function ($result) { $count = 1; return color('Create: ', 'g') . str_replace(FCPATH, '', $result, $count); }, $results); array_unshift($results, '新增成功!'); call_user_func_array('console_log', $results);
function debug($input, $title = null) { $backtrace = debug_backtrace(); $result = "<div style=\"font-family:'dejavu sans mono','consolas','monospaced','monospace';font-size:10pt;width:600px;margin-bottom:20px;margin-left:20px;\"><div style='background:#f0f0f0'>"; foreach ($backtrace as $key => $value) { $result .= "<a href='subl://" . str_replace('\\', '/', $value['file']) . ":" . $value['line'] . "' style='color:black;text-decoration:none;'>" . $value['file'] . "</a> [" . $value['line'] . "] <font color=red>" . $value['function'] . "</font><br>"; } $result .= '</div>'; if ($title !== null) { if (is_object($title)) { $result .= "<div style='background:#669999;color:white;'>QUERY " . $title->count . "</div>"; } else { $result .= "<div style='background:black;color:white'>" . $title . "</div>"; } } if (is_string($input)) { $result .= color($input); } else { $result .= str_replace(array("\\'", "\n", " ", "var", "array", "class", "=>", " '", "' <b><font color=green>="), array("'", "<br>\n", ' ', "<b><font color=blue>var</font></b>", "<b><font color=red>array</font></b>", "<b><font color=green>class</font></b>", "<b><font color=green>=</font></b>", " <font color=green>'", "'</font> <b><font color=green>="), htmlspecialchars(@var_export($input, true), ENT_NOQUOTES, 'UTF-8')); } $result .= "</div>"; echo $result; }
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../../LinePlot.class.php"; function color($a = NULL) { if ($a === NULL) { $a = mt_rand(20, 80); } return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a); } $graph = new Graph(400, 400, "Abel", time() + 5); $graph->setTiming(TRUE); $graph->setAntiAliasing(TRUE); $x = array(); for ($i = 0; $i < 10; $i++) { $x[] = mt_rand(0, 100); } $plot = new LinePlot($x); $plot->setThickness(1); $plot->setColor(color()); $plot->setFillGradient(new LinearGradient(color(), color(), 0)); $plot->grid->setType(LINE_DASHED); $plot->setYMin(mt_rand(-20, 0)); $plot->yAxis->setLabelNumber(mt_rand(0, 10)); $plot->yAxis->setLabelPrecision(1); $plot->xAxis->label->hideFirst(TRUE); $plot->xAxis->setNumberByTick('minor', 'major', 2); $plot->setXAxisZero((bool) mt_rand(0, 1)); $graph->add($plot); $graph->draw();
function show_config($server, $dedi_cfg, $config) { if (empty($dedi_cfg)) { $errstr = utf8_encode(html_entity_decode(htmlentities($errstr, ENT_QUOTES), ENT_QUOTES)); throw new Exception("\n ({$errno}) {$errstr}\n"); } echo "\n Affichage de la configuration de " . $dedi_cfg->masterserver_account->login . ", sur le port " . $dedi_cfg->system_config->xmlrpc_port . "\n"; echo "\n"; $affiche = array("TMS version :" => $config->version, "Serveur IP :" => $config->server->ip, "Path (executable) :" => $config->dedicated->exec, "Path (dedicated) :" => $config->dedicated->path, "" => "", "Login :"******"Master_pass :"******"Master_key :" => $dedi_cfg->masterserver_account->validation_key, "Port :" => $dedi_cfg->system_config->xmlrpc_port, " " => "", "SuperAdmin :" => $dedi_cfg->authorization_levels->level[0]->password, "Admin :" => $dedi_cfg->authorization_levels->level[1]->password, "User :"******" " => "", "Visibilite :" => tms_convert($dedi_cfg->server_options->hide_server, "visibilite"), "Servername :" => $dedi_cfg->server_options->name, "Packmask :" => !empty($xml->system_config->packmask) ? $xml->system_config->packmask : 'stadium', " " => "", "Max Players :" => $dedi_cfg->server_options->max_players, "Max spectators :" => $dedi_cfg->server_options->max_spectators, "Serveur password :"******"Spectator password :"******"Ladder :" => $dedi_cfg->server_options->ladder_mode, "Ladder-min :" => $dedi_cfg->server_options->ladder_serverlimit_min, "Ladder-max :" => $dedi_cfg->server_options->ladder_serverlimit_max, "P2P upload :" => $dedi_cfg->server_options->enable_p2p_upload, "P2P download :" => $dedi_cfg->server_options->enable_p2p_download, "p2p_cache_size :" => $dedi_cfg->system_config->p2p_cache_size, " " => "", "Challenge download :" => $dedi_cfg->server_options->allow_challenge_download, "Save replay :" => $dedi_cfg->server_options->autosave_replays, "Save validation replay :" => $dedi_cfg->server_options->autosave_validation_replays, " " => "", "Uploadrate :" => !empty($xml->system_config->connection_uploadrate) ? $xml->system_config->connection_uploadrate : 'Auto', "Downloadrate :" => !empty($xml->system_config->connection_downloadrate) ? $xml->system_config->connection_downloadrate : 'Auto', " " => "", "Allow remote XML :" => $dedi_cfg->system_config->xmlrpc_allowremote, "Allow TV :" => $dedi_cfg->system_config->allow_spectator_relays); foreach ($affiche as $key => $value) { echo " " . color($key, "cyan") . " " . $value . "\n"; } echo "\n"; }
$graph->setAntiAliasing(TRUE); $x = array(); $k = array(); for ($i = 0; $i < 100; $i++) { $x[] = cos($i / 10); $k[] = sprintf("%.1f", $i / 10); } $plot = new LinePlot($x, $k); $plot->setBackgroundColor(color(80)); $plot->setYAxis(PLOT_BOTH); $plot->setColor(color()); $plot->grid->setInterval(mt_rand(1, 4), mt_rand(1, 4)); $plot->yAxis->setLabelNumber(20); $plot->yAxis->setLabelPrecision(1); $plot->xAxis->setTickInterval(5); $plot->xAxis->setLabelInterval(2); $plot->xAxis->label->hideFirst(TRUE); $plot->xAxis->label->hideLast(TRUE); $plot->xAxis->setNumberByTick('minor', 'major', 1); $plot->xAxis->setLabelText($k); foreach ($x as $k => $v) { $x[$k] = sprintf("%.2f", $v); } $plot->label->set($x); $plot->label->setColor(color(0)); $plot->label->setBackgroundColor(new Color(mt_rand(180, 220), mt_rand(180, 220), mt_rand(180, 220), mt_rand(25, 35))); $plot->label->border->setColor(color()); $plot->label->setPadding(1, 0, 0, 0); $plot->label->setAngle(0); $graph->add($plot); $graph->draw();
function accent($title) { $color = color($title); $accents = array('indigo' => 'pink', 'blue' => 'red', 'red' => 'orange', 'pink' => 'blue', 'purple' => 'pink', 'deep-purple' => 'red', 'light-blue' => 'amber', 'cyan' => 'pink', 'teal' => 'green', 'light-green' => 'red', 'green' => 'light-blue', 'lime' => 'purple', 'yellow' => 'blue', 'amber' => 'indigo', 'orange' => 'indigo', 'brown' => 'orange', 'blue-grey' => 'pink', 'grey' => 'orange'); return $accents[$color]; }