function add_tbdata(&$oc, $schema, $yearsback = 0)
{
    global $MONPRD, $PRDMON;
    /* fetch prev year trial bal data */
    $tb = new dbSelect("trial_bal_actual", $schema, grp(m("where", "period!='0'"), m("order", "period, acctype, topacc, accnum")));
    $tb->run();
    $cprd = false;
    $cprd_name = false;
    while ($row = $tb->fetch_array()) {
        /* the period in the table data changed */
        if ($cprd != $row["period"]) {
            $cprd = $row["period"];
            $year = getYearOfFinMon($PRDMON[$cprd]) - $yearsback;
            $mon = getMonthNameS($PRDMON[$cprd]);
            $cprd_name = "{$mon} {$year}";
            $oc[$cprd_name] = array();
        }
        if ($row["period"] == 1 && $row["acctype"] != "B") {
            $hcode = new dbSelect("trial_bal", $schema, grp(m("where", "period='1' AND accid='{$row['accid']}'"), m("limit", 1)));
            $hcode->run();
            $row = $hcode->fetch_array();
        } else {
            if ($row["period"] == 1 && $row["topacc"] == "5200" && $row["accnum"] == "000") {
                /* calculate previous year profit/loss */
                $sql = "SELECT SUM(tb.credit) AS credit, SUM(tb.debit) AS debit\n\t\t\t\t\tFROM core.accounts acc LEFT JOIN {$schema}.trial_bal tb\n\t\t\t\t\t\tON acc.accid=tb.accid AND acc.div=tb.div\n\t\t\t\t\tWHERE (acc.acctype='I' OR acc.acctype='E') AND acc.div='" . USER_DIV . "'\n\t\t\t\t\t\tAND tb.period='0'";
                $qry = new dbSql($sql);
                $qry->run();
                /* then deduct from debit/credit of retained income/accumulated loss */
                $qry->fetch_array();
                $row["debit"] -= $qry->d["debit"];
                $row["credit"] -= $qry->d["credit"];
            }
        }
        /* store data */
        $oc[$cprd_name]["{$row['topacc']}/{$row['accnum']} {$row['accname']}"] = array("debit" => $row["debit"], "credit" => $row["credit"]);
    }
    #sort array to make some sense
    $oc = natksort($oc);
}
示例#2
0
 /**
  * Performs a reverse natural sort on the array keys 
  * Behaves the same as krsort() with natural sorting added. 
  * 
  * @param Array $array The array to sort 
  */
 function natkrsort(&$array)
 {
     natksort($array);
     $array = array_reverse($array, TRUE);
     return true;
 }
示例#3
0
function DisplayUniqueSeries($id)
{
    $sqlstring = "select * from projects where project_id = {$id}";
    $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>{$sqlstring}</i><br>");
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    $name = $row['project_name'];
    $urllist['Project List'] = "projects.php";
    $urllist[$name] = "projects.php?action=displayproject&id={$id}";
    $urllist['Edit Group Protocols'] = "projects.php?action=viewuniqueseries&id={$id}";
    NavigationBar("Projects", $urllist, 0, '', '', '', '');
    /* get all studies associated with this project */
    $sqlstring = "select study_id, study_modality from projects a left join enrollment b on a.project_id = b.project_id left join studies c on b.enrollment_id = c.enrollment_id where a.project_id = {$id}";
    $result = MySQLQuery($sqlstring, __FILE__, __LINE__);
    //PrintSQLTable($result);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $studyid = $row['study_id'];
        $modality = strtolower($row['study_modality']);
        if ($modality != "" && $studyid != "") {
            $sqlstringA = "select * from {$modality}" . "_series where study_id = '{$studyid}'";
            //PrintSQL($sqlstringA);
            $resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
            while ($rowA = mysql_fetch_array($resultA, MYSQL_ASSOC)) {
                $seriesaltdesc = $rowA['series_altdesc'];
                if ($rowA['series_desc'] != "") {
                    $seriesdesc = $rowA['series_desc'];
                } elseif ($rowA['series_protocol'] != "") {
                    $seriesdesc = $rowA['series_protocol'];
                }
                if ($seriesdesc != "") {
                    $seriesdescs[$modality][$seriesdesc]++;
                }
            }
        }
    }
    //echo "<pre>";
    //print_r($seriesdescs);
    //echo "</pre>";
    ?>
		<form action="projects.php" method="post">
		<input type="hidden" name="action" value="changealternatenames">
		<input type="hidden" name="id" value="<?php 
    echo $id;
    ?>
">
		<table class="graydisplaytable">
			<thead>
				<th>Modality</th>
				<th>Series Description</th>
				<th>Count</th>
				<th>New Description</th>
			</thead>
		<?php 
    $i = 0;
    foreach ($seriesdescs as $modality => $serieslist) {
        natksort($serieslist);
        foreach ($serieslist as $series => $count) {
            ?>
				<tr>
					<td><?php 
            echo strtoupper($modality);
            ?>
</td>
					<td><tt><?php 
            echo $series;
            ?>
</tt></td>
					<td><?php 
            echo $count;
            ?>
</td>
					<td><input type="hidden" name="modalities[<?php 
            echo $i;
            ?>
]" value="<?php 
            echo strtolower($modality);
            ?>
"><input type="hidden" name="oldname[<?php 
            echo $i;
            ?>
]" value="<?php 
            echo $series;
            ?>
"><input type="text" name="newname[<?php 
            echo $i;
            ?>
]"></td>
				</tr>
				<?php 
            $i++;
        }
    }
    ?>
			<tr>
				<td colspan="3" align="right"><input type="submit"></td>
			</tr>
		</table>

		<?php 
}
示例#4
0
 /**
  * Test natksort
  */
 function test_natksort()
 {
     $data = array('a1' => 1, 'a20' => 2, 'a2' => 3);
     $expected = array('a1' => 1, 'a2' => 3, 'a20' => 2);
     natksort($data);
     $this->assertEquals($data, $expected);
 }
示例#5
0
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once dirname(__FILE__) . '/include/config.inc.php';
require_once dirname(__FILE__) . '/include/screens.inc.php';
$page['title'] = _('Configuration of slide shows');
$page['file'] = 'slideconf.php';
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
$page['hist_arg'] = array();
require_once dirname(__FILE__) . '/include/page_header.php';
//	VAR		TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('shows' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'slideshowid' => array(T_ZBX_INT, O_NO, P_SYS, DB_ID, '(isset({form})&&({form}=="update"))'), 'name' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})', _('Name')), 'delay' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, SEC_PER_DAY), 'isset({save})', _('Default delay (in seconds)')), 'slides' => array(null, O_OPT, null, null, null), 'go' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'clone' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'delete' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null));
check_fields($fields);
validate_sort_and_sortorder('name', ZBX_SORT_UP);
if (!empty($_REQUEST['slides'])) {
    natksort($_REQUEST['slides']);
}
/*
 * Permissions
 */
if (isset($_REQUEST['slideshowid'])) {
    if (!slideshow_accessible($_REQUEST['slideshowid'], PERM_READ_WRITE)) {
        access_deny();
    }
    $dbSlideshow = get_slideshow_by_slideshowid(get_request('slideshowid'));
    if (empty($dbSlideshow)) {
        access_deny();
    }
}
if (isset($_REQUEST['go'])) {
    if (!isset($_REQUEST['shows']) || !is_array($_REQUEST['shows'])) {
示例#6
0
$result = array_trim_strings($data, '-');
assert('$result === $expected');
$expected = array('foo', 'bar', 'foo', 'bar');
$result = array_trim_strings($data, ' -');
assert('$result === $expected');
/* test array_get_int */
$data = array('first' => 1, 'second' => '2', 'third' => 'drei', 4 => 4);
assert('array_get_int($data, "first") == 1');
assert('array_get_int($data, "first", 2) == 1');
assert('array_get_int($data, "notfound", 3) == 3');
assert('array_get_int($data, "third", 33) == 33');
assert('array_get_int($data, "4") == 4');
assert('array_get_int($data, 4) == 4');
/* test numeric_array_to_associative_array */
$x = numeric_array_to_associative_array('one', 2, 3, 'data');
$y = numeric_array_to_associative_array(array('one', 2, 3, 'data'));
assert('count($x) == 2');
assert('array_has_key($x, "one")');
assert('array_has_key($x, 3)');
assert('!array_has_key($x, 2)');
assert('!array_has_key($x, "data")');
assert('count($y) == 2');
assert('array_has_key($y, "one")');
assert('array_has_key($y, 3)');
assert('!array_has_key($y, 2)');
assert('!array_has_key($y, "data")');
/* test natksort */
$data = array('a1' => 1, 'a20' => 2, 'a2' => 3);
$expected = array('a1' => 1, 'a2' => 3, 'a20' => 2);
natksort($data);
assert('$data === $expected');
    /**
     * Call the admin option template
     * 
     * @echo the shortcode 
     * @author Benjamin Niess
     */
    function displayOptions()
    {
        global $shortcode_tags;
        // Copy array shortcodes for allow manipulation
        $_shortcode_tags = $shortcode_tags;
        $_shortcode_tags_total = count($_shortcode_tags);
        // Sort shortcodes by name
        natksort($_shortcode_tags);
        if (isset($_POST['save'])) {
            check_admin_referer('ssm_save_settings');
            $new_options = array();
            // Get the old option in order to merge it (if a plugin with a shortcode is is_not_default, we'll keep it's infos)
            $old_options = get_option('ssm_options');
            if (empty($old_options) || !is_array($old_options)) {
                $old_options = array();
            }
            // Update existing
            foreach ((array) $_POST['ssm'] as $key => $value) {
                $new_options[$key]['description'] = stripslashes($value['description']);
                $new_options[$key]['usage'] = stripslashes($value['usage']);
                $new_options[$key]['default'] = stripslashes($value['default']);
                $new_options[$key]['hide'] = isset($value['hide']) ? 1 : 0;
            }
            // Merge old and new options
            $ssm_fields = array_merge($old_options, $new_options);
            update_option('ssm_options', $ssm_fields);
            $this->message = __('Options updated!', 'ssm');
        }
        // Get settings, put array empty if no exist...
        $ssm_fields = get_option('ssm_options');
        if ($ssm_fields == false) {
            $ssm_fields = array();
        }
        // Pagination
        $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
        if ($_GET['paged'] < 1) {
            $_GET['paged'] = 1;
        }
        // Split array shortcodes
        $_shortcode_tags = array_slice($_shortcode_tags, $this->quantity_per_page * ($_GET['paged'] - 1), $this->quantity_per_page);
        $this->displayMessage();
        ?>
		<div class="wrap" id="ssm_options">
			<h2><?php 
        _e('Simple Shortcodes Manager', 'ssm');
        ?>
</h2>
			
			<form method="post" action="">
				<div class="tablenav">
					<?php 
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($_shortcode_tags_total / $this->quantity_per_page), 'current' => $_GET['paged']));
        if ($page_links) {
            echo "<div class='tablenav-pages'>{$page_links}</div>";
        }
        ?>
				</div>
	
				<table class="wp-list-table widefat fixed posts" cellspacing="0"> 
					<thead>
						<tr>
							<th scope='col' id='cb' class='manage-column column-comments' style="text-align: center;"><?php 
        _e('Hide ?', 'ssm');
        ?>
</th>
							<th scope='col' id='title' class='manage-column column-author'><?php 
        _e('Name', 'ssm');
        ?>
</th>
							<th scope='col' id='description' class='manage-column column-title'><?php 
        _e('Description', 'ssm');
        ?>
</th>
							<th scope='col' id='usage' class='manage-column column-title'><?php 
        _e('Usage', 'ssm');
        ?>
</th>
							<th scope='col' id='default' class='manage-column column-title'><?php 
        _e('Default', 'ssm');
        ?>
</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th scope='col' class='manage-column column-comments' style="text-align: center;"><?php 
        _e('Hide ?', 'ssm');
        ?>
</th>
							<th scope='col' class='manage-column column-author'><?php 
        _e('Name', 'ssm');
        ?>
</th>
							<th scope='col' class='manage-column column-title'><?php 
        _e('Description', 'ssm');
        ?>
</th>
							<th scope='col' class='manage-column column-title'><?php 
        _e('Usage', 'ssm');
        ?>
</th>
							<th scope='col' class='manage-column column-title'><?php 
        _e('Default', 'ssm');
        ?>
</th>
						</tr>
					</tfoot>
					
					<tbody id="the-list">
						<?php 
        foreach ($_shortcode_tags as $shortcode_key => $shortcode_value) {
            // Default values
            if (!isset($ssm_fields[$shortcode_key])) {
                $ssm_fields[$shortcode_key] = array('hide' => '', 'description' => '', 'usage' => '', 'default' => '');
            }
            $class = empty($class) ? 'alternate' : '';
            ?>
							<tr class='<?php 
            echo $class;
            ?>
' valign="top"> 
								<td><input type="checkbox" name="ssm[<?php 
            echo $shortcode_key;
            ?>
][hide]" <?php 
            checked($ssm_fields[$shortcode_key]['hide'] == 1 ? 1 : 0, 1);
            ?>
 value="1" /></td>
								<td>[<?php 
            echo esc_html($shortcode_key);
            ?>
]</td>
								<td><textarea class="widefat lmceEditor" rows="5" cols="15" name="ssm[<?php 
            echo $shortcode_key;
            ?>
][description]"><?php 
            echo stripslashes($ssm_fields[$shortcode_key]['description']);
            ?>
</textarea></td>
								<td><textarea class="widefat lmceEditor" rows="5" cols="15" name="ssm[<?php 
            echo $shortcode_key;
            ?>
][usage]"><?php 
            echo stripslashes($ssm_fields[$shortcode_key]['usage']);
            ?>
</textarea></td>
								<td><input class="widefat" style="width: 90%" name="ssm[<?php 
            echo $shortcode_key;
            ?>
][default]" value="<?php 
            echo esc_attr(stripslashes($ssm_fields[$shortcode_key]['default']));
            ?>
" /></td>
							</tr>
						<?php 
        }
        ?>
					</tbody>
				</table>
				
				<p class="submit">
					<?php 
        wp_nonce_field('ssm_save_settings');
        ?>
					<input type="submit" name="save" class="button-primary" value="<?php 
        _e('Save Changes', 'ssm');
        ?>
" />
				</p>
			</form>
		</div>
		
		<div class="wrap">
			<h2><?php 
        _e("Simple Shortcode Manager : Export/Import", 'ssm');
        ?>
</h2>
			
			<a class="button" href="<?php 
        echo wp_nonce_url($this->admin_url . '?action=export_config_ssm', 'export-config-ssm');
        ?>
"><?php 
        _e("Export config file", 'ssm');
        ?>
</a>
			<a class="button" href="#" id="toggle-import_form"><?php 
        _e("Import config file", 'ssm');
        ?>
</a>
			<script type="text/javascript">
				jQuery("#toggle-import_form").click(function(event) {
					event.preventDefault();
					jQuery('#import_form').removeClass('hide-if-js');
				});
			</script>
			<div id="import_form" class="hide-if-js">
				<form action="<?php 
        echo $this->admin_url;
        ?>
" method="post" enctype="multipart/form-data">
					<p>
						<label><?php 
        _e("Config file", 'ssm');
        ?>
</label>
						<input type="file" name="config_file" />
					</p>
					<p class="submit">
						<?php 
        wp_nonce_field('import_config_file_ssm');
        ?>
						<input class="button-primary" type="submit" name="import_config_file_ssm" value="<?php 
        _e('I want import a config from a previous backup, this action will REPLACE current configuration', 'ssm');
        ?>
" />
					</p>
				</form>
			</div>
		</div>
		<?php 
    }
    function form()
    {
        global $shortcode_tags;
        // Copy array shortcodes for allow manipulation
        $_shortcode_tags = $shortcode_tags;
        // Sort shortcodes by name
        natksort($_shortcode_tags);
        // Get settings, put array empty if no exist...
        $ssm_fields = get_option('ssm_options');
        if ($ssm_fields == false) {
            $ssm_fields = array();
        }
        // Remove shortcode that explicity checkbox hide !
        foreach ($_shortcode_tags as $_shortcode_tag => $val) {
            if (isset($ssm_fields[$_shortcode_tag]) && isset($ssm_fields[$_shortcode_tag]['hide']) && $ssm_fields[$_shortcode_tag]['hide'] == 1) {
                unset($_shortcode_tags[$_shortcode_tag]);
            }
        }
        // Counter shortcodes
        $_shortcode_tags_total = count($_shortcode_tags);
        // Pagination
        $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
        if ($_GET['paged'] < 1) {
            $_GET['paged'] = 1;
        }
        // Split array shortcodes
        $_shortcode_tags = array_slice($_shortcode_tags, $this->quantity_per_page * ($_GET['paged'] - 1), $this->quantity_per_page);
        ?>
		<form method="get" action="" id="filter">
			<div class="tablenav">
				<?php 
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($_shortcode_tags_total / $this->quantity_per_page), 'current' => $_GET['paged']));
        if ($page_links) {
            echo "<div class='tablenav-pages'>{$page_links}</div>";
        }
        ?>
			</div>
		</form>
		
		<form method="post" action="" class="media-upload-form validate" id="library-form">
			<div id="media-items">
				<?php 
        foreach ($_shortcode_tags as $shortcode_key => $shortcode_value) {
            $insertion = !empty($ssm_fields[$shortcode_key]['default']) ? $ssm_fields[$shortcode_key]['default'] : '[' . $shortcode_key . ']';
            ?>
					<div class='media-item'>
						<a type="submit" class="button insert_link" href="<?php 
            echo stripslashes(esc_js(add_query_arg(array('shortcode' => $insertion))));
            ?>
"><?php 
            _e('Insert', 'ssm');
            ?>
</a>
						
						<a class='toggle describe-toggle-on' href='#'><?php 
            _e('Show usage', 'ssm');
            ?>
</a>
						<a class='toggle describe-toggle-off' href='#'><?php 
            _e('Hide usage', 'ssm');
            ?>
</a>
						
						<div class='filename new'><span class='title'>[<?php 
            echo esc_html($shortcode_key);
            ?>
]</span> <span class="description"><?php 
            echo stripslashes($ssm_fields[$shortcode_key]['description']);
            ?>
</span></div>
						<div class="slidetoggle describe startclosed">
							<div class="usage-box">
								<strong><?php 
            _e('Usage :', 'ssm');
            ?>
</strong>
								<?php 
            remove_filter('the_content', 'do_shortcode', 11);
            // AFTER wpautop()
            echo apply_filters('the_content', stripslashes($ssm_fields[$shortcode_key]['usage']));
            add_filter('the_content', 'do_shortcode', 11);
            // AFTER wpautop()
            ?>
							</div>
						</div>
					</div>
				<?php 
        }
        ?>
			</div>
		</form>
		
		<script type="text/javascript">
			<!--
			// Also bind toggle to the links
			jQuery('a.toggle').click(function () {
				jQuery(this).siblings('.slidetoggle').slideToggle(350, function () {
					var w = jQuery(window).height(),
						t = jQuery(this).offset().top,
						h = jQuery(this).height(),
						b;
					if (w && t && h) {
						b = t + h;
						if (b > w && (h + 48) < w) window.scrollBy(0, b - w + 13);
						else if (b > w) window.scrollTo(0, t - 36);
					}
				});
				jQuery(this).siblings('.toggle').andSelf().toggle();
				jQuery(this).siblings('a.toggle').focus();
				return false;
			});
			-->
		</script>
		
		<style type="text/css">
			.usage-box { padding:5px 10px; }
			.usage-box p { margin: 0 0 7px 0; }
			.insert_link { display:block;float:right;margin:8px 10px 0 0; }
		</style>
		<?php 
    }
示例#9
0
 function classToMd($class, $link)
 {
     global $home;
     list($dc, $is_private) = $this->_getDc($class, 'class');
     $mod = implode(" ", $class['modifiers']);
     $hash = md5($class['name']);
     $tpl = "\n## {$mod} {$class['type']} <a id='{$hash}'/>{$class['name']}\n" . ($dc ? $dc->RenderAsMD() : "NOT DOCUMENTED");
     if ($class['ns']) {
         $tpl .= "\n\n**Namespace**: <NAMESPACE::{$class['ns']}>";
         if (!isset($home['namespaces'][$class['ns']])) {
             $home['namespaces'][$class['ns']] = array('hash' => md5($class['ns']), 'classes' => array());
         }
         $home['namespaces'][$class['ns']]['classes'][] = $class['name'];
     }
     if (isset($class['extends'])) {
         //$tpl .= "\n\nExtends: <{$class['extends']}>";
         $home['tree'][$class['name']] = $class['extends'];
     } else {
         $home['tree'][$class['name']] = false;
     }
     if (isset($class['implements'])) {
         $tpl .= "\n\n**Implements**: <" . implode("> <", $class['implements']) . ">";
     }
     $tpl .= "<PARENTCLASSES::{$class['name']}>";
     $tpl .= "<SUBCLASSES::{$class['name']}>";
     $lines = array($tpl);
     $home['classes'][$class['name']] = "{$link}#wiki-{$hash}";
     if (!$dc || !$dc->hasOne('internal', 'deprecated')) {
         natksort($class['methods']);
         foreach ($class['methods'] as $meth) {
             $l = $this->funcToMd($meth, '###', "method {$class['name']}.", $class);
             if ($l) {
                 $lines[] = $l;
                 $home['methods'][$class['name']][$meth['name']] = "{$link}#wiki-" . md5($meth['name']);
             }
         }
     }
     return implode("\n", $lines);
 }
示例#10
0
文件: index.php 项目: kelsh/classic
        mysql_query("INSERT INTO `redvote` VALUES ('NULL','" . str_replace(array("\\", "'", "\""), array("\\\\", "\\'", "\\\""), $quote) . "','','')");
    }
    if (mysql_error() == "") {
        die("Quote list updated successfully. Redirecting...<meta http-equiv = \"refresh\" content = \"1;url=./\">");
    }
}
if ($_GET['quotereset'] != "" && $_GET['admin'] == ADMIN_PASSWORD) {
    $quotes = str_replace("<", "&lt;", file_get_contents($_GET['quotereset']));
    $quotes = explode("\n", $quotes);
    $quotes = cleanArray($quotes);
    foreach ($quotes as $key => $quote) {
        list($tempkey, $tempvote, $tempquote) = explode("\t", $quote);
        $temparray[str_replace("#", "", $tempkey)] = array($tempquote, str_replace(array("- ", " + "), array("", ""), $tempvote));
    }
    $quotes = $temparray;
    natksort($quotes);
    mysql_query("DROP TABLE IF EXISTS `redvote`");
    mysql_query("CREATE TABLE `redvote` (`id` int(10) NOT NULL auto_increment,`quote` text NOT NULL,`vote` int(10) NOT NULL default '0',`ip` text NOT NULL,PRIMARY KEY  (`id`))");
    foreach ($quotes as $quote) {
        mysql_query("INSERT INTO `redvote` VALUES ('NULL','" . str_replace(array("\\", "'", "\""), array("\\\\", "\\'", "\\\""), $quote[0]) . "','{$quote['1']}','')");
    }
    if (mysql_error() == "") {
        die("Quote list reset successfully. Redirecting...<meta http-equiv = \"refresh\" content = \"1;url=./\">");
    }
}
if ($_GET['fail'] != "") {
    $quoteinfo = mysql_query("SELECT `vote`,`ip` FROM `redvote` WHERE `id` = '{$_GET['fail']}'");
    list($vote, $ip) = mysql_fetch_array($quoteinfo);
    $ip = explode(",", $ip);
    if (in_array($_SERVER['REMOTE_ADDR'], $ip)) {
        die("You've already voted on this quote!");
示例#11
0
文件: browse.php 项目: jwinget/LabInv
            exit;
        } else {
            // Set up an array to be sorted
            $resultarray = array();
            while ($row = mysql_fetch_array($result)) {
                $resultarray[$row['name']] = $row;
            }
            function natksort($array)
            {
                $keys = array_keys($array);
                natsort($keys);
                $ret = array();
                foreach ($keys as $k) {
                    $ret[$k] = $array[$k];
                }
                return $ret;
            }
            $resultarray = natksort($resultarray);
            foreach ($resultarray as $resultvalue) {
                echo "<li><p><a href=?dna_type=" . $dna_type . "&id=" . $resultvalue['id'] . ">" . $resultvalue['name'] . "</a>";
                echo " - " . $resultvalue['short_desc'] . "</p></li>";
            }
        }
    }
    ?>
	</div>
</div>
<?php 
    #Close the else statement follwing the check for login credentials
}
include 'foot.php';
$chr = 1;
foreach ($rpts->get_page_type_names() as $name) {
    if ($chr != strtoupper($name[0]) && !in_array(strtoupper($name[0]), $alphabet)) {
        $chr = strtoupper($name[0]);
        $alphabet[] = $chr;
    }
}
sort($alphabet);
foreach ($alphabet as $letter) {
    $alphabet_links[] = '<a href = "#' . strtolower($letter) . '"> ' . $letter . '</a>';
}
echo '<em>Jump to:</em> ' . implode(' | ', $alphabet_links);
//display relevant $page_type values
$pts = $rpts->get_page_types();
$default_pt = $rpts->get_page_type('default');
natksort($pts);
$chr1 = 1;
foreach ($pts as $page_type) {
    $page_type_name = $page_type->get_name();
    if ($chr1 != strtolower($page_type_name[0])) {
        if ($chr1 != 1) {
            echo $top_link;
        }
        $chr1 = strtolower($page_type_name[0]);
        echo '<h2><a name = "' . $chr1 . '">' . strtoupper($chr1) . '</a></h2>';
    }
    echo '<h3><a name="' . $page_type_name . '">' . prettify_string($page_type_name) . '</a></h3>';
    echo '<ul>';
    foreach ($page_type->get_region_names() as $region) {
        $region_info = $page_type->get_region($region);
        $default_region_info = $default_pt->get_region($region);
示例#13
0
/**
 * 更高级的对数组按照键名进行“自然排序”类似natcasesort和ksort
 * 可将多维数组全部按照各维度的键名排序
 * @param array $array <strong style="color:red">引用结果</strong>
 * @author Deepseath
 * @return boolean
 */
function natksort(&$array)
{
    $keys = array_keys($array);
    natcasesort($keys);
    foreach ($keys as $k) {
        $_sub = $array[$k];
        if (is_array($_sub)) {
            natksort($_sub);
        }
        $new_array[$k] = $_sub;
        unset($_sub);
    }
    $array = $new_array;
    return true;
}