/** * Test recursively if an array is empty */ public function testArrayEmpty() { $array1 = ['fii' => 3, 'faa' => 2, 'foo' => 1]; $array2 = []; $array3 = ['fee' => false, 'foo' => ['faa' => ['fii' => 0]], 'fuu' => 0]; $array4 = ['fee' => false, 'foo' => ['faa' => ['fii' => 1]], 'fuu' => 0]; $this->assertEquals(array_empty($array1), false); $this->assertEquals(array_empty($array2), true); $this->assertEquals(array_empty($array3), true); $this->assertEquals(array_empty($array4), false); }
/** * public function Page( $url = NULL ) * * Parses through url and returns the path and query contained, also sets up Db and Sql Classes. * * @return void * @author Katalyst Canada **/ public function __construct($url = NULL) { $url = $url == NULL ? $_SERVER['REQUEST_URI'] : $url; $url = parse_url(trim($url, '#')); $this->pg["path"] = explode("/", trim($url['path'], '/')); $this->pg["path"] = array_empty($this->pg["path"]) ? array() : $this->pg["path"]; $this->pg["get"] = isset($url['query']) ? $url['query'] : NULL; // Set _post, _get, and _path for sharing.. $this->V->_post = $_POST; $this->V->_get = $_GET; $this->V->_path = $this->pg['path']; }
/** * Test recursively if an array is empty * * @param array $array * * @return bool */ function array_empty(array $array) { $bool = true; foreach ($array as $key => $value) { if (is_array($value)) { $bool = array_empty($value); } else { if (!empty($value)) { $bool = false; } } } return $bool; }
function wpsight_get_option($name, $default = false) { $options = get_option(WPSIGHT_DOMAIN); // Get std value if default set TRUE and no options set if ($default === true && (empty($options[$name]) || array_empty($options[$name]))) { require_once WPSIGHT_ADMIN_DIR . '/options.php'; $options = wpsight_options(); if (!empty($options[$name]['std'])) { return $options[$name]['std']; } } if (array_empty($options)) { return $default; } if (isset($options[$name])) { return $options[$name]; } return $default; }
/** * Check if an array is empty * * @return void * @author Tyler Diaz **/ function array_empty($mixed) { if (is_array($mixed)) { foreach ($mixed as $value) { if (!array_empty($value)) { return false; } } } elseif (!empty($mixed)) { return false; } return true; }
public function home() { global $user; $v = $this->__(w('f e')); if (array_empty($v)) { _fatal(); } $location = './style/' . $v['e'] . '/'; $filename = _filename($v['f'], $v['e']); if (!@is_dir($location)) { _fatal(); } if ($v['e'] == 'css' && $v['f'] != 'default') { $v['field'] = !is_numb($v['f']) ? 'alias' : 'id'; $sql = 'SELECT * FROM _tree WHERE tree_?? = ? LIMIT 1'; if (!($tree = _fieldrow(sql_filter($sql, $v['field'], $v['f'])))) { _fatal(); } $filetree = _rewrite($tree); $filename = _filename('_tree_' . $filetree, $v['e']); } // 304 Not modified response header if (@file_exists($location . $filename)) { $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT'; $http_if_none_match = v_server('HTTP_IF_NONE_MATCH'); $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE'); header('Last-Modified: ' . $f_last_modified); if ($f_last_modified == $http_if_modified_since) { header('HTTP/1.0 304 Not Modified'); header('Content-Length: 0'); exit; } } switch ($v['e']) { case 'css': if ($v['f'] != 'default') { $filetree = _rewrite($tree); $filename = _filename('_tree_' . $filetree, $v['e']); if (!@file_exists($location . $filename)) { _fatal(); } } $browser = _browser(); if (f($browser['browser'])) { $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']); foreach ($custom as $row) { $handler = _filename('_tree_' . $row, 'css'); if (@file_exists($location . $handler)) { _style('includes', array('CSS' => _style_handler('css/' . $handler))); } } } break; case 'js': if (!@file_exists($location . $filename)) { _fatal(); } _style_vreplace(false); break; } v_style(array('SPATH' => LIBD . 'visual')); sql_close(); $ext = _style_handler($v['e'] . '/' . $filename); switch ($v['e']) { case 'css': $content_type = 'text/css; charset=utf-8'; $ext = preg_replace('#(border-radius\\-?.*?)\\: ?(([0-9]+)px;)#is', _browser('firefox') || _browser('namoroka') ? '-moz-\\1: \\2' : '', $ext); $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext); $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext); $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext); break; case 'js': $content_type = 'application/x-javascript'; require_once XFS . 'core/jsmin.php'; $ext = JSMin::minify($ext); break; } ob_start('ob_gzhandler'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 30) . ' GMT'); header('Content-type: ' . $content_type); echo $ext; exit; }
/** * Creates a new session. * * If cookies are disabled the page will be reloaded with session id added to query string. * * @param boolean Set to true if this function is called from sid_load() * @return object Data of the user who is calling this script */ function sid_new() { global $config, $db, $gpc; if (!$this->sidload && !array_empty($this->cookiedata)) { $load = $db->query('SELECT mid FROM ' . $db->pre . 'session WHERE mid = "' . $this->cookiedata[0] . '" LIMIT 1', __LINE__, __FILE__); if ($db->num_rows($load) == 1) { $this->sidload = true; $my = $this->sid_load(); return $my; } } if (!array_empty($this->cookiedata)) { $result = $db->query('SELECT u.*, f.* FROM ' . $db->pre . 'user AS u LEFT JOIN ' . $db->pre . 'userfields as f ON f.ufid = u.id WHERE u.id = "' . $this->cookiedata[0] . '" AND u.pw = "' . $this->cookiedata[1] . '" LIMIT 1', __LINE__, __FILE__); $my = $gpc->prepare($db->fetch_object($result)); $nodata = $db->num_rows($result) == 1 ? false : true; } else { $nodata = true; } if ($nodata == false && $my->confirm == '11') { $id =& $my->id; $lastvisit =& $my->lastvisit; $my->clv = $my->lastvisit; $my->vlogin = true; makecookie($config['cookie_prefix'] . '_vdata', $my->id . "|" . $my->pw); } else { $id = 0; $lastvisit = $this->cookielastvisit; $my->clv = $this->cookielastvisit; $my->vlogin = false; makecookie($config['cookie_prefix'] . '_vdata', "|", -60); } makecookie($config['cookie_prefix'] . '_vlastvisit', $lastvisit); $my->is_bot = $this->log_robot(); $this->sid = $this->construct_sid(); $my->sid =& $this->sid; $my->mark = serialize(array()); $my->pwfaccess = serialize(array()); $my->settings = serialize(array()); $action = $gpc->get('action', str); $qid = $gpc->get('id', int); $db->query("INSERT INTO {$db->pre}session\n\t(sid, mid, wiw_script, wiw_action, wiw_id, active, ip, user_agent, lastvisit, mark, pwfaccess, settings, is_bot) VALUES\n\t('{$this->sid}', '{$id}','" . SCRIPTNAME . "','{$action}','{$qid}','" . time() . "','{$this->ip}','" . $gpc->save_str(htmlspecialchars($this->user_agent)) . "','{$lastvisit}','{$my->mark}','{$my->pwfaccess}','{$my->settings}','{$my->is_bot}')", __LINE__, __FILE__); return $my; }
function validation_form_action(array $form, array $posting, array $report) { return array_empty($report) ? $form['success']($posting) : $form['fail']($posting, $report); }
$input = array(); foreach ($fields as $key => $data) { $value = $gpc->get($key, $data[1], DONT_CARE); if ($key == 'regdate' || $key == 'lastvisit') { if (is_array($value) && array_sum($value) != 0) { // for php version >= 5.1.0 $input[$key] = @mktime(0, 0, 0, intval($value[2]), intval($value[1]), intval($value[3])); if ($input[$key] == -1 || $input[$key] == false) { // -1 for php version < 5.1.0, false for php version >= 5.1.0 $input[$key] = DONT_CARE; } } else { $input[$key] = DONT_CARE; } } elseif ($key == 'groups') { if (array_empty($value) !== false) { $input[$key] = DONT_CARE; } else { $input[$key] = $value; } } elseif ($key == 'birthday') { if (!isset($value[1]) || !isset($value[2]) || !isset($value[3])) { $input[$key] = DONT_CARE; } else { $value[1] = intval(trim($value[1])); if ($value[1] < 1 || $value[1] > 31) { $value[1] = '%'; }
if ($str[0] == '-') { $not = 'NOT '; $str = substr($str, 1); } else { $not = ''; } if ($i > 0) { $sql_where_like .= $op . $not; } if ($gpc->get('opt_0', int) == 0) { $sql_where_like .= "(r.topic LIKE{$binary} '%{$str}%' OR r.comment LIKE{$binary} '%{$str}%') "; } else { $sql_where_like .= "r.topic LIKE{$binary} '%{$str}%' "; } } if (array_empty($boards)) { $boards = $slog->getBoards(); } $sql_where = $slog->sqlinboards('r.board', 1, $boards) . " "; if (count($used) > 0) { $sql_where .= "({$sql_where_like}) "; } if (empty($rname) == false) { if (count($used) > 0) { $sql_where .= "AND "; } $sql_where .= "r.name = '{$rname}' "; } if (strxlen($name) >= $config['searchminlength']) { $used[] = $name; } else {
static function Parse($url) { // save 'original' Url::$data['_url'] = $url; // send through routes Url::$data['url'] = Url::DoRoutes($url); // get extension preg_match('/(.*)\\.(\\w{1,4})$/Ui', Url::$data['url'], $matches); if (!empty($matches)) { Url::$data['url'] = $matches[1]; Url::$data['type'] = $matches[2]; } // get parts $parts = explode(DS, Url::$data['url']); // is subdomain? // if (count($host_parts=explode('.', $_SERVER['HTTP_HOST'])) > 2 && $host_parts[0]!='www') { if (($subdomain = Url::GetSubdomain()) != null) { Url::$data['is_subdomain'] = true; Url::$data['subdomain'] = $subdomain; } Url::$data['host'] = 'http' . (array_get($_SERVER, 'HTTPS') ? 's' : '') . '://' . wrap($subdomain, '', '.') . DOMAIN; // d($url);d_arr($parts);d_arr(Url::$data);die; // nothing left? if (array_empty($parts)) { if (Url::GetData('is_admin')) { // is admin $parts = array(ADMIN_DEFAULT_CONTROLLER, ADMIN_DEFAULT_ACTION); } else { // is default $parts = explode(DS, Url::GetData('is_subdomain') ? SUBDOMAIN_DEFAULT_URL : DEFAULT_URL); } } // is execute? if (Url::$data['type'] == 'php') { Url::$data['model'] = 'app'; Url::$data['modelName'] = 'AppModel'; Url::$data['controller'] = EXECUTE_CONTROLLER; Url::$data['controllerName'] = ucfirst(EXECUTE_CONTROLLER) . 'Controller'; Url::$data['action'] = 'include_to_buffer'; // set filename Url::$data['params'] = array('filename' => implode(DS, $parts) . '.php'); } else { // set controller Url::$data['controller'] = array_shift($parts); Url::$data['controllerName'] = AppInflector::classify(Url::$data['controller'], 'controller'); // set model Url::$data['model'] = AppInflector::singularize(Url::$data['controller']); Url::$data['modelName'] = AppInflector::classify(Url::$data['model'], 'model'); // set action Url::$data['action'] = ($action = array_shift($parts)) != null ? $action : 'index'; // add prefix to admin actions if (Url::GetData('is_admin')) { Url::$data['action'] = ADMIN_PREFIX . Url::$data['action']; } // set params while (($value = array_shift($parts)) != null) { Url::$data['params'][] = $value; } } // set request Url::$data['request'] = $_REQUEST; // set domain Url::$data['domain'] = DOMAIN; // d_arr(Url::$data);die; }
public function home() { global $warning, $bio, $core, $warning; $v = $this->__(w('path ext')); if (array_empty($v)) { $warning->now(); } $location = XFS . XHTM . _tbrowser() . '/' . $v->ext . '/'; if (!@is_dir($location)) { $warning->now(); } $filename = _filename($v->path, $v->ext); if ($v->ext == 'css' && $v->path != 'default') { $v->field = !is_numb($v->path) ? 'alias' : 'id'; $sql = 'SELECT * FROM _tree WHERE tree_?? = ? LIMIT 1'; if (!($tree = sql_fieldrow(sql_filter($sql, $v->field, $v->path)))) { $warning->now(); } $filetree = _rewrite($tree); $filename = _filename('_tree_' . $filetree, $v->ext); } // // 304 Not modified response header if (@file_exists($location . $filename)) { $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT'; $http_if_none_match = v_server('HTTP_IF_NONE_MATCH'); $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE'); header('Last-Modified: ' . $f_last_modified); if ($f_last_modified == $http_if_modified_since) { header('HTTP/1.0 304 Not Modified'); header('Content-Length: 0'); exit; } } switch ($v->ext) { case 'css': if ($v->path != 'default') { $filetree = _rewrite($tree); $filename = _filename('_tree_' . $filetree, $v->ext); if (!@file_exists($location . $filename)) { $warning->now(); } } $browser = _browser(); if (!empty($browser['browser'])) { $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']); foreach ($custom as $row) { $handler = _filename('_tree_' . $row, 'css'); if (@file_exists($location . $handler)) { _style('includes', array('CSS' => _style_handler('css/' . $handler))); } } } _style_vreplace(false); break; case 'js': if (!@file_exists($location . $filename)) { $warning->now(); } _style_vreplace(false); break; } v_style(array('DOMAIN' => 'media')); sql_close(); // // Headers $ext = _style_handler($v->ext . '/' . $filename); switch ($v->ext) { case 'css': $content_type = 'text/css; charset=utf-8'; //$ext = preg_replace('#(border-radius\-?.*?)\: ?(([0-9]+)px;)#is', ((_browser('firefox')) ? '-moz-\1: \2' : ''), $ext); $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext); $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext); $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext); break; case 'js': $content_type = 'application/x-javascript'; require_once XFS . XCOR . 'jsmin.php'; $ext = JSMin::minify($ext); break; } ob_start('ob_gzhandler'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT'); // 30 days = 60 * 60 * 24 * 30 header('Content-type: ' . $content_type); echo $ext; exit; }
public function setProgress() { // Cálculo del % de progreso $progress = 100 * $this->score / $this->max; $progress = round($progress, 0); if ($progress > 100) { $progress = 100; } if ($progress < 0) { $progress = 0; } if ($this->status == 1 && $progress >= 80 && \array_empty($this->errors)) { $this->finishable = true; } $this->progress = $progress; // actualizar el registro self::query("UPDATE project SET progress = :progress WHERE id = :id", array(':progress' => $this->progress, ':id' => $this->id)); }
function wpsight_get_option($name, $default = false) { global $wpsight_wpml; $options = get_option(WPSIGHT_DOMAIN); // Get std value if default set TRUE and no options set if ($default === true && (empty($options[$name]) || array_empty($options[$name]))) { require_once WPSIGHT_ADMIN_DIR . '/options.php'; $options = wpsight_options(); if (!empty($options[$name]['std'])) { return $options[$name]['std']; } } if (array_empty($options)) { return $default; } if (isset($options[$name])) { if (in_array($name, $wpsight_wpml->wpsight_wpml_admin_texts())) { return icl_t(WPSIGHT_NAME . ' - ' . __('Theme Options', 'wpsight-wpml'), $name, $options[$name]); } else { return $options[$name]; } } return $default; }
function wpsight_listing_title_action_favorite($data) { $labels = array('favorites_add' => $data['label'], 'favorites_see' => __('Favorites', 'wpsight')); $labels = apply_filters('wpsight_do_listing_title_actions_labels', $labels); // Check if listings are still published $favorites_removed = array(); if (isset($_COOKIE[WPSIGHT_COOKIE_FAVORITES])) { $favorites = explode(',', $_COOKIE[WPSIGHT_COOKIE_FAVORITES]); foreach ($favorites as $favorite) { if (get_post_status($favorite) != 'publish') { $favorites_removed[] = $favorite; } } } ?> <script type="text/javascript"> jQuery(document).ready(function($){ var cookie_favs = '<?php echo WPSIGHT_COOKIE_FAVORITES; ?> '; var removeValue = function(list, value) { var values = list.split(","); for(var i = 0 ; i < values.length ; i++) { if(values[i] == value) { values.splice(i, 1); return values.join(","); } } return list; }; <?php // Remove unpublished listings from cookie if (!array_empty($favorites_removed)) { foreach ($favorites_removed as $favorite_removed) { echo 'var favs = removeValue($.cookie(cookie_favs), ' . $favorite_removed . ');'; } echo '$.cookie(cookie_favs, favs,{ expires: 60, path: \'' . COOKIEPATH . '\' });'; } ?> if($.cookie(cookie_favs)!=null) { if($.cookie(cookie_favs).search('<?php the_ID(); ?> ')!=-1) { $('.actions-favorites').hide(); $('.actions-favorites-link').show(); if($('.actions-favorites-link small').length == 0) { $('.actions-favorites-link').append(' <span class="badge badge-important">' + $.cookie(cookie_favs).split(',').length + '</span>'); } } } $('.actions-favorites').click(function(e) { e.preventDefault(); if($.cookie(cookie_favs)==null || $.cookie(cookie_favs)=='') { $.cookie(cookie_favs, <?php the_ID(); ?> ,{ expires: 60, path: '<?php echo COOKIEPATH; ?> ' }); } else { var fav = $.cookie(cookie_favs); $.cookie(cookie_favs, fav + ',' + <?php the_ID(); ?> ,{ expires: 60, path: '<?php echo COOKIEPATH; ?> ' }); } $(this).fadeOut(75, function() { $('.actions-favorites-link').fadeIn(75); $('.actions-favorites-link').append(' <span class="badge badge-important">' + $.cookie(cookie_favs).split(',').length + '</span>'); }); }); }); </script><?php $output = ''; if (is_pagetemplate_active('page-tpl-favorites.php')) { // Save Button $output .= '<a href="' . $data['href'] . '" id="' . $data['id'] . '" class="' . $data['class'] . '" target="' . $data['target'] . '" ' . $data['atts'] . '>'; // check if icon is available if ($data['icon']) { $output .= '<i class="' . $data['icon'] . '"></i>'; } $output .= $labels['favorites_add']; $output .= '</a>'; // Favorites Button $output .= '<a href="' . get_pagetemplate_permalink('page-tpl-favorites.php') . '" class="' . apply_filters('wpsight_title_action_css', 'btn btn-mini actions-favorites-link action-link', 'favorites_see') . '" style="display:none">'; $output .= '<i class="icon-star"></i>' . $labels['favorites_see']; $output .= '</a>'; } // return output return $output; }
} elseif (count($header) > 0) { break; } } fclose($fd); } else { $header = $lang->phrase('admin_db_file_too_large'); } } else { $header = $lang->phrase('admin_db_unknown_file_format'); } if (is_array($header) && count($header) > 0) { $header = array_map('trim', $header); $header = implode("<br />\n", $header); } if (empty($header) || array_empty($header) == true) { $header = $lang->phrase('admin_db_file_no_comments'); } echo $header; } elseif ($job == 'restore') { echo head(); $result = array(); $dir = "./admin/backup/"; // Old names: DD_MM_YYYY-HH_MM_SS // New names: DBNAME-YYYYMMDD-HHMMSS $handle = opendir($dir); while ($file = readdir($handle)) { if ($file != "." && $file != ".." && !is_dir($dir . $file)) { $nfo = pathinfo($dir . $file); if ($nfo['extension'] == 'zip' || $nfo['extension'] == 'sql') { $result[] = array('file' => $nfo['basename'], 'size' => filesize($dir . $file));
/** * Creates a new session. * * If cookies are disabled the page will be reloaded with session id added to query string. * * @param boolean Set to true if this function is called from sid_load() * @return object Data of the user who is calling this script */ function sid_new() { global $config, $db, $gpc; if (!$this->sidload && !array_empty($this->cookiedata)) { $load = $db->query('SELECT mid FROM '.$db->pre.'session WHERE mid = "'.$this->cookiedata[0].'" LIMIT 1'); if ($db->num_rows($load) == 1) { $this->sidload = true; $my = $this->sid_load(); return $my; } } if (!array_empty($this->cookiedata) && count($this->cookiedata) == 2) { $result = $db->query('SELECT u.*, f.* FROM '.$db->pre.'user AS u LEFT JOIN '.$db->pre.'userfields as f ON f.ufid = u.id WHERE u.id = "'.$this->cookiedata[0].'" AND u.pw = "'.$this->cookiedata[1].'" LIMIT 1'); $my = $this->cleanUserData($db->fetch_object($result)); $nodata = ($db->num_rows($result) == 1) ? false : true; if ($nodata == true) { // Loginversuch mit falschen Daten => Versuch protokollieren! makecookie($config['cookie_prefix'].'_vdata', '|', 0); set_failed_login(); } } else { $nodata = true; } if (!isset($my) || !is_object($my)) { $my = new stdClass(); } if ($nodata == false && $my->confirm == '11') { $id = &$my->id; $lastvisit = $my->lastvisit; $my->clv = $my->lastvisit; $my->vlogin = true; makecookie($config['cookie_prefix'].'_vdata', $my->id."|".$my->pw); } else { $id = 0; $lastvisit = $gpc->save_int(getcookie('vlastvisit')); $my->clv = $lastvisit; $my->vlogin = false; makecookie($config['cookie_prefix'].'_vdata', "|", -60); } $my->is_bot = $this->log_robot(); $this->sid = $this->construct_sid(); $my->sid = &$this->sid; $my->mark = serialize(array()); $my->pwfaccess = serialize(array()); $my->settings = serialize(array()); $action = $gpc->get('action', str); $qid = $gpc->get('id', int); $db->query("INSERT INTO {$db->pre}session (sid, mid, wiw_script, wiw_action, wiw_id, active, ip, user_agent, lastvisit, mark, pwfaccess, settings, is_bot) VALUES ('{$this->sid}', '{$id}','".SCRIPTNAME."','{$action}','{$qid}','".time()."','{$this->ip}','".$gpc->save_str($this->user_agent)."','{$lastvisit}','".$db->escape_string($my->mark)."','".$db->escape_string($my->pwfaccess)."','".$db->escape_string($my->settings)."','{$my->is_bot}')"); return $my; }
function include_uberdev_text() { global $building_count, $building_output, $building_variables; if ($_SERVER['SERVER_NAME'] != DEV_SERVER_NAME) { echo "EVIL!!!! HOW DID YOU GET HERE?!"; include_game_down(); exit; } $objSrcUser =& $GLOBALS['objSrcUser']; $userid = $objSrcUser->get_userid(); // if stuff is posted, do that first if ($_SERVER['REQUEST_METHOD'] == "POST") { if (!array_empty($_POST['building'])) { var_dump($_POST['building']); //debug foreach ($_POST['building'] as $strToBuild => $strNumber) { if ($strNumber == '') { continue; } if (get_magic_quotes_gpc()) { $strToBuild = stripslashes($strToBuild); $strNumber = stripslashes($strNumber); } $strToBuild = mysql_real_escape_string($strToBuild); $strNumber = mysql_real_escape_string($strNumber); //print("<br />" . "UPDATE build SET $strToBuild = $strNumber WHERE id = $userid" . "<br />"); //debug var_dump(mysql_query("UPDATE build SET {$strToBuild} = {$strNumber} WHERE id = {$userid}")); echo '<br />' . mysql_error(); } } if (!array_empty($_POST['population'])) { var_dump($_POST['population']); //debug foreach ($_POST['population'] as $strToTrain => $strNumber) { if ($strNumber == '') { continue; } if (get_magic_quotes_gpc()) { $strToTrain = stripslashes($strToTrain); $strNumber = stripslashes($strNumber); } $strToTrain = mysql_real_escape_string($strToTrain); $strNumber = mysql_real_escape_string($strNumber); if ($strToTrain == "citizen") { $objSrcUser->set_pop(CITIZENS, $strNumber); print "<br />true"; } else { //print("<br />" . "UPDATE army SET $strToTrain = $strNumber WHERE id = $userid" . "<br />"); //debug var_dump(mysql_query("UPDATE army SET {$strToTrain} = {$strNumber} WHERE id = {$userid}")); echo '<br />' . mysql_error(); } } } if (!empty($_POST['SQL'])) { $strSQL = $_POST['SQL']; if (get_magic_quotes_gpc()) { $strSQL = stripslashes($strSQL); } var_dump($strSQL); //debug $res = mysql_query($strSQL); if (!$res) { echo '<br />' . mysql_error(); } elseif ($res === true) { echo '<br />Success! ' . mysql_affected_rows() . ' rows updated.'; } else { $rows = mysql_num_rows($res); echo "{$rows} rows returned<br />"; if ($rows) { echo "<table class='medium'><tr class='subheader'>"; $line = mysql_fetch_assoc($res); foreach (array_keys($line) as $label) { echo "<th>{$label}</th>"; } echo "</tr>"; do { echo "<tr class='data'>"; foreach ($line as $item) { echo '<td>' . $item . '</td>'; } echo '</tr>'; } while ($line = mysql_fetch_assoc($res)); echo '</table>'; } } } } //now for the actual form ?> <form action="<? echo $_SERVER['REQUEST_URI']; ?>" method="post"> <table class="medium"> <tr class="header"> <th>Data</th> <th class="right">Value</th> </tr> <?php $objUser =& $GLOBALS["objSrcUser"]; $arrSrcStats = $objUser->get_stats(); $level = $arrSrcStats['level']; if ($level >= 5) { ?> <tr class="subheader"> <th>raw SQL</th> </tr> <tr class="data"> <th>SQL</th> <td><input type="text" name="SQL" size="50" /></td> </tr> <?php } ?> <tr class="subheader"> <th>Buildings</th> </tr> <tr class="data"> <th>Total acres</th> <td><input type="text" name="building[land]" /></td> </tr> <?php include_once "inc/functions/build.php"; $arrBuild = $objSrcUser->get_builds(); $arrStat = $objSrcUser->get_stats(); //mysql_grab($userid, 'local', 'goods', 'build', 'pop'); build_cost(); building_names(); //general_build(); for ($i = 1; $i <= $building_count; $i++) { echo "<tr class=\"data\">" . "<th>{$building_output[$i]}</th>" . "<td><input type=\"text\" name=\"building[{$building_variables[$i]}]\" /></td>" . "</tr>"; } ?> <tr class="subheader"> <th>Population</th> </tr> <?php $objRace = clsRace::getRace($objSrcUser->get_stat(RACE)); $arrUnitVar = $objRace->getUnitVariables(); $arrUnitNames = $objRace->getUnitNames(); for ($i = 1; $i < 7; $i++) { echo "<tr class=\"data\">" . "<th>{$arrUnitNames[$i]}</th>" . "<td><input type=\"text\" name=\"population[{$arrUnitVar[$i]}]\" /></td>" . "</tr>"; } ?> </table> <input type="submit" value="do crazy stuff" /> </form> <?php }
<div id="sub-header"> <div> <h2><?php echo Text::html('discover-banner-header') ?></h2> </div> </div> */ ?> <div id="main"> <?php echo new View('view/discover/searcher.html.php', array('categories' => $categories, 'locations' => $locations, 'rewards' => $rewards, 'skills' => $skills)); ?> <?php foreach ($this['lists'] as $type => $list) { if (array_empty($list)) { continue; } ?> <div class="widget projects"> <h2 class="title"><?php echo $this['title'][$type]; ?> </h2> <?php foreach ($list as $group => $projects) { ?> <div class="discover-group discover-group-<?php echo $type; ?>
if (count($error) > 0) { error('admin.php?action=members&job=ban_add', $error); } if ($until[0] == 'D') { $until = strtotime('+' . $until[1] . ' day' . iif($until[1] > 0, 's')); } elseif ($until[0] == 'M') { $until = strtotime('+' . $until[1] . ' month' . iif($until[1] > 0, 's')); } $new = array($type, $data, $until, $my->id, time(), str_replace(array("\r", "\n", "\t"), ' ', $reason)); $file[] = implode("\t", $new); $filesystem->file_put_contents('data/bannedip.php', implode("\n", $file)); ok('admin.php?action=members&job=banned', iif($type == 'ip', $lang->phrase('admin_member_banned_ip_addr'), $lang->phrase('admin_member_banned_user')) . $lang->phrase('admin_member_has_been_banned')); } elseif ($job == 'ban_delete') { echo head(); $delete = $gpc->get('delete', arr_none); if (array_empty($delete) == true) { error('admin.php?action=members&job=banned', $lang->phrase('admin_member_nothing_selected')); } $banned = file('data/bannedip.php'); $file = array(); foreach ($banned as $line) { $add = true; $row = explode("\t", rtrim($line, "\r\n"), 6); foreach ($delete as $del) { $del = explode("#", $del, 2); if ($del[0] == $row[0] && $del[1] == $row[1]) { $add = false; } } if ($add == true && empty($line) == false) { $file[] = $line;