コード例 #1
0
function api_data_source_remove_multi($local_data_ids)
{
    $ids_to_delete = "";
    $dtd_ids_to_delete = "";
    $i = 0;
    $j = 0;
    if (sizeof($local_data_ids)) {
        foreach ($local_data_ids as $local_data_id) {
            if ($i == 0) {
                $ids_to_delete .= $local_data_id;
            } else {
                $ids_to_delete .= ", " . $local_data_id;
            }
            $i++;
        }
        $data_template_data_ids = db_fetch_assoc("SELECT id\n\t\t\tFROM data_template_data\n\t\t\tWHERE local_data_id IN ({$ids_to_delete})");
        if (sizeof($data_template_data_ids)) {
            foreach ($data_template_data_ids as $data_template_data_id) {
                if ($j == 0) {
                    $dtd_ids_to_delete .= $data_template_data_id["id"];
                } else {
                    $dtd_ids_to_delete .= ", " . $data_template_data_id["id"];
                }
                $j++;
            }
            db_execute("DELETE FROM data_template_data_rra WHERE data_template_data_id IN ({$dtd_ids_to_delete})");
            db_execute("DELETE FROM data_input_data WHERE data_template_data_id IN ({$dtd_ids_to_delete})");
        }
        db_execute("DELETE FROM data_template_data WHERE local_data_id IN ({$ids_to_delete})");
        db_execute("DELETE FROM data_template_rrd WHERE local_data_id IN ({$ids_to_delete})");
        db_execute("DELETE FROM poller_item WHERE local_data_id IN ({$ids_to_delete})");
        db_execute("DELETE FROM data_local WHERE id IN ({$ids_to_delete})");
    }
}
コード例 #2
0
 function __perform_refresh_thumbnails_batch()
 {
     if ($this->_batchlimit > 0) {
         $results = fetch_file_cache_rs('ITEM');
         if ($results) {
             while ($file_cache_r = db_fetch_assoc($results)) {
                 // its not a case of only a thumbnail, if not even the source exists
                 if (file_cache_get_cache_file($file_cache_r) !== FALSE && file_cache_get_cache_file_thumbnail($file_cache_r) === FALSE) {
                     // in this case we want to refresh the URL, so TRUE as last parameter idicates overwrite
                     if (file_cache_save_thumbnail_file($file_cache_r, $errors)) {
                         $this->_processed++;
                     } else {
                         $this->_failures++;
                     }
                     // don't process anymore this time around.
                     if ($this->_processed >= $this->_batchlimit) {
                         break;
                     }
                 }
             }
             db_free_result($results);
         }
     }
     $this->_remaining = fetch_file_cache_missing_thumbs_cnt('ITEM');
 }
function marriage_lovedrinks()
{
    $z = 2;
    $s = get_module_setting('loveDrinksAdd');
    if (is_module_installed('drinks') && $s < $z) {
        $sql = array();
        $ladd = array();
        if ($s < 1) {
            // We use 'lessthan' so more drinks can be packaged with this
            $sql[] = "INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Love Brew', 1, 25, 5, 0, 0, 0, 20, 0, 5, 15, 0.0, 0, 0, 'Cedrik reaches under the bar, pulling out a purple cupid shaped bottle... as he pours it into a crystalline glass, the glass shines and he puts a pineapple within the liquid... \"Here, have a Love Brew..\" says Cedrik.. and as you try it, you feel uplifted!', '`%Love Brew', 12, 'You remember love..', 'Despair sets in.', '1.1', '.9', '1.5', '0', '', '', '')";
            $ladd[] = "Love Brew";
        }
        if ($s < 2) {
            // We use 'lessthan' so more drinks can be packaged with this
            $sql[] = "INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Heart Mist', 1, 25, 5, 0, 0, 0, 20, 0, 5, 15, 0.0, 0, 0, 'Cedrik grabs for a rather garish looking bottle on the shelf behind him... as he pours it into a large yellow mug, the porcelain seems to dissolve.. ooh er.. he puts a tomato within the sweet smelling gunk... \"Here, have a Heart Mist..\" says Cedrik.. and as you try it, you see symbols of love!', '`\$Heart Mist', 18, '`%Misty hearts fly around you..', '`#The sky falls...', '1.1', '.9', '1.5', '0', '', '', '')";
            $ladd[] = "Heart Misy";
        }
        foreach ($sql as $val) {
            db_query($val);
        }
        foreach ($ladd as $val) {
            $sql = "SELECT * FROM " . db_prefix("drinks") . " WHERE name='{$val}' ORDER BY costperlevel";
            $result = db_query($sql);
            $row = db_fetch_assoc($result);
            set_module_objpref('drinks', $row['drinkid'], 'loveOnly', 1, 'marriage');
        }
        set_module_setting('loveDrinksAdd', $z);
        output("`n`c`b`^Marriage Module - Drinks have been added to the Loveshack`0`b`c");
    } elseif (!is_module_active('drinks')) {
        set_module_setting('loveDrinksAdd', 0);
    }
}
コード例 #4
0
 function getlabeltree()
 {
     $root = array();
     $root['id'] = 'root';
     $root['name'] = __('Labels');
     $root['items'] = array();
     $result = db_query($this->link, "SELECT *\n\t\t\tFROM ttrss_labels2\n\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . "\n\t\t\tORDER BY caption");
     while ($line = db_fetch_assoc($result)) {
         $label = array();
         $label['id'] = 'LABEL:' . $line['id'];
         $label['bare_id'] = $line['id'];
         $label['name'] = $line['caption'];
         $label['fg_color'] = $line['fg_color'];
         $label['bg_color'] = $line['bg_color'];
         $label['type'] = 'label';
         $label['checkbox'] = false;
         array_push($root['items'], $label);
     }
     $fl = array();
     $fl['identifier'] = 'id';
     $fl['label'] = 'name';
     $fl['items'] = array($root);
     print json_encode($fl);
     return;
 }
コード例 #5
0
    function handleOption($option, $currentValue)
    {
        $count = 0;
        $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="externalFeed" ORDER BY `aux`');
        if ($result) {
            $list = array();
            while ($row = db_fetch_assoc($result)) {
                $count++;
                $key = $row['data'];
                $site = $row['aux'];
                ?>
				<div>
					<label><?php 
                printf(gettext('<em><strong>%1$s</strong></em> key=%2$s'), $site, $key);
                ?>
 <input type="checkbox" name="externalFeed_delete_<?php 
                echo $site;
                ?>
" /></label>
				</div>
				<?php 
            }
        }
        if (!$count) {
            echo gettext('No sites registered');
        }
    }
コード例 #6
0
ファイル: welcome.php プロジェクト: horrabin/opendb
function get_announcements_block()
{
    $buffer = '';
    if (is_user_granted_permission(PERM_ADMIN_ANNOUNCEMENTS)) {
        // include a login warning if user password and email are still the defaults
        if (get_opendb_session_var('user_id') == 'admin') {
            $announcements_rs = get_admin_announcements_rs();
            while (list(, $announcement_r) = each($announcements_rs)) {
                $buffer .= "<li><h4>" . $announcement_r['heading'] . "</h4>\n\t\t\t\t\t<p class=\"content\">" . $announcement_r['message'] . "<a class=\"adminLink\" href=\"" . $announcement_r['link'] . "\">" . $announcement_r['link_text'] . "</a></p>";
            }
        }
    }
    if (get_opendb_config_var('welcome.announcements', 'enable') !== FALSE && is_user_granted_permission(PERM_VIEW_ANNOUNCEMENTS)) {
        $results = fetch_announcement_rs('submit_on', 'DESC', 0, get_opendb_config_var('welcome.announcements', 'display_count'), 'Y', 'Y');
        if ($results) {
            while ($announcement_r = db_fetch_assoc($results)) {
                $buffer .= "<li><h4>" . $announcement_r['title'] . "</h4>";
                $buffer .= "<small class=\"submitDate\">" . get_localised_timestamp(get_opendb_config_var('welcome.announcements', 'datetime_mask'), $announcement_r['submit_on']) . "</small>";
                $buffer .= "<p class=\"content\">" . nl2br($announcement_r['content']) . "</p></li>";
            }
            db_free_result($results);
        }
    }
    if (strlen($buffer) > 0) {
        return "\n<div id=\"announcements\">" . "<h3>" . get_opendb_lang_var('announcements') . "</h3>" . "\n<ul>" . $buffer . "\n</ul></div>";
    } else {
        return NULL;
    }
}
コード例 #7
0
ファイル: TitleMask.class.php プロジェクト: horrabin/opendb
 /**
     @param mask_group - if an array, then will use first group that has values defined.
 */
 function TitleMask($mask_group = NULL)
 {
     if ($mask_group !== NULL) {
         if (is_array($mask_group)) {
             while (list(, $group) = each($mask_group)) {
                 $results = fetch_title_display_mask_rs($group);
                 if ($results) {
                     $this->_mask_group = $group;
                     break;
                 }
             }
         } else {
             $this->_mask_group = $mask_group;
             $results = fetch_title_display_mask_rs($mask_group);
         }
         $default_found = FALSE;
         if ($results) {
             while ($title_display_mask_r = db_fetch_assoc($results)) {
                 if ($title_display_mask_r['s_item_type_group'] == '*' && $title_display_mask_r['s_item_type'] == '*') {
                     $default_found = TRUE;
                 }
                 $this->_title_mask_rs[] = $title_display_mask_r;
             }
             db_free_result($results);
         }
         // fall back on a default if none defined
         if (!$default_found) {
             $this->_title_mask_rs[] = array('s_item_type_group' => '*', 's_item_type' => '*', 'display_mask' => '{title}');
         }
     }
 }
function scrapbots_get_armies($defenderid, $attackerid)
{
    global $session;
    //get attackers
    $sql = "SELECT id,owner,name,activated,hitpoints,brains,brawn,briskness,junglefighter,retreathp FROM " . db_prefix("scrapbots") . " WHERE owner = {$attackerid}";
    $result = db_query($sql);
    $attacker = array();
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $attacker[$i] = db_fetch_assoc($result);
    }
    $sql = "SELECT id,owner,name,activated,hitpoints,brains,brawn,briskness,junglefighter,retreathp FROM " . db_prefix("scrapbots") . " WHERE owner = {$defenderid}";
    $result = db_query($sql);
    $defender = array();
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $defender[$i] = db_fetch_assoc($result);
    }
    debug("Debugging Attacker");
    debug($attacker);
    debug("Debugging Defender");
    debug($defender);
    $armies = array("attacker" => $attacker, "defender" => $defender);
    //Set starting vals
    $armies['attacker']['retreatpct'] = get_module_pref("retreatpct", "scrapbots", $attackerid);
    $armies['defender']['retreat'] = get_module_pref("retreatpct", "scrapbots", $defenderid);
    debug("Debugging Armies");
    debug($armies);
    return $armies;
}
function monsterkills_run()
{
    page_header("Most Monster Kills");
    $acc = db_prefix("accounts");
    $mp = db_prefix("module_userprefs");
    $sql = "SELECT {$acc}.name AS name,\r\n\t\t{$acc}.acctid AS acctid,\r\n\t\t{$mp}.value AS kills,\r\n\t\t{$mp}.userid FROM {$mp} INNER JOIN {$acc}\r\n\t\tON {$acc}.acctid = {$mp}.userid \r\n\t\tWHERE {$mp}.modulename = 'monsterkills' \r\n\t\tAND {$mp}.setting = 'kills' \r\n\t\tAND {$mp}.value > 0 ORDER BY ({$mp}.value+0)\t\r\n\t\tDESC limit " . get_module_setting("list") . "";
    $result = db_query($sql);
    $rank = translate_inline("Kills");
    $name = translate_inline("Name");
    output("`n`b`c`@Most`\$ Monster `@Kills`n`n`c`b");
    rawoutput("<table border='0' cellpadding='2' cellspacing='1' align='center'>");
    rawoutput("<tr class='trhead'><td align=center>{$name}</td><td align=center>{$rank}</td></tr>");
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $row = db_fetch_assoc($result);
        if ($row['name'] == $session['user']['name']) {
            rawoutput("<tr class='trhilight'><td>");
        } else {
            rawoutput("<tr class='" . ($i % 2 ? "trdark" : "trlight") . "'><td align=left>");
        }
        output_notl("%s", $row['name']);
        rawoutput("</td><td align=right>");
        output_notl("%s", $row['kills']);
        rawoutput("</td></tr>");
    }
    rawoutput("</table>");
    addnav("Back to HoF", "hof.php");
    villagenav();
    page_footer();
}
function get_typeid($modulename)
{
    $sql = "SELECT typeid FROM " . db_prefix("dwellingtypes") . " WHERE module='{$modulename}'";
    $res = db_query($sql);
    $row = db_fetch_assoc($res);
    return $row['typeid'];
}
コード例 #11
0
ファイル: podbor_function.php プロジェクト: gblok/rsc
function getProductByBrand($brandID)
{
    $sql = '
        select
        categoryID,
        name,
        productID,
        default_picture,
        sort_order,
        enabled,
        product_code,
        uri,
        uri_opt_val
        ' . convert_prices() . '
        FROM ' . PRODUCTS_TABLE . '
        WHERE categoryID = ' . (int) $brandID . '
        ORDER BY name';
    $q = db_query($sql);
    $result = array();
    while ($row = db_fetch_assoc($q)) {
        _setPictures($row);
        $row['url'] = fu_make_url($row);
        $result[] = $row;
    }
    return $result;
}
function bioextension_dohook($hookname, $args)
{
    global $session;
    if ($hookname == "bioinfo") {
        $sql = "SELECT donation FROM " . db_prefix("accounts") . " WHERE acctid = '" . $args['acctid'] . "'";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        if ($row['donation'] >= get_module_setting("threshhold")) {
            $bio = get_module_pref("user_extendedbio", "bioextension", $args['acctid']);
            $link = get_module_pref("user_extlink", "bioextension", $args['acctid']);
            $bio = str_replace(chr(13), "`n", $bio);
            $bio = stripslashes($bio);
            output("`0%s`n`n", $bio);
            if (substr($link, 0, 5) == "http:") {
                rawoutput("<a href=\"" . $link . "\">Player's webpage</a><br /><br />");
            }
        }
    } else {
        if ($hookname == "footer-prefs") {
            $bio = get_module_pref("user_extendedbio");
            $limit = get_module_setting("charlimit");
            if (strlen($bio) > $limit) {
                output("`c`4`bWARNING`b`0`c`nYour Extended Bio is oversized by %s characters.  If you navigate away from this page, your Extended Bio will have %s characters indiscriminately cut from the end.  Please edit and re-save your Extended Bio to avoid cuts.", strlen($bio) - $limit, strlen($bio) - $limit);
                $bio = substr($bio, 0, $limit);
                set_module_pref("user_extendedbio", $bio);
            }
        }
    }
    return $args;
}
function lovers_install()
{
    module_addhook("newday");
    module_addhook("inn");
    $sql = "DESCRIBE " . db_prefix("accounts");
    $result = db_query($sql);
    while ($row = db_fetch_assoc($result)) {
        if ($row['Field'] == "seenlover") {
            $sql = "SELECT seenlover,acctid FROM " . db_prefix("accounts") . " WHERE seenlover>0";
            $result1 = db_query($sql);
            debug("Migrating seenlover.`n");
            while ($row1 = db_fetch_assoc($result1)) {
                $sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) VALUES ('lovers','seenlover',{$row1['acctid']},{$row1['seenlover']})";
                db_query($sql);
            }
            //end while
            debug("Dropping seenlover column from the user table.`n");
            $sql = "ALTER TABLE " . db_prefix("accounts") . " DROP seenlover";
            db_query($sql);
            //drop it from the user's session too.
            unset($session['user']['seenlover']);
        }
        //end if
    }
    //end while
    return true;
}
コード例 #14
0
ファイル: poller_info.php プロジェクト: songchin/Cacti
function api_poller_list($filter_array = "", $current_page = 0, $rows_per_page = 0) {
	require_once(CACTI_BASE_PATH . "/lib/poller/poller_form.php");

	$sql_where = "";
	/* validation and setup for the WHERE clause */
	if ((is_array($filter_array)) && (sizeof($filter_array) > 0)) {
		/* validate each field against the known master field list */
		$field_errors = api_poller_fields_validate(sql_filter_array_to_field_array($filter_array));

		/* if a field input error has occured, register the error in the session and return */
		if (sizeof($field_errors) > 0) {
			field_register_error($field_errors);
			return false;
		/* otherwise, form an SQL WHERE string using the filter fields */
		}else{
			$sql_where = sql_filter_array_to_where_string($filter_array, api_poller_form_list(), true);
		}
	}

	$sql_limit = "";
	/* validation and setup for the LIMIT clause */
	if ((is_numeric($current_page)) && (is_numeric($rows_per_page)) && (!empty($current_page)) && (!empty($rows_per_page))) {
		$sql_limit = "LIMIT " . ($rows_per_page * ($current_page - 1)) . ",$rows_per_page";
	}

	return db_fetch_assoc("SELECT
		*
		FROM poller
		$sql_where
		ORDER BY poller.name
		$sql_limit");
}
コード例 #15
0
function checkban(string $login, bool $connect = false) : bool
{
    global $session;
    $accounts = db_prefix('accounts');
    $bans = db_prefix('accounts');
    $today = date('Y-m-d');
    $sql = db_query("SELECT lastip, uniquid, banoverride, superuser FROM {$accounts}\n        WHERE login = '******'");
    $row = db_fetch_assoc($sql);
    if ($row['banoverride'] || $row['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
        return false;
    }
    db_free_result($sql);
    $sql = db_query("SELECT * FROM {$bans}\n        WHERE (\n            (ipfilter = '{$row['lastip']}' OR ipfilter = '{$_SERVER['REMOTE_ADDR']}')\n            OR (uniqueid = '{$row['uniqueid']}' OR uniqueid = '{$_COOKIE['lgi']}')\n        )\n        AND (banexpire = '000-00-00' OR banexpire >= '{$today}')");
    if (db_num_rows($sql) > 0) {
        if ($connect) {
            $session = [];
            tlschema('ban');
            $session['message'] .= translate_inline('`n`4You fall under a ban currently in place on this website:');
            while ($row = db_fetch_assoc($sql)) {
                $session['message'] .= "`n{$row['banreason']}`n";
                if ($row['banexpire'] == '0000-00-00') {
                    $session['message'] .= translate_inline("`\$This ban is permanent!`0");
                } else {
                    $session['message'] .= sprintf_translate("`^This ban will be removed `\$after`^ %s.`0", date("M d, Y", strtotime($row['banexpire'])));
                }
                db_query("UPDATE {$bans}\n                    SET lasthit = '{$today} 00:00:00'\n                    WHERE ipfilter = '{$row['ipfilter']}'\n                    AND uniqueid = '{$row['uniqueid']}'\n                    ");
            }
            $session['message'] .= translate_inline("`n`4If you wish, you may appeal your ban with the petition link.");
            tlschema();
            header('Location: home.php');
        }
        return true;
    }
    return false;
}
function get_partner($player = false)
{
    global $session;
    if ($player === false) {
        $partner = getsetting("barmaid", "`%Violet");
        if ($session['user']['sex'] != SEX_MALE) {
            $partner = getsetting("bard", "`^Seth");
        }
    } else {
        if ($session['user']['marriedto'] == INT_MAX) {
            $partner = getsetting("barmaid", "`%Violet");
            if ($session['user']['sex'] != SEX_MALE) {
                $partner = getsetting("bard", "`^Seth");
            }
        } else {
            $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid = {$session['user']['marriedto']}";
            $result = db_query($sql);
            if ($row = db_fetch_assoc($result)) {
                $partner = $row['name'];
            } else {
                $session['user']['marriedto'] = 0;
                $partner = getsetting("barmaid", "`%Violet");
                if ($session['user']['sex'] != SEX_MALE) {
                    $partner = getsetting("bard", "`^Seth");
                }
            }
        }
    }
    //	No need to translate names...
    //	tlschema("partner");
    //	$partner = translate_inline($partner);
    //	tlschema();
    return $partner;
}
コード例 #17
0
function profilefields_show($uid)
{
    $l = '';
    $a = array();
    $q = db_query("SHOW COLUMNS FROM prefix_user");
    while ($r = db_fetch_assoc($q)) {
        $a[$r['Field']] = $r['Field'];
    }
    $q = db_query("SELECT id, `show`, func FROM prefix_profilefields WHERE func < 4 ORDER BY pos");
    while ($r = db_fetch_assoc($q)) {
        if ($r['func'] == 1) {
            $str = @db_result(db_query("SELECT val FROM prefix_userfields WHERE uid = " . $uid . " AND fid = " . $r['id']), 0);
            $l .= '<tr><td class="Cmite">' . $r['show'] . '</td><td class="Cnorm">' . $str . '</td></tr>';
        } elseif ($r['func'] == 2) {
            $l .= '<tr><td class="Cdark" colspan="2"><b>' . $r['show'] . '</b></td></tr>';
        } elseif ($r['func'] == 3) {
            $str = '';
            if (isset($a[$r['show']])) {
                $str = @db_result(db_query("SELECT `" . $r['show'] . "` FROM prefix_user WHERE id = " . $uid), 0);
            }
            if (function_exists('profilefields_show_spez_' . $r['show'])) {
                $l .= call_user_func('profilefields_show_spez_' . $r['show'], $str, $uid);
            } elseif ($r['show'] != 'opt_pm_popup') {
                $l .= '<tr><td class="Cmite">' . ucfirst($r['show']) . '</td><td class="Cnorm">' . $str . '</td></tr>';
            }
        }
    }
    return $l;
}
function translationconvert_run()
{
    global $session;
    page_header("Translations Convertor Thing");
    output("Outputting all known translations, so that you can do a find-and-replace in the files themselves and we can stop doing this silly translate thing.`n`n");
    if (httpget('delete')) {
        $del = httpget('delete');
        $sql = "UPDATE " . db_prefix("translations") . " SET version='updated' WHERE tid={$del}";
        db_query($sql);
    }
    $sql = "SELECT * FROM " . db_prefix("translations") . " WHERE version='dragonbones' ORDER BY uri";
    $result = db_query($sql);
    $total = 0;
    while ($row = db_fetch_assoc($result)) {
        if ($row['intext'] != $row['outtext']) {
            $total++;
            rawoutput("<a href=\"runmodule.php?module=translationconvert&delete=" . $row['tid'] . "\">MARK</a>");
            addnav("", "runmodule.php?module=translationconvert&delete=" . $row['tid']);
            output_notl("`n`0`b%s`b:", $row['uri']);
            rawoutput("<table width=100%><tr><td width=50% border=1px solid #cccccc>" . $row['intext'] . "</td><td width=50%>" . $row['outtext'] . "</td></tr></table>");
            output_notl("`n`n");
        }
    }
    debug($total);
    addnav("Back to the Grotto", "superuser.php");
    page_footer();
}
コード例 #19
0
ファイル: db.inc.php プロジェクト: adamfranco/segue-1.x
function _valid_db($name, $pass, $admin_auser = 0)
{
    $name = strtolower($name);
    global $dbhost, $dbuser, $dbpass, $dbdb;
    db_connect($dbhost, $dbuser, $dbpass, $dbdb);
    $query = "SELECT * FROM user WHERE user_uname='" . addslashes($name) . "'" . ($admin_auser ? "" : " AND user_pass='******' AND user_authtype='db'");
    $r = db_query($query);
    //	$a = db_fetch_assoc($r);
    //	if (db_num_rows($r)  && $a['pass'] == $pass) {
    if (db_num_rows($r)) {
        $a = db_fetch_assoc($r);
        $x = array();
        // array for returned info
        $x[fullname] = $a[user_fname];
        $x[user] = $name;
        $x[pass] = $pass;
        $x[email] = $a[user_email];
        $x[type] = $a[user_type];
        $x[method] = 'db';
        $x[id] = $a[user_id];
        return $x;
    }
    /*else {
    	    $query = "select * from users where email='$name' and pass='******' and status='open'";
    	    $r = db_query($query);
    	    if (db_num_rows($r)) {
    	        $logmethod = "open";
    	        return $r;
    	    }
    	}*/
    return 0;
}
コード例 #20
0
ファイル: index.php プロジェクト: horrabin/opendb
function display_role_permissions_editor($HTTP_VARS)
{
    global $ADMIN_TYPE;
    global $PHP_SELF;
    echo "\n<form name=\"edit_role_permissions\" action=\"{$PHP_SELF}\" method=\"POST\">";
    echo "\n<input type=\"hidden\" name=\"op\" value=\"" . $HTTP_VARS['op'] . "\">";
    echo "\n<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">";
    echo "\n<input type=\"hidden\" name=\"role_name\" value=\"" . $HTTP_VARS['role_name'] . "\">";
    echo "<table>";
    echo "<tr class=\"navbar\">\n\t<th>Permission</th>\n\t<th>Include</th>\n\t<th>Remember Me</th>\n\t</tr>";
    $results = fetch_role_permission_rs($HTTP_VARS['role_name']);
    if ($results) {
        while ($permission_r = db_fetch_assoc($results)) {
            echo "<tr>";
            echo "<td>";
            echo $permission_r['description'];
            echo "</td>";
            $is_enabled = strlen($permission_r['role_name']) > 0;
            $remember_me_enabled = $permission_r['remember_me_ind'] == 'Y';
            echo "<td><input type=\"checkbox\" class=\"checkbox\" name=\"" . $permission_r['permission_name'] . "[enabled_ind]\" value=\"Y\"" . ($is_enabled ? " CHECKED" : "") . "></td>";
            echo "<td><input type=\"checkbox\" class=\"checkbox\" name=\"" . $permission_r['permission_name'] . "[remember_me_ind]\" value=\"Y\"" . ($remember_me_enabled ? " CHECKED" : "") . "></td>";
            echo "</tr>";
        }
    }
    echo "</table>";
    echo "<input type=\"button\" class=\"button\" value=\"Refresh\" onclick=\"this.form['op'].value='edit'; this.form.submit();\">";
    echo "\n<input type=\"button\" class=\"button\" value=\"Update\" onclick=\"this.form['op'].value='update'; this.form.submit();\">";
    echo "</form>";
}
コード例 #21
0
ファイル: wrms_search.php プロジェクト: Br3nda/medusa
 /**
  * Performs a search using dynamically generated SQL from the input parameters.
  */
 private function search()
 {
     /**
      * Acceptable paramters are;
      *
      */
     $found = false;
     foreach ($this->parameters as $parameterkey => $parameterstring) {
         if (array_key_exists($parameterkey, $this->gettodbfields) && array_key_exists($parameterkey, $this->gettodbjoins)) {
             $found = true;
             $joinsql[] = $this->gettodbjoins[$parameterkey];
             $wheresql[] = $this->formatBoolValues($this->gettodbfields[$parameterkey], $parameterstring);
         }
     }
     if ($found == false) {
         return new error("No usable search terms found.");
     }
     $sql = "SELECT DISTINCT " . $this->gettable . ".* FROM " . $this->gettable . " " . implode(' ', $joinsql) . " WHERE " . implode(' AND ', $wheresql);
     error_logging('DEBUG', "wrms_search auto generated {$sql}");
     $result = db_query($sql);
     $resp = new response('Success');
     while ($row = db_fetch_assoc($result)) {
         $object = $this->sqldata->getNewObject();
         error_logging('DEBUG', "Creating new " . get_class($object) . " in wrms_search");
         $object->populate($row);
         $object->populateChildren();
         $resp->data[] = $object;
     }
     return $resp;
 }
function friendlist_unignore()
{
    global $session;
    $ac = httpget('ac');
    $ignored = rexplode(get_module_pref('ignored', 'friendlist', $ac));
    $iveignored = rexplode(get_module_pref('iveignored'));
    if (in_array($ac, $iveignored)) {
        $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid={$ac} AND locked=0";
        $result = db_query($sql);
        if (db_num_rows($result) > 0) {
            $row = db_fetch_assoc($result);
            $info = sprintf_translate("%s`Q has been removed from your list.", $row['name']);
            require_once "lib/systemmail.php";
            $t = array("`\$Ignore List Removal");
            $mailmessage = array("%s`0`@ has removed you from %s ignore list.", $session['user']['name'], $session['user']['sex'] ? translate_inline("her") : translate_inline("his"));
            systemmail($ac, $t, $mailmessage);
        } else {
            $info = translate_inline("That user no longer exists...");
        }
    }
    $ignored = array_diff($ignored, array($session['user']['acctid']));
    $ignored = rimplode($ignored);
    set_module_pref('ignored', $ignored, 'friendlist', $ac);
    if (in_array($ac, $iveignored)) {
        $iveignored = array_diff($iveignored, array($ac));
        $iveignored = rimplode($iveignored);
        set_module_pref('iveignored', $iveignored);
    }
    output_notl($info);
}
function serverloadperpage_run()
{
    global $session;
    page_header("Server Load by Page Execution Times");
    //Show player number table
    $sql = "SELECT * FROM " . db_prefix("performancepage") . " ORDER BY totalpages DESC";
    $result = db_query($sql);
    output("`bAverage Page Generation Times by script request`b`n");
    rawoutput("<table border='0' cellpadding='2' cellspacing='1' align='center' width='100%'>");
    rawoutput("<tr class='trhead'><td>URL</td><td>Total Count</td><td>Total Time</td><td>Average Time / Page</td></tr>");
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $row = db_fetch_assoc($result);
        if ($row['totalpages'] >= 1) {
            $avg = $row['totaltime'] / $row['totalpages'];
            $max = 100;
            $bwidth = round($avg * 100);
            $bnonwidth = $max - $bwidth;
            if ($bnonwidth > 0) {
                $bar = "<table style='border: solid 1px #000000' width='{$max}' height='7' bgcolor='#333333' cellpadding=0 cellspacing=0><tr><td width='{$bwidth}' bgcolor='#00ff00'></td><td width='{$bnonwidth}'></td></tr></table>";
            } else {
                $over = $bwidth - $max;
                $total = $max + $over;
                $bar = "<table style='border: solid 1px #000000' height='7' width='{$total}' cellpadding=0 cellspacing=0><tr><td width='{$max}' bgcolor='#990000'></td><td width='{$over}' bgcolor='#ff0000'></td></tr></table>";
            }
            rawoutput("<tr class='" . ($i % 2 ? "trdark" : "trlight") . "'>");
            rawoutput("<td>" . $row['page'] . "</td><td>" . number_format($row['totalpages']) . "</td><td>" . $row['totaltime'] . "</td><td>" . $bar . round($row['totaltime'] / $row['totalpages'], 4) . "</td></tr>");
        }
    }
    rawoutput("</table>");
    page_footer();
}
コード例 #24
0
ファイル: UserGroup.php プロジェクト: hultberg/relancms
 /**
  * Provides all members of this group.
  * 
  * @return UserGroupMember[]
  */
 public function getMembers()
 {
     // First get all userIDs that are members.
     $qAllMembers = db_query(sprintf("SELECT `userID`,`access` FROM `%s_group_members` WHERE `groupID`=%d", db_prefix(), $this->getGroupID()));
     $nAllMembers = db_num($qAllMembers);
     // Verify that we got any users.
     if ($qAllMembers === false || $nAllMembers < 1) {
         return array();
     }
     $members = array();
     $userIDs = array();
     $rowsIndexedByUID = array();
     // Fetch each as User
     while ($row = db_fetch_assoc($qAllMembers)) {
         $userIDs[] = $row["userID"];
         $rowsIndexedByUID[$row["userID"]] = $row;
     }
     // Fetch the users.
     $users = UserManager::getInstance()->getUsersByID($userIDs);
     if (count($users) < 1) {
         return array();
     }
     // Create as UserGroupMember
     foreach ($users as $user) {
         $memberRow = $rowsIndexedByUID[$user->getUserID()];
         $member = new UserGroupMember($user->getUserID());
         $member->fillInfo($user->getInfo());
         // fill extra variables
         $member->setAccess($memberRow["access"]);
         $member->setGroup($this);
         $members[] = $member;
         unset($memberRow, $user, $member);
     }
     return $members;
 }
コード例 #25
0
ファイル: init.php プロジェクト: GregThib/Tiny-Tiny-RSS
 function showrelated()
 {
     $id = (int) db_escape_string($_REQUEST['param']);
     $owner_uid = $_SESSION["uid"];
     $result = db_query("SELECT title FROM ttrss_entries, ttrss_user_entries\n\t\t\tWHERE ref_id = id AND id = {$id} AND owner_uid = {$owner_uid}");
     $title = db_fetch_result($result, 0, "title");
     print "<h2>{$title}</h2>";
     $title = db_escape_string($title);
     $result = db_query("SELECT ttrss_entries.id AS id,\n\t\t\t\tfeed_id,\n\t\t\t\tttrss_entries.title AS title,\n\t\t\t\tupdated, link,\n\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\tSIMILARITY(ttrss_entries.title, '{$title}') AS sm\n\t\t\tFROM\n\t\t\t\tttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON (ttrss_feeds.id = feed_id)\n\t\t\tWHERE\n\t\t\t\tttrss_entries.id = ref_id AND\n\t\t\t\tttrss_user_entries.owner_uid = {$owner_uid} AND\n\t\t\t\tttrss_entries.id != {$id} AND\n\t\t\t\tdate_entered >= NOW() - INTERVAL '2 weeks'\n\t\t\tORDER BY\n\t\t\t\tsm DESC, date_entered DESC\n\t\t\tLIMIT 10");
     print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
     while ($line = db_fetch_assoc($result)) {
         print "<li>";
         print "<div class='insensitive small' style='margin-left : 20px; float : right'>" . smart_date_time(strtotime($line["updated"])) . "</div>";
         $sm = sprintf("%.2f", $line['sm']);
         print "<img src='images/score_high.png' title='{$sm}'\n\t\t\t\tstyle='vertical-align : middle'>";
         $article_link = htmlspecialchars($line["link"]);
         print " <a target=\"_blank\" href=\"{$article_link}\">" . $line["title"] . "</a>";
         print " (<a href=\"#\" onclick=\"viewfeed(" . $line["feed_id"] . ")\">" . htmlspecialchars($line["feed_title"]) . "</a>)";
         print " <span class='insensitive'>({$sm})</span>";
         print "</li>";
     }
     print "</ul>";
     print "<div style='text-align : center'>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('trgmRelatedDlg').hide()\">" . __('Close this window') . "</button>";
     print "</div>";
 }
function friendlist_search()
{
    global $session;
    $n = httppost("n");
    rawoutput("<form action='runmodule.php?module=friendlist&op=search' method='POST'>");
    addnav("", "runmodule.php?module=friendlist&op=search");
    if ($n != "") {
        $string = "%";
        for ($x = 0; $x < strlen($n); $x++) {
            $string .= substr($n, $x, 1) . "%";
        }
        $sql = "SELECT name,dragonkills,acctid FROM " . db_prefix("accounts") . " WHERE name LIKE '%{$string}%' AND acctid<>" . $session['user']['acctid'] . " AND locked=0 ORDER BY level,dragonkills";
        $result = db_query($sql);
        if (db_num_rows($result) > 0) {
            $ignored = rexplode(get_module_pref('ignored'));
            $friends = rexplode(get_module_pref('friends'));
            $request = rexplode(get_module_pref('request'));
            $iveignored = rexplode(get_module_pref('iveignored'));
            output("`@These users were found:`n");
            rawoutput("<table style='width:60%;text-align:center;' cellpadding='3' cellspacing='0' border='0'>");
            rawoutput("<tr class='trhead'><td>" . translate_inline("Name") . "</td><td>" . translate_inline("Operations") . "</td></tr>");
            for ($i = 0; $i < db_num_rows($result); $i++) {
                $row = db_fetch_assoc($result);
                rawoutput("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'><td>");
                output_notl($row['name']);
                rawoutput("</td><td>");
                if (in_array($row['acctid'], $ignored)) {
                    $info = translate_inline("This user has ignored you.");
                    $info .= " [<a href='runmodule.php?module=friendlist&op=ignore&ac=" . $row['acctid'] . "' class='colDkGreen'>" . translate_inline("Ignore") . "</a>]";
                    addnav("", "runmodule.php?module=friendlist&op=ignore&ac=" . $row['acctid']);
                } elseif (in_array($row['acctid'], $friends)) {
                    $info = translate_inline("This user is already in your list.");
                } elseif (in_array($row['acctid'], $request)) {
                    $info = translate_inline("This user has already requested to you.");
                } else {
                    if (in_array($row['acctid'], $iveignored)) {
                        $info = "[<a href='runmodule.php?module=friendlist&op=unignore&ac=" . $row['acctid'] . "' class='colLtRed'>" . translate_inline("Unignore") . "</a>]";
                        addnav("", "runmodule.php?module=friendlist&op=unignore&ac=" . $row['acctid']);
                    } else {
                        $info = "[<a href='runmodule.php?module=friendlist&op=ignore&ac=" . $row['acctid'] . "' class='colDkGreen'>" . translate_inline("Ignore") . "</a>]";
                        addnav("", "runmodule.php?module=friendlist&op=ignore&ac=" . $row['acctid']);
                        $info .= " - [<a href='runmodule.php?module=friendlist&op=request&ac=" . $row['acctid'] . "' class='colDkGreen'>" . translate_inline("Request") . "</a>]";
                        addnav("", "runmodule.php?module=friendlist&op=request&ac=" . $row['acctid']);
                    }
                }
                rawoutput("{$info}</td></tr>");
            }
            rawoutput("</table>");
        } else {
            output("`c`@`bA user was not found with that name.`b`c");
        }
        output_notl("`n");
    }
    output("`^`b`cFriend Search...`c`b");
    output("`n`nWho do you want to search for?");
    output("`n`nName of user: "******"<input name='n' maxlength='50' value=\"" . htmlentities(stripslashes(httppost('n'))) . "\">");
    $apply = translate_inline("Search");
    rawoutput("<input type='submit' class='button' value='{$apply}'></form>");
}
コード例 #27
0
function viewcommentaryargs_dohook($hook, $args)
{
    global $currentCommentaryArea;
    switch ($hook) {
        case 'blockcommentarea':
            $currentCommentaryArea = $args['section'];
            break;
        case 'viewcommentary':
            $accounts = db_prefix('accounts');
            $commentary = db_prefix('commentary');
            preg_match("/bio.php\\?char=(.*)&ret/", $args['commentline'], $matches);
            $acctid = filter_var($matches[1], FILTER_SANITIZE_NUMBER_INT);
            $sql = db_query_cached("SELECT login, name FROM {$accounts} WHERE acctid = {$acctid}", "commentary-author_name-{$acctid}", 86400);
            $row = db_fetch_assoc($sql);
            $name = $row['name'];
            $login = $row['login'];
            $temp = explode($row['name'], $args['commentline']);
            $temp = str_replace('`3 says, "`#', '', $temp[1]);
            $temp = str_replace('`3"', '', $temp);
            $temp = str_replace('/me', '', $temp);
            $temp = str_replace(':', '', $temp);
            $temp = str_replace('</a>', '', $temp);
            $temp = full_sanitize($temp);
            $temp = addslashes(implode('%', str_split(trim($temp))));
            $sql = db_query("SELECT commentid, comment, postdate FROM {$commentary}\n                WHERE comment LIKE '%{$temp}%'\n                AND section = '{$currentCommentaryArea}'");
            $row = db_fetch_assoc($sql);
            $args = ['commentline' => $args['commentline'], 'section' => $currentCommentaryArea, 'commentid' => $row['commentid'], 'comment' => $row['comment'], 'author_acctid' => $acctid, 'author_login' => $login, 'author_name' => $name, 'date' => $row['postdate']];
            unset($row);
            unset($temp);
            break;
    }
    return $args;
}
コード例 #28
0
ファイル: polling.php プロジェクト: tinchobsas/cacti-gpsmaps
function gpsmap_poller_bottom()
{
    global $config;
    //Here we are getting the available hostnames (Numbers only) and
    //Processing them to create our XML index arrays. So that it can
    //pass an partial IP as a parameter to the region() function in
    //the processregion.php file. Start with high subnet and work down.
    include $config['base_path'] . '/plugins/gpsmap/includes/polling/functions.php';
    $result = db_fetch_assoc("SELECT `hostname` FROM `host`");
    $firstArray = array();
    $secondArray = array();
    $thirdArray = array();
    foreach ($result as $row) {
        list($first, $second, $third, $fourth) = explode('.', gethostbyname($row["hostname"]));
        if (!in_array($first . '.', $firstArray)) {
            $firstArray[] = $first . '.';
        }
        if (!in_array($first . '.' . $second . '.', $secondArray)) {
            $secondArray[] = $first . '.' . $second . '.';
        }
        if (!in_array($first . '.' . $second . '.' . $third . '.', $thirdArray)) {
            $thirdArray[] = $first . '.' . $second . '.' . $third . '.';
        }
    }
    callRegion("all");
    for ($i = 0; $i < count($firstArray); $i++) {
        callRegion($firstArray[$i]);
    }
    for ($i = 0; $i < count($secondArray); $i++) {
        callRegion($secondArray[$i]);
    }
    for ($i = 0; $i < count($thirdArray); $i++) {
        callRegion($thirdArray[$i]);
    }
}
function dwellings_run()
{
    checkday();
    page_header("Dwellings");
    global $session;
    $op = httpget("op");
    $dwid = httpget('dwid');
    $type = httpget('type');
    debug(get_module_pref("location_saver"));
    if ($type == "" && $dwid > 0) {
        $sql = "SELECT type FROM " . db_prefix("dwellings") . " WHERE dwid={$dwid}";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        $type = $row['type'];
    }
    $cityid = httpget('cityid');
    require_once "modules/dwellings/run/case_{$op}.php";
    if ($op != "list" && $op != "") {
        addnav("Leave");
        addnav("Return to Hamlet", "runmodule.php?module=dwellings");
    } else {
        addnav("Navigation");
        villagenav();
    }
    page_footer();
}
function ekd_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "biostat":
            $acctid = $args['acctid'];
            $sql = "SELECT dragonkills FROM " . db_prefix("accounts") . " WHERE acctid = {$acctid}";
            $result = db_fetch_assoc(db_query($sql));
            $tdk = $result['dragonkills'];
            $edk = get_module_pref("edks", "edk", $acctid);
            $cdk = $tdk - $edk;
            if ($edk > 1 && $tdk > 1) {
                output("Out of %s total Drive Kills, %s were Economic Drive Kills.`n", $tdk, $edk);
            } else {
                if ($edk == 1) {
                    output("This player has completed an Economic Drive Kill.`n");
                }
            }
            break;
        case "counciloffices":
            addnav("Ask about the Gun", "runmodule.php?module=edk&op=start");
            break;
    }
    return $args;
}