当前位置: 首页>>代码示例>>PHP>>正文


PHP percentage函数代码示例

本文整理汇总了PHP中percentage函数的典型用法代码示例。如果您正苦于以下问题:PHP percentage函数的具体用法?PHP percentage怎么用?PHP percentage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了percentage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delta

function delta($current_value, $old_value)
{
    if ($current_value == $old_value) {
        return '--';
    }
    return percentage($current_value - $old_value, $old_value, 1, 'NA', '%', true);
}
开发者ID:inikoo,项目名称:fact,代码行数:7,代码来源:common_functions.php

示例2: get_wait_info

function get_wait_info($data)
{
    require_once 'common_natural_language.php';
    global $mysqli;
    $fork_key = $data['fork_key'];
    $sql = sprintf("select `Fork Key`,`Fork Result`,`Fork Scheduled Date`,`Fork Start Date`,`Fork State`,`Fork Type`,`Fork Operations Done`,`Fork Operations No Changed`,`Fork Operations Errors`,`Fork Operations Total Operations` from `Fork Dimension` where `Fork Key`=%d ", $fork_key);
    $res = $mysqli->query($sql);
    if ($row = $res->fetch_assoc()) {
        $result_extra_data = array();
        switch ($data['tag']) {
            case 'journals':
                $formated_tag = ' ' . ngettext('journal', 'journals', $row['Fork Operations Total Operations']);
                break;
            default:
                $formated_tag = ' ' . ngettext('record', 'records', $row['Fork Operations Total Operations']);
        }
        $etr = '';
        if ($row['Fork State'] == 'In Process') {
            //$msg=number($row['Fork Operations Done']+$row['Fork Operations Errors']+$row['Fork Operations No Changed']).'/'.$row['Fork Operations Total Operations'];
            $formated_status = _('In Process');
            $formated_progress = _('Processing') . ' ' . number($row['Fork Operations Done']) . ' ' . _('of') . ' ' . number($row['Fork Operations Total Operations']);
            $formated_progress .= $formated_tag;
            if ($row['Fork Operations Done'] > 1) {
                $etr = _('ETA') . ': ' . seconds_to_string(($row['Fork Operations Total Operations'] - $row['Fork Operations Done']) * (gmdate('U') - strtotime($row['Fork Start Date'])) / $row['Fork Operations Done']);
            }
        } elseif ($row['Fork State'] == 'Queued') {
            $formated_status = _('Queued');
            $formated_progress = _('Records to process') . ': ' . number($row['Fork Operations Total Operations']);
        } elseif ($row['Fork State'] == 'Finished') {
            $formated_status = _('Finished');
            $formated_progress = number($row['Fork Operations Done']) . $formated_tag . ' ' . _('processed');
        } elseif ($row['Fork State'] == 'Cancelled') {
            $formated_status = _('Cancelled');
            $formated_progress = number($row['Fork Operations Done']) . $formated_tag . ' ' . _('processed');
        } else {
            $formated_status = $row['Fork State'];
            $formated_progress = '';
        }
        $response = array('state' => 200, 'date' => gmdate('Y-m-d H:i:s'), 'fork_key' => $fork_key, 'fork_state' => $row['Fork State'], 'done' => number($row['Fork Operations Done']), 'no_changed' => number($row['Fork Operations No Changed']), 'errors' => number($row['Fork Operations Errors']), 'total' => number($row['Fork Operations Total Operations']), 'todo' => number($row['Fork Operations Total Operations'] - $row['Fork Operations Done']), 'result' => $row['Fork Result'], 'formated_status' => $formated_status, 'formated_progress' => $formated_progress . '<br>' . $etr, 'progress' => sprintf('%s/%s (%s)', number($row['Fork Operations Done']), number($row['Fork Operations Total Operations']), percentage($row['Fork Operations Done'], $row['Fork Operations Total Operations'])), 'tag' => $data['tag'], 'result_extra_data' => $result_extra_data, 'etr' => $etr);
        echo json_encode($response);
    } else {
        $response = array('state' => 400);
        echo json_encode($response);
    }
}
开发者ID:inikoo,项目名称:fact,代码行数:45,代码来源:ar_fork.php

示例3: Step2

function Step2()
{
    $q = new mysql_squid_builder();
    percentage("Fix tables", 2);
    $q->FixTables();
    percentage("check_to_hour_tables", 2);
    $squid_stats_tools = new squid_stats_tools();
    $squid_stats_tools->check_to_hour_tables(true);
    percentage("not_categorized_day_scan", 2);
    $squid_stats_tools->not_categorized_day_scan();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:11,代码来源:exec.squid.stats.central.php

示例4: column_quality

 public function column_quality($Item)
 {
     $quality = isset(ShoppImageSetting::$qualities[$Item->quality]) ? ShoppImageSetting::$qualities[$Item->quality] : $Item->quality;
     $quality = percentage($quality, array('precision' => 0));
     echo esc_html($quality);
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:6,代码来源:Images.php

示例5: function

        $response->header('Content-Type', 'application/json');
        return $response;
    }
});
Route::post('upload/data', 'MediaController@uploadData');
Route::post('upload/file', 'MediaController@uploadFile');
Route::get('premium', function () {
    if (Auth::guest()) {
    } else {
        return View::make('widgets.premium');
    }
});
Route::get('user/settings', function () {
    if (Auth::guest()) {
    } else {
        $data = array('avlbytes' => getfilesize(Auth::user()->avl_bytes), 'usedbytes' => getfilesize(Auth::user()->used_bytes), 'freebytes' => getfilesize(Auth::user()->avl_bytes - Auth::user()->used_bytes), 'perc' => percentage(Auth::user()->used_bytes, Auth::user()->avl_bytes, '1'), 'plan_name' => Auth::user()->category()->name, 'plan_exp' => Auth::user()->prem_valid, 'set_ea' => Auth::user()->ea, 'set_sub_lng' => Auth::user()->default_sub_lng);
        return View::make('widgets.settings', $data);
    }
});
Route::get('user/share/{id}', function ($id) {
    if (Auth::user()->category_id == 1 || Auth::user()->category_id == 27) {
    } else {
        $user_media = UserMedia::where('uni_id', '=', $id)->where('user_id', '=', Auth::user()->id)->first();
        if (isset($user_media->id)) {
            $share_m = ShareMedia::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $user_media->media_id)->first();
            if (isset($share_m->id)) {
                $link = "http://okaydrive.com/share/" . $share_m->uni_id;
            } else {
                $media = Media::where('id', '=', $user_media->media_id)->first();
                if ($media->state == "done") {
                    $new_smedia = new ShareMedia();
开发者ID:naveengamage,项目名称:okaydrive,代码行数:31,代码来源:routes.php

示例6: tag


//.........这里部分代码省略.........
			case "promos":
				if (!isset($this->_promo_looping)) {
					reset($this->discounts);
					$this->_promo_looping = true;
				} else next($this->discounts);

				$discount = current($this->discounts);
				while ($discount && empty($discount->applied) && !$discount->freeshipping)
					$discount = next($this->discounts);

				if (current($this->discounts)) return true;
				else {
					unset($this->_promo_looping);
					reset($this->discounts);
					return false;
				}
			case "promoname":
			case "promo-name":
				$discount = current($this->discounts);
				if ($discount->applied == 0 && empty($discount->items) && !isset($this->freeshipping)) return false;
				return $discount->name;
				break;
			case "promodiscount":
			case "promo-discount":
				$discount = current($this->discounts);
				if ($discount->applied == 0 && empty($discount->items) && !isset($this->freeshipping)) return false;
				if (!isset($options['label'])) $options['label'] = ' '.__('Off!','Ecart');
				else $options['label'] = ' '.$options['label'];
				$string = false;
				if (!empty($options['before'])) $string = $options['before'];

				switch($discount->type) {
					case "Free Shipping": $string .= money($discount->freeshipping).$options['label']; break;
					case "Percentage Off": $string .= percentage($discount->discount,array('precision' => 0)).$options['label']; break;
					case "Amount Off": $string .= money($discount->discount).$options['label']; break;
					case "Buy X Get Y Free": return sprintf(__('Buy %s get %s free','Ecart'),$discount->buyqty,$discount->getqty); break;
				}
				if (!empty($options['after'])) $string .= $options['after'];

				return $string;
				break;
			case "function":
				$result = '<div class="hidden"><input type="hidden" id="cart-action" name="cart" value="true" /></div><input type="submit" name="update" id="hidden-update" />';

				$Errors = &EcartErrors();
				if (!$Errors->exist(ECART_STOCK_ERR)) return $result;

				ob_start();
				include(ECART_TEMPLATES."/errors.php");
				$errors = ob_get_contents();
				ob_end_clean();
				return $result.$errors;
				break;
			case "emptybutton":
			case "empty-button":
				if (!isset($options['value'])) $options['value'] = __('Empty Cart','Ecart');
				return '<input type="submit" name="empty" id="empty-button" '.inputattrs($options,$submit_attrs).' />';
				break;
			case "updatebutton":
			case "update-button":
				if (!isset($options['value'])) $options['value'] = __('Update Subtotal','Ecart');
				if (isset($options['class'])) $options['class'] .= " update-button";
				else $options['class'] = "update-button";
				return '<input type="submit" name="update"'.inputattrs($options,$submit_attrs).' />';
				break;
			case "sidecart":
开发者ID:robbiespire,项目名称:paQui,代码行数:67,代码来源:Cart.php

示例7: tag


//.........这里部分代码省略.........
					$unit = $convert;
				}

				$range = false;
				if ($min != $max) {
					$range = array($min,$max);
					sort($range);
				}

				$string = ($min == $max)?round($min,3):round($range[0],3)." - ".round($range[1],3);
				$string .= value_is_true($units) ? " $unit" : "";
				return $string;
				break;
			case "onsale":
				if (empty($this->prices)) $this->load_data(array('prices'));
				if (empty($this->prices)) return false;
				return $this->onsale;
				break;
			case "has-savings": return ($this->onsale && $this->min['saved'] > 0); break;
			case "savings":
				if (empty($this->prices)) $this->load_data(array('prices'));
				if (!isset($options['taxes'])) $options['taxes'] = null;

				$taxrate = ecart_taxrate($options['taxes']);
				$range = false;

				if (!isset($options['show'])) $options['show'] = '';
				if ($options['show'] == "%" || $options['show'] == "percent") {
					if ($this->options > 1) {
						if (round($this->min['savings']) != round($this->max['savings'])) {
							$range = array($this->min['savings'],$this->max['savings']);
							sort($range);
						}
						if (!$range) return percentage($this->min['savings'],array('precision' => 0)); // No price range
						else return percentage($range[0],array('precision' => 0))." &mdash; ".percentage($range[1],array('precision' => 0));
					} else return percentage($this->max['savings'],array('precision' => 0));
				} else {
					if ($this->options > 1) {
						if (round($this->min['saved']) != round($this->max['saved'])) {
							$range = array($this->min['saved'],$this->max['saved']);
							sort($range);
						}
						if (!$range) return money($this->min['saved']+($this->min['saved']*$taxrate)); // No price range
						else return money($range[0]+($range[0]*$taxrate))." &mdash; ".money($range[1]+($range[1]*$taxrate));
					} else return money($this->max['saved']+($this->max['saved']*$taxrate));
				}
				break;
			case "freeshipping":
				if (empty($this->prices)) $this->load_data(array('prices'));
				return $this->freeshipping;
			case "hasimages":
			case "has-images":
				if (empty($this->images)) $this->load_data(array('images'));
				return (!empty($this->images));
				break;
			case "images":
				if (!$this->images) return false;
				if (!isset($this->_images_loop)) {
					reset($this->images);
					$this->_images_loop = true;
				} else next($this->images);

				if (current($this->images) !== false) return true;
				else {
					unset($this->_images_loop);
					return false;
开发者ID:robbiespire,项目名称:paQui,代码行数:67,代码来源:Product.php

示例8: human_size

			<?php 
}
?>

			<h2 id="apcu">APCu</h2>
			<div>
				<h3>Memory <?php 
echo human_size(apc_mem('used'));
?>
 of <?php 
echo human_size(apc_mem('total'));
?>
</h3>
				<div class="full bar green">
					<div class="orange" style="width: <?php 
echo percentage(apc_mem('used'), apc_mem('total'));
?>
%"></div>
				</div>
			</div>
			<div>
				<h3>Actions</h3>
				<form action="?" method="GET">
					<label>Cache:
						<button name="action" value="apc_restart">Restart</button>
					</label>
				</form>
				<form action="?" method="GET">
					<label>Key(s):
						<input name="selector" type="text" value="" placeholder=".*" />
					</label>
开发者ID:RamboLau,项目名称:php-cache-dashboard,代码行数:31,代码来源:cache.php

示例9: URL

                $failedUrls[] = $item;
            }
        }
        // Label
        skipHandleResults:
        //
        // Check which alerts if a title yields alot of hits. Means this title's query may be worth verifying.
        //
        if ($itemCount >= $verifyLimit) {
            $toVerifyArray[] = $titleName . " (ID: " . $titleId . " - Results:" . $itemCount . " )";
        }
        $curResultCnt = " " . $itemCount . " URL(s) added succesfully!";
        echo "\r";
        // Wipe line
        printf($mask, " " . $titleName, $curResultCnt);
        echo "\rProgress: " . floor(percentage($curTitle, $totalTitles)) . "% (" . $curTitle . "/" . $totalTitles . ") | URL's found: " . $totalItemCount . " | Ignored URL's: " . count($failedUrls) . " | Queries: " . $queryCount . " | Errors: " . $errors . "/" . $errorLimit;
        // SIGNAL handling
        if (isset($exit)) {
            echo "\n\nGot an exit signal! ({$exit})\n";
            break 2;
        }
        // Slow down - Google seems to like this
        usleep(200000);
    }
    echo "\r+--------------------------------------------------------------------------------------------------------------+\n";
}
//Add line-break
echo "\n";
//Print info
echo "Found a total of " . $totalItemCount . " new links!\n";
echo "I needed " . $queryCount . " queries to find these!\n";
开发者ID:Beertie,项目名称:web_scraper,代码行数:31,代码来源:voorbeeld.php

示例10: percentage

        echo percentage(folderdisktotal($currentgroup), $clientmaxfilesize);
        ?>
" data-line-width="2" data-size="100" data-bar-color="#3675c5" data-track-color="#eeeeee">
                                        <span class="h4"><?php 
        echo humanFileSize(folderdisktotal($currentgroup), 'MB');
        ?>
 <br><small class="h5 font-w400 text-muted">/<?php 
        echo humanFileSize($clientmaxfilesize, 'MB');
        ?>
</small></span>
                                    <canvas height="0" width="0"></canvas></div>
                                </div>
                                <div class="block-content block-content-full col-lg-6 text-center">
                                    <!-- Pie Chart Container -->
                                    <div class="js-pie-chart pie-chart" data-percent="<?php 
        echo percentage(orbislookup($currentgroup, 'file_group_id', 'files', 'COUNT(*)'), $clientmaxfiles);
        ?>
" data-line-width="2" data-size="100" data-bar-color="#3675c5" data-track-color="#eeeeee">
                                        <span class="h4"><?php 
        echo orbislookup($currentgroup, 'file_group_id', 'files', 'COUNT(*)');
        ?>
 Files<br><small class="h5 font-w400 text-muted">/<?php 
        echo $clientmaxfiles;
        ?>
 Files</small></span>
                                    <canvas height="0" width="0"></canvas></div>
                                </div>
                                        </div>
                                <div class="block-content">
                                    <div class="row items-push text-center">
                                        <div class="col-xs-6">
开发者ID:Aloogy,项目名称:orbis-online,代码行数:31,代码来源:files.php

示例11: microtime

                }
            }
        }
        /* End Models */
    }
    # Progress Info
    $mtime = microtime();
    $mtime = explode(" ", $mtime);
    $mtime = $mtime[1] + $mtime[0];
    $endtime = $mtime;
    $totaltime = $endtime - $starttime;
    $systemAllowTime = ini_get('max_execution_time');
    //$systemAllowTime = 100;
    $timeStatus = 0;
    if ($systemAllowTime != 0) {
        $timeStatus = percentage($totaltime, $systemAllowTime, 0);
    }
    echo '
		  <script>
			function getGreenToRed(percent){
						r = percent<50 ? 255 : Math.floor(255-(percent*2-100)*255/100);
						g = percent>50 ? 255 : Math.floor((percent*2)*255/100);
						return "rgb("+g+","+r+",0)";
					}
		  
			$("#import_prog .well").append("- ' . subscribers_file_opened . '<br>");
			$("#import_prog .well").append("- ' . subscribers_counting_records . '..<br>");
			$("#import_prog .well").append("- ' . subscribers_max_valid_data . ': ' . $fTotal . '<br>");
			$("#import_prog .well").append("- ' . subscribers_total_phase . ': ~' . $fTotalPhase . '<br>");
			$("#import_prog .well").append("- ' . subscribers_parsing_has_begun . '..<br>");
			$("#import_prog .well").append("- ' . subscribers_found_in_the_blacklist . ': <span class=text-muted>' . $recBL . '</span><br>");
开发者ID:BersnardC,项目名称:DROPINN,代码行数:31,代码来源:exip.xmlhttp.php

示例12: Item

 function Item($Product, $pricing, $category, $data = array())
 {
     global $Shopp;
     // To access settings
     $Product->load_data(array('prices', 'images'));
     // If product variations are enabled, disregard the first priceline
     if ($Product->variations == "on") {
         array_shift($Product->prices);
     }
     // If option ids are passed, lookup by option key, otherwise by id
     if (is_array($pricing)) {
         $Price = $Product->pricekey[$Product->optionkey($pricing)];
         if (empty($Price)) {
             $Price = $Product->pricekey[$Product->optionkey($pricing, true)];
         }
     } elseif ($pricing) {
         $Price = $Product->priceid[$pricing];
     } else {
         foreach ($Product->prices as &$Price) {
             if ($Price->type != "N/A" && (!$Price->stocked || $Price->stocked && $Price->stock > 0)) {
                 break;
             }
         }
     }
     if (isset($Product->id)) {
         $this->product = $Product->id;
     }
     if (isset($Price->id)) {
         $this->price = $Price->id;
     }
     $this->category = $category;
     $this->option = $Price;
     $this->name = $Product->name;
     $this->slug = $Product->slug;
     $this->description = $Product->summary;
     if (isset($Product->thumbnail)) {
         $this->thumbnail = $Product->thumbnail;
     }
     $this->menus = $Product->options;
     if ($Product->variations == "on") {
         $this->options = $Product->prices;
     }
     $this->sku = $Price->sku;
     $this->type = $Price->type;
     $this->sale = $Price->onsale;
     $this->freeshipping = $Price->freeshipping;
     $this->saved = $Price->price - $Price->promoprice;
     $this->savings = $Price->price > 0 ? percentage($this->saved / $Price->price) * 100 : 0;
     $this->unitprice = $Price->onsale ? $Price->promoprice : $Price->price;
     $this->optionlabel = count($Product->prices) > 1 ? $Price->label : '';
     $this->donation = $Price->donation;
     $this->data = stripslashes_deep(attribute_escape_deep($data));
     // Map out the selected menu name and option
     if ($Product->variations == "on") {
         $selected = explode(",", $this->option->options);
         $s = 0;
         foreach ($this->menus as $i => $menu) {
             foreach ($menu['options'] as $option) {
                 if ($option['id'] == $selected[$s]) {
                     $this->variation[$menu['name']] = $option['name'];
                     break;
                 }
             }
             $s++;
         }
     }
     if (!empty($Price->download)) {
         $this->download = $Price->download;
     }
     if ($Price->type == "Shipped") {
         $this->shipping = true;
         if ($Price->shipping == "on") {
             $this->weight = $Price->weight;
             $this->shipfee = $Price->shipfee;
         } else {
             $this->freeshipping = true;
         }
     }
     $this->inventory = $Price->inventory == "on" ? true : false;
     $this->taxable = $Price->tax == "on" && $Shopp->Settings->get('taxes') == "on" ? true : false;
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:81,代码来源:Item.php

示例13: _repair_from_sources_tables

function _repair_from_sources_tables($sourcetable, $daytable)
{
    percentage("Repair {$daytable} FROM {$sourcetable}", 2);
    //zMD5                             | sitename                   | familysite        | client        | hostname | account | hour | remote_ip     | MAC | country | size  | hits | uid           | category                      | cached
    $f = array();
    $sql = "SELECT HOUR(zDate) as `hour`,SUM(QuerySize) as size, SUM(hits) as hits, \n\tsitename,uid,CLIENT,hostname,MAC,account,cached FROM {$sourcetable}  \n\tGROUP BY `hour`,sitename,uid,CLIENT,hostname,MAC,account,cached";
    $prefix = "INSERT IGNORE INTO {$daytable} \n\t(`zMD5`,`sitename`,`familysite`,`client`,`hostname`,`uid`,`account`,`hour`,`MAC`,`size`,`hits`) VALUES";
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $zMD5 = md5(serialize($ligne));
        $familysite = $q->GetFamilySites($ligne["sitename"]);
        while (list($key, $val) = each($ligne)) {
            $ligne[$key] = mysql_escape_string2($val);
        }
        $f[] = "('{$zMD5}','{$ligne["sitename"]}','{$familysite}','{$ligne["CLIENT"]}','{$ligne["hostname"]}','{$ligne["uid"]}','{$ligne["account"]}','{$ligne["hour"]}','{$ligne["MAC"]}','{$ligne["size"]}','{$ligne["hits"]}')";
        if (count($f) > 0) {
            $q->QUERY_SQL($prefix . @implode(",", $f));
            $f = array();
        }
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        $f = array();
    }
    $sql = "SELECT COUNT(`sitename`) as tcount FROM {$daytable} WHERE LENGTH(`category`)=0";
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . "\n";
    }
    $ligne2 = mysql_fetch_array($q->QUERY_SQL($sql));
    $max = $ligne2["tcount"];
    $sql = "UPDATE tables_day SET `not_categorized`={$max} WHERE tablename='{$sourcetable}'";
    $q->QUERY_SQL($sql);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:34,代码来源:exec.squid.stats.repair.php

示例14: _e

&quot;' href='' rel="<?php 
        echo $Promotion->id;
        ?>
"><?php 
        _e('Delete', 'Shopp');
        ?>
</a></span>
				</div>				
				
			</td>
			<td class="discount column-discount<?php 
        echo in_array('discount', $hidden) ? ' hidden' : '';
        ?>
"><?php 
        if ($Promotion->type == "Percentage Off") {
            echo percentage($Promotion->discount);
        }
        if ($Promotion->type == "Amount Off") {
            echo money($Promotion->discount);
        }
        if ($Promotion->type == "Free Shipping") {
            echo $this->Settings->get("free_shipping_text");
        }
        if ($Promotion->type == "Buy X Get Y Free") {
            echo __('Buy', 'Shopp') . ' ' . $Promotion->buyqty . ' ' . __('Get', 'Shopp') . ' ' . $Promotion->getqty . ' ' . __('Free', 'Shopp');
        }
        ?>
</td>
			<td class="applied column-applied<?php 
        echo in_array('applied', $hidden) ? ' hidden' : '';
        ?>
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:31,代码来源:promotions.php

示例15: sync_categories

function sync_categories()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    $unix = new unix();
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Already executed pid {$pid}\n";
        }
        return;
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $sql = "SELECT * FROM visited_sites WHERE sitename LIKE 'www.%'";
    $results = $GLOBALS["Q"]->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $website = trim($ligne["sitename"]);
        if (preg_match("#^www\\.(.+)#", $website, $re)) {
            $ligne2 = mysql_fetch_array($GLOBALS["Q"]->QUERY_SQL("SELECT sitename FROM visited_sites WHERE sitename='{$re[1]}'"));
            if ($ligne2["sitename"] != null) {
                $GLOBALS["Q"]->QUERY_SQL("DELETE FROM visited_sites WHERE sitename='{$website}'");
            } else {
                $GLOBALS["Q"]->QUERY_SQL("UPDATE visited_sites SET sitename='{$re[1]}' WHERE sitename='{$ligne["sitename"]}'");
            }
            $GLOBALS["Q"]->UPDATE_WEBSITES_TABLES($ligne["sitename"], $re[1]);
        }
    }
    $sql = "SELECT sitename FROM visited_sites WHERE LENGTH(category)=0 ORDER BY Querysize DESC LIMIT 0,500";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$sql}\n";
    }
    $results = $GLOBALS["Q"]->QUERY_SQL($sql);
    if (!$GLOBALS["Q"]->ok) {
        ufdbguard_admin_events("Starting analyzing not categorized websites Failed " . $GLOBALS["Q"]->mysql_error, __FUNCTION__, __FILE__, __LINE__, "stats");
        return;
    }
    $num_rows = mysql_num_rows($results);
    $t = time();
    if ($num_rows == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No datas " . __FUNCTION__ . " " . __LINE__ . "\n";
        }
        return;
    }
    stats_admin_events(0, "Starting analyzing {$num_rows} not categorized websites", null, __FILE__, __LINE__);
    $c = 0;
    $d = 0;
    $CATZP = 0;
    $TTIME = 0;
    $NOTCATZ = array();
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $website = trim($ligne["sitename"]);
        $category = null;
        if ($website == null) {
            continue;
        }
        $t2 = time();
        $c++;
        $d++;
        $TTIME++;
        if ($d > 1000) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Analyzed {$c} websites\n";
                $d = 0;
            }
        }
        percentage("{$c}/{$num_rows} {$ligne["sitename"]}", 49);
        $category = $GLOBALS["Q"]->GET_CATEGORIES($website, true);
        if (trim($category) != null) {
            $CATZP++;
            $took = $unix->distanceOfTimeInWords($t2, time());
            $GLOBALS["Q"]->UPDATE_CATEGORIES_TABLES($website, $category);
            if ($GLOBALS["VERBOSE"]) {
                echo "UPDATE_CATEGORIES_TABLES DONE..\n";
            }
            $GLOBALS["Q"]->QUERY_SQL("UPDATE visited_sites SET category='{$category}' WHERE sitename='{$website}'");
            if (!$GLOBALS["Q"]->ok) {
                stats_admin_events(0, "Fatal error while update visited_sites", $GLOBALS["Q"]->mysql_error, __FILE__, __LINE__);
            }
        } else {
            $NOTCATZ[] = $website;
        }
        if ($TTIME > 10) {
            if (SquidStatisticsTasksOverTime()) {
                stats_admin_events(1, "Statistics overtime... Aborting", null, __FILE__, __LINE__);
                return;
            }
        }
    }
    if ($CATZP > 0) {
        $took = $unix->distanceOfTimeInWords($t, time());
        stats_admin_events(2, "{$CATZP} new categorized website task:finish ({$took})", null, __FILE__, __LINE__);
    }
    if (count($NOTCATZ) > 0) {
        stats_admin_events(1, count($NOTCATZ) . " unknown websites", @implode("\n", $NOTCATZ), __FILE__, __LINE__);
    }
    $unix = new unix();
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.stats.php


注:本文中的percentage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。