function relatedTags($tags) { /* related tags */ $twhere = ""; foreach ($tags as $tag) { $tag = rss_real_escape_string($tag); $twhere .= "t.tag='{$tag}' or "; } $twhere .= "1=0"; $sql = "select fid,tid,m.tdate from " . getTable('metatag') . " m " . "inner join " . getTable('tag') . " t on t.id = m.tid where m.ttype = 'item'" . " and ({$twhere})"; //echo $sql; $res = rss_query($sql); $fids = array(); $ctid = -1; while (list($fid, $tid) = rss_fetch_row($res)) { $fids[] = $fid; $tids[] = $tid; } $fids = array_unique($fids); $tids = array_unique($tids); $rtags = array(); if (count($fids)) { $sql = "select t.tag, count(*) as cnt from " . getTable('metatag') . " m left join " . getTable('item') . " i on (m.fid=i.id) " . " inner join " . getTable('tag') . " t on (t.id = m.tid) " . " where m.fid in (" . implode(",", $fids) . ")" . " and t.id not in (" . implode(",", $tids) . ")"; if (hidePrivate()) { $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") "; } $sql .= " group by t.tag order by cnt desc"; //echo $sql; $res = rss_query($sql); while (list($rtag, $cnt) = rss_fetch_row($res)) { $rtags[$rtag] = $cnt; } } return $rtags; }
function checkETag($withDB = true, $keyPrefix = "", $cacheValidity = 0) { $key = $keyPrefix . '$Revision$' . $_SERVER["REQUEST_URI"]; if ($withDB) { list($dt) = rss_fetch_row(rss_query('select timestamp from ' . getTable('cache') . " where cachekey='data_ts'")); $key .= $dt; } if (array_key_exists(RSS_USER_COOKIE, $_REQUEST)) { $key .= $_REQUEST[RSS_USER_COOKIE]; } $key = md5($key); if (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER) && $_SERVER['HTTP_IF_NONE_MATCH'] == $key) { header("HTTP/1.1 304 Not Modified"); header("X-RSS-CACHE-STATUS: HIT"); header("ETag: {$key}"); flush(); exit; } else { header("ETag: {$key}"); header("X-RSS-CACHE-STATUS: MISS"); if ($cacheValidity) { header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cacheValidity * 3600) . 'GMT'); } } }
function provaGetByFiltro($id_local = -1, $id_modalidade = -1, $status_array = null, $reject_status_array = null) { $where = ''; if ($id_local !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_local = " . dbInteger($id_local); } if ($id_modalidade !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_modalidade = " . dbInteger($id_modalidade); } if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } // if ($data !== null) { // $where .= ($where == '') ? '' : ' AND '; // $where .= "data_hora = " . dbDate($data); // } return getTable('provas_total', $where, 'data_hora, duracao'); }
function print_parent_article_link($articleid) { $query = "SELECT title FROM articles WHERE articleid = " . $articleid . ";"; $table = getTable($query); $row = getNextRow($table); echo '<a href="index.php?articleid=' . $articleid . '&m_c=va">' . stripslashes($row['title']) . '</a>'; }
function elementoEquipaGetByFiltro($id_delegacao, $id_equipa, $id_elemento, $status_array, $reject_status_array) { $where = ''; if ($id_delegacao !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_delegacao = " . dbInteger($id_delegacao); } if ($id_equipa !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_equipa = " . dbInteger($id_equipa); } if ($id_elemento !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_elemento = " . dbInteger($id_elemento); } if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } if ($where == "") { return array(); } else { return getTable('elementos_equipas_total', $where, 'pais_nome, elemento_nome'); } }
function rss_search_channels_combo($id) { $ret = "\t\t<select name=\"{$id}\" id=\"{$id}\">\n" . "\t\t\t<option value=\"" . ALL_CHANNELS_ID . "\"" . (!array_key_exists(QUERY_CHANNEL, $_REQUEST) || $_REQUEST[QUERY_CHANNEL] == ALL_CHANNELS_ID ? " selected=\"selected\"" : "") . ">" . __('All') . "</option>\n"; $sql = "select " . " c.id, c.title, f.name, f.id " . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " f " . " on f.id = c.parent "; if (hidePrivate()) { $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") "; } $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE . ") "; $sql .= " order by " . (getConfig('rss.config.absoluteordering') ? "f.position asc, c.position asc" : "f.name asc, c.title asc"); $res = rss_query($sql); $prev_parent = -1; while (list($id_, $title_, $parent_, $parent_id_) = rss_fetch_row($res)) { if ($prev_parent != $parent_id_) { if ($prev_parent > -1) { $ret .= "\t\t\t</optgroup>\n"; } if ($parent_ == "") { $parent_ = __('Root'); } $ret .= "\t\t\t<optgroup label=\"{$parent_} /\">\n"; $prev_parent = $parent_id_; } if (strlen($title_) > 25) { $title_ = substr($title_, 0, 22) . "..."; } $ret .= "\t\t\t\t<option value=\"{$id_}\"" . (array_key_exists(QUERY_CHANNEL, $_REQUEST) && $_REQUEST[QUERY_CHANNEL] == $id_ ? " selected=\"selected\"" : "") . ">{$title_}</option>\n"; } if ($prev_parent != 0) { $ret .= "\t\t\t</optgroup>\n"; } $ret .= "\t\t</select>\n"; return $ret; }
function sugestaoGetAll($ids = null) { $where = ''; if ($ids !== null) { $where = 'id_sugestao IN (' . join(', ', $ids) . ')'; } return getTable('sugestoes_total', $where, 'data, id_sugestao'); }
function parametroGetAll() { $pms = getTable("parametros", "", ""); $p = array(); while ($row = foreachRow($pms)) { $p[$row['chave']] = $row['valor']; } return $p; }
function getArray($query) { $table = getTable($query); $array = array(); while ($row = getNextRow($table)) { $array[] = $row; } return $array; }
private function getConcretStsTableNames() { $this->stablishmentTypeList = array(); $SQL = "SELECT * FROM stablishTypes " . "ORDER BY name ASC"; $rows = getTable($SQL); foreach ($rows as $row) { $this->stablishmentTypeList[$row['id']] = $row['tableName']; } }
function getAllUsersNames() { $query = "SELECT firstname FROM user ORDER BY firstname ASC"; $table = getTable($query); while ($row = getNextRow($table)) { $newtable[] = $row['firstname']; // Add name to array } return $newtable; }
function getAllLanguageIds() { $query = "SELECT id FROM Languages"; $table = getTable($query); while ($row = getNextRow($table)) { $newtable[] = $row['id']; // Add id to array } return $newtable; }
function userLeaderboard($club, $discipline) { $disciplines = getDisciplines(); $users = getTable("SELECT u.id AS uid, u.fname AS fname, u.sname AS sname, u.sex AS sex, SUM(t.score) AS score, AVG(t.score) AS avg\r\n\t\t\t\t\t\t\tFROM users AS u, timeline AS t, rounds AS r\r\n\t\t\t\t\t\t\tWHERE u.clubid='" . $club['cid'] . "' AND u.id = t.userid AND r.id = t.roundid " . $disciplines[$discipline] . "\r\n\t\t\t\t\t\t\tGROUP BY u.id\r\n\t\t\t\t\t\t\tORDER BY score DESC"); $output = "<h2>Leaderboard:</h2>" . "<table class='leaderboard'>" . "<tr><td>Name</td><td>Total Score</td><td>Average Score</td></tr>"; for ($i = 0; $i < count($users); $i++) { $output .= "<tr><td><a href='/group3/dashboard?uid=" . $users[$i]['uid'] . "'>" . $users[$i]['fname'] . " " . $users[$i]['sname'] . "</a></td><td>" . $users[$i]['score'] . "</td><td>" . round($users[$i]['avg'], 2) . "</td></tr>"; } $output .= "</table>"; return $output; }
public function merge($entity) { $table = getTable($entity); $data = getData($entity); $idColumn = key($data); $id = array_shift($data); $where = buildWhere($idColumn, $id); $update = $this->conn->update($table, $data); $return = $update->where($where, $id)->execute(); return $return; }
function getLastBidInfo($auctionId) { $link = getConnection(); $tableName = getTable('auction_bid'); $sql = "SELECT * FROM `{$tableName}` WHERE `productauction_id`={$auctionId} AND `status`<>'2' ORDER BY `auctionbid_id` DESC"; $result = mysql_query($sql, $link); if ($result) { return mysql_fetch_assoc($result); } else { return false; } }
function modalidadeGetByFiltro($status_array, $reject_status_array) { $where = ''; if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } return getTable('modalidades', $where, 'nome'); }
function render() { $res = rss_query("select url from " . getTable("channels") . " where id = " . $this->fid); if (!defined('MAGPIE_DEBUG') || !MAGPIE_DEBUG) { define('MAGPIE_DEBUG', true); } list($url) = rss_fetch_row($res); define('MAGPIE_CACHE_ON', false); $rss = fetch_rss($url); echo "<pre>\n"; echo htmlentities(print_r($rss, 1)); echo "</pre>\n"; }
function eventosGetByFiltro($status_array, $reject_status_array) { $where = ''; if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } return getTable("eventos_total", $where, "id_evento"); }
function localGetByFiltro($status_array, $reject_status_array) { $where = ''; if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } return getTable("locais", $where, "nome"); }
function __exp__getFromDelicious($id) { list($url) = rss_fetch_row(rss_query('select url from ' . getTable('item') . " where id={$id}")); $ret = array(); $durl = "http://del.icio.us/url/" . md5($url) . "?settagview=list"; $bfr = getUrl($durl, 3000); if ($bfr) { define('DLSRX', '|<a href="/tag/([^"]+)".*>\\1</a>|U'); if ($bfr && preg_match_all(DLSRX, $bfr, $hits, PREG_SET_ORDER)) { $hits = array_slice($hits, 0, MAX_TAGS_PER_ITEM); foreach ($hits as $hit) { $ret[] = $hit[1]; } } } return "{$id}," . implode(" ", $ret); }
function bilheteGetByFiltro($id_visitante, $status_array, $reject_status_array) { $where = ''; if ($id_visitante !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_visitante = " . dbInteger($id_visitante); } if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } return getTable('bilhetes_total', $where, 'acontecimento_data, id_entidade, data'); }
function equipasPorModalidade($id_modalidade, $status_array, $reject_status_array) { $where = ''; if ($id_modalidade !== -1) { $where .= $where == '' ? '' : ' AND '; $where .= "id_modalidade = " . dbInteger($id_modalidade); } if ($status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status IN ('" . join("', '", $status_array) . "')"; } if ($reject_status_array !== null) { $where .= $where == '' ? '' : ' AND '; $where .= "status NOT IN ('" . join("', '", $reject_status_array) . "')"; } return getTable('equipas_total', $where, 'modalidade_nome, pais_nome'); }
function set_admin_pass($uname = null, $pass = null) { $sql = "select count(*) from " . getTable('users') . " where password != '' and ulevel >=99"; list($adminexists) = rss_fetch_row(rss_query($sql)); if ($adminexists) { die('Oops. Admin already exists!'); } if ($uname && $pass) { rss_query("update " . getTable('users') . " set uname='{$uname}', " . "password='******' where ulevel=99"); rss_invalidate_cache(); rss_redirect('admin/'); exit; } admin_header(); ?> <script type="text/javascript"> <!-- function on_submit_password_match() { pass=document.getElementById('password').value; pass2=document.getElementById('password2').value; if(pass !== pass2){ msg = '<?php echo __('Passwords do not match!'); ?> '; document.getElementById('admin_match_result').innerHTML = msg; document.getElementById('password').value = ''; document.getElementById('password2').value = ''; return false; }else{ document.getElementById('password2').value = ''; return loginHandler(); } } --> </script> <?php echo "\n<div id=\"channel_admin\" class=\"frame\">"; echo "<h2></h2>\n" . __('<p>No Administrator has been specified yet!</p><p>Please provide an Administrator username and password now!</p>'); echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" onsubmit=\"return on_submit_password_match();\" method=\"post\">\n" . "<fieldset style=\"width:400px;\">" . "<p><label style=\"display:block\" for=\"username\">" . __('Username') . ":</label>\n" . "<input type=\"text\" id=\"username\" name=\"username\" /></p>\n" . "<p><label style=\"display:block\" for=\"password\">" . __('Password') . ":</label>\n" . "<input type=\"password\" id=\"password\" name=\"password\" /></p>\n" . "<p><label style=\"display:block\" for=\"password2\">" . __('Password (again)') . ":</label>\n" . "<input type=\"password\" id=\"password2\" name=\"password2\" /></p>\n" . "<p><input type=\"submit\" value=\"" . __('OK') . "\" /></p>\n" . "<div style=\"display:inline;\" id=\"admin_match_result\"></div>\n" . "</fieldset>\n" . "</form>\n"; echo "</div>\n"; admin_footer(); exit; }
function dashboard() { $idtoken = _VERSION_ . "-" . md5($_SERVER["HTTP_HOST"]); $magpieCacheAge = 60 * 60 * 24; if (function_exists('apache_request_headers')) { $hdrs = apache_request_headers(); if (isset($hdrs['Pragma']) && $hdrs['Pragma'] == 'no-cache' || isset($hdrs['Cache-Control']) && $hdrs['Cache-Control'] == 'no-cache') { $magpieCacheAge = 0; } } define('MAGPIE_FETCH_TIME_OUT', 2); define('MAGPIE_CACHE_AGE', $magpieCacheAge); $rs = rss_query("select id, title, position, url, obj, unix_timestamp(daterefreshed), itemcount " . " from " . getTable('dashboard') . " order by position asc"); $rss = array(); while (list($id, $title, $pos, $url, $obj, $ts, $cnt) = rss_fetch_row($rs)) { if ($obj && time() - $ts < $magpieCacheAge) { $rss[$title] = unserialize($obj); } else { $old_level = error_reporting(E_ERROR); $rss[$title] = fetch_rss($url . $idtoken); error_reporting($old_level); if ($rss[$title] && is_object($rss[$title])) { $rss[$title]->items = array_slice($rss[$title]->items, 0, $cnt); rss_query('update ' . getTable('dashboard') . " set obj='" . rss_real_escape_string(serialize($rss[$title])) . "', " . " daterefreshed=now()\twhere id={$id}"); } } if ($rss[$title] && is_object($rss[$title])) { if ($pos == 0) { echo "\n\t\t\t\t\t\t\t<h2 style=\"margin-bottom: 0.5em\">{$title}</h2>\n\t\t\t\t\t\t\t<div id=\"db_main\">\n\t\t\t\t\t\t\t<ul>"; foreach ($rss[$title]->items as $item) { echo "<li class=\"item unread\">\n" . "<h4><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a></h4>\n" . "<h5>Posted: " . time_since(strtotime($item['pubdate'])) . " ago </h5>\n" . "<div class=\"content\">" . $item['content']['encoded'] . "</div>\n</li>\n"; } echo "</ul></div>\n"; } else { echo "<div class=\"frame db_side\">\n"; db_side($title, $rss[$title]); echo "</div>"; } } } }
function textSearchService($text, $partialmatch, $author, $checkcomments) { if (strlen($text) < 3) { return NULL; } $text = makeSafeForDAO($text); $selectfrom = "SELECT * FROM articles "; $where = "WHERE body LIKE '%" . $text . "%' AND is_deleted IS NULL AND is_draft IS NULL "; $orderby = " ORDER BY date_posted DESC, time_posted DESC;"; $findWordAlone = "| " . $text . "[ !?,.:;'/)]|i"; $findWordAnywhere = "|" . $text . "|i"; if ($partialmatch == 0) { $pattern = $findWordAlone; } else { $pattern = $findWordAnywhere; } if ($author == "0") { } else { $where .= " AND author_username = '******' "; } if ($checkcomments == "0") { $where .= " AND comment_to IS NULL"; } $query = $selectfrom . $where . $orderby; $newtable = array(); $table = getTable($query); $num_rows = getRowsAffected($table); if ($table && $num_rows > 0) { while ($row = getNextRow($table)) { if (preg_match($pattern, $row['body'])) { $newtable[] = $row; // Add row to array } } return $newtable; } else { return NULL; } }
<?php header('content-type:text/html;charset=utf-8'); // 作业1,输出4行5列的表格、 function getTable() { echo '<table border="1" cellpadding="0" cellspacing="0">'; for ($i = 1; $i <= 4; $i++) { echo '<tr>'; for ($j = 1; $j <= 5; $j++) { echo '<td>X</td>'; } echo '</tr>'; } echo '</table>'; } getTable(); echo '<hr />'; // 作业2 得到2015年8月21日 星期五 $search = array(0, 1, 2, 3, 4, 5, 6); $replace = array('日', '一', '二', '三', '四', '五', '六'); $string = date('w'); echo date('Y年m月d日 星期') . str_replace($search, $replace, $string);
function tag_edit($tid) { $sql = "select id, tag from " . getTable("tag") . " where id={$tid}"; $res = rss_query($sql); list($id, $tag) = rss_fetch_row($res); echo "<div>\n" . "<h2>" . ucfirst(__('edit')) . " '{$tag}'</h2>\n" . "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\" id=\"tagedit\">\n" . "<div style=\"inline\"><input type=\"hidden\" name=\"" . CST_ADMIN_DOMAIN . "\" value=\"" . CST_ADMIN_DOMAIN_TAGS . "\"/>\n" . "<input type=\"hidden\" name=\"action\" value=\"" . CST_ADMIN_SUBMIT_EDIT . "\"/>\n" . "<input type=\"hidden\" name=\"id\" value=\"{$tid}\"/>\n" . "<label for=\"t_name\">" . __('Rename to...') . "</label>\n" . "<input type=\"text\" id=\"t_name\" name=\"t_name\" value=\"{$tag}\"/>\n" . "<input type=\"submit\" name=\"action_\" value=\"" . __('Submit Changes') . "\"/></div>" . "</form></div>\n"; }
} if ($send_module == 'Targets') { $send_module = 'Prospects'; } $helpPath = 'modules/' . $send_module . '/language/' . $send_lang . '.help.' . $send_action . '.html'; $sugar_smarty = new Sugar_Smarty(); //if the language is english then be sure to skip this check, otherwise go to the support //portal if the file is not found. if ($send_lang != 'en_us' && file_exists($helpPath)) { $sugar_smarty->assign('helpFileExists', TRUE); $sugar_smarty->assign('helpPath', $helpPath); $sugar_smarty->assign('helpBar', getHelpBar($send_module)); $sugar_smarty->assign('bookmarkScript', bookmarkJS()); $sugar_smarty->assign('title', $mod_strings['LBL_SUGARCRM_HELP'] . " - " . $send_module); $sugar_smarty->assign('styleSheet', SugarThemeRegistry::current()->getCSS()); $sugar_smarty->assign('table', getTable()); $sugar_smarty->assign('endtable', endTable()); $sugar_smarty->assign('charset', $app_strings['LBL_CHARSET']); echo $sugar_smarty->fetch('modules/Administration/SupportPortal.tpl'); } else { if (empty($send_module)) { $send_module = 'toc'; } $dev_status = 'GA'; //If there is an alphabetic portion between the decimal prefix and integer suffix, then use the //value there as the dev_status value $dev_status = getVersionStatus($GLOBALS['sugar_version']); $send_version = getMajorMinorVersion($GLOBALS['sugar_version']); $editionMap = array('ENT' => 'Enterprise', 'PRO' => 'Professional', 'CE' => 'Community_Edition'); if (!empty($editionMap[$send_edition])) { $send_edition = $editionMap[$send_edition];
global $array, $column; $array = $arr; $column = $col; usort($array, "cmp"); return $array; } $ip = $_SERVER['REMOTE_ADDR']; $entry_line = $ip . "\r\n"; $fp = fopen('logs.txt', 'a'); fputs($fp, $entry_line); fclose($fp); $file = file('logs.txt'); $counts = array_count_values($file); $ipList = array_unique($file); $array = array(); $ind = 0; for ($i = 0; $i < count($file); $i++) { if (array_key_exists($i, $ipList)) { $array[$ind][0] = $ipList[$i]; $array[$ind++][1] = $counts[$ipList[$i]]; } } $array = razor_sort($array, 1); $text = ''; for ($i = count($array) - 1; $i >= 1; $i--) { $text .= getRow($array[$i][0], $array[$i][1]); } echo getTable($text); ?> </body> </html>
function modifrepGetAll() { return getTable("modifrep", "", ""); }