function main($server_cfg) { $options = get_options($server_cfg); foreach ($options['games'] as $game) { zpm_preamble($game); $game_cfg = load_game_config($game); if (!$game_cfg) { error_log("Daily job: Failed to load config for {$game}\n", 3, sprintf($server_cfg['log_file'], $game)); continue; } // log_file and logger object are used by all child functions. $game_cfg['log_file'] = sprintf($server_cfg['log_file'], $game); $game_cfg['logger'] = new Logger($server_cfg, $game_cfg); $job = $options['job']; //instance detail report per game if ($job == "both" or $job == "report") { InstanceReport::generate_detail_report($server_cfg, $game_cfg, $options['timeslot'], $options['period']); } zpm_postamble($game); } //instance summary report for all games $job = $options['job']; if ($job == "both" or $job == "report") { InstanceReport::generate_summary_report($server_cfg, $options['timeslot'], $options['period']); } }
function main($server_cfg) { $options = get_options($server_cfg); foreach ($options['games'] as $game) { zpm_preamble($game); $game_cfg = load_game_config($game); if (!$game_cfg) { error_log("Daily job: Failed to load config for {$game}\n", 3, sprintf($server_cfg['log_file'], $game)); continue; } // log_file and logger object are used by all child functions. $game_cfg['log_file'] = sprintf($server_cfg['log_file'], $game); $game_cfg['logger'] = new Logger($server_cfg, $game_cfg); $job = $options['job']; if ($job == "both" or $job == "daily") { process_daily($server_cfg, $game_cfg, $options['timeslot'], $options['period']); } //performance report /* if ($job == "both" or $job == "report") { generate_report($server_cfg, $game_cfg, $options['timeslot'], $options['period']); }*/ zpm_postamble($game); } }
function main($server_cfg) { $options = get_options(); if (isset($options['g']) && $options['g'] !== '') { $game_names = explode(",", $options['g']); } else { $game_names = $server_cfg['game_list']; } foreach ($game_names as $game) { zpm_preamble($game); $game_cfg = load_game_config($game); $retval = null; // refs will start failing in 5.3.x if not declared $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null "; $output = system($cleanup, $retval); if ($retval != 0) { error_log("Couldn`t cleanup game {$game}", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } $arrays_to_id = get_array_id_map($server_cfg, $game_cfg); foreach ($arrays_to_id as $array => $id) { $game_cfg = load_game_config($game, $id); $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null "; $output = system($cleanup, $retval); if ($retval != 0) { error_log("Couldn`t cleanup game {$game}", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } } zpm_postamble($game); } }
function admin_server() { global $db; $tpl = new smarty(); $db->query('SELECT `ID`, `verwendung`, `intervall`, `betrag`, `nextbuch` FROM ' . DB_PRE . 'ecp_clankasse_auto'); $auto = array(); while ($row = $db->fetch_assoc()) { $row['nextbuch'] = date(LONG_DATE, $row['nextbuch']); $row['betrag'] = number_format($row['betrag'], 2, ',', '.'); $auto[] = $row; } $tpl->assign('auto', $auto); ob_start(); $tpl->display(DESIGN . '/tpl/admin/clankasse_auto_overview.html'); $content = ob_get_contents(); ob_end_clean(); $tpl->assign('overview', $content); $db->query('SELECT a.*, b.username FROM ' . DB_PRE . 'ecp_clankasse_transaktion as a LEFT JOIN ' . DB_PRE . 'ecp_user as b ON b.ID = vonuser ORDER BY datum DESC'); $buchung = array(); while ($row = $db->fetch_assoc()) { $row['datum'] = date(LONG_DATE, $row['datum']); if ($row['vonuser']) { $row['verwendung'] .= ' ' . FROM . ' ' . $row['username']; } $row['geld'] = number_format($row['geld'], 2, ',', '.'); $buchung[] = $row; } $tpl->assign('buchung', $buchung); ob_start(); $tpl->display(DESIGN . '/tpl/admin/clankasse_trans_overview.html'); $content = ob_get_contents(); ob_end_clean(); $tpl->assign('buch_overview', $content); $db->query('SELECT username, userID, verwendung, monatgeld FROM ' . DB_PRE . 'ecp_clankasse_member LEFT JOIN ' . DB_PRE . 'ecp_user ON userID = ID ORDER BY username ASC'); $user = array(); while ($row = $db->fetch_assoc()) { $row['geld'] = number_format($row['monatgeld'], 2, ',', '.'); $user[] = $row; } $tpl->assign('user', $user); ob_start(); $tpl->display(DESIGN . '/tpl/admin/clankasse_user_overview.html'); $content = ob_get_contents(); ob_end_clean(); $tpl->assign('user_trans', $content); $konto = $db->fetch_assoc('SELECT * FROM ' . DB_PRE . 'ecp_clankasse'); $konto['kontostand'] = number_format($konto['kontostand'], 2, ',', ''); foreach ($konto as $key => $value) { $tpl->assign($key, $value); } $tpl->assign('options', get_options(date('m'), date('Y'))); ob_start(); $tpl->display(DESIGN . '/tpl/admin/clankasse.html'); $content = ob_get_contents(); ob_end_clean(); main_content(FINANCES, $content, '', 1); }
function get_options($array, $parent = 0, $indent = "") { $return = array(); foreach ($array as $key => $val) { if ($val["parent_category_id"] == $parent) { $return["x" . $val["category_id"]] = $indent . $val["category_name"]; $return = array_merge($return, get_options($array, $val["category_id"], $indent . " ")); } } return $return; }
function common_ticket($vars, $pre) { $options = get_options(); $ticketid = $vars['ticketid']; $userid = $vars['userid']; $user = get_client_info($userid); $ticket = get_ticket_info($ticketid); if (!$user || !$ticket) { return; } $msg = $pre . $ticket['tid'] . ' from ' . $user['lastname'] . ' ' . $user['firstname'] . '(' . $user['email'] . ')'; $url = $options['whmcs_host'] . '/supporttickets.php?action=view&id=' . $ticketid; $attach = [array('title' => $ticket['subject'], 'text' => $url)]; send_mesage($options['channel_tickets'], $msg, $attach); }
/** * Set up our object. * * @param string $path Project root path, should contain composer.json. * @param string $plugin_file Path to the plugin file calling Horme class. */ public function __construct($path, $plugin_file) { $defaults = ['installed' => false, 'path' => '', 'plugins' => []]; $options = get_option(self::OPTION_KEY, $defaults); // Old version... start from scratch. if ('1' === $options['installed']) { delete_option(self::OPTION_KEY); $options = get_options(self::OPTION_KEY, $defaults); } $this->project_path = $path; $this->plugin_file = plugin_basename($plugin_file); $this->installed = $options['installed']; $this->path = $options['path']; $this->plugins = $options['plugins']; $this->prepare_paths_index(); }
function better_excerpt() { $options = get_options(); extract($options); $permalink = get_permalink($post->ID); $text = get_the_content(); $text = preg_replace(" (\\[.*?\\])", '', $text); $text = strip_tags($text); $text = substr($text, 0, $length); $text = substr($text, 0, strripos($text, " ")); $text = trim(preg_replace('/\\s+/', ' ', $text)); $text = stripslashes($before_text) . $text . $ellipsis; if ($link_to_post == 1) { $text = $text . ' <a href="' . $permalink . '">' . $link_text . '</a>'; } $text .= stripslashes($after_text); return $text; }
function validazione_impostazioni_tema($input) { //echo "<pre>"; print_r( $_FILES ); echo "</pre>"; foreach ($_FILES as $image) { // Controllo che sia stato effettivamente inviato un file if ($image['size']) { if (preg_match('/(jpg|jpeg|png|gif)$/i', $image['type'])) { $sovrascrivi = array('test_form' => false); $file = wp_handle_upload($image, $sovrascrivi); $input['logo'] = $file['url']; } else { wp_die('Nessuna immagine e&grave; stata caricata'); } } else { // Questo codice viene lanciato se non viene caricata nessuna immagine $opzioni = get_options('opt_impostazioni_tema'); $input['logo'] = $opzioni['logo']; } } return $input; }
function main($server_cfg) { $options = get_options(); if (isset($options['g']) && $options['g'] !== '') { $game_names = explode(",", $options['g']); } else { $game_names = $server_cfg['game_list']; } foreach ($game_names as $game_name) { zpm_preamble($game_name); try { $game_cfg = load_game_config($game_name); //$game_cfg = $game_cfg[$game_name]; $now = time(); $query_period = $now - 5 * 60; // 5 minutes ago if (isset($game_cfg['splunk_url'])) { $splunk_url = $game_cfg['splunk_url']; $splunk_user = $game_cfg['splunk_user']; $splunk_pass = $game_cfg['splunk_password']; $splunk_queries = $game_cfg['splunk_queries']; $splunk_collector = new SplunkCollector($splunk_url, $splunk_user, $splunk_pass); $splunk_store = new SplunkAdapter($game_cfg); foreach ($splunk_queries as $query_name => $query) { $results = $splunk_collector->run_query($query, $query_period); if (is_array($results)) { $count = $results[0]["count"]; $splunk_store->store_splunk_count($now, $query_name, $count); } else { echo "Could not fetch {$query_name} for {$game_name}\n"; } } } } catch (Exception $e) { } zpm_postamble($game_name); } }
/** * Get all Recursive Relationship into select field options * * @param $f1 = root/parent id * @param $table_name = name of the table * @param $dir = direction of breadcrumbs */ function get_options($f1, $table_name, $dir = 'left') { $frm = ''; $breadcr = '««'; if ($dir == 'right') { $breadcr = '»»'; } $sql = "select id, parent_id, title from {$table_name} where parent_id='{$f1}' order by sort_order"; //echo $sql; $res = mysql_exec($sql); if ($res !== false) { foreach ($res as $k => $v) { if ($v['parent_id'] != 0) { $frm .= '<option value="' . $v['id'] . '">' . get_uppers($v['id'], $table_name, 'right') . '</option>'; } $t1 = get_options($v['id'], $table_name, $dir); if (!empty($t1) && $t1 != '0') { $frm .= $t1; } } //end foreach.... } return $frm; }
function main($server_cfg) { $options = get_options(); if (isset($options['g']) && $options['g'] !== '') { $game_names = explode(",", $options['g']); } else { $game_names = $server_cfg['game_list']; } $time_slots = null; if (!empty($options['t'])) { $time_slots = $options['t']; } $timestamp = $_SERVER['REQUEST_TIME']; $current_time_slot = (int) ($timestamp / (30 * 60)); foreach ($game_names as $game_name) { zpm_preamble($game_name); // MODIFIED!!!! Create and mount next two timeslots !!! $game_cfg = load_game_config($game_name); if (!$game_cfg) { error_log("configuration for " . $game_name . " is not loaded\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } $target_dir = sprintf($server_cfg['root_upload_directory'], $game_cfg["name"]); $target_dir = $target_dir . "/%s/" . $server_cfg["profile_upload_directory"]; $dir_name_array = create_directory($target_dir, $current_time_slot, $server_cfg, $game_cfg); if ($dir_name_array === null) { error_log("Directory creation failed for the game " . $game_cfg['name'], 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } if ($dir_name_array === 0) { error_log("No Ram disk Exist!!!" . $game_cfg['name'], 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } //creating new games and getting the list of web arrays to process data for $rs = new RightScale($server_cfg, load_game_config($game_name)); $rs->make_array_games(); $array_ids = $rs->get_arrays_to_serve(); // // Wrap processing for each game inside a file lock // $game_lock_file = sprintf($server_cfg["zperfmon_lock_file"], $game_name); $game_lock_handle = grab_lock($game_lock_file, $server_cfg, $game_cfg); if (!$game_lock_handle) { error_log("Could not get exclusive lock for \"{$game_name}\"\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); delete_ramdisk_data($game_name, $time_slots, $timestamp, $server_cfg, $game_cfg); continue; } //processing parent game try { // // process uploaded data // run_cron_for_game($server_cfg, $game_cfg, $time_slots); } catch (Exception $e) { error_log("Upload processing for {$game_name} failed\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); error_log("Exception says: " . $e->getMessage() . "\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } // loop to process data for each web array foreach ($array_ids as $array) { try { $game_cfg = load_game_config($game_name, $array); if (!$game_cfg) { error_log("configuration for " . $game_name . " is not loaded\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); continue; } // // process uploaded data // run_cron_for_game($server_cfg, $game_cfg, $time_slots); } catch (Exception $e) { error_log("Upload processing for {$game_name} failed\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); error_log("Exception says: " . $e->getMessage() . "\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } } // compress for parent game // This implementation forces us to always pass a timeslot // while calling this script. otherwise compression will fail. $game_cfg = load_game_config($game_name); compress_unziped_profiles($server_cfg, $game_cfg, $time_slots); // Now compress the array games foreach ($array_ids as $array) { $game_cfg = load_game_config($game_name, $array); compress_unziped_profiles($server_cfg, $game_cfg, $time_slots); } // cleanup the lock drop_lock($game_lock_handle, $game_lock_file); zpm_postamble($game_name); //MODIFIED!!!! if ($dir_name_array != 0) { delete_ramdisk_data($game_name, $time_slots, $timestamp, $server_cfg, $game_cfg); } } }
} print "All time total payout: " . prettySatoshis($everpaid); if ($donated > 0) { print "<BR><FONT SIZE=\"-1\">Total donated Eligius: " . prettySatoshis($donated) . " - <I>Thanks!</I></FONT>"; } print "<BR><BR><HR>"; if ($savedbal) { print "<BR><B>Estimated Position in Payout Queue</B><BR>"; if ($payoutqueue = apc_fetch('wizstats_payoutqueuetxt')) { } else { $payoutqueue = file_get_contents("/var/lib/eligius/{$serverid}/payout_queue.txt"); apc_store('wizstats_payoutqueuetxt', $payoutqueue, 600); } print "<span style=\"font-size: 0.8em\">"; if (strpos($payoutqueue, $givenuser) == false && substr($payoutqueue, 0, strlen($givenuser)) != $givenuser) { $options = get_options($link, $user_id); if (isset($options["Minimum_Payout_BTC"])) { $minpay = $options["Minimum_Payout_BTC"] * 100000000; } else { $minpay = 4194304; } if ($minpay < 1048576) { $minpay = 1048576; } if ($minpay > 2147483648) { $minpay = 2147483648; } $diff = $minpay - $savedbal; if ($diff < 0) { $diff = 0; }
<?php $promoted = get_options('cop_options'); print_r($promoted); echo 'kenny'; ?> <div class="promoted"> <div class="item"> <div class="wrapper"> <img src="<?php echo get_template_directory_uri(); ?> /images/events_125.jpg"> <h3><a href="#">Events Calendar</a></h3> </div> </div> <div class="item"> <div class="wrapper"> <img src="<?php echo get_template_directory_uri(); ?> /images/meetings_125.jpg"> <h3><a href="#">City Meetings</a></h3> </div> </div> <div class="item"> <div class="wrapper"> <img src="<?php echo get_template_directory_uri(); ?> /images/trails_125.jpg">
function main($server_cfg) { $options = get_options(); if (isset($options['g']) && $options['g'] !== '') { $game_names = explode(",", $options['g']); } else { $game_names = $server_cfg['game_list']; } $time_slot = null; if (!empty($options['t'])) { $time_slot = $options['t']; } foreach ($game_names as $game_name) { // Top5 metrics file for this time slot $top5_file = sprintf($server_cfg['top5_file'], $game_name, (string) $time_slot); error_log("top5 file is {$top5_file}\n", 3, sprintf($server_cfg['log_file'], $game_name)); if (file_exists($top5_file)) { $top5 = igbinary_unserialize(file_get_contents($top5_file)); error_log(sprintf("top5 file exists: %d byte\n", filesize($top5_file), 3, sprintf($server_cfg['log_file'], $game_name))); } else { $top5 = array(); error_log("No top5 file\n", 3, sprintf($server_cfg['log_file'], $game_name)); } $output = move_slow_page($server_cfg, $game_name, $time_slot, $top5); error_log(sprintf("in main: top5 list has %d lines\n", count($top5)), 3, sprintf($server_cfg['log_file'], $game_name)); // Dump updated top5 to file file_put_contents($top5_file, igbinary_serialize($top5)); print json_encode($output); } }
function process($data) { global $CFG; $sections = $this->obj->getSectionsInfoAsTeacher(); $options = get_options($sections); $this->notices = array(); foreach ($sections as $id => $section) { $opts = array('non_primary_control' => $this->get_value_or_default($data->{'opt|non_primary_control|' . $id}, 'block_student_gradeviewer_non_primary_control'), 'primary' => $this->get_value_or_default($data->{'opt|primary_instructor|' . $id}, 'cas_reporting_primary'), 'non_primary' => $this->get_value_or_default($data->{'opt|non_primary_instructor|' . $id}, 'cas_reporting_non_primary'), 'student' => $this->get_value_or_default($data->{'opt|student|' . $id}, 'cas_reporting_student')); $option = $options[$id]; $saved_option = null; if (!$option) { $option = new stdClass(); $option->sectionsid = $id; } else { $saved_option = clone $option; } $option->primary_instructor = $opts['primary']; $option->non_primary_instructor = $opts['non_primary']; $option->student = $opts['student']; $option->non_primary_control = $opts['non_primary_control']; $no_control = $this->is_non_primary($option) && !$this->has_control($option); $same = $this->compare($saved_option, $option); if ($no_control or $same) { continue; } $a->section = $this->handle_section($section); $saved_options = array_map(array($this, 'map_options'), array_keys(array_filter($opts, array($this, 'filter_options')))); $a->options = empty($saved_options) ? "No reporting options" : implode(' and ', $saved_options); $code = 'saved'; if (!$this->save_option($option)) { $code = 'error'; } $this->notices[] = get_string('option_' . $code, 'block_student_gradeviewer', $a); } /* foreach($options as $option) { $a->section = $this->handle_section($sections[$option->sectionsid]); $this->notices[] = get_string('option_removed', 'block_student_gradeviewer', $a); } $delete = implode(',', array_map(array($this, 'transform_option'), $options)); delete_records_select('block_teacher_referral_opt', 'id IN ('.$delete .')'); */ }
function get_form($name) { switch (strtolower($name)) { case "deportista": ?> <!--<p> <span>Peso </span><input type="text" name="txtWeight" onkeypress="ValidKey(event,'number','decimal')" /> <span>Altura </span><input type="text" name="txtHeight" onkeypress="ValidKey(event,'number','decimal')" /> </p> <p> <span>Edad </span><input type="text" name="txtAge" onkeypress="ValidKey(event,'number','unsigned')" /> <span>Sexo </span><input type="radio" name="chkSex" value="1" checked="checked" /> Masculino <input type="radio" name="chkSex" value="2" /> Femenino </p>--> <p> <span>Posición/Disciplina </span> <select name="cboPosition"> <?php get_options("list_position"); ?> </select> <span>Categoría </span> <select name="cboCategorySport"> <?php //get_options("list_provinces", "users_club"); ?> </select> <span>Provincia</span> <select name="cboProvince"> <?php get_options("list_provinces", "users_club"); ?> </select> </p> <p> <span>Pierna/Mano Hábil </span> <select name="cboLegHand"> <option value="0">Ambos</option> <option value="1">Derecha</option> <option value="2">Izquierda</option> </select> <span>Nivel </span> <select name="cboLevel"> <option value="0">Todos los Niveles</option> <option value="1">Profesional</option> <option value="2">Amateur</option> <option value="3">Ambos</option> </select> <span>Ciudad</span> <select name="cboCity"> <?php get_options("list_city", "users_club"); ?> </select> </p> <p> <!--PASAPORTE--> <span>Pasaporte</span> <select name="cboPassport"> <option value="0">Todos los Pasaportes</option> <option value="1">Sin pasaporte</option> <option value="2">Comunitario</option> <option value="3">Extra comunitario</option> </select> </p> <p> <!--<input type="checkbox" name="chkConRepr" /><span> Con representante</span><br /> <input type="checkbox" name="chkHisDep" /><span> Con historial deportivo</span><br />--> <input type="checkbox" name="chkMovie" /><span> Con videos</span><br /> <input type="checkbox" name="chkPhoto" /><span> Con fotos</span> </p> <?php break; case "club": ?> <!--PROVINCIAS--> <select name="cboProvince"> <?php get_options("list_provinces", "users_club"); ?> </select> <!--CIUDADES--> <select name="cboCity"> <?php get_options("list_city", "users_club"); ?> </select> <!--CATEGORIA--> <select name="cboCompetitionCategory"> <?php get_options("list_competition_category"); ?> </select> <?php break; case "sponsor": ?> <!--RUBROS--> <select name="cboItem"> <?php get_options("list_items"); ?> </select> <!--PROVINCIAS--> <select name="cboProvince"> <?php get_options("list_provinces", "users_sponsors"); ?> </select> <!--CIUDADES--> <select name="cboCity"> <?php get_options("list_city", "users_sponsors"); ?> </select> <?php break; case "representante": ?> <!--TRABAJO--> <select name="cboWork"> <?php get_options("list_work"); ?> </select> <!--LICENCIA--> <input type="checkbox" name="chkLicence" /><span>Con Licencia </span> <br /><br /> <!--PROVINCIAS--> <select name="cboProvinces"> <?php get_options("list_provinces", "users_representatives"); ?> </select> <!--CIUDADES--> <select name="cboCity"> <?php get_options("list_city", "users_representatives"); ?> </select> <!--NIVEL--> <select name="cboLevel"> <option value="all">Todos los Niveles</option> <option value="1">Profesional</option> <option value="2">Amateur</option> <option value="3">Ambos</option> </select> <?php break; } }
function mytheme_admin() { global $themename, $shortname, $options; $i = 0; if ($_REQUEST['action'] == 'save') { echo '<div id="message" class="updated fade"><p><strong> настройки темы ' . $themename . ' были сохранены</strong></p></div>'; } if ($_REQUEST['reset']) { echo '<div id="message" class="updated fade"><p><strong> настройки темы ' . $themename . ' были сброшены</strong></p></div>'; } ?> <div class="wrap rm_wrap"> <h2>Настройки <?php echo $themename; ?> </h2> <div class="rm_opts"> <form method="post"> <?php foreach ($options as $value) { switch ($value['type']) { case "open": ?> <?php break; case "close": ?> </div> </div> <br /> <?php break; case "title": ?> <p>Для более удобного управления темой <?php echo $themename; ?> , вы можете использовать меню, расположенное ниже</p> <?php break; case "text": ?> <div class="rm_input rm_text"> <label for="<?php echo $value['id']; ?> "> <?php echo $value['name']; ?> </label> <input name="<?php echo $value['id']; ?> " id="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " value="<?php if (get_settings($value['id']) != "") { echo stripslashes(get_settings($value['id'])); } else { echo $value["std"]; } ?> " /> <small><?php echo $value['desc']; ?> </small> <div class="clearfix"></div> </div> <?php break; case "textarea": ?> <div class="rm_input rm_textarea"> <label for="<?php echo $value['id']; ?> "> <?php echo $value['name']; ?> </label> <textarea name="<?php echo $value['id']; ?> " type="<?php echo $value['type']; ?> " > <?php if (get_settings($value['id']) != "") { echo stripslashes(get_settings($value['id'])); } else { echo $value["std"]; } ?> </textarea> <small><?php echo $value['desc']; ?> </small> <div class="clearfix"></div> </div> <?php break; case "select": ?> <div class="rm_input rm_select"> <label for="<?php echo $value['id']; ?> "> <?php echo $value['name']; ?> </label> <select name="<?php echo $value['id']; ?> " id="<?php echo $value['id']; ?> "> <?php foreach ($value['options'] as $option) { ?> <option <?php if (get_settings($value['id']) == $option) { echo "selected=selected"; } ?> > <?php echo $option; ?> </option> <?php } ?> </select> <small><?php echo $value['desc']; ?> </small> <div class="clearfix"></div> </div> <?php break; case "checkbox": ?> <div class="rm_input rm_checkbox"> <label for="<?php echo $value['id']; ?> "> <?php echo $value['name']; ?> </label> <?php if (get_options($value['id'])) { $checked = "checked=\"checked\""; } else { $checked = ""; } ?> <input type="checkbox" name="<?php echo $value['id']; ?> " id="<?php echo $value['id']; ?> " value="true" <?php echo $checked; ?> /> <small><?php echo $value['desc']; ?> </small> <div class="clearfix"></div> </div> <?php break; case "section": $i++; ?> <div class="rm_section"> <div class="rm_title"> <h3> <img src="<?php bloginfo('template_directory'); ?> /functions/images/trans.gif" class="inactive" alt=""/> <?php echo $value['name']; ?> </h3> <span class="submit"> <input name="save<?php echo $i; ?> " type="submit" value="Сохранить" /> </span> <div class="clearfix"></div> </div> <div class="rm_options"> <?php break; } } ?> <input type="hidden" name="action" value="save" /> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" value="Сброс" /> <input name="action" type="hidden" value="reset" /> </p> </form> <div style="font-size:9px; margin-bottom:10px;"> Иконки: <a href="http://www.woothemes.com/2009/09/woofunction/">WooFunction</a> </div> </div> <?php }
$game_config_path = "/etc/zperfmon/"; $per_game_config_path = "/etc/zperfmon/conf.d/"; $core_include = "/var/www/html/zperfmon/include/"; set_include_path(get_include_path() . ":{$game_config_path}:{$per_game_config_path}:{$core_include}"); include_once 'server.cfg'; include_once 'game_config.php'; include_once 'XhProfDAO.php'; function get_options() { $options = array(); $params = getopt("g:t:p:j:"); if (isset($params['g'])) { return $params['g']; } } $game = get_options(); if (!file_exists($per_game_config_path . $game . ".cfg")) { exit(0); } $game_cfg = load_game_config($game); $user = $game_cfg['db_user']; $pass = $game_cfg['db_pass']; $host = $game_cfg['db_host']; $db = 'rightscale'; $deploy_id = $game_cfg['deployIDs'][0]; $XhProfDAO = new XhProfDAO($host, $user, $pass, $db); $XhProfDAO->connect(); $array_id = $XhProfDAO->prepare_and_query('select distinct array_id from instances where deploy_id =' . $deploy_id . ';'); $ids = array(); foreach ($array_id as $id) { array_push($ids, $id['array_id']);
//Bootstrap SPF require 'includes/master.inc.php'; //This loads up $user - $isadmin - $js require 'includes/user.inc.php'; printr(gimme(Options::groups(), 'group')); ?> <form method="post"> <select name='option' title='Options'> <?php echo get_options('options', 'key', 'key', @$_POST['option']); ?> </select> <select name='group' title='Groups of options'> <?php echo get_options('options_groups', 'group', 'group', @$_POST['group']); ?> </select> <select name='type' title='Type of variable'> <?php echo array2options(Options::types(), @$_POST['type']); ?> </select> <input type='hidden' name='action' value='update' /> <input type='submit' class='input-large' value='Update' /> </form> <?php if (isset($_POST)) { if (isset($_POST['action']) && $_POST['action'] == 'update') {
define('DEV_TW_MEMBERS_URL', 'http://dev.tiki.org/getTikiUser.php'); define('README_FILENAME', 'README'); define('README', ROOT . '/' . README_FILENAME); define('LICENSE_FILENAME', 'license.txt'); // Display all errors and warnings, including strict level define('ERROR_REPORTING_LEVEL', E_ALL | E_STRICT); error_reporting(ERROR_REPORTING_LEVEL); chdir(ROOT . '/'); require_once ROOT . '/lib/setup/third_party.php'; require_once TOOLS . '/svntools.php'; if (version_compare(PHP_VERSION, '5.0.0', '<')) { error("You need PHP version 5 or more to run this script\n"); } $phpCommand = isset($_SERVER['_']) ? $_SERVER['_'] : 'php'; $phpCommandArguments = implode(' ', $_SERVER['argv']); if (!($options = get_options()) || $options['help']) { display_usage(); } if ($options['howto']) { display_howto(); } if (!check_svn_version()) { error("You need the subversion 'svn' program at least at version " . SVN_MIN_VERSION . "\n"); } if (!$options['no-check-svn'] && has_uncommited_changes('.')) { error("Uncommited changes exist in the working folder.\n"); } $script = $_SERVER['argv'][0]; $version = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : ''; $subrelease = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : ''; if (!preg_match("/^\\d+\\.\\d+\$/", $version)) {
function get_categories() { // find previously made categories in mysql $cat_occur = get_options(); arsort($cat_occur); // sort the options in desc by value of occurences $html = ""; foreach ($cat_occur as $key => $value) { if ($key == 'no category') { continue; } else { $html .= "<option value='{$key}'>{$key}</option><br />\n"; } } return $html; }
"><?php echo $value['brd_title']; ?> </option> <?php } } ?> </select> </div> </div> <div class="control-group"> <label class="control-label">Category</label> <div class="controls"> <?php $options = get_options($category); echo '<select name="product[prd_category]" id="prd_category" class="form-control">'; echo '<option value="">Select Category</option>'; foreach ($options as $key => $val) { echo "<option value='" . substr($key, 1) . "'>" . $val . "</option>"; } echo "</select>"; ?> </div> </div> <div class="control-group"> <label class="control-label">Description</label> <div class="controls"> <textarea placeholder="Price" class="editor" name="product[prd_desc]"></textarea> </div>
<?php require_once dirname(__FILE__) . "/markdown_extended.php"; $tree = array(); $base = dirname(dirname(__FILE__)); $options = get_options(isset($argv[2]) ? $argv[2] : ''); $docs_path = $base . '/' . $options['docs_path']; $multilanguage = !empty($options['languages']) ? TRUE : FALSE; // Options function get_options($config_file) { global $base; $options = array('title' => "Documentation", 'tagline' => false, 'image' => false, 'theme' => 'red', 'docs_path' => 'docs', 'date_modified' => true, 'float' => true, 'repo' => false, 'toggle_code' => false, 'twitter' => array(), 'links' => array(), 'colors' => false, 'clean_urls' => true, 'google_analytics' => false, 'piwik_analytics' => false, 'piwik_analytics_id' => 1, 'ignore' => array(), 'languages' => array(), 'file_editor' => false, 'template' => 'default'); // Load User Config $config_file = $config_file === '' ? 'docs/config.json' : $config_file; if (substr($config_file, 0, 1) !== '/') { $config_file = $base . '/' . $config_file; } if (file_exists($config_file)) { $config = json_decode(file_get_contents($config_file), true); $options = array_merge($options, $config); } if (!isset($options['ignore']['files'])) { $options['ignore']['files'] = array(); } if (!isset($options['ignore']['folders'])) { $options['ignore']['folders'] = array(); } if ($options['theme'] !== 'custom') { $themes = array("blue", "navy", "green", "red"); if (!in_array($options['theme'], $themes)) {
function get_tree($path = '.', $clean_path = '', $title = '', $first = true, $language = null) { $options = get_options(); $tree = array(); $ignore = get_ignored(); $dh = @opendir($path); $index = 0; // Build array of paths $paths = array(); while (false !== ($file = readdir($dh))) { $paths[$file] = $file; } // Close the directory handle closedir($dh); // Sort paths sort($paths); if ($first && $language !== null) { $language_path = $language . "/"; } else { $language_path = ""; } // Loop through the paths // while(false !== ($file = readdir($dh))){ foreach ($paths as $file) { // Check that this file or folder is not to be ignored if (!in_array($file, $ignore) && $file[0] !== '.') { $full_path = "{$path}/{$file}"; $clean_sort = clean_sort($file); // If clean_urls is set to false and this is the first branch of the tree, append index.php to the clean_path. if ($options['clean_urls'] == false) { if ($first) { $url = $clean_path . '/' . $language_path . 'index.php/' . $clean_sort; } else { $url = $clean_path . '/' . $language_path . $clean_sort; } } else { $url = $clean_path . '/' . $language_path . $clean_sort; } $clean_name = clean_name($clean_sort); // Title if (empty($title)) { $full_title = $clean_name; } else { $full_title = $title . ': ' . $clean_name; } if (is_dir("{$path}/{$file}")) { // Directory $tree[$clean_sort] = array('type' => 'folder', 'name' => $clean_name, 'title' => $full_title, 'path' => $full_path, 'clean' => $clean_sort, 'url' => $url, 'tree' => get_tree($full_path, $url, $full_title, false, $language)); } else { // File $tree[$clean_sort] = array('type' => 'file', 'name' => $clean_name, 'title' => $full_title, 'path' => $full_path, 'clean' => $clean_sort, 'url' => $url); } } $index++; } return $tree; }
function main($server_cfg) { global $mysql_pdo, $pool_name, $game_name, $deregistered_ips; $relative_path = realpath(dirname(__FILE__)); $options = get_options(); if (isset($options['a']) && $options['a'] !== '') { $array_id = $options['a']; } else { die("Array ID not provided\n"); } $query = "select distinct hostgroup,deploy_id,private_ip from instances where array_id={$array_id}"; $stmt = $mysql_pdo->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($rows) { $ip_list = array(); $row = $rows[0]; $pool_name = $row['hostgroup']; $deploy_id = $row['deploy_id']; foreach ($rows as $key => $row) { $ip_list[] = $row['private_ip']; } } else { die("Could not map array id to hostgroup\n"); } //Fetching the game name from the game_deploy_map.json file $game_deploy_map = get_game_deploy_map($server_cfg); if (isset($game_deploy_map[$deploy_id])) { $game_name = $game_deploy_map[$deploy_id]; } else { die("Unable to map game deployment id to game name\n"); } $game_cfg = load_game_config($game_name); // Getting the ip of loadbalancer to be hit $f5_credentials = $game_cfg["f5_credentials"][$pool_name]; $f5_vip = $f5_credentials["f5_vip"]; //Fetching the target slack $target_slack = $game_cfg["target_slack"][$pool_name]; if ($target_slack <= 0) { die("Unable to proceed as the target slack is less than or equal to zero\n"); } $pool_data = get_instance_count_slack_offset($game_name, $pool_name); //Delete any previous rollback file existing unlink_rollback_file($server_cfg, $game_name, $pool_name); $instance_count = count($ip_list); $slack_offset = $pool_data['slack']; $opt_inst_count = $pool_data['optimal_instance_count']; //Getting the current slack via api from the zmon machine. $current_slack = get_current_slack($game_name, $pool_name, $instance_count); if ($current_slack < $slack_offset) { die("Unable to proceed as the current slack is less than the 1 day lowest slack.\n"); } //Setting the target slack relative to the slack offset and finding the optimal instance count for acheving it. $target_slack = $target_slack + ($current_slack - $slack_offset); if ($target_slack >= $current_slack) { die("Unable to proceed as the target slack is greater than current slack\n"); } //Calculating the optimal instance count for the target slack $opt_inst_count_target = $target_slack * ($instance_count - $opt_inst_count) / $slack_offset + $opt_inst_count; $opt_inst_count_target = round($opt_inst_count_target); if ($opt_inst_count_target <= 0) { die("Unable to proceed as the optimal instance count required for target slack is less then or equal to 0\n"); } echo "Current slack = {$current_slack}%\nCurrent Instance Count = {$instance_count}\nTarget slack = {$target_slack}%\nOptimal count for target slack = {$opt_inst_count_target}\n\n"; $iteration_count = 0; /* FETCH THE INITIAL PRT from all the nodes and store it */ echo "Calculating initial page response times...\n"; $initial_page_pdt_array = get_pdt_per_page($f5_vip, count($ip_list)); $prev_pdt = $initial_page_pdt_array; foreach ($initial_page_pdt_array as $page => $pdt_data) { echo "Page Delivery time for page {$page} is " . $pdt_data[2] . " ms\n"; } echo "\n"; //Fetching the tolerable pdt limit percent from the game cfg file $pdt_diff_tol_percent = $game_cfg["pdt_diff_tol_percent"]; while ($iteration_count < 5) { $instance_count = count($ip_list); $count_overflow = $instance_count - $opt_inst_count_target; $count_deregister = (int) ($count_overflow / 2); //Deregister the first (count_overflow) / 2 nodes from the ip_list and wait for 5 minutes if ($count_overflow > 2) { echo "Deregistering {$count_deregister} nodes from F5...\n"; $deregister_ips = array_slice($ip_list, 0, $count_deregister); $deregister_ip_list = json_encode($deregister_ips); $deregister_ip_list = substr($deregister_ip_list, 1, -1); //Deregister $count_deregister nodes from F5 parallelly system("php {$relative_path}/deregister_node.php -g {$game_name} -p {$pool_name} -i {$deregister_ip_list}", $exit_code); if ($exit_code == 0) { echo "Failed to complete the deregistration process. Exiting.\n"; exit(0); } $ip_list = array_slice($ip_list, $count_deregister); $deregistered_ips = array_merge($deregistered_ips, $deregister_ips); update_zmon_machines($game_cfg, $deregistered_ips); } else { echo "The current instance count ({$instance_count}) is almost optimal for the target slack.\n"; $current_slack = get_current_slack($game_name, $pool_name, $instance_count); print_final_result($current_slack, count($ip_list), $deregistered_ips); } //Wait for 5 minutes for the changes to take place wait_for_change(5); //Calculate the current slack $current_slack_after_dereg = get_current_slack($game_name, $pool_name, count($ip_list)); /* FETCH THE PRT from all the nodes and store it. Also Compare the PRT */ //Flag to check if the pdt diff is huge so as to terminate the workflow in this iteration $pdt_stop_iteration = false; while (true) { $pdt_huge_diff = false; $current_page_pdt_array = get_pdt_per_page($f5_vip, count($ip_list), $prev_pdt); $prev_pdt = $current_page_pdt_array; foreach ($current_page_pdt_array as $page => $pdt_data) { $pdt_diff = $pdt_data[2] - $initial_page_pdt_array[$page][2]; $diff_tol = $pdt_diff_tol_percent / 100 * $initial_page_pdt_array[$page][2]; echo "Checking PDT for {$page} .... (" . $pdt_data[2] . " ms) .... "; if ($pdt_diff > $diff_tol) { echo "\nPDT (" . $pdt_data[2] . " ms) increased more than {$pdt_diff_tol_percent} % for page {$page}.\n\n"; $pdt_stop_iteration = true; $pdt_huge_diff = true; } else { echo "OK\n"; } } //If the pdt difference is intolerable then register $count_deregister/2 nodes wait for 5 mins and check again. if ($pdt_huge_diff) { $count_register = ceil($count_deregister / 2); if (count($deregistered_ips) < $count_register) { $count_register = count($deregistered_ips); } if (empty($deregistered_ips)) { echo "All the nodes have been registerd.Still pdt difference is high...\n"; print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips); } echo "Registering {$count_register} nodes .... \n"; $register_ips = array_slice($deregistered_ips, 0, $count_register); $register_ip_list = json_encode($register_ips); $register_ip_list = substr($register_ip_list, 1, -1); system("php {$relative_path}/register_node.php -g {$game_name} -p {$pool_name} -i {$register_ip_list}", $exit_code); if ($exit_code == 0) { echo "Failed to complete the Registration process. Exiting.\n"; print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips, false); } $ip_list = array_merge($ip_list, $register_ips); $deregistered_ips = array_slice($deregistered_ips, $count_register); update_zmon_machines($game_cfg, $deregistered_ips); //Wait for 5 minutes for the changes to take place wait_for_change(5); } else { break; } } $current_slack_after_dereg = get_current_slack($game_name, $pool_name, count($ip_list)); if ($current_slack_after_dereg > $target_slack) { echo "Current slack ({$current_slack_after_dereg} %) is greater than target slack ({$target_slack} %). continuing .....\n"; } else { if ($current_slack_after_dereg == $target_slack) { echo "Current slack ({$current_slack_after_dereg} %) is equal to target slack. Slack reduction completed successfully...\n"; print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips); } else { // Current slack is less than the target slack - add $count_deregister/2 nodes, wait for 5 mins and check slack again. echo "Current slack ({$current_slack_after_dereg} %) is less than target slack ({$target_slack} %)\n"; $count_register = ceil($count_deregister / 2); while ($current_slack_after_dereg < $target_slack) { if (count($deregistered_ips) < $count_register) { $count_register = count($deregistered_ips); } if (empty($deregistered_ips)) { echo "All the ips have been registered...\n"; break; } echo "Registering {$count_register} nodes .... \n"; $register_ips = array_slice($deregistered_ips, 0, $count_register); $register_ip_list = json_encode($register_ips); $register_ip_list = substr($register_ip_list, 1, -1); system("php {$relative_path}/register_node.php -g {$game_name} -p {$pool_name} -i {$register_ip_list}", $exit_code); if ($exit_code == 0) { echo "Failed to complete the Registration process. Exiting.\n"; print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips, false); } $ip_list = array_merge($ip_list, $register_ips); $deregistered_ips = array_slice($deregistered_ips, $count_register); update_zmon_machines($game_cfg, $deregistered_ips); //Wait for 5 minutes for the changes to take place wait_for_change(5); $current_slack_after_dereg = get_current_slack($game_name, $pool_name, count($ip_list)); } print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips); } } if ($pdt_stop_iteration) { print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips); } $iteration_count++; } if ($iteration_count >= $limit) { echo "{$iteration_count} iterations completed!\n"; print_final_result($current_slack_after_dereg, count($ip_list), $deregistered_ips); } }
$file = fopen(DIR_OPENCART . 'admin/config.php', 'w'); fwrite($file, $output); fclose($file); } function dir_permissions() { $dirs = array(DIR_OPENCART . 'image/', DIR_OPENCART . 'system/storage/download/', DIR_OPENCART . 'system/storage/upload/', DIR_OPENCART . 'system/storage/cache/', DIR_OPENCART . 'system/storage/logs/', DIR_OPENCART . 'system/storage/modification/'); exec('chmod o+w -R ' . implode(' ', $dirs)); } $argv = $_SERVER['argv']; $script = array_shift($argv); $subcommand = array_shift($argv); switch ($subcommand) { case "install": try { $options = get_options($argv); define('HTTP_OPENCART', $options['http_server']); $valid = valid($options); if (!$valid[0]) { echo "FAILED! Following inputs were missing or invalid: "; echo implode(', ', $valid[1]) . "\n\n"; exit(1); } install($options); echo "SUCCESS! Opencart successfully installed on your server\n"; echo "Store link: " . $options['http_server'] . "\n"; echo "Admin link: " . $options['http_server'] . "admin/\n\n"; } catch (ErrorException $e) { echo 'FAILED!: ' . $e->getMessage() . "\n"; exit(1); }
echo "<strong>Done - saved options. Installation complete. <a href='index.php'>Go to gallery!</a></strong><br /><i>You should rename install.php to prevent others from changing settings.</i>"; } function set_config($text) { global $cfg; $fh = fopen($cfg, 'a') or die("Can't open file '{$cfg}' for writing. Try 'chmod 777 pwaphp.cfg'"); fwrite($fh, $text); fclose($fh); } $cfg = "config.php"; $loc = $_GET['loc']; if ($loc == "return") { set_gdata_token(); } else { if ($loc == "options") { get_options(); } else { if ($loc == "finish") { set_options(); } else { if (file_exists($cfg)) { $file = file_get_contents($cfg); if (strpos($file, "GDATA_TOKEN") >= 0) { echo "PWP+PHP is already configured. Delete {$cfg} and reload this page to reconfigure."; } else { get_gdata_token(); } } else { get_gdata_token(); } }
<?php $options = get_options(); extract($options); ?> <div class="wrap"><h2>Better Excerpt Options</h2> <form method="post" action="options.php"> <?php wp_nonce_field('update-options'); ?> <table class="form-table"> <tr valign="top"><td width="20%"><h3>Length</h3></td><td valign="middle"><input type="text" name="better_excerpt_length" value="<?php echo esc_html($length); ?> " /></td><td><p style="font-size: 80%;">The length of the excerpt <b>in characters</b>; as the final result will be trimmed to the nearest whole word, it may be a little shorter. <br/>As a general rule, assume 5 letters in the average word in English. <br><b>Cannot be left blank. </b></p></td></tr> <tr valign="top"><td width="20%"><h3>Text/HTML before excerpt</h3></td><td valign="middle"><input type="text" name="better_excerpt_before_text" value='<?php echo esc_html($before_text); ?> ' /></td><td><p style="font-size: 80%;">Text or HTML code to go before excerpt: e.g. <p> or <div> <br>Can be left blank.</p></td></tr> <tr valign="top"><td width="20%"><h3>And there's more... (ellipsis)</h3></td><td valign="middle"><input type="text" name="better_excerpt_ellipsis" value="<?php echo esc_html($ellipsis); ?> " /></td><td><p style="font-size: 80%;">For ... or >> to indicate that part of the post is missing: if you don't want anything extra added, leave blank. </p></td></tr>
$data = array_merge($data, $options); $app->render('quotation_view.html', $data); }); $app->get('/quotation_delete/:id', function ($id) use($app) { $option_keys = array('company_fax'); $options = get_options($option_keys); $quotation = check_quotation_exists($id); $quotation_items = unserialize($quotation->items); $data = array('breadcrumb_title' => '刪除報價單', 'quotation' => $quotation, 'quotation_items' => $quotation_items); $data = array_merge($data, $options); $app->render('quotation_delete.html', $data); }); $app->get('/quotation_download_pdf/:id', function ($id) use($app) { require 'lib/Wkhtmltopdf.php'; $option_keys = array('company_fax'); $options = get_options($option_keys); $quotation = check_quotation_exists($id); $url = $app->config('full_doc_root') . '/quotation_view/' . $id; try { $wkhtmltopdf = new Wkhtmltopdf(array('path' => PROJECT_PATH . '/pdf/', 'binpath' => WKHTMLTOPDF_BIN_PATH)); $wkhtmltopdf->setTitle($quotation->quotation_name); $wkhtmltopdf->setUrl($url); $wkhtmltopdf->setCookie(COOKIE_NAME, urlencode($app->getCookie(COOKIE_NAME))); $wkhtmltopdf->output(Wkhtmltopdf::MODE_DOWNLOAD, $quotation->quotation_name . '.pdf'); } catch (Exception $e) { $app->notFound(); } }); $app->get('/quotation_status_update/:id', function ($id) use($app) { $quotation_status_words = array('confirmed' => '訂單確認', 'canceled' => '取消', 'paid' => '已付款', 'wait' => '待回應'); $quotation = check_quotation_exists($id);