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


PHP populate函数代码示例

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


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

示例1: FormatAlertTpl

/**
 * Format Alert
 * @param string $tpl Template
 * @param array  $obj Alert-Array
 * @return string
 */
function FormatAlertTpl($tpl, $obj)
{
    $msg = '$ret .= "' . str_replace(array('{else}', '{/if}', '{/foreach}'), array('"; } else { $ret .= "', '"; } $ret .= "', '"; } $ret .= "'), addslashes($tpl)) . '";';
    $parsed = $msg;
    $s = strlen($msg);
    $x = $pos = -1;
    $buff = '';
    $if = $for = false;
    while (++$x < $s) {
        if ($msg[$x] == '{' && $buff == '') {
            $buff .= $msg[$x];
        } else {
            if ($buff == '{ ') {
                $buff = '';
            } else {
                if ($buff != '') {
                    $buff .= $msg[$x];
                }
            }
        }
        if ($buff == '{if') {
            $pos = $x;
            $if = true;
        } else {
            if ($buff == '{foreach') {
                $pos = $x;
                $for = true;
            }
        }
        if ($pos != -1 && $msg[$x] == '}') {
            $orig = $buff;
            $buff = '';
            $pos = -1;
            if ($if) {
                $if = false;
                $o = 3;
                $native = array('"; if( ', ' ) { $ret .= "');
            } else {
                if ($for) {
                    $for = false;
                    $o = 8;
                    $native = array('"; foreach( ', ' as $key=>$value) { $ret .= "');
                } else {
                    continue;
                }
            }
            $cond = trim(populate(substr($orig, $o, -1), false));
            $native = $native[0] . $cond . $native[1];
            $parsed = str_replace($orig, $native, $parsed);
            unset($cond, $o, $orig, $native);
        }
        //end if
    }
    //end while
    $parsed = populate($parsed);
    return RunJail($parsed, $obj);
}
开发者ID:Operasoft,项目名称:librenms,代码行数:63,代码来源:alerts.php

示例2: renderPage


//.........这里部分代码省略.........
            }
        }
        // Pages must be in a subpages node, thus we should bail here
        if ($scope->nodeName == "page") {
            $scope = $scope->parentNode;
            continue;
        }
        // Trace current path
        $path = "";
        $ptr = $scope;
        $subdepth = 0;
        while ($ptr->nodeName != "site") {
            if ($ptr->getAttribute("link")) {
                $path = (string) $ptr->getAttribute("link") . "/" . $path;
            }
            $ptr = $ptr->parentNode;
        }
        $path = $basepath . $path;
        //str_repeat("../",($depth-1)/2).$path;
        // Calculated how many "sub"s to add to this set of links (TODO: fix up this grossness)
        $prefix = str_repeat("sub", (2 * count($sections) - 1 - $i) / 2 + $offset);
        // Add all pages to sublinks
        $menu_links = $xml->createElement($prefix . "links");
        // Extract the links
        $query = $xml_xpath->query("page", $scope);
        foreach ($query as $page) {
            $link = (string) $page->getAttribute("link");
            $name = (string) $page->getAttribute("name");
            $links[] = $path . $link;
            // If they're not hidden, link them
            if ($page->getAttribute("hidden") != "true") {
                $ref = $page->getAttribute("ref");
                $link_node = $xml->createElement("a");
                $link_href = $xml->createAttribute("href");
                $link_href->appendChild($xml->createTextNode($ref ? $ref : $path . $link));
                $link_node->appendChild($link_href);
                $link_node->appendChild($xml->createTextNode($name ? $name : $link));
                if (in_array($link, $path_elements)) {
                    $link_style = $xml->createAttribute("class");
                    $link_style->appendChild($xml->createTextNode("selected"));
                    $link_node->appendChild($link_style);
                }
                $menu_links->appendChild($link_node);
                $menu_links->appendChild($xml->createTextNode(" "));
            }
        }
        $variables[$prefix . "links"] = $menu_links;
        // Pop to parent
        $scope = $scope->parentNode;
    }
    // Build the all encompassing breadcrum
    $path = "path";
    $breadcrumb = $xml->createElement("breadcrumb");
    while ($variables[$path]) {
        $container = $xml->createElement("div");
        $source = $variables[$path];
        foreach ($source->childNodes as $child) {
            $container->appendChild($child->cloneNode(TRUE));
        }
        $breadcrumb->appendChild($container);
        $path = "sub" . $path;
    }
    $variables["breadcrumb"] = $breadcrumb;
    // Build the all encompassing links_list
    $path = "links";
    $alllinks = $xml->createElement("alllinks");
    while ($variables[$path]) {
        $container = $xml->createElement("div");
        $source = $variables[$path];
        foreach ($source->childNodes as $child) {
            $container->appendChild($child->cloneNode(TRUE));
        }
        $alllinks->appendChild($container);
        $path = "sub" . $path;
    }
    $variables["alllinks"] = $alllinks;
    // Set the title
    $site_title = $xml->documentElement->getAttribute('title');
    $page_title = $requested_page->getAttribute('title');
    $html_xpath->query("/html/head/title")->item(0)->nodeValue = $site_title . ' ' . $page_title;
    // Set the css
    $css = $html->createElement("link");
    $css_href = $html->createAttribute("href");
    $subpath = $xml->documentElement->getAttribute('css');
    $css_href->appendChild($html->createTextNode(($subpath[0] == '/' ? "" : $basepath) . $subpath));
    $css_rel = $html->createAttribute("rel");
    $css_rel->appendChild($html->createTextNode("stylesheet"));
    $css_type = $html->createAttribute("type");
    $css_type->appendChild($html->createTextNode("text/css"));
    $css->appendChild($css_href);
    $css->appendChild($css_rel);
    $css->appendChild($css_type);
    $html_xpath->query("/html/head")->item(0)->appendChild($css);
    //print_r($variables);
    //print_r($links);
    // Substitute all the IDs in the html with the corresponding page elements
    $path = rtrim($pagename, "/") . "/";
    populate($html, $variables, $links, $path, $basepath, !$rw);
    return $html->saveHTML();
}
开发者ID:newhouseb,项目名称:SWS,代码行数:101,代码来源:library.php

示例3: mysql_query

     }
     $re = mysql_query("SELECT id_category, lang_code, text_name, text_desc\r\n\t\t\tFROM learning_competence_category_text\r\n\t\t\tWHERE 1");
     while (list($id_cat, $lang_code, $name, $description) = mysql_fetch_row($re)) {
         mysql_query("INSERT INTO learning_competence_category_lang\r\n\t\t\t\tVALUES (" . $id_category . ", '" . $lang_code . "', '" . $name . "', '" . $description . "')");
     }
     $re = mysql_query("SELECT id_category, lang_code, text_name, text_desc\r\n\t\t\tFROM learning_competence_text\r\n\t\t\tWHERE 1");
     while (list($id_cat, $lang_code, $name, $description) = mysql_fetch_row($re)) {
         mysql_query("INSERT INTO learning_competence_lang\r\n\t\t\t\tVALUES (" . $id_category . ", '" . $lang_code . "', '" . $name . "', '" . $description . "')");
     }
     break;
 case "4":
     // --- Upgrade trees (ileft / iright) ----------------------------
     $GLOBALS['tree_st'] = '';
     $tables = array('core_org_chart_tree' => 'idOrg', 'learning_category' => 'idCategory');
     foreach ($tables as $tab => $p_key) {
         populate($tab, $p_key);
     }
     break;
 case "5":
     // --- Upgrade settings table ------------------------------------
     updateSettings();
     break;
 case "6":
     // --- Adding god admins and all users roles ---------------------
     addUpgraderRoles();
     break;
 case "7":
     // --- Remove old photo ------------------------------------------
     $db = mysql_connect($_SESSION['db_info']['db_host'], $_SESSION['db_info']['db_user'], $_SESSION['db_info']['db_pass']);
     mysql_select_db($_SESSION['db_info']['db_name']);
     $query = "SELECT photo" . " FROM core_user" . " WHERE avatar <> ''" . " AND photo <> ''";
开发者ID:abhinay100,项目名称:forma_app,代码行数:31,代码来源:upg_step.php

示例4: main

function main()
{
    global $debug;
    global $DEFAULT_DEPTHS;
    if ($debug) {
        printf("Garbage Collector Test\n");
        printf("Stretching memory with a binary tree of depth %d\n", kStretchTreeDepth);
    }
    $t_start = microtime(true);
    $temp_tree = make_tree(kStretchTreeDepth);
    if ($debug) {
        printf(" Creating a long-lived binary tree of depth %d\n", kLongLivedTreeDepth);
    }
    $long_lived_tree = new Node();
    populate(kLongLivedTreeDepth, $long_lived_tree);
    if ($debug) {
        printf(" Creating a long-lived array of %d doubles\n", kArraySize);
    }
    $long_lived_array = array(0.0);
    for ($i = 1; $i < kArraySize; $i++) {
        $long_lived_array[] = 1 / $i;
    }
    time_constructions($DEFAULT_DEPTHS, $debug);
    $t_finish = microtime(true);
    return $t_finish - $t_start;
}
开发者ID:jemmy655,项目名称:hippyvm,代码行数:26,代码来源:gcbench.php

示例5: dar_mount_1

if(isset($_GET["dar-list"])){dar_list();exit;}
if(isset($_GET["dar-list-index"])){dar_list_type();exit;}
if(isset($_GET["dar-list-query"])){dar_list_query();exit;}


if(isset($_GET["dar-browse"])){dar_browse();exit;}

if(isset($_GET["schedule"])){schedule();exit;}
if(isset($_GET["RefreshCache"])){RefreshCache();exit;}
if(isset($_GET["perform-backup"])){run_backup_js();exit;}

if(isset($_GET["restore-full"])){retore_full_mode();exit;}
if(isset($_GET["restore-single-file"])){restore_single_file();exit;}
if(isset($_GET["original_path"])){restore_full_mode_exec();exit;}
if(isset($_GET["original_file_path"])){restore_single_mode_exec();exit;}
if(isset($_GET["populate"])){populate();exit;}


function dar_mount_1(){
	$html="<div id='mounted_logs_1'></div>";
	echo $html;
	}
	
	
function run_backup_js(){
	
	$tpl=new templates();
	$page=CurrentPageName();
	$confirm=$tpl->_ENGINE_parse_body('{error_want_operation}');
	
	$html="
开发者ID:rsd,项目名称:artica-1.5,代码行数:31,代码来源:dar.index.php

示例6: while

    <tr>
      <th>First Name</th><th>Last Name</th><th>Class</th><th>IQ</th>
    </tr>
  </thead>
  <tbody>
  <?php 
while ($row = mysqli_fetch_assoc($result)) {
    echo "<tr><td>" . $row['firstName'] . "</td><td>" . $row['lastName'] . "</td><td>" . $row['Class'] . "</td><td>" . $row['IQ'] . "</td></tr>";
}
?>
  </table>
  <hr><?php 
$query = "SELECT * FROM QuizQuestion";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) == 0) {
    populate($connection);
} else {
    echo "Database already populated";
}
?>
  <hr>
  <h2>Number of Participating Schools</h2>
  
<?php 
$query = "SELECT * FROM SchoolCount ;";
$result = mysqli_query($connection, $query);
$quer = "SELECT Count(*) AS 'Cnt' FROM SchoolCount ;";
$rest = mysqli_query($connection, $quer);
?>
<table cellpadding='5px' >
<thead>
开发者ID:jflash49,项目名称:capstone-funq,代码行数:31,代码来源:connect.php

示例7: mysql_query

    $result = mysql_query($query, $session->fDbInfo);
    if (!$result) {
        echo "<p>+++ DB {$db_name} nicht erzeugt: " . htmlentities(mysql_error()) . "</p>\n";
    } else {
        echo "<p>DB {$db_name} wurde erzeugt</p>\n";
        $db_status = checkDB($session);
    }
}
if ($table_status = checkTableStatus($db_status, $tables_exist)) {
    echo "<p>{$table_status}</p>\n";
}
if (isset($db_overwrite)) {
    echo "db_overwrite: {$db_overwrite}<br/>\n";
}
if (isset($db_populate) && (!isset($db_overwrite) || $db_overwrite == "J")) {
    populate($session, $file);
} else {
    echo "<form name=\"form\" action=\"install.php\" method=\"post\">\n";
    echo '<table><tr><td>MySQL-Server</td><td>';
    guiTextField('db_server', $db_server, 16, 0);
    echo "</td></tr>\n<tr><td>Datenbank</td><td>";
    guiTextField('db_name', $db_name, 16, 0);
    echo "</td></tr>\n<tr><td>Benutzer</td><td>";
    guiTextField('db_user', $db_user, 16, 0);
    echo "</td></tr>\n<tr><td>Passwort</td><td>";
    guiTextField('db_passw', $db_passw, 16, 0);
    echo "</td></tr>\n<tr><td>Tabellenvorspann</td><td>";
    guiTextField('db_prefix', $db_prefix, 16, 0);
    echo "</td></tr>\n<tr><td>";
    if ($sql_exists) {
        if ($tables_exist) {
开发者ID:BackupTheBerlios,项目名称:infobasar,代码行数:31,代码来源:install.php

示例8: DescribeAlert

/**
 * Describe Alert
 * @param array $alert Alert-Result from DB
 * @return array
 */
function DescribeAlert($alert)
{
    $obj = array();
    $i = 0;
    $device = dbFetchRow('SELECT hostname FROM devices WHERE device_id = ?', array($alert['device_id']));
    $tpl = dbFetchRow('SELECT `template`,`title`,`title_rec` FROM `alert_templates` JOIN `alert_template_map` ON `alert_template_map`.`alert_templates_id`=`alert_templates`.`id` WHERE `alert_template_map`.`alert_rule_id`=?', array($alert['rule_id']));
    $default_tpl = "%title\r\nSeverity: %severity\r\n{if %state == 0}Time elapsed: %elapsed\r\n{/if}Timestamp: %timestamp\r\nUnique-ID: %uid\r\nRule: {if %name}%name{else}%rule{/if}\r\n{if %faults}Faults:\r\n{foreach %faults}  #%key: %value.string\r\n{/foreach}{/if}Alert sent to: {foreach %contacts}%value <%key> {/foreach}";
    $obj['hostname'] = $device['hostname'];
    $obj['device_id'] = $alert['device_id'];
    $extra = $alert['details'];
    if (!isset($tpl['template'])) {
        $obj['template'] = $default_tpl;
    } else {
        $obj['template'] = $tpl['template'];
    }
    if ($alert['state'] >= 1) {
        if (!empty($tpl['title'])) {
            $obj['title'] = $tpl['title'];
        } else {
            $obj['title'] = 'Alert for device ' . $device['hostname'] . ' - ' . ($alert['name'] ? $alert['name'] : $alert['rule']);
        }
        if ($alert['state'] == 2) {
            $obj['title'] .= ' got acknowledged';
        } elseif ($alert['state'] == 3) {
            $obj['title'] .= ' got worse';
        } elseif ($alert['state'] == 4) {
            $obj['title'] .= ' got better';
        }
        foreach ($extra['rule'] as $incident) {
            $i++;
            $obj['faults'][$i] = $incident;
            foreach ($incident as $k => $v) {
                if (!empty($v) && $k != 'device_id' && (stristr($k, 'id') || stristr($k, 'desc') || stristr($k, 'msg')) && substr_count($k, '_') <= 1) {
                    $obj['faults'][$i]['string'] .= $k . ' => ' . $v . '; ';
                }
            }
        }
        $obj['elapsed'] = TimeFormat(time() - strtotime($alert['time_logged']));
        if (!empty($extra['diff'])) {
            $obj['diff'] = $extra['diff'];
        }
    } elseif ($alert['state'] == 0) {
        $id = dbFetchRow('SELECT alert_log.id,alert_log.time_logged,alert_log.details FROM alert_log WHERE alert_log.state != 2 && alert_log.state != 0 && alert_log.rule_id = ? && alert_log.device_id = ? && alert_log.id < ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'], $alert['id']));
        if (empty($id['id'])) {
            return false;
        }
        $extra = json_decode(gzuncompress($id['details']), true);
        if (!empty($tpl['title_rec'])) {
            $obj['title'] = $tpl['title_rec'];
        } else {
            $obj['title'] = 'Device ' . $device['hostname'] . ' recovered from ' . ($alert['name'] ? $alert['name'] : $alert['rule']);
        }
        $obj['elapsed'] = TimeFormat(strtotime($alert['time_logged']) - strtotime($id['time_logged']));
        $obj['id'] = $id['id'];
        $obj['faults'] = false;
    } else {
        return 'Unknown State';
    }
    //end if
    $obj['uid'] = $alert['id'];
    $obj['severity'] = $alert['severity'];
    $obj['rule'] = $alert['rule'];
    $obj['name'] = $alert['name'];
    $obj['timestamp'] = $alert['time_logged'];
    $obj['contacts'] = $extra['contacts'];
    $obj['state'] = $alert['state'];
    if (strstr($obj['title'], '%')) {
        $obj['title'] = RunJail('$ret = "' . populate(addslashes($obj['title'])) . '";', $obj);
    }
    return $obj;
}
开发者ID:HenocKA,项目名称:librenms,代码行数:76,代码来源:alerts.php

示例9: foreach

    //	var_dump($rolesPermissions);
    // Right now if we get two different answers from different chains, then the result is not gaurenteed.
    // Aka: Dont have ambiguous ACL trees
    foreach ($permissions as $name => $values) {
        if (!isset($rolesPermissions[$name])) {
            $rolesPermissions[$name] = array();
        }
        foreach ($values as $key => $value) {
            $rolesPermissions[$name][$key] = $value;
        }
    }
    return $rolesPermissions;
    //echo "\n";
    //	var_dump($rolesPermissions);
    //	echo "\n\n\n";
    //return $permissions;
}
function can($permissions, $name, $value)
{
    if (isset($permissions[$name][$value])) {
        return $permissions[$name][$value];
    } else {
        return false;
    }
}
$permissions = populate(4);
var_dump($permissions);
$value = can($permissions, "Article1", "Edit");
var_dump($value);
?>
</pre>
开发者ID:TheSavior,项目名称:WhiteBoard,代码行数:31,代码来源:ACLTest.php

示例10: instDBAnswer

function instDBAnswer(&$session)
{
    global $inst_populate;
    $session->trace(TC_Init, 'instDBAnswer');
    $message = '';
    if (isset($inst_populate)) {
        $message = populate($session, instGetSqlFile($session));
    }
    instDB($session, $message);
}
开发者ID:BackupTheBerlios,项目名称:infobasar,代码行数:10,代码来源:install.php

示例11: form_error

					<strong><?php 
    echo form_error('section[]');
    ?>
</strong>
					</p>
				</td>
				<td>
					<p><strong>Тип тура:</strong></p><br>
					<?php 
    foreach ($type_tours_list as $item) {
        ?>
						<input type = "checkbox" name = "section[]" value = <?php 
        echo $item['section_id'];
        ?>
 <?php 
        echo populate($material_id, $names, $item['section_id']);
        echo set_checkbox('section[]', $item['section_id']);
        ?>
><?php 
        echo $item['title'];
        ?>
&nbsp;(<?php 
        echo $item['section_id'];
        ?>
)<br>
					<?php 
    }
    ?>
				</td>
			</tr>
		</table>
开发者ID:vskrip,项目名称:abclass,代码行数:31,代码来源:edit_view.php

示例12: file_get_contents

}
$query = "select * from stats where s_id={$s_id}";
$result = $conn->query($query);
if ($result->num_rows == 0) {
    $json = file_get_contents("https://na.api.pvp.net/api/lol/na/v2.2/matchlist/by-summoner/{$s_id}?seasons=PRESEASON2016&api_key=9073dedb-d0e0-43db-8557-9ae31bf7967e");
    $obj = json_decode($json, TRUE);
    if ($obj["totalGames"] == 0) {
        header("Location: stats.php");
        $conn->close();
        die;
    }
    for ($i = 0; $i < 10; $i++) {
        $matchid = $obj["matches"][$i]["matchId"];
        $championid = $obj["matches"][$i]["champion"];
        $timestamp = $obj["matches"][$i]["timestamp"];
        populate($matchid, $timestamp, $championid, $s_id);
        // 1 API request per a call.
        sleep(1.5);
    }
    $query = "select * from wins\n                    where wins.s_id = {$s_id}\n                    union\n                    select * from losses\n                    where losses.s_id = {$s_id}\n                    order by timestamp desc";
    $results = $conn->query($query);
    $numrows = $results->num_rows;
    $latest_timestamp = 0;
    $kills = 0;
    $deaths = 0;
    $assists = 0;
    $gold = 0;
    $cs = 0;
    $resultrow = $results->fetch_assoc();
    $latest_timestamp = $resultrow["timestamp"];
    $kills = $resultrow["kills"];
开发者ID:jlarobello,项目名称:League-Stats,代码行数:31,代码来源:populate.php

示例13: util_getRequestParameter

$jsonMeanings = util_getRequestParameter('jsonMeanings');
// LexemModel parameters (arrays)
$modelType = util_getRequestParameter('modelType');
$modelNumber = util_getRequestParameter('modelNumber');
$restriction = util_getRequestParameter('restriction');
$sourceIds = util_getRequestParameter('lexemSourceIds');
$lmTags = util_getRequestParameter('lmTags');
$isLoc = util_getRequestParameter('isLoc');
// Button parameters
$refreshLexem = util_getRequestParameter('refreshLexem');
$saveLexem = util_getRequestParameter('saveLexem');
$lexem = Lexem::get_by_id($lexemId);
$original = Lexem::get_by_id($lexemId);
// Keep a copy so we can test whether certain fields have changed
if ($refreshLexem || $saveLexem) {
    populate($lexem, $original, $lexemForm, $lexemNumber, $lexemDescription, $lexemComment, $needsAccent, $hyphenations, $pronunciations, $variantOfId, $structStatus, $modelType, $modelNumber, $restriction, $lmTags, $isLoc, $sourceIds);
    $meanings = json_decode($jsonMeanings);
    if (validate($lexem, $original, $variantIds, $meanings)) {
        // Case 1: Validation passed
        if ($saveLexem) {
            if ($original->hasModelType('VT') && !$lexem->hasModelType('VT')) {
                $original->deleteParticiple();
            }
            if (($original->hasModelType('VT') || $original->hasModelType('V')) && (!$lexem->hasModelType('VT') && !$lexem->hasModelType('V'))) {
                $original->deleteLongInfinitive();
            }
            foreach ($original->getLexemModels() as $lm) {
                $lm->delete();
                // This will also delete LexemSources and InflectedForms
            }
            $lexem->deepSave();
开发者ID:florinp,项目名称:dexonline,代码行数:31,代码来源:lexemEdit.php

示例14: verify

function verify($s_name, $s_id2)
{
    // Start session
    session_start();
    // For MySQL
    $servername = 'localhost';
    $username = 'jlarobello';
    $password = 'Ics321808';
    $dbname = 'leaguestats';
    // Establish connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_error) {
        $conn->close();
        die("Connection failed: " . $conn->connect_error);
    }
    $s_id = 0;
    $url = 'https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/' . rawurlencode($s_name) . '?api_key=9073dedb-d0e0-43db-8557-9ae31bf7967e';
    $json = file_get_contents($url);
    $obj = json_decode($json, true);
    if (empty($obj)) {
        $s_id = -1;
    } else {
        $temp = preg_replace('/\\s/', '', $s_name);
        $temp = strtolower($temp);
        $s_id = $obj[$temp]['id'];
        if ($s_id == $s_id2) {
            return -1;
        }
        $query = "select latest_timestamp from stats where s_id = {$s_id}";
        $result = $conn->query($query);
        $resultrow = $result->fetch_assoc();
        $json = file_get_contents("https://na.api.pvp.net/api/lol/na/v2.2/matchlist/by-summoner/{$s_id}?seasons=PRESEASON2016&api_key=9073dedb-d0e0-43db-8557-9ae31bf7967e");
        $obj = json_decode($json, TRUE);
        $timestamp = $obj["matches"][0]["timestamp"];
        if ($obj["totalGames"] == 0) {
            return 1;
        }
        if ($result->num_rows > 0 && $timestamp > $resultrow["latest_timestamp"] && !empty($obj)) {
            repopulate($obj, $s_id);
        } else {
            if ($result->num_rows == 0) {
                for ($i = 0; $i < 10; $i++) {
                    $matchid = $obj["matches"][$i]["matchId"];
                    $championid = $obj["matches"][$i]["champion"];
                    $timestamp = $obj["matches"][$i]["timestamp"];
                    populate($matchid, $timestamp, $championid, $s_id);
                    // 1 API request per a call.
                    sleep(1.5);
                }
                $query = "select * from wins\n                            where wins.s_id = {$s_id}\n                            union\n                            select * from losses\n                            where losses.s_id = {$s_id}\n                            order by timestamp desc";
                $results = $conn->query($query);
                $numrows = $results->num_rows;
                $latest_timestamp = 0;
                $kills = 0;
                $deaths = 0;
                $assists = 0;
                $gold = 0;
                $cs = 0;
                $resultrow = $results->fetch_assoc();
                $latest_timestamp = $resultrow["timestamp"];
                $kills = $resultrow["kills"];
                $deaths = $resultrow["deaths"];
                $assists = $resultrow["assists"];
                $gold = $resultrow["gold"];
                $cs = $resultrow["cs"];
                while ($resultrow = $results->fetch_assoc()) {
                    $kills += $resultrow["kills"];
                    $deaths += $resultrow["deaths"];
                    $assists += $resultrow["assists"];
                    $gold += $resultrow["gold"];
                    $cs += $resultrow["cs"];
                }
                $kills /= $numrows;
                $deaths /= $numrows;
                $assists /= $numrows;
                $gold /= $numrows;
                $cs /= $numrows;
                // Average stats
                $query = "insert into stats(s_id, latest_timestamp, kills, deaths, assists, gold, cs) \n                           values({$s_id}, {$latest_timestamp}, {$kills}, {$deaths}, {$assists}, {$gold}, {$cs})";
                $result = $conn->query($query);
                $conn->close();
            }
        }
    }
    return $s_id;
}
开发者ID:jlarobello,项目名称:League-Stats,代码行数:86,代码来源:helpers.php

示例15: foreach

{
    foreach ($listacibi as $cibo => $ingredienti) {
        if (strpos($ingredienti, $key) !== false) {
            echo "'" . $key . "' presente in: '" . htmlentities($cibo) . "' ({$ingredienti})";
            echo "<br />";
        }
    }
}
//////VIEW/////
?>

<html>
	<form method="POST">
		<select name="cibo">
			Inserisci la chiave da cercare:
			<?php 
populate($cibieingredienti);
?>
		
		</select>
	<input type="submit" value="Cerca" />
	</form>
	<br />
	<br />
	<?php 
if (isset($_POST["cibo"])) {
    search($cibieingredienti, $_POST["cibo"]);
}
?>
</html>
开发者ID:shadaki85,项目名称:PHPTests,代码行数:30,代码来源:cibi.php


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