Beispiel #1
1
 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
Beispiel #2
1
 /**
  * Get human readable file size, quick and dirty.
  * 
  * @todo Improve i18n support.
  *
  * @param int $bytes
  * @param string $format
  * @param int|null $decimal_places
  * @return string Human readable string with file size.
  */
 public static function humanReadableBytes($bytes, $format = "en", $decimal_places = null)
 {
     switch ($format) {
         case "sv":
             $dec_separator = ",";
             $thousands_separator = " ";
             break;
         default:
         case "en":
             $dec_separator = ".";
             $thousands_separator = ",";
             break;
     }
     $b = (int) $bytes;
     $s = array('B', 'kB', 'MB', 'GB', 'TB');
     if ($b <= 0) {
         return "0 " . $s[0];
     }
     $con = 1024;
     $e = (int) log($b, $con);
     $e = min($e, count($s) - 1);
     $v = $b / pow($con, $e);
     if ($decimal_places === null) {
         $decimal_places = max(0, 2 - (int) log($v, 10));
     }
     return number_format($v, !$e ? 0 : $decimal_places, $dec_separator, $thousands_separator) . ' ' . $s[$e];
 }
 /**
  * {@inheritdoc}
  */
 protected function transfer()
 {
     while (!$this->stopped && !$this->source->isConsumed()) {
         if ($this->source->getContentLength() && $this->source->isSeekable()) {
             // If the stream is seekable and the Content-Length known, then stream from the data source
             $body = new ReadLimitEntityBody($this->source, $this->partSize, $this->source->ftell());
         } else {
             // We need to read the data source into a temporary buffer before streaming
             $body = EntityBody::factory();
             while ($body->getContentLength() < $this->partSize && $body->write($this->source->read(max(1, min(10 * Size::KB, $this->partSize - $body->getContentLength()))))) {
             }
         }
         // @codeCoverageIgnoreStart
         if ($body->getContentLength() == 0) {
             break;
         }
         // @codeCoverageIgnoreEnd
         $params = $this->state->getUploadId()->toParams();
         $command = $this->client->getCommand('UploadPart', array_replace($params, array('PartNumber' => count($this->state) + 1, 'Body' => $body, 'ContentMD5' => (bool) $this->options['part_md5'], Ua::OPTION => Ua::MULTIPART_UPLOAD)));
         // Notify observers that the part is about to be uploaded
         $eventData = $this->getEventData();
         $eventData['command'] = $command;
         $this->dispatch(self::BEFORE_PART_UPLOAD, $eventData);
         // Allow listeners to stop the transfer if needed
         if ($this->stopped) {
             break;
         }
         $response = $command->getResponse();
         $this->state->addPart(UploadPart::fromArray(array('PartNumber' => count($this->state) + 1, 'ETag' => $response->getHeader('ETag', true), 'Size' => $body->getContentLength(), 'LastModified' => gmdate(DateFormat::RFC2822))));
         // Notify observers that the part was uploaded
         $this->dispatch(self::AFTER_PART_UPLOAD, $eventData);
     }
 }
Beispiel #4
1
	public function GenerateLogo()
	{
		$this->NewLogo($this->FileType); // defaults to png. can use jpg or gif as well

		$this->FontPath = dirname(__FILE__) . '/fonts/';
		$this->ImagePath = dirname(__FILE__) . '/';
		$this->SetBackgroundImage('back.png');
		$size = getimagesize(dirname(__FILE__)."/back.png");
		$imageHeight = $size['1'];

		if(strlen($this->Text[0]) > 0) {
			// AddText() - text, font, fontcolor, fontSize (pt), x, y, center on this width
			$text_position = $this->AddText($this->Text[0], 'xt.otf', 'd0a642', 15, 43, 20);
			$top_right = $text_position['top_right_x'];
		}
		else {
			$top_right = 0;
		}

		if(strlen($this->Text[1]) > 0) {
			// put in our second bit of text
			$text_position2 = $this->AddText($this->Text[1], 'xt.otf', 'ffffff', 45, 5, 46);
			$top_right = max($top_right, $text_position2['top_right_x']);
		}

		if(strlen($this->Text[2]) > 0) {
			// put in our third bit of text
			$text_position3 = $this->AddText($this->Text[2], 'xt.otf', 'b49a5d', 20, 75, 100);
			$top_right = max($top_right, $text_position3['top_right_x']);
		}
		$this->SetImageSize($top_right+20, $imageHeight);
		$this->CropImage = true;

		return $this->MakeLogo();
	}
Beispiel #5
1
 protected function outputRoutes(OutputInterface $output, $routes = null)
 {
     if (null === $routes) {
         $routes = $this->getContainer()->get('router')->getRouteCollection()->all();
     }
     $output->writeln($this->getHelper('formatter')->formatSection('router', 'Current routes'));
     $maxName = strlen('name');
     $maxMethod = strlen('method');
     $maxHostname = strlen('hostname');
     foreach ($routes as $name => $route) {
         $requirements = $route->getRequirements();
         $method = isset($requirements['_method']) ? strtoupper(is_array($requirements['_method']) ? implode(', ', $requirements['_method']) : $requirements['_method']) : 'ANY';
         $hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
         $maxName = max($maxName, strlen($name));
         $maxMethod = max($maxMethod, strlen($method));
         $maxHostname = max($maxHostname, strlen($hostname));
     }
     $format = '%-' . $maxName . 's %-' . $maxMethod . 's %-' . $maxHostname . 's %s';
     // displays the generated routes
     $format1 = '%-' . ($maxName + 19) . 's %-' . ($maxMethod + 19) . 's %-' . ($maxHostname + 19) . 's %s';
     $output->writeln(sprintf($format1, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Hostname</comment>', '<comment>Pattern</comment>'));
     foreach ($routes as $name => $route) {
         $requirements = $route->getRequirements();
         $method = isset($requirements['_method']) ? strtoupper(is_array($requirements['_method']) ? implode(', ', $requirements['_method']) : $requirements['_method']) : 'ANY';
         $hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
         $output->writeln(sprintf($format, $name, $method, $hostname, $route->getPattern()));
     }
 }
 function getSize($TextString, $Format = "")
 {
     $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
     $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
     $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
     $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
     $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12;
     $Height = isset($Format["Height"]) ? $Format["Height"] : 30;
     $TextString = $this->encode39($TextString);
     $BarcodeLength = strlen($this->Result);
     if ($DrawArea) {
         $WOffset = 20;
     } else {
         $WOffset = 0;
     }
     if ($ShowLegend) {
         $HOffset = $FontSize + $LegendOffset + $WOffset;
     } else {
         $HOffset = 0;
     }
     $X1 = cos($Angle * PI / 180) * ($WOffset + $BarcodeLength);
     $Y1 = sin($Angle * PI / 180) * ($WOffset + $BarcodeLength);
     $X2 = $X1 + cos(($Angle + 90) * PI / 180) * ($HOffset + $Height);
     $Y2 = $Y1 + sin(($Angle + 90) * PI / 180) * ($HOffset + $Height);
     $AreaWidth = max(abs($X1), abs($X2));
     $AreaHeight = max(abs($Y1), abs($Y2));
     return array("Width" => $AreaWidth, "Height" => $AreaHeight);
 }
 function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows)
 {
     if (empty($current_page_number)) {
         $current_page_number = 1;
     }
     $pos_to = strlen($sql_query);
     $pos_from = strpos($sql_query, ' from', 0);
     $pos_group_by = strpos($sql_query, ' group by', $pos_from);
     if ($pos_group_by < $pos_to && $pos_group_by != false) {
         $pos_to = $pos_group_by;
     }
     $pos_having = strpos($sql_query, ' having', $pos_from);
     if ($pos_having < $pos_to && $pos_having != false) {
         $pos_to = $pos_having;
     }
     $pos_order_by = strpos($sql_query, ' order by', $pos_from);
     if ($pos_order_by < $pos_to && $pos_order_by != false) {
         $pos_to = $pos_order_by;
     }
     $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, $pos_to - $pos_from));
     $reviews_count = tep_db_fetch_array($reviews_count_query);
     $query_num_rows = $reviews_count['total'];
     $num_pages = ceil($query_num_rows / $max_rows_per_page);
     if ($current_page_number > $num_pages) {
         $current_page_number = $num_pages;
     }
     $offset = $max_rows_per_page * ($current_page_number - 1);
     $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
 }
/**
 * Format a relative time (duration) into weeks, days, hours, minutes,
 * seconds, but unlike phabricator_format_relative_time, does so for more than
 * just the largest unit.
 *
 * @param int Duration in seconds.
 * @param int Levels to render - will render the three highest levels, ie:
 *            5 h, 37 m, 1 s
 * @return string Human-readable description.
 */
function phutil_format_relative_time_detailed($duration, $levels = 2)
{
    if ($duration == 0) {
        return 'now';
    }
    $levels = max(1, min($levels, 5));
    $remainder = 0;
    $is_negative = false;
    if ($duration < 0) {
        $is_negative = true;
        $duration = abs($duration);
    }
    $this_level = 1;
    $detailed_relative_time = phutil_format_units_generic($duration, array(60, 60, 24, 7), array('s', 'm', 'h', 'd', 'w'), $precision = 0, $remainder);
    $duration = $remainder;
    while ($remainder > 0 && $this_level < $levels) {
        $detailed_relative_time .= ', ' . phutil_format_units_generic($duration, array(60, 60, 24, 7), array('s', 'm', 'h', 'd', 'w'), $precision = 0, $remainder);
        $duration = $remainder;
        $this_level++;
    }
    if ($is_negative) {
        $detailed_relative_time .= ' ago';
    }
    return $detailed_relative_time;
}
Beispiel #9
0
 public function save()
 {
     $maxHeight = 0;
     $width = 0;
     foreach ($this->_segmentsArray as $segment) {
         $maxHeight = max($maxHeight, $segment->height);
         $width += $segment->width;
     }
     // create our canvas
     $img = imagecreatetruecolor($width, $maxHeight);
     $background = imagecolorallocatealpha($img, 255, 255, 255, 127);
     imagefill($img, 0, 0, $background);
     imagealphablending($img, false);
     imagesavealpha($img, true);
     // start placing our images on a single x axis
     $xPos = 0;
     foreach ($this->_segmentsArray as $segment) {
         $tmp = imagecreatefromjpeg($segment->pathToImage);
         imagecopy($img, $tmp, $xPos, 0, 0, 0, $segment->width, $segment->height);
         $xPos += $segment->width;
         imagedestroy($tmp);
     }
     // create our final output image.
     imagepng($img, $this->_saveToPath);
 }
Beispiel #10
0
 function Row($data)
 {
     //Calculate the height of the row
     $h = 0;
     $numData = count($data);
     for ($i = 0; $i < $numData; $i++) {
         $hTmp = $this->getStringHeight($this->widths[$i], $data[$i]);
         $h = max($h, $hTmp);
     }
     $h += 0.5;
     //Issue a page break first if needed
     $this->CheckPageBreak($h);
     //Draw the cells of the row
     for ($i = 0; $i < $numData; $i++) {
         $w = $this->widths[$i];
         $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
         //Save the current position
         $x = $this->GetX();
         $y = $this->GetY();
         //Draw the border
         $this->Rect($x, $y, $w, $h);
         //Print the text
         $this->MultiCell($w, $h, $data[$i], 0, $a);
         //Put the position to the right of the cell
         $this->SetXY($x + $w, $y);
     }
     //Go to the next line
     $this->Ln($h);
 }
 /**
  * Find pixels coords and draw these on the current image
  *
  * @param integer $image Number of the image (to be used with $this->height)
  * @return boolean Success
  **/
 function drawPixels($image)
 {
     $limit = 0;
     do {
         /** Select with limit */
         $result = mysql_query(sprintf($this->query, $image * $this->height, ($image + 1) * $this->height - 1) . ' LIMIT ' . $limit . ',' . $this->limit);
         if ($result === false) {
             return $this->raiseError('Query failed: ' . mysql_error());
         }
         $count = mysql_num_rows($result);
         while ($click = mysql_fetch_row($result)) {
             $x = (int) $click[0];
             $y = (int) ($click[1] - $image * $this->height);
             if ($x < 0 || $x >= $this->width) {
                 continue;
             }
             /** Apply a calculus for the step, with increases the speed of rendering : step = 3, then pixel is drawn at x = 2 (center of a 3x3 square) */
             $x -= $x % $this->step - $this->startStep;
             $y -= $y % $this->step - $this->startStep;
             /** Add 1 to the current color of this pixel (color which represents the sum of clicks on this pixel) */
             $color = imagecolorat($this->image, $x, $y) + 1;
             imagesetpixel($this->image, $x, $y, $color);
             $this->maxClicks = max($this->maxClicks, $color);
             if ($image === 0) {
                 /** Looking for the maximum height of click */
                 $this->maxY = max($y, $this->maxY);
             }
         }
         /** Free resultset */
         mysql_free_result($result);
         $limit += $this->limit;
     } while ($count === $this->limit);
     return true;
 }
 public function convert()
 {
     $paddingTop = array_key_exists('SpaceBefore', $this->idmlContext) ? $this->idmlContext['SpaceBefore'] : '0';
     $paddingRight = array_key_exists('RightIndent', $this->idmlContext) ? $this->idmlContext['RightIndent'] : '0';
     $paddingBottom = array_key_exists('SpaceAfter', $this->idmlContext) ? $this->idmlContext['SpaceAfter'] : '0';
     $paddingLeft = array_key_exists('LeftIndent', $this->idmlContext) ? $this->idmlContext['LeftIndent'] : '0';
     // InDesign allows negative SpaceBefore and SpaceAfter, but CSS does not allow negative padding.
     $paddingTop = max(0, $paddingTop);
     $paddingBottom = max(0, $paddingBottom);
     $paddingTop = round($paddingTop);
     $paddingRight = round($paddingRight);
     $paddingBottom = round($paddingBottom);
     $paddingLeft = round($paddingLeft);
     if ($paddingTop == $paddingRight && $paddingRight == $paddingBottom && $paddingBottom == $paddingLeft) {
         $this->registerCSS('padding', $paddingTop . 'px');
     } else {
         $this->registerCSS('padding', sprintf("%dpx %dpx %dpx %dpx", $paddingTop, $paddingRight, $paddingBottom, $paddingLeft));
     }
     // IDML differs from CSS in it's implementation of space before the first paragraph.
     // IDML only uses SpaceBefore for the second and subsequent paragraphs, so we need CSS
     // to suppress padding-top on the first paragraph.
     if ($paddingTop > 0 && $this->decodeContext == 'Typography') {
         $this->registerPseudoCSS('first-of-type', 'padding', sprintf("%dpx %dpx %dpx %dpx", 0, $paddingRight, $paddingBottom, $paddingLeft));
     }
 }
Beispiel #13
0
 function Row($data)
 {
     //Calculate the height of the row
     $nb = 0;
     for ($i = 0; $i < count($data); $i++) {
         $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
     }
     $h = 5 * $nb;
     //Issue a page break first if needed
     $this->CheckPageBreak($h);
     //Draw the cells of the row
     for ($i = 0; $i < count($data); $i++) {
         $w = $this->widths[$i];
         $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
         //Save the current position
         $x = $this->GetX();
         $y = $this->GetY();
         //Draw the border
         $this->Rect($x, $y, $w, $h);
         //Print the text
         if (count($data) - 1 == $i && strtolower($data[count($data) - 1]) == 'desactivado') {
             $this->SetTextColor(255, 0, 0);
         } else {
             $this->SetTextColor(0, 0, 0);
         }
         $this->MultiCell($w, 5, $data[$i], 0, $a);
         //Put the position to the right of the cell
         $this->SetXY($x + $w, $y);
     }
     //Go to the next line
     $this->Ln($h);
 }
 public function execute()
 {
     if ($target_blog = max(0, $this->getRequest()->post('blog', 0, waRequest::TYPE_INT))) {
         $blog_model = new blogBlogModel();
         if ($blog = $blog_model->getById($target_blog)) {
             if ($ids = $this->getRequest()->post('id', null, waRequest::TYPE_ARRAY_INT)) {
                 $post_model = new blogPostModel();
                 $comment_model = new blogCommentModel();
                 $this->response['moved'] = array();
                 foreach ($ids as $id) {
                     try {
                         //rights will checked for each record separately
                         $post_model->updateItem($id, array('blog_id' => $target_blog));
                         $comment_model->updateByField('post_id', $id, array('blog_id' => $target_blog));
                         $this->response['moved'][$id] = $id;
                     } catch (Exception $ex) {
                         if (!isset($this->response['error'])) {
                             $this->response['error'] = array();
                         }
                         $this->response['error'][$id] = $ex->getMessage();
                     }
                 }
                 $this->response['style'] = $blog['color'];
                 $blog_model->recalculate();
             }
         } else {
         }
     }
 }
Beispiel #15
0
 public function main($UrlAppend = NULL, $get = NULL, $post = NULL)
 {
     if (!$_REQUEST['server_id']) {
         return array();
     }
     $this->_assign['URL_silenceLocalLog'] = $this->_urlLocalLog();
     $this->_assign['URL_silenceInGame'] = $this->_urlInGame();
     switch ($_REQUEST['doaction']) {
         case self::INGAME:
             //拿游戏中实际封号数据
             $this->_dataInLocalLog();
             break;
         default:
             $getData = $this->_gameObject->getGetData($get);
             $getData["Page"] = max(0, intval($_GET['page']));
             $data = $this->getResult($UrlAppend, $getData);
             //		print_r($data);
             if ($data['states'] == '1') {
                 $this->_assign['dataList'] = $data["List"];
                 $this->_loadCore('Help_Page');
                 $helpPage = new Help_Page(array('total' => $data["Count"], 'perpage' => PAGE_SIZE));
                 $this->_assign['pageBox'] = $helpPage->show();
             }
             $this->_assign['gameData'] = 1;
             break;
     }
     $this->_assign['Add_Url'] = $this->_urlAdd();
     $this->_assign['Del_Url'] = $this->_urlDel();
     return $this->_assign;
 }
Beispiel #16
0
 /**
  * @param int $position
  * @param array $options
  * @param string $detailedMessage
  * @return bool|int|string|true
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     /* @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     $locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
     if (count($locations) < 1) {
         return true;
     }
     XenForo_Db::beginTransaction();
     $db = XenForo_Application::getDb();
     /** @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     foreach ($locations as $locationId => $location) {
         $position = $location['location_id'];
         try {
             $client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
             $response = $client->request('GET');
             $response = @json_decode($response->getBody(), true);
             if (empty($response['results'][0])) {
                 continue;
             }
             $address = $response['results'][0]['formatted_address'];
             $lat = $response['results'][0]['geometry']['location']['lat'];
             $lng = $response['results'][0]['geometry']['location']['lng'];
             $db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
         } catch (Exception $e) {
             continue;
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
function nuage_tags($limit = 30, $id_cat = 0)
{
    $list_tags = array();
    $count_tags = array();
    $limit_sql = $limit != 0 ? ' LIMIT ' . intval($limit) : '';
    $where_cat = $id_cat != 0 ? ' AND n_id_cat = ' . intval($id_cat) : '';
    $rqt_tags = Nw::$DB->query('SELECT c_id, c_couleur, c_nom, t_id_news, t_tag, COUNT(t_tag) AS nbr_tags, n_id_cat FROM ' . Nw::$prefix_table . 'tags
        LEFT JOIN ' . Nw::$prefix_table . 'news ON t_id_news = n_id
        LEFT JOIN ' . Nw::$prefix_table . 'categories ON c_id = n_id_cat
    WHERE n_etat = 3' . $where_cat . '
    GROUP BY t_tag ORDER BY t_tag ASC ' . $limit_sql) or Nw::$DB->trigger(__LINE__, __FILE__);
    while ($donnees = $rqt_tags->fetch_assoc()) {
        $list_tags[$donnees['t_tag']] = $donnees;
        $count_tags[$donnees['t_tag']] = $donnees['nbr_tags'];
    }
    $max_size = 200;
    $min_size = 100;
    $max_qty = 0;
    $min_qty = 0;
    if (count($count_tags) > 0) {
        $max_qty = max(array_values($count_tags));
        $min_qty = min(array_values($count_tags));
    }
    $spread = $max_qty - $min_qty;
    if (0 == $spread) {
        $spread = 1;
    }
    $step = ($max_size - $min_size) / $spread;
    foreach ($list_tags as $tags) {
        $list_tags[$tags['t_tag']]['size'] = floor($min_size + ($tags['nbr_tags'] - $min_qty) * $step);
    }
    return $list_tags;
}
Beispiel #18
0
 public function main($UrlAppend = NULL, $get = NULL, $post = NULL)
 {
     if (!$_REQUEST['server_id']) {
         return $this->_assign;
     }
     if ($_REQUEST["sbm"] == "") {
         return $this->_assign;
     }
     $getData = $this->_gameObject->getGetData($get);
     if ($_GET["WorldID"] != "") {
         $WorldID = $_GET["WorldID"];
     }
     $postData = array('PlayerID' => trim($_GET['PlayerID']), 'AccountName' => trim($_GET['AccountName']), 'AccountID' => trim($_GET['AccountID']), 'WorldID' => trim($WorldID), 'PlayerName' => urlencode(trim($_GET['PlayerName'])), 'Page' => max(0, intval($_GET['page'] - 1)));
     $getData = array_merge($getData, $postData);
     $account = $this->getResult($UrlAppend, $getData);
     if ($account['Result'] === 0) {
         $status = 1;
         if ($account['PlayerList']) {
             $this->_loadCore('Help_Page');
             //载入分页工具
             $helpPage = new Help_Page(array('total' => $account['Count'], 'perpage' => PAGE_SIZE));
             $this->_assign['data'] = $account;
             $this->_assign['dataList'] = $account['PlayerList'];
             $this->_assign['pageBox'] = $helpPage->show();
         }
     } else {
         $this->_assign['connectError'] = 'Error Message:' . $data['info'];
         $info = $data['info'];
     }
     $this->_assign['ajax'] = Tools::url(CONTROL, 'PlayerRoleList', array('zp' => PACKAGE, '__game_id' => $this->_gameObject->_gameId, 'server_id' => $_REQUEST['server_id']));
     return $this->_assign;
 }
 /**
  * Render the information header for the view
  * 
  * @param string $title
  * @param string $title
  */
 public function writeInfo($title, $subtitle, $description = false)
 {
     echo wordwrap(strtoupper($title), 100) . "\n";
     echo wordwrap($subtitle, 100) . "\n";
     echo str_repeat('-', min(100, max(strlen($title), strlen($subtitle)))) . "\n";
     echo wordwrap($description, 100) . "\n\n";
 }
Beispiel #20
0
 /**
  * @param Diff $diff
  * @param array $lines
  */
 private function parseFileDiff(Diff $diff, array $lines)
 {
     $chunks = array();
     foreach ($lines as $line) {
         if (preg_match('/^@@\\s+-(?P<start>\\d+)(?:,\\s*(?P<startrange>\\d+))?\\s+\\+(?P<end>\\d+)(?:,\\s*(?P<endrange>\\d+))?\\s+@@/', $line, $match)) {
             $chunk = new Chunk($match['start'], isset($match['startrange']) ? max(1, $match['startrange']) : 1, $match['end'], isset($match['endrange']) ? max(1, $match['endrange']) : 1);
             $chunks[] = $chunk;
             $diffLines = array();
             continue;
         }
         if (preg_match('/^(?P<type>[+ -])?(?P<line>.*)/', $line, $match)) {
             $type = Line::UNCHANGED;
             if ($match['type'] == '+') {
                 $type = Line::ADDED;
             } elseif ($match['type'] == '-') {
                 $type = Line::REMOVED;
             }
             $diffLines[] = new Line($type, $match['line']);
             if (isset($chunk)) {
                 $chunk->setLines($diffLines);
             }
         }
     }
     $diff->setChunks($chunks);
 }
Beispiel #21
0
function laser($inimigos)
{
    if (empty($inimigos)) {
        return 0;
    }
    $linhas = $colunas = array();
    foreach ($inimigos as $inimigo) {
        if (!isset($linhas[$inimigo->x])) {
            $linhas[$inimigo->x] = 0;
        }
        if (!isset($colunas[$inimigo->y])) {
            $colunas[$inimigo->y] = 0;
        }
        $linhas[$inimigo->x]++;
        $colunas[$inimigo->y]++;
    }
    // Escolhe qual linha ou coluna atirar
    if (count($linhas) < count($colunas)) {
        $maiorLinha = array_search(max($linhas), $linhas);
        $maiorColuna = false;
    } else {
        $maiorColuna = array_search(max($colunas), $colunas);
        $maiorLinha = false;
    }
    // Remove os inimigos da linha/coluna escolhida
    foreach ($inimigos as $key => $inimigo) {
        if ($inimigo->x === $maiorLinha or $inimigo->y === $maiorColuna) {
            unset($inimigos[$key]);
        }
    }
    return 1 + laser($inimigos);
}
 public function formatColor(\OttawaDeveloper\Tools\ColorAnalyzer\Color $color)
 {
     $colorValues = array('red' => $color->red() / 255, 'green' => $color->green() / 255, 'blue' => $color->blue() / 255);
     $minimumValue = min($colorValues);
     $maximumValue = max($colorValues);
     $luminescence = round(($minimumValue + $maximumValue) / 2, 2);
     if ($minimumValue == $maximumValue) {
         return $this->formatHslColor(0, 0, $luminescence, $color->alpha());
     }
     $colorRange = $maximumValue - $minimumValue;
     $saturation = $colorRange;
     if ($luminescence < 0.5) {
         $saturation /= $maximumValue + $minimumValue;
     } else {
         $saturation /= 2 - $colorRange;
     }
     $hue = 0;
     if ($colorValues['red'] >= $colorValues['blue'] && $colorValues['red'] >= $colorValues['green']) {
         $hue = ($colorValues['green'] - $colorValues['blue']) / $colorRange;
     } elseif ($colorValues['green'] >= $colorValues['blue'] && $colorValues['green'] >= $colorValues['red']) {
         $hue = 2 + ($colorValues['blue'] - $colorValues['red']) / $colorRange;
     } else {
         $hue = 4 + ($colorValues['red'] - $colorValues['green']) / $colorRange;
     }
     return $this->formatHslColor($hue * 60, $saturation, $luminescence, $color->alpha());
 }
Beispiel #23
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('position' => 0, 'batch' => 100, 'delete' => false), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $statsModel XenForo_Model_Stats */
     $statsModel = XenForo_Model::create('XenForo_Model_Stats');
     if ($data['position'] == 0) {
         // delete old stats cache if required
         if (!empty($data['delete'])) {
             $statsModel->deleteStats();
         }
         // an appropriate date from which to start... first thread, or earliest user reg?
         $data['position'] = min(XenForo_Model::create('XenForo_Model_Thread')->getEarliestThreadDate(), XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate());
         // start on a 24 hour increment point
         $data['position'] = $data['position'] - $data['position'] % 86400;
     } else {
         if ($data['position'] > XenForo_Application::$time) {
             return true;
         }
     }
     $endPosition = $data['position'] + $data['batch'] * 86400;
     $statsModel->buildStatsData($data['position'], $endPosition);
     $data['position'] = $endPosition;
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('daily_statistics');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::date($data['position'], 'absolute'));
     return $data;
 }
 /**
  * {@inheritdoc}
  */
 protected function writePrompt(OutputInterface $output, Question $question)
 {
     $text = $question->getQuestion();
     $default = $question->getDefault();
     switch (true) {
         case null === $default:
             $text = sprintf(' <info>%s</info>:', $text);
             break;
         case $question instanceof ConfirmationQuestion:
             $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
             break;
         case $question instanceof ChoiceQuestion && $question->isMultiSelect():
             $choices = $question->getChoices();
             $default = explode(',', $default);
             foreach ($default as $key => $value) {
                 $default[$key] = $choices[trim($value)];
             }
             $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, implode(', ', $default));
             break;
         case $question instanceof ChoiceQuestion:
             $choices = $question->getChoices();
             $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, $choices[$default]);
             break;
         default:
             $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, $default);
     }
     $output->writeln($text);
     if ($question instanceof ChoiceQuestion) {
         $width = max(array_map('strlen', array_keys($question->getChoices())));
         foreach ($question->getChoices() as $key => $value) {
             $output->writeln(sprintf("  [<comment>%-{$width}s</comment>] %s", $key, $value));
         }
     }
     $output->write(' > ');
 }
 function Row($data)
 {
     //Calculate the height of the row
     $nb = 0;
     for ($i = 0; $i < count($data); $i++) {
         $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
     }
     $h = 5 * $nb;
     //Issue a page break first if needed
     $this->CheckPageBreak($h);
     //Draw the cells of the row
     for ($i = 0; $i < count($data); $i++) {
         $w = $this->widths[$i];
         $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'C';
         //sets the alignment of text inside the cell
         //Save the current position
         $x = $this->GetX();
         $y = $this->GetY();
         //Draw the border
         $this->Rect($x, $y, $w, $h);
         //Print the text
         $this->MultiCell($w, 5, $data[$i], 0, $a);
         //Put the position to the right of the cell
         $this->SetXY($x + $w, $y);
     }
     //Go to the next line
     $this->Ln($h);
 }
Beispiel #26
0
 function ShowRecommend()
 {
     if (jstrpos($_SERVER['HTTP_REFERER'], 'at') > 0) {
         return;
     }
     $uid = max(0, (int) $this->Post['uid']);
     $tid = max(0, (int) $this->Post['tid']);
     if ($uid < 1) {
         exit;
     }
     $return_tid = jlogic('buddy')->check_new_recd_topic($uid, $tid);
     if ($return_tid) {
         $tids = array($return_tid);
         $TopicListLogic = jlogic('topic_list');
         $options = array('tid' => $tids, 'count' => '1');
         $info = $TopicListLogic->get_data($options);
         $topic_list = $info['list'];
         if ($topic_list) {
             $TopicLogic = jlogic('topic');
             $parent_list = $TopicLogic->GetParentTopic($topic_list, 1);
             $relate_list = $TopicLogic->GetRelateTopic($topic_list);
             foreach ($topic_list as $key => $val) {
                 if ($val['longtextid'] > 0) {
                     $topic_list[$key]['content'] = $val['content'] . '...';
                 }
             }
             include template('ajax_recommend');
         }
     }
 }
Beispiel #27
0
function add_pagination_vars(&$page, $total, $curPage, $perPage, $append = '')
{
    $pgs = array();
    $p_min = 0;
    $p_max = $lastPage = floor($total / $perPage);
    if ($curPage == 0) {
        $p_max = min($lastPage, $curPage + 4);
    } else {
        if ($curPage == 1) {
            $p_max = min($lastPage, $curPage + 3);
        } else {
            $p_max = min($lastPage, $curPage + 2);
        }
    }
    if ($curPage == $lastPage) {
        $p_min = max(0, $curPage - 4);
    } else {
        if ($curPage == $lastPage - 1) {
            $p_min = max(0, $curPage - 3);
        } else {
            $p_min = max(0, $curPage - 2);
        }
    }
    for ($p = $p_min; $p <= $p_max; $p++) {
        $pgs[] = $p;
    }
    $page['pager'] = array('pages' => $pgs, 'first' => 0, 'current' => $curPage, 'last' => floor($total / $perPage), 'append' => $append);
}
 /**
  * @Request({"filter": "array", "page":"int"})
  * @Response("extension://page/views/admin/pages/index.razr")
  */
 public function indexAction($filter = null, $page = 0)
 {
     if ($filter) {
         $this['session']->set('page.filter', $filter);
     } else {
         $filter = $this['session']->get('page.filter', []);
     }
     $query = $this->pages->query();
     if (isset($filter['status']) && is_numeric($filter['status'])) {
         $query->where(['status' => intval($filter['status'])]);
     }
     if (isset($filter['search']) && strlen($filter['search'])) {
         $query->where(function ($query) use($filter) {
             $query->orWhere('title LIKE :search', ['search' => "%{$filter['search']}%"]);
         });
     }
     $limit = self::PAGES_PER_PAGE;
     $count = $query->count();
     $total = ceil($count / $limit);
     $page = max(0, min($total - 1, $page));
     $query->offset($page * $limit)->limit($limit)->orderBy('title');
     if ($this['request']->isXmlHttpRequest()) {
         return $this['response']->json(['table' => $this['view']->render('extension://page/views/admin/pages/table.razr', ['count' => $count, 'pages' => $query->get(), 'roles' => $this->roles->findAll()]), 'total' => $total]);
     }
     return ['head.title' => __('Pages'), 'pages' => $query->get(), 'statuses' => Page::getStatuses(), 'filter' => $filter, 'total' => $total, 'count' => $count];
 }
function amr_handle_copy_delete()
{
    global $amain, $aopt;
    if (!current_user_can('administrator')) {
        _e('Inadequate access', 'amr-users');
        return;
    }
    if (isset($_GET['copylist'])) {
        $source = (int) $_REQUEST['copylist'];
        if (!isset($amain['names'][$source])) {
            echo 'Error copying list ' . $source;
        }
        $next = 1;
        // get the current max index
        foreach ($amain['names'] as $j => $name) {
            $next = max($next, $j);
        }
        $next = $next + 1;
        //
        foreach ($amain as $j => $setting) {
            if (is_array($setting)) {
                echo '<br />copying ' . $j . ' from list ' . $source;
                if (!empty($amain[$j][$source])) {
                    $amain[$j][$next] = $amain[$j][$source];
                }
            }
        }
        $amain['names'][$next] .= __(' - copy', 'amr-users');
        $amain['no-lists'] = count($amain['names']);
        if (!empty($aopt['list'][$source])) {
            echo '<br />copying settings from list ' . $source;
            $aopt['list'][$next] = $aopt['list'][$source];
        }
        ausers_update_option('amr-users-main', $amain);
        ausers_update_option('amr-users', $aopt);
    } elseif (isset($_GET['deletelist'])) {
        $source = (int) $_REQUEST['deletelist'];
        if (!isset($amain['names'][$source])) {
            amr_users_message(sprintf(__('Error deleting list %S', 'amr-users'), $source));
        } else {
            foreach ($amain as $j => $setting) {
                if (is_array($setting)) {
                    //if (WP_DEBUG) echo '<br />deleting '.$j.' from list '.$source;
                    if (isset($amain[$j][$source])) {
                        unset($amain[$j][$source]);
                    }
                }
            }
        }
        $amain['no-lists'] = count($amain['names']);
        if (!empty($aopt['list'][$source])) {
            unset($aopt['list'][$source]);
        }
        $acache = new adb_cache();
        $acache->clear_cache($acache->reportid($source));
        ausers_update_option('amr-users-main', $amain);
        ausers_update_option('amr-users', $aopt);
        amr_users_message(__('List and the cache deleted.', 'amr-users'));
    }
}
Beispiel #30
-15
 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }