Ejemplo n.º 1
0
    public function compare_versions($article, $from, $to)
    {
        if ($from == 0 || $to == 0) {
            trigger_error('NO_VERSIONS_SELECTED');
        }
        require $this->phpbb_root_path . 'includes/diff/diff.' . $this->php_ext;
        require $this->phpbb_root_path . 'includes/diff/engine.' . $this->php_ext;
        require $this->phpbb_root_path . 'includes/diff/renderer.' . $this->php_ext;
        $sql = 'SELECT article_text, bbcode_uid, bbcode_bitfield, article_sources, article_description
			FROM ' . $this->article_table . '
			WHERE article_id = ' . (int) $from;
        $result = $this->db->sql_query($sql);
        $from_row = $this->db->sql_fetchrow($result);
        $sql = 'SELECT article_text, bbcode_uid, bbcode_bitfield, article_sources, article_description
			FROM ' . $this->article_table . '
			WHERE article_id = ' . (int) $to;
        $result = $this->db->sql_query($sql);
        $to_row = $this->db->sql_fetchrow($result);
        $from_article = generate_text_for_edit($from_row['article_text'], $from_row['bbcode_uid'], $from_row['bbcode_bitfield'], 3, true);
        $to_article = generate_text_for_edit($to_row['article_text'], $to_row['bbcode_uid'], $to_row['bbcode_bitfield'], 3, true);
        $u_from = $this->helper->route('tas2580_wiki_index', array('id' => $from));
        $u_to = $this->helper->route('tas2580_wiki_index', array('id' => $to));
        $article_diff = new \diff($from_article['text'], $to_article['text']);
        $article_diff_empty = $article_diff->is_empty();
        $sources_diff = new \diff($from_row['article_sources'], $to_row['article_sources']);
        $sources_diff_empty = $sources_diff->is_empty();
        $description_diff = new \diff($from_row['article_description'], $to_row['article_description']);
        $descriptiondiff_empty = $sources_diff->is_empty();
        $renderer = new \diff_renderer_inline();
        $this->template->assign_vars(array('HEADLINE' => sprintf($this->user->lang['VERSION_COMPARE_HEADLINE'], $from, $to, $u_from, $u_to), 'DIFF' => $article_diff_empty ? '' : $renderer->get_diff_content($article_diff), 'DIFF_SOURCE' => $sources_diff_empty ? '' : $renderer->get_diff_content($sources_diff), 'DIFF_DESCRIPTION' => $descriptiondiff_empty ? '' : $renderer->get_diff_content($description_diff)));
        return $this->helper->render('article_compare.html', $this->user->lang['VERSIONS_OF_ARTICLE']);
    }
 public function assert_equal_array($expected, $actual, $debug = null)
 {
     if ($expected !== $actual) {
         throw new Kohana_Unit_Test_Exception(sprintf("Expected (%s) %s but received (%s) %s\n Diff: %s", gettype($expected), var_export($expected, true), gettype($actual), var_export($actual, true), diff::compare(var_export($expected, true), var_export($actual, true))), $debug);
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Creates the array which contains two compared page versions
  *
  * @author Johannes Klose <*****@*****.**>
  * @param  string $origText  Original page text
  * @param  string $finalText Final page text
  * @param  array  $versions  All page versions
  * @return array         Page differences
  **/
 function makeDiff($origText, $finalText, &$versions)
 {
     $diff = diff::getDiff($finalText, $origText);
     $origLines = explode("\n", $origText);
     $finalLines = explode("\n", $finalText);
     $lineCount = count($origLines) > count($finalLines) ? count($origLines) : count($finalLines);
     $origTextT = array();
     $finalTextT = array();
     $ol = 0;
     $fl = 0;
     for ($i = 0; $i <= $lineCount; $i++) {
         if (isset($diff[$i])) {
             $opType = $diff[$i][0];
             $opVal = isset($diff[$i][1]) ? $diff[$i][1] : '';
             if ($opType == '~') {
                 $origTextT[] = htmlentities($origLines[$ol]);
                 $finalTextT[] = array('type' => 'edit', 'line' => htmlentities($opVal));
                 $ol++;
                 $fl++;
             } elseif ($opType == '+') {
                 $origTextT[] = '';
                 $finalTextT[] = array('type' => 'add', 'line' => htmlentities($opVal));
                 $fl++;
             } else {
                 $origTextT[] = htmlentities($origLines[$ol]);
                 $finalTextT[] = array('type' => 'subs', 'line' => htmlentities($origLines[$ol]));
                 $ol++;
             }
         } else {
             if (isset($origLines[$ol])) {
                 $origTextT[] = htmlentities($origLines[$ol]);
                 $ol++;
             }
             if (isset($finalLines[$fl])) {
                 $finalTextT[] = array('type' => 'none', 'line' => htmlentities($finalLines[$fl]));
                 $fl++;
             }
         }
     }
     return array('orig' => $origTextT, 'final' => $finalTextT);
 }
Ejemplo n.º 4
0
     $getPathSqlYesterday = $db->q("SELECT * FROM configs \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE deviceId = {$deviceId}\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND configFilename LIKE '%{$command}%'\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND configDate < \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT configDate FROM configs \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE deviceId = {$deviceId}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND configFilename LIKE '%{$command}%'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY configDate \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDESC LIMIT 1)\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY configDate \n\t\t\t\t\t\t\t\t\t\t\t\t\tDESC LIMIT 1");
     $pathResultToday = mysql_fetch_assoc($getPathSqlToday);
     $pathResultYesterday = mysql_fetch_assoc($getPathSqlYesterday);
     if (empty($pathResultToday) || empty($pathResultYesterday)) {
         // continue for the foreach if one of the files is not available as this compare will be invalid
         echo 'continue invoked for ' . $device['deviceName'] . "\n";
         continue;
     }
     $pathResult_a = $pathResultToday['configLocation'];
     $pathResult_b = $pathResultYesterday['configLocation'];
     $filenameResult_a = $pathResultToday['configFilename'];
     $filenameResult_b = $pathResultYesterday['configFilename'];
     $path_a = $pathResult_a . '/' . $filenameResult_a;
     $path_b = $pathResult_b . '/' . $filenameResult_b;
     // run the compare with no linepadding set
     $diff = new diff();
     $text = $diff->inline($path_a, $path_b);
     $count = count($diff->changes) . ' changes';
     // send output to the report
     $report->eachData($device['deviceName'], $count, $text);
     // log to report
 }
 // End Data insert loop
 // script endTime
 $endTime = date('h:i:s A');
 $time_end = microtime(true);
 $time = round($time_end - $time_start) . " Seconds";
 $report->findReplace('<taskEndTime>', $endTime);
 $report->findReplace('<taskRunTime>', $time);
 $report->footer();
 if ($taskRow['mailConnectionReport'] == '1') {
	/**
	* Compare files for storage in update_list
	*/
	function make_update_diff(&$update_list, $original_file, $file, $custom = false)
	{
		global $phpbb_root_path, $user;

		$update_ary = array('filename' => $file, 'custom' => $custom);

		if ($custom)
		{
			$update_ary['original'] = $original_file;
		}

		// On a successfull update the new location file exists but the old one does not exist.
		// Check for this circumstance, the new file need to be up-to-date with the current file then...
		if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists($phpbb_root_path . $file))
		{
			$tmp = array(
				'file1'		=> file_get_contents($this->new_location . $original_file),
				'file2'		=> file_get_contents($phpbb_root_path . $file),
			);

			// We need to diff the contents here to make sure the file is really the one we expect
			$diff = new diff($tmp['file1'], $tmp['file2'], false);
			$empty = $diff->is_empty();

			unset($tmp, $diff);

			// if there are no differences we have an up-to-date file...
			if ($empty)
			{
				$update_list['up_to_date'][] = $update_ary;
				return;
			}

			// If no other status matches we have another file in the way...
			$update_list['new_conflict'][] = $update_ary;
			return;
		}

		// Old file removed?
		if (file_exists($this->old_location . $original_file) && !file_exists($this->new_location . $original_file))
		{
			return;
		}

		// Check for existance, else abort immediately
		if (!file_exists($this->old_location . $original_file) || !file_exists($this->new_location . $original_file))
		{
			trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR);
		}

		$tmp = array(
			'file1'		=> file_get_contents($this->old_location . $original_file),
			'file2'		=> file_get_contents($phpbb_root_path . $file),
		);

		// We need to diff the contents here to make sure the file is really the one we expect
		$diff = new diff($tmp['file1'], $tmp['file2'], false);
		$empty_1 = $diff->is_empty();

		unset($tmp, $diff);

		$tmp = array(
			'file1'		=> file_get_contents($this->new_location . $original_file),
			'file2'		=> file_get_contents($phpbb_root_path . $file),
		);

		// We need to diff the contents here to make sure the file is really the one we expect
		$diff = new diff($tmp['file1'], $tmp['file2'], false);
		$empty_2 = $diff->is_empty();

		unset($tmp, $diff);

		// If the file is not modified we are finished here...
		if ($empty_1)
		{
			// Further check if it is already up to date - it could happen that non-modified files
			// slip through
			if ($empty_2)
			{
				$update_list['up_to_date'][] = $update_ary;
				return;
			}

			$update_list['not_modified'][] = $update_ary;
			return;
		}

		// If the file had been modified then we need to check if it is already up to date

		// if there are no differences we have an up-to-date file...
		if ($empty_2)
		{
			$update_list['up_to_date'][] = $update_ary;
			return;
		}

		// if the file is modified we try to make sure a merge succeed
		$tmp = array(
			'file1'		=> file_get_contents($this->old_location . $original_file),
			'file2'		=> file_get_contents($phpbb_root_path . $file),
			'file3'		=> file_get_contents($this->new_location . $original_file),
		);

		$diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3'], false);

		unset($tmp);

		if ($diff->merged_output(false, false, false, true))
		{
			$update_ary['conflicts'] = $diff->_conflicting_blocks;

			// There is one special case... users having merged with a conflicting file... we need to check this
			$tmp = array(
				'file1'		=> file_get_contents($phpbb_root_path . $file),
				'file2'		=> implode("\n", $diff->merged_orig_output()),
			);

			$diff = new diff($tmp['file1'], $tmp['file2'], false);
			$empty = $diff->is_empty();

			if ($empty)
			{
				unset($update_ary['conflicts']);
				unset($diff);
				$update_list['up_to_date'][] = $update_ary;
				return;
			}

			$update_list['conflict'][] = $update_ary;
			unset($diff);

			return;
		}

		$tmp = array(
			'file1'		=> file_get_contents($phpbb_root_path . $file),
			'file2'		=> implode("\n", $diff->merged_output()),
		);

		// now compare the merged output with the original file to see if the modified file is up to date
		$diff = new diff($tmp['file1'], $tmp['file2'], false);
		$empty = $diff->is_empty();

		if ($empty)
		{
			unset($diff);

			$update_list['up_to_date'][] = $update_ary;
			return;
		}

		// If no other status matches we have a modified file...
		$update_list['modified'][] = $update_ary;
	}
Ejemplo n.º 6
0
	/**
	* Compare files for storage in update_list
	*/
	function make_update_diff(&$update_list, $original_file, $file, $custom = false)
	{
		global $phpbb_root_path, $user;

		$update_ary = array('filename' => $file, 'custom' => $custom);

		if ($custom)
		{
			$update_ary['original'] = $original_file;
		}

		// we only want to know if the files are successfully merged and newlines could result in errors (duplicate addition of lines and such things)
		// Therefore we check for empty diffs with two methods, preserving newlines and not preserving them (which mostly works best, therefore the first option)

		// On a successfull update the new location file exists but the old one does not exist.
		// Check for this circumstance, the new file need to be up-to-date with the current file then...
		if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists($phpbb_root_path . $file))
		{
			$tmp = array(
				'file1'		=> file_get_contents($this->new_location . $original_file),
				'file2'		=> file_get_contents($phpbb_root_path . $file),
			);

			// We need to diff the contents here to make sure the file is really the one we expect
			$diff = new diff($tmp['file1'], $tmp['file2'], false);
			$empty = $diff->is_empty();

			unset($tmp, $diff);

			// if there are no differences we have an up-to-date file...
			if ($empty)
			{
				$update_list['up_to_date'][] = $update_ary;
				return;
			}

			// If no other status matches we have another file in the way...
			$update_list['new_conflict'][] = $update_ary;
			return;
		}

		// Old file removed?
		if (file_exists($this->old_location . $original_file) && !file_exists($this->new_location . $original_file))
		{
			return;
		}

		// Check for existance, else abort immediately
		if (!file_exists($this->old_location . $original_file) || !file_exists($this->new_location . $original_file))
		{
			trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR);
		}

		$preserve_cr_ary = array(false, true);

		foreach ($preserve_cr_ary as $preserve_cr)
		{
			$tmp = array(
				'file1'		=> file_get_contents($this->old_location . $original_file),
				'file2'		=> file_get_contents($phpbb_root_path . $file),
			);

			// We need to diff the contents here to make sure the file is really the one we expect
			$diff = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
			$empty_1 = $diff->is_empty();

			unset($tmp, $diff);

			$tmp = array(
				'file1'		=> file_get_contents($this->new_location . $original_file),
				'file2'		=> file_get_contents($phpbb_root_path . $file),
			);

			$diff = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
			$empty_2 = $diff->is_empty();

			unset($tmp, $diff);

			// If the file is not modified we are finished here...
			if ($empty_1)
			{
				// Further check if it is already up to date - it could happen that non-modified files
				// slip through
				if ($empty_2)
				{
					$update_list['up_to_date'][] = $update_ary;
					return;
				}

				$update_list['not_modified'][] = $update_ary;
				return;
			}

			// If the file had been modified then we need to check if it is already up to date

			// if there are no differences we have an up-to-date file...
			if ($empty_2)
			{
				$update_list['up_to_date'][] = $update_ary;
				return;
			}
		}

		$conflicts = false;

		foreach ($preserve_cr_ary as $preserve_cr)
		{
			// if the file is modified we try to make sure a merge succeed
			$tmp = array(
				'orig'		=> file_get_contents($this->old_location . $original_file),
				'final1'	=> file_get_contents($phpbb_root_path . $file),
				'final2'	=> file_get_contents($this->new_location . $original_file),
			);

			$diff = new diff3($tmp['orig'], $tmp['final1'], $tmp['final2'], $preserve_cr);
			unset($tmp);

			if (!$diff->get_num_conflicts())
			{
				$tmp = array(
					'file1'		=> file_get_contents($phpbb_root_path . $file),
					'file2'		=> implode("\n", $diff->merged_output()),
				);

				// now compare the merged output with the original file to see if the modified file is up to date
				$diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
				$empty = $diff2->is_empty();

				unset($diff, $diff2);

				if ($empty)
				{
					$update_list['up_to_date'][] = $update_ary;
					return;
				}

				// If we preserve cr tag it as modified because the conflict would not show in this mode anyway
				if ($preserve_cr)
				{
					$update_list['modified'][] = $update_ary;
					return;
				}
			}
			else
			{
				// There is one special case... users having merged with a conflicting file... we need to check this
				$tmp = array(
					'file1'		=> file_get_contents($phpbb_root_path . $file),
					'file2'		=> implode("\n", $diff->merged_new_output()),
				);

				$diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
				$empty = $diff2->is_empty();

				if (!$empty)
				{
					unset($tmp, $diff2);

					// We check if the user merged with his output
					$tmp = array(
						'file1'		=> file_get_contents($phpbb_root_path . $file),
						'file2'		=> implode("\n", $diff->merged_orig_output()),
					);

					$diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
					$empty = $diff2->is_empty();
				}

				if (!$empty)
				{
					$conflicts = $diff->get_num_conflicts();
				}

				unset($diff, $diff2);

				if ($empty)
				{
					// A conflict got resolved...
					$update_list['up_to_date'][] = $update_ary;
					return;
				}
			}
		}

		if ($conflicts !== false)
		{
			$update_ary['conflicts'] = $conflicts;
			$update_list['conflict'][] = $update_ary;
			return;
		}

		// If no other status matches we have a modified file...
		$update_list['modified'][] = $update_ary;
	}
Ejemplo n.º 7
0
 * @copyright 	2005-2009, TestLink community 
 * @version    	CVS: $Id: reqCompareVersions.php,v 1.5 2010/08/31 09:31:51 mx-julian Exp $
 * @link 		http://www.teamst.org/index.php
 *
 * Compares selected requirements versions with each other.
 *
 * @internal Revisions:
 * 20100831 - Julian - added requirement title to page heading
 */
require_once "../../config.inc.php";
require_once "common.php";
require '../../third_party/diff/diff.php';
$templateCfg = templateConfiguration();
testlinkInitPage($db);
$smarty = new TLSmarty();
$differ = new diff();
$args = init_args();
$gui = new stdClass();
$reqMgr = new requirement_mgr($db);
$reqSet = $reqMgr->get_by_id($args->req_id);
$gui->req_versions = $reqSet;
$gui->req_id = $args->req_id;
$gui->compare_selected_versions = $args->compare_selected_versions;
$gui->context = $args->context;
$gui->version_short = lang_get('version_short');
$labels = array();
$labels["num_changes"] = lang_get("num_changes");
$labels["no_changes"] = lang_get("no_changes");
//if already two versions are selected, display diff
//else display template with versions to select
if ($args->compare_selected_versions) {
Ejemplo n.º 8
0
    /**
     * Crewside
     */
    protected static function page_crew()
    {
        if (!isset(login::$extended_access['authed'])) {
            echo '
	<p class="c">Du må logge inn for utvidede tilganger.</p>';
        } else {
            $subpage2 = getval("b");
            redirect::store(page_min_side::addr(NULL, $subpage2 != "" ? "b=" . $subpage2 : ''));
            ess::$b->page->add_title("Crew");
            ess::$b->page->add_css('
.minside_links .active { color: #CCFF00 }');
            $links = array();
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr("crew", "", "user")) . '">Min bruker</a>';
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "")) . '"' . ($subpage2 == "" ? ' class="active"' : '') . '>Oversikt</a>';
            if (access::has("seniormod")) {
                $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=rank")) . '"' . ($subpage2 == "rank" ? ' class="active"' : '') . '>Juster rank</a>';
            }
            if (access::has("mod")) {
                $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=name")) . '"' . ($subpage2 == "name" ? ' class="active"' : '') . '>Endre spillernavn</a>';
            }
            echo '
	<p class="c minside_links">' . implode(" | ", $links) . '</p>';
            if ($subpage2 == "") {
                echo '
	<div class="col2_w">
		<div class="col_w left">
			<div class="col">
				<div class="bg1_c">
					<h1 class="bg1">Oversikt<span class="left2"></span><span class="right2"></span></h1>
					<div class="bg1">' . (access::has("mod") ? '
						<ul>' . (access::has("admin") && KOFRADIA_DEBUG ? '
							<li><a href="innboks?u_id=' . page_min_side::$active_user->id . '">Vis innboksen</a></li>
							<li><a href="innboks_sok?u_id=' . page_min_side::$active_user->id . '">Søk i innboksen</a></li>' : '') . '
							<li><a href="poker?up_id=' . page_min_side::$active_player->id . '&amp;stats">Vis pokerhistorien</a></li>
							<li><a href="admin/brukere/bankoverforinger?u1=' . page_min_side::$active_player->id . '">Vis bankoverføringer</a></li>
							<li><a href="drap?up_id=' . page_min_side::$active_player->id . '">Vis angrep utført av spilleren</a></li>
							<li><a href="drap?offer_up_id=' . page_min_side::$active_player->id . '">Vis angrep utført mot spilleren</a></li>
						</ul>' : '') . '
						<p>Trykk på <a href="' . htmlspecialchars(page_min_side::addr(NULL, "", "user")) . '">min bruker</a> for å vise informasjon om brukeren.</p>
					</div>
				</div>
			</div>
		</div>
		<div class="col_w right">
			<div class="col">
				<div class="bg1_c">
					<h1 class="bg1">Crewnotat for brukeren<span class="left2"></span><span class="right2"></span></h1>
					<p class="h_right"><a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=enote", "user")) . '">rediger</a></p>
					<div class="bg1">
						<p>Her kan hvem som helst i crewet legge til eller endre et notat for denne brukeren for å memorere ting som har med <u>brukeren</u> å gjøre.</p>' . (empty(page_min_side::$active_user->data['u_note_crew']) ? '
						<p>Ingen notat er registrert.</p>' : '
						<div class="p">' . game::bb_to_html(page_min_side::$active_user->data['u_note_crew']) . '</div>') . '
					</div>
				</div>
				<div class="bg1_c">
					<h1 class="bg1">Crewnotat for spilleren<span class="left2"></span><span class="right2"></span></h1>
					<p class="h_right"><a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=enote")) . '">rediger</a></p>
					<div class="bg1">
						<p>Her kan hvem som helst i crewet legge til eller endre et notat for denne spilleren for å memorere ting som har med <u>spilleren</u> å gjøre.</p>' . (empty(page_min_side::$active_player->data['up_note_crew']) ? '
						<p>Ingen notat er registrert.</p>' : '
						<div class="p">' . game::bb_to_html(page_min_side::$active_player->data['up_note_crew']) . '</div>') . '
					</div>
				</div>
			</div>
		</div>
	</div>
	<p class="c">Loggoppføringer for denne spilleren - <a href="' . htmlspecialchars(page_min_side::addr(NULL, "", "user")) . '">se komplett logg for brukeren</a></p>';
                // hent loggene for denne spilleren
                $pagei = new pagei(pagei::ACTIVE_GET, "side", pagei::PER_PAGE, 50);
                $result = $pagei->query("SELECT lc_id, lc_up_id, lc_time, lc_lca_id, lc_a_up_id, lc_log FROM log_crew WHERE lc_a_up_id = " . page_min_side::$active_player->id . " ORDER BY lc_time DESC");
                // ingen handlinger?
                if ($result->rowCount() == 0) {
                    echo '
	<p class="c">Ingen oppføringer eksisterer.</p>';
                } else {
                    $rows = array();
                    while ($row = $result->fetch()) {
                        $rows[$row['lc_id']] = $row;
                    }
                    $data = crewlog::load_summary_data($rows);
                    $logs = array();
                    foreach ($data as $row) {
                        // hent sammendrag
                        $summary = crewlog::make_summary($row, NULL, $row['lc_a_up_id'] != page_min_side::$active_player->id);
                        $day = ess::$b->date->get($row['lc_time'])->format(date::FORMAT_NOTIME);
                        $logs[$day][] = '<p><span class="time">' . ess::$b->date->get($row['lc_time'])->format("H:i") . ':</span> ' . $summary . '</p>';
                    }
                    ess::$b->page->add_css('.crewlog .time { color: #888888; padding-right: 5px }');
                    foreach ($logs as $day => $items) {
                        echo '
	<div class="bg1_c">
		<h1 class="bg1">' . $day . '<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1 crewlog">
			' . implode('
			', $items) . '
		</div>
	</div>';
                    }
                    echo '
	<p class="c">' . $pagei->pagenumbers() . '</p>';
                }
            } elseif ($subpage2 == "enote") {
                ess::$b->page->add_title("Endre notat");
                // lagre endringer?
                if (isset($_POST['notat'])) {
                    $notat = postval("notat");
                    if ($notat == page_min_side::$active_player->data['up_note_crew']) {
                        ess::$b->page->add_message("Ingen endringer ble utført.", "error");
                    } else {
                        \Kofradia\DB::get()->exec("UPDATE users_players SET up_note_crew = " . \Kofradia\DB::quote($notat) . " WHERE up_id = " . page_min_side::$active_player->id);
                        // legg til crewlogg
                        crewlog::log("player_note_crew", page_min_side::$active_player->id, NULL, array("note_old" => page_min_side::$active_player->data['up_note_crew'], "note_diff" => diff::make(page_min_side::$active_player->data['up_note_crew'], $notat)));
                        page_min_side::$active_player->data['up_note_crew'] = $notat;
                        ess::$b->page->add_message("Notet ble endret.");
                        redirect::handle();
                    }
                }
                echo '
	<div class="bg1_c" style="width: 400px">
		<h1 class="bg1">Endre crewnotat for spiller<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<form action="" method="post">
				<p>Dette endrer notatet som er tilknyttet denne spilleren. Du kan også tilknytte <a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=enote", "user")) . '">informasjon til brukeren</a>, eller til en annen av brukerens spillere hvis det heller er ønskelig.</p>
				<p>Notat:</p>
				<p><textarea name="notat" rows="10" cols="30" style="width: 98%">' . htmlspecialchars(page_min_side::$active_player->data['up_note_crew']) . '</textarea></p>
				<p class="c">' . show_sbutton("Lagre") . '</p>
			</form>
		</div>
	</div>';
            } elseif ($subpage2 == "rank" && access::has("seniormod")) {
                // endre?
                if (isset($_POST['rel']) || isset($_POST['abs'])) {
                    $log = trim(postval("log"));
                    $rel = 0;
                    // mangler begrunnelse?
                    if ($log == "") {
                        ess::$b->page->add_message("Mangler begrunnelse.", "error");
                    } elseif (isset($_POST['abs'])) {
                        $points = game::intval(postval("points_abs"));
                        // samme?
                        if ($points == page_min_side::$active_player->data['up_points']) {
                            ess::$b->page->add_message("Ingen endringer ble utført.", "error");
                        } elseif ($points < 0) {
                            ess::$b->page->add_message("Kan ikke sette til negativt tall.", "error");
                        } elseif ($points > 9999999) {
                            ess::$b->page->add_message("Kan ikke settes til så høyt tall.", "error");
                        } else {
                            $rel = $points - page_min_side::$active_player->data['up_points'];
                        }
                    } elseif (isset($_POST['rel'])) {
                        $points = game::intval(postval("points_rel"));
                        // ingen endring?
                        if ($points == 0) {
                            ess::$b->page->add_message("Ingen endringer ble utført.", "error");
                        } elseif (page_min_side::$active_player->data['up_points'] + $points < 0) {
                            ess::$b->page->add_message("Kan ikke utføre handlingen. Vil føre til <b>for lav</b> verdi.", "error");
                        } elseif (page_min_side::$active_player->data['up_points'] + $points > 9999999) {
                            ess::$b->page->add_message("Kan ikke utføre handlingen. Vil føre til <b>for høy</b> verdi.", "error");
                        } else {
                            $rel = $points;
                        }
                    }
                    // skal ikke dette annonseres?
                    $silent = isset($_POST['silent']);
                    // øke ranken?
                    if ($rel > 0) {
                        page_min_side::$active_player->increase_rank($rel, false, $silent, 0);
                        // legg til crewlogg
                        crewlog::log("player_rank_inc", page_min_side::$active_player->id, $log, array("points" => $rel));
                        ess::$b->page->add_message("Endringene ble lagret. Du økte ranken med " . game::format_number($rel) . " poeng." . ($silent ? ' Informasjonen ble ikke annonsert.' : ''));
                        redirect::handle();
                    } elseif ($rel < 0) {
                        page_min_side::$active_player->increase_rank($rel, false, $silent, 0);
                        $rel = abs($rel);
                        // legg til crewlogg
                        crewlog::log("player_rank_dec", page_min_side::$active_player->id, $log, array("points" => $rel));
                        ess::$b->page->add_message("Endringene ble lagret. Du senket ranken med " . game::format_number($rel) . " poeng." . ($silent ? ' Informasjonen ble ikke annonsert.' : ''));
                        redirect::handle();
                    }
                }
                ess::$b->page->add_title("Juster rank");
                echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Juster rank<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<p>Antall rankpoeng: <b>' . game::format_number(page_min_side::$active_player->data['up_points']) . '</b></p>
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Bestem rankpoeng (absolutt verdi)</dt>
					<dd><input type="text" name="points_abs" value="' . game::format_number(postval("points_abs", page_min_side::$active_player->data['up_points'])) . '" class="styled w60" maxlength="10" /> ' . show_sbutton("Lagre", 'name="abs"') . '</dd>
					<dt>Juster ranken (relativ verdi)</dt>
					<dd><input type="text" name="points_rel" value="' . game::format_number(postval("points_rel", 0)) . '" class="styled w60" maxlength="10" /> ' . show_sbutton("Lagre", 'name="rel"') . '</dd>
					<dd><input type="checkbox" name="silent"' . (isset($_POST['silent']) ? ' checked="checked"' : '') . ' id="silent" /><label for="silent"> Ikke annonser denne endringen (f.eks. på IRC)</label></dd>
					<dt>Begrunnelse for endring (crewlogg)</dt>
					<dd><textarea name="log" id="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
				</dl>
			</form>
		</div>
	</div>';
            } elseif ($subpage2 == "name" && access::has("mod")) {
                // lagre nytt spillernavn?
                if (isset($_POST['name'])) {
                    $name = trim(postval("name"));
                    $log = trim(postval("log"));
                    // ingen endringer utført?
                    if (strcmp(page_min_side::$active_player->data['up_name'], $name) === 0) {
                        ess::$b->page->add_message("Spillernavnet er det samme som før.", "error");
                    } elseif ($log == "") {
                        ess::$b->page->add_message("Mangler begrunnelse.", "error");
                    } else {
                        // kontroller spillernavnet (kun hvis endringer utover små/store bokstaver er gjort)
                        $check = strcasecmp(page_min_side::$active_player->data['up_name'], $name) !== 0;
                        if ($check) {
                            $result = \Kofradia\DB::get()->query("SELECT " . \Kofradia\DB::quoteNoNull($name) . " REGEXP regex AS m, error FROM regex_checks WHERE type = 'reg_user_strength' HAVING m = 1");
                        }
                        if ($check && $result->rowCount() > 0) {
                            // sett opp feilmeldingene
                            $feil = array();
                            while ($row = $result->fetch()) {
                                $feil[] = '<li>' . htmlspecialchars($row['error']) . '</li>';
                            }
                            // legg til feilmeldingene
                            ess::$b->page->add_message("<p>Spillernavnet var ikke gyldig:</p><ul>" . implode("", $feil) . "</ul>", "error");
                        } else {
                            // sjekk at spillernavnet ikke finnes fra før
                            $result = \Kofradia\DB::get()->query("SELECT up_id, up_name, up_access_level FROM users_players WHERE up_name = " . \Kofradia\DB::quote($name) . " AND up_id != " . page_min_side::$active_player->id . " AND (up_u_id != " . page_min_side::$active_user->id . " OR up_access_level != 0)");
                            if ($result->rowCount() > 0) {
                                $row = $result->fetch();
                                ess::$b->page->add_message("Spillernavnet er allerede i bruk: " . game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level']), "error");
                            } else {
                                // utfør endringer - endre spillernavnet
                                \Kofradia\DB::get()->exec("UPDATE users_players SET up_name = " . \Kofradia\DB::quote($name) . " WHERE up_id = " . page_min_side::$active_player->id);
                                // legg til crewlogg
                                crewlog::log("player_name", page_min_side::$active_player->id, $log, array("user_old" => page_min_side::$active_player->data['up_name'], "user_new" => $name));
                                ess::$b->page->add_message("Spillernavnet ble endret fra " . htmlspecialchars(page_min_side::$active_player->data['up_name']) . " til " . game::profile_link(page_min_side::$active_player->id, $name, page_min_side::$active_player->data['up_access_level']) . '.');
                                redirect::handle();
                            }
                        }
                    }
                }
                ess::$b->page->add_title("Endre spillernavn");
                echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Endre spillernavn<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<p>Ikke utfør andre endringer enn store/små bokstaver i spillernavnet dersom det ikke er veldig nødvendig. Dette på grunn av BB-koder som [user=..] ikke lenger vil fungere.</p>
			<p>Det er mulig å gi en spiller samme navn som en annen spiller, så lenge spillerene tilhører samme bruker.</p>
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Nåværende spillernavn</dt>
					<dd>' . htmlspecialchars(page_min_side::$active_player->data['up_name']) . '</dd>
					<dt>Nytt spillernavn</dt>
					<dd><input type="text" value="' . htmlspecialchars(postval("name", page_min_side::$active_player->data['up_name'])) . '" name="name" class="styled w120" /></dd>
					<dt>Begrunnelse for endring (crewlogg)</dt>
					<dd><textarea name="log" id="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
				</dl>
				<p class="c">' . show_sbutton("Endre spillernavnet") . '</p>
			</form>
		</div>
	</div>';
            }
        }
    }
 * @link 		http://www.teamst.org/index.php
 *
 * Compares selected requirements spec revisions with each other.
 *
 * @internal revisions
 */
require_once "../../config.inc.php";
require_once "common.php";
require '../../third_party/diff/diff.php';
require '../../third_party/daisydiff/src/HTMLDiff.php';
$templateCfg = templateConfiguration();
testlinkInitPage($db);
$smarty = new TLSmarty();
$labels = init_labels(array("num_changes" => null, "no_changes" => null, "version_short" => null, "diff_details_rev" => null, "type" => null, "status" => null, "name" => "title", "doc_id" => null, "revision_short" => null, "revision" => null));
$itemMgr = new requirement_spec_mgr($db);
$differ = new diff();
$args = init_args();
$gui = initializeGui($db, $args, $labels, $itemMgr);
// if already two revisions are selected, display diff
// else display template with versions to select
if ($args->doCompare) {
    // Side By Side
    $sbs = getItemsToCompare($args->left_item_id, $args->right_item_id, $gui->items);
    prepareUserFeedback($db, $gui, $args->req_spec_id, $labels, $sbs);
    $gui->attrDiff = getAttrDiff($sbs['left_item'], $sbs['right_item'], $labels);
    $cfields = getCFToCompare($sbs, $args->tproject_id, $itemMgr);
    $gui->cfieldsDiff = null;
    if (!is_null($cfields)) {
        $gui->cfieldsDiff = getCFDiff($cfields, $itemMgr);
    }
    $gui->diff = array("scope" => array());
 /**
  * This function displays the difference between two page versions.
  *
  * @author Johannes Klose <*****@*****.**>
  * @return void
  **/
 function opDiff()
 {
     $tpl =& singleton('template');
     if (isset($this->get['orig'], $this->get['final'])) {
         $orig = $this->get['orig'];
         $final = $this->get['final'];
         if (!preg_match('/^\\d+\\.\\d+\\.\\d+$/', $orig) || !preg_match('/^\\d+\\.\\d+\\.\\d+$/', $final)) {
             if (preg_match('/^\\d+\\.\\d+\\.\\d+$/', $final)) {
                 $orig = diff::findPrevVersion($final, $this->pageVersions);
                 if ($orig === false) {
                     $this->opList();
                     return;
                 }
             } else {
                 $this->opList();
                 return;
             }
         }
         if (!isset($this->pageVersions[$orig]) || !isset($this->pageVersions[$final])) {
             $this->opList();
             return;
         }
         $origText = diff::createVersion($this->page['page_text'], $this->pageVersions, $orig);
         $finalText = diff::createVersion($this->page['page_text'], $this->pageVersions, $final);
         $diff = diff::makeDiff($origText, $finalText, $this->pageVersions);
         $tpl->assign('diff_orig', $diff['orig']);
         $tpl->assign('diff_final', $diff['final']);
         $this->historyTemplate = 'action_history_diff.tpl';
         $this->lang['history_original'] = sprintf($this->lang['history_original'], $orig, $final, $this->pageVersions[$final]['log_time']);
         $this->lang['history_final'] = sprintf($this->lang['history_final'], $orig, $final, $this->pageVersions[$final]['log_time']);
         return;
     } else {
         $this->opList();
     }
 }
Ejemplo n.º 11
0
 /**
  * This function creates a older version of the current page.
  *
  * @author Johannes Klose <*****@*****.**>
  * @param  string $version Version number of the old text
  * @return array           Text, version and date of the old text
  **/
 function getOldPageText($version)
 {
     $tpl =& singleton('template');
     $versions = diff::getVersions();
     if (!isset($versions[$version])) {
         return false;
     }
     $oldText = diff::createVersion($this->page['page_text'], $versions, $version);
     return array('text' => $oldText, 'version' => $version, 'time' => $versions[$version]['log_time']);
 }
Ejemplo n.º 12
0
// Validate and set full path vars
$verified = TRUE;
foreach ($_GET as $v) {
    if (!isset($v) || empty($v)) {
        $verified = FALSE;
    }
}
if (!$verified) {
    echo "<font color=\"red\">*</font> You must select all items with an asterisk";
    // put in session to break and return error to script here
    exit;
} else {
    // initialise Vars
    $path_a = $_GET['path_a'];
    $path_b = $_GET['path_b'];
    $linepadding = $_GET['linepadding'];
}
$diff = new diff();
if ($linepadding >= 1 && $linepadding <= 99) {
    //if linepadding var is number and is between 1 and 99
    $text = $diff->inline($path_a, $path_b, $linepadding);
} else {
    $text = $diff->inline($path_a, $path_b);
}
echo count($diff->changes) . ' changes';
echo $text;
// echo output
// Print time taken script
$End = getTime();
echo "<div class=\"spacer\"></div>";
echo "<Strong>Time taken = " . number_format($End - $Start, 2) . " secs </strong>";
Ejemplo n.º 13
0
 /**
  * Creates a changelog and version information
  * for a edited page.
  *
  * @author Johannes Klose <*****@*****.**>
  * @param  int    $pageId   The page id
  * @param  string $oldText  Old page text
  * @param  string $newText  New page text
  * @param  string $version  Old page version
  * @param  int    $userId   The authors id (if logged in)
  * @param  string $userName The authors name (if it is an unregistered author)
  * @param  string $summary  Summary of changes
  * @return string           New page version
  **/
 function logChanges($pageId, $oldText, $newText, $version, $userId, $userName, $summary)
 {
     $db =& singleton('database');
     $pageVersion = $version;
     $linesOld = explode("\n", $newText);
     $diff = diff::getDiff($oldText, $newText);
     if (count($diff) > 0) {
         $oldLineCount = count($linesOld);
         $changedLineCount = count($diff);
         $percentSteps = $oldLineCount / 100;
         $percentChanged = $changedLineCount / $percentSteps;
         if ($version != '') {
             $pageVersion = explode('.', $version);
         } else {
             $pageVersion = array(0, 0, 0);
         }
         if ($percentChanged <= 5 || count($diff) <= 5) {
             $pageVersion[2]++;
         } elseif ($percentChanged <= 25) {
             $pageVersion[1]++;
             $pageVersion[2] = 0;
         } else {
             $pageVersion[0]++;
             $pageVersion[1] = 0;
             $pageVersion[2] = 0;
         }
         $pageVersion = join('.', $pageVersion);
         $db->query('INSERT INTO ' . DB_PREFIX . 'changelog(log_page_id, ' . 'log_page_version, log_time, log_diff, log_user_id, log_user_name, ' . 'log_summary, log_ip) ' . 'VALUES(' . $pageId . ', \'' . $pageVersion . '\', ' . $this->time . ', ' . '\'' . addslashes(serialize($diff)) . '\', ' . $userId . ', ' . '\'' . addslashes($userName) . '\', \'' . addslashes($summary) . '\', ' . '\'' . addslashes($this->server['REMOTE_ADDR']) . '\')');
     }
     return $pageVersion;
 }
Ejemplo n.º 14
0
Archivo: diff.php Proyecto: jvinhit/php
 /**
  * Computes a diff between sequences of strings.
  *
  * This can be used to compute things like case-insensitve diffs, or diffs
  * which ignore changes in white-space.
  *
  * @param array $from_lines         An array of strings.
  * @param array $to_lines           An array of strings.
  * @param array $mapped_from_lines  This array should have the same size number of elements as $from_lines.
  *                                  The elements in $mapped_from_lines and $mapped_to_lines are what is actually
  *                                  compared when computing the diff.
  * @param array $mapped_to_lines    This array should have the same number of elements as $to_lines.
  */
 function mapped_diff(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines)
 {
     if (sizeof($from_lines) != sizeof($mapped_from_lines) || sizeof($to_lines) != sizeof($mapped_to_lines)) {
         return false;
     }
     parent::diff($mapped_from_lines, $mapped_to_lines);
     $xi = $yi = 0;
     for ($i = 0; $i < sizeof($this->_edits); $i++) {
         $orig =& $this->_edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($from_lines, $xi, sizeof($orig));
             $xi += sizeof($orig);
         }
         $final =& $this->_edits[$i]->final;
         if (is_array($final)) {
             $final = array_slice($to_lines, $yi, sizeof($final));
             $yi += sizeof($final);
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Compara el schema actual con la última foto que se sacó. 
  */
 function opcion__compara_foto_schema()
 {
     $base = $this->consola->dialogo_ingresar_texto('Introduzca la base donde se encuentra el schema');
     $schema = $this->consola->dialogo_ingresar_texto('Introduzca el schema');
     $db = $this->get_instalacion()->conectar_base($base);
     $tablas = $db->get_lista_tablas();
     // abro el achivo donde van los resultados
     $archivo_salida = self::get_path_comparacion();
     $salida = fopen($archivo_salida, 'w');
     // Para cada tabla hago la comparación
     foreach ($tablas as $tabla) {
         // datos viejos: levanto del archivo y ordeno
         $archivo_old = toba_dir() . '/temp/sql/' . $tabla['nombre'] . '.old';
         $cont = file_get_contents($archivo_old);
         $datos_old = explode("\n", $cont);
         sort($datos_old);
         // datos nuevos, recupero y ordeno
         $datos = $this->exportar_tabla_inserts($base, $schema, $tabla['nombre']);
         sort($datos);
         // Calculo la diferencia y muestro
         $diff = diff::PHPDiff($datos_old, $datos);
         if (count($diff['I']) || count($diff['D']) || count($diff['U'])) {
             fputs($salida, "==============================================\nTabla: {$tabla['nombre']}\n");
         }
         if (count($diff['I'])) {
             fputs($salida, "----------------------------------------------\nInserts:\n");
         }
         foreach ($diff['I'] as $s) {
             fputs($salida, $s . "\n");
         }
         if (count($diff['D'])) {
             fputs($salida, "----------------------------------------------\nDeletes:\n");
         }
         foreach ($diff['D'] as $s) {
             fputs($salida, $s . "\n");
         }
         if (count($diff['U'])) {
             fputs($salida, "----------------------------------------------\nUpdates:\n");
         }
         foreach ($diff['U'] as $s) {
             fputs($salida, "_____\n" . $s['D'] . "\n" . $s['I'] . "\n_____\n");
         }
         $this->consola->progreso_avanzar();
         //}
     }
     fclose($salida);
     $this->consola->progreso_fin();
 }
Ejemplo n.º 16
0
 /**
  * Renders a diff.
  *
  * @param diff &$diff A diff object.
  *
  * @return string  The formatted output.
  */
 function render(&$diff)
 {
     $xi = $yi = 1;
     $block = false;
     $context = array();
     // Create a new diff object if it is a 3-way diff
     if (is_a($diff, 'diff3')) {
         $diff3 =& $diff;
         $diff_1 = $diff3->get_original();
         $diff_2 = $diff3->merged_output();
         unset($diff3);
         $diff = new diff($diff_1, $diff_2);
     }
     $nlead = $this->_leading_context_lines;
     $ntrail = $this->_trailing_context_lines;
     $output = $this->_start_diff();
     $diffs = $diff->get_diff();
     foreach ($diffs as $i => $edit) {
         // If these are unchanged (copied) lines, and we want to keep leading or trailing context lines, extract them from the copy block.
         if (is_a($edit, 'diff_op_copy')) {
             // Do we have any diff blocks yet?
             if (is_array($block)) {
                 // How many lines to keep as context from the copy block.
                 $keep = $i == sizeof($diffs) - 1 ? $ntrail : $nlead + $ntrail;
                 if (sizeof($edit->orig) <= $keep) {
                     // We have less lines in the block than we want for context => keep the whole block.
                     $block[] = $edit;
                 } else {
                     if ($ntrail) {
                         // Create a new block with as many lines as we need for the trailing context.
                         $context = array_slice($edit->orig, 0, $ntrail);
                         $block[] = new diff_op_copy($context);
                     }
                     $output .= $this->_block($x0, $ntrail + $xi - $x0, $y0, $ntrail + $yi - $y0, $block);
                     $block = false;
                 }
             }
             // Keep the copy block as the context for the next block.
             $context = $edit->orig;
         } else {
             // Don't we have any diff blocks yet?
             if (!is_array($block)) {
                 // Extract context lines from the preceding copy block.
                 $context = array_slice($context, sizeof($context) - $nlead);
                 $x0 = $xi - sizeof($context);
                 $y0 = $yi - sizeof($context);
                 $block = array();
                 if ($context) {
                     $block[] = new diff_op_copy($context);
                 }
             }
             $block[] = $edit;
         }
         $xi += $edit->orig ? sizeof($edit->orig) : 0;
         $yi += $edit->final ? sizeof($edit->final) : 0;
     }
     if (is_array($block)) {
         $output .= $this->_block($x0, $xi - $x0, $y0, $yi - $y0, $block);
     }
     return $output . $this->_end_diff();
 }
Ejemplo n.º 17
0
    /**
     * Crewside
     */
    protected static function page_crew()
    {
        global $__server, $_lang;
        ess::$b->page->add_title("Crew");
        $subpage2 = getval("b");
        redirect::store(page_min_side::addr(NULL, $subpage2 != "" ? "b=" . $subpage2 : ''));
        ess::$b->page->add_css('
.minside_crew_links .active { color: #CCFF00 }');
        $links = array();
        $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "", "player")) . '">Min spiller</a>';
        $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "")) . '"' . ($subpage2 == "" ? ' class="active"' : '') . '>Oversikt / logg</a>';
        if (access::has("forum_mod")) {
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=addlog")) . '"' . ($subpage2 == "addlog" ? ' class="active"' : '') . '>Nytt notat</a>';
        }
        $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=blokk")) . '"' . ($subpage2 == "blokk" ? ' class="active"' : '') . '>Blokkeringer</a>';
        if (access::has("mod")) {
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=banka")) . '"' . ($subpage2 == "banka" ? ' class="active"' : '') . '>Bankpassord</a>';
        }
        if (access::has("mod")) {
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=birth")) . '"' . ($subpage2 == "birth" ? ' class="active"' : '') . '>Fødselsdato</a>';
        }
        if (access::has("mod")) {
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr("set", "b=pass")) . '">Passord</a>';
        }
        if (access::has("admin")) {
            $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=level")) . '"' . ($subpage2 == "level" ? ' class="active"' : '') . '>Tilgangsnivå</a>';
        }
        $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=send_email")) . '"' . ($subpage2 == "send_email" ? ' class="active"' : '') . '>Send e-post</a>';
        $links[] = '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=warning")) . '"' . ($subpage2 == "warning" ? ' class="active"' : '') . '>Gi advarsel</a>';
        echo '
	<p class="c minside_crew_links">' . implode(" | ", $links) . '</p>';
        if ($subpage2 == "") {
            // javascript for rapporteringer
            ess::$b->page->add_js_domready('
	var w = $("minside_reports");
	var xhr = new Request({
		url: relative_path + "/ajax/minside_report",
		data: { u_id: ' . page_min_side::$active_user->id . ' },
		evalScripts: function(script)
		{
			ajax.js += script;
		}
	});
	xhr.addEvent("success", function(text)
	{
		w.set("html", text);
		w.getElements(".pagenumbers").each(function(elm)
		{
			elm.addEvent("set_page", function(s) { load(null, s, true); });
		});
		ajax.refresh();
	});
	xhr.addEvent("failure", function(x)
	{
		var p = new Element("p", {html: "Feil: " + x}).inject(w.empty());
	});
	function load(a, s, goto)
	{
		if (a !== null) xhr.options.data.a = a;
		if (s) xhr.options.data.s = s;
		if (goto) w.getParent().goto(-10);
		w.set("html", "<p>Laster inn data..</p>");
		xhr.send();
	}
	$("minside_reports_from").addEvent("click", function() { load("from", 1, true); });
	$("minside_reports_to").addEvent("click", function() { load("to", 1, true); });
	$("minside_reports_all").addEvent("click", function() { load("", 1, true); });
	load();');
            // css for rapporteringer
            ess::$b->page->add_css('
.rap_wrap {
	margin: 1em 0;
	background-color: #222222;
	position: relative;
	overflow: auto;
}
.rap_time {
	position: absolute;
	top: 8px;
	right: 5px;
	margin: 0;
	color: #777777;
}
.rap_time span {
	color: #EEEEEE;
}
.rap_w {
	margin: 0;
	padding: 5px;
	background-color: #282828;
}
.rap_u {
	font-size: 14px;
}

.rap_wrap .col2_w { margin: 0 }
.rap_wrap .col_w.left { width: 40% }
.rap_wrap .col_w.right { width: 60% }
.rap_wrap .col_w.left .col { margin: 0 0 0 5px }
.rap_wrap .col_w.right .col { margin: 5px 5px 5px 0 }

.rap_note {
	background-color: #1C1C1C;
	padding: 5px !important;
	overflow: auto;
	border: 1px dotted #525252
}
');
            // faner
            ess::$b->page->add_js_domready('
	$$(".minside_fane_link").addEvent("click", function(elm)
	{
		$$(".minside_fane").setStyle("display", "none");
		$$(".minside_fane_link").removeClass("minside_fane_active");
		this.addClass("minside_fane_active");
		$(this.get("rel")).setStyle("display", "");
	});
	$$(".minside_fane_active").fireEvent("click");');
            ess::$b->page->add_css('
.minside_fane_active, .minside_fane_active:hover {
	color: #CCFF00;
}');
            echo '
	<div class="col2_w">
		<div class="col_w left">
			<div class="col">
				<div class="bg1_c">
					<h1 class="bg1">Oversikt<span class="left2"></span><span class="right2"></span></h1>
					<div class="bg1">';
            // hent blokkeringer for brukeren
            $result = \Kofradia\DB::get()->query("SELECT ub_id, ub_type, ub_time_expire, ub_reason FROM users_ban WHERE ub_u_id = " . page_min_side::$active_user->id . " AND ub_time_expire > " . time());
            if ($result->rowCount() > 0) {
                while ($row = $result->fetch()) {
                    $access = access::has(blokkeringer::$types[$row['ub_type']]['access']);
                    echo '
						<p>Blokkert: ' . ($access ? '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=blokk&t={$row['ub_type']}")) . '">' : '') . htmlspecialchars(blokkeringer::$types[$row['ub_type']]['title']) . ($access ? '</a>' : '') . ' (til ' . ess::$b->date->get($row['ub_time_expire'])->format(date::FORMAT_SEC) . ', ' . game::counter($row['ub_time_expire'] - time()) . ')</p>';
                }
            }
            echo '
						<p>Trykk deg inn på de forskjellige spillerene til brukeren for å se informasjon knyttet opp mot dem.</p>
					</div>
				</div>
			</div>
		</div>
		<div class="col_w right">
			<div class="col">
				<div class="bg1_c">
					<h1 class="bg1">Crewnotat for brukeren<span class="left2"></span><span class="right2"></span></h1>
					<p class="h_right"><a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=enote")) . '">rediger</a></p>
					<div class="bg1">
						<p>Her kan hvem som helst i crewet legge til eller endre et notat for denne brukeren for å memorere ting som har med <u>brukeren</u> å gjøre.</p>' . (empty(page_min_side::$active_user->data['u_note_crew']) ? '
						<p>Ingen notat er registrert.</p>' : '
						<div class="p">' . game::bb_to_html(page_min_side::$active_user->data['u_note_crew']) . '</div>') . '
					</div>
				</div>
			</div>
		</div>
	</div>
	<p class="c"><a class="minside_fane_link minside_fane_active" rel="minside_fane2">Loggoppføringer</a> | <a class="minside_fane_link" rel="minside_fane1">Rapporteringer</a></p>
	<div id="minside_fane1" class="minside_fane">
		<p class="c">Filter: <a id="minside_reports_from">Brukerens egne rapporteringer</a> | <a id="minside_reports_to">Andres rapporteringer</a> | <a id="minside_reports_all">Alle</a></p>
		<div id="minside_reports">
			<p>Laster inn..</p>
		</div>
	</div>
	<div id="minside_fane2" class="minside_fane">
	<p class="c">Loggoppføringer for denne brukeren</p>';
            // hent loggene for denne brukeren
            $pagei = new pagei(pagei::ACTIVE_GET, "side", pagei::PER_PAGE, 50);
            $result = $pagei->query("SELECT lc_id, lc_up_id, lc_time, lc_lca_id, lc_a_up_id, lc_log FROM log_crew JOIN users_players ON up_u_id = " . page_min_side::$active_user->id . " WHERE lc_a_up_id = up_id ORDER BY lc_time DESC");
            // ingen handlinger?
            if ($result->rowCount() == 0) {
                echo '
	<p class="c">Ingen oppføringer eksisterer.</p>';
            } else {
                $rows = array();
                while ($row = $result->fetch()) {
                    $rows[$row['lc_id']] = $row;
                }
                $data = crewlog::load_summary_data($rows);
                $logs = array();
                foreach ($data as $row) {
                    // hent sammendrag
                    $summary = crewlog::make_summary($row, NULL, $row['lc_a_up_id'] != page_min_side::$active_player->id);
                    $day = ess::$b->date->get($row['lc_time'])->format(date::FORMAT_NOTIME);
                    $logs[$day][] = '<p><span class="time">' . ess::$b->date->get($row['lc_time'])->format("H:i") . ':</span> ' . $summary . '</p>';
                }
                ess::$b->page->add_css('.crewlog .time { color: #888888; padding-right: 5px }');
                foreach ($logs as $day => $items) {
                    echo '
	<div class="bg1_c">
		<h1 class="bg1">' . $day . '<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1 crewlog">
			' . implode('
			', $items) . '
		</div>
	</div>';
                }
                echo '
	<p class="c">' . $pagei->pagenumbers() . '</p>';
            }
            echo '
	</div>';
        } elseif ($subpage2 == "addlog" && access::has("forum_mod")) {
            // legge til?
            if (isset($_POST['notat'])) {
                $notat = trim(postval("notat"));
                $notat_bb = trim(game::bb_to_html($notat));
                if (empty($notat_bb)) {
                    ess::$b->page->add_message("Notatet kan ikke være tomt.", "error");
                } else {
                    // legg til i crewloggen
                    crewlog::log("user_add_note", page_min_side::$active_player->id, $notat);
                    ess::$b->page->add_message("Notatet ble registrert.");
                    redirect::handle(page_min_side::addr());
                }
            }
            ess::$b->page->add_title("Nytt notat");
            ess::$b->page->add_js_domready('$("notat_felt").focus();');
            echo '
	<div class="bg1_c">
		<h1 class="bg1">Legg til notat i crewloggen<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<p>Notat: (Vil bli lagt til som vanlig logg i <a href="' . htmlspecialchars(page_min_side::addr(NULL)) . '">Crewloggen</a>.)</p>
			<form action="" method="post">
				<p><textarea name="notat" id="notat_felt" rows="10" cols="30" style="width: 98%; overflow: auto">' . htmlspecialchars(postval("notat")) . '</textarea></p>
				<p>' . show_sbutton("Legg til notat") . '</p>
			</form>
		</div>
	</div>';
        } elseif ($subpage2 == "blokk") {
            ess::$b->page->add_title("Blokkeringer");
            $type = false;
            if (isset($_GET['t'])) {
                // kontroller type
                $type_id = intval($_GET['t']);
                // fant ikke?
                if (!isset(blokkeringer::$types[$type_id])) {
                    ess::$b->page->add_message("Ugyldig type '.{$type_id}.'.", "error");
                } else {
                    $type = blokkeringer::$types[$type_id];
                    // har vi tilgang til å gjøre noe med denne blokkeringen?
                    if (!access::has($type['access'])) {
                        ess::$b->page->add_message('Du har ikke tilgang til denne typen blokkering. (' . htmlspecialchars($type['title']) . ')', "error");
                        $type = false;
                    }
                }
            }
            // vise en type blokkering?
            if ($type) {
                redirect::store(page_min_side::addr(NULL, "b=blokk&t={$type_id}"));
                // sjekk om det er en aktiv blokkering for denne typen
                $active = blokkeringer::check($type_id, page_min_side::$active_user->id);
                if ($active) {
                    // hent informasjon om blokkeringen
                    $info = blokkeringer::get_info($active['ub_id']);
                }
                // handling: legg til blokkering
                if (isset($_POST['add']) && $active) {
                    ess::$b->page->add_message("Det er allerede en blokkering på brukeren som varer til " . ess::$b->date->get($active['ub_time_expire'])->format() . ".", "error");
                } elseif (isset($_POST['add'])) {
                    // kontroller verdier
                    $date_type = isset($_POST['date_type']) && $_POST['date_type'] == "abs" ? "abs" : "rel";
                    $rel_weeks = intval(postval("rel_weeks"));
                    $rel_days = intval(postval("rel_days"));
                    $rel_hours = intval(postval("rel_hours"));
                    $rel_mins = intval(postval("rel_mins"));
                    $abs_date = postval("abs_date");
                    $abs_time = postval("abs_time");
                    // sjekk type og verdiene
                    $expire = false;
                    // bestemt dato/tidspunkt
                    if ($date_type == "abs") {
                        // kontroller datoen
                        if (!($abs_date_m = check_date($abs_date, "%y-%m-%d"))) {
                            ess::$b->page->add_message('Datoen du skrev inn er ikke gyldig.', "error");
                        } elseif (!($abs_time_m = check_date($abs_time, "%h:%i:%s"))) {
                            ess::$b->page->add_message('Tidspunktet du skrev inn er ikke gyldig.', "error");
                        } else {
                            // ok
                            $date = ess::$b->date->get();
                            $date->setTime($abs_time_m[1], $abs_time_m[2], $abs_time_m[3]);
                            $date->setDate($abs_date_m[1], $abs_date_m[2], $abs_date_m[3]);
                            $expire = $date->format("U");
                        }
                    } else {
                        // sjekk uker
                        if ($rel_weeks < 0 || $rel_weeks > 9) {
                            ess::$b->page->add_message('Antall uker kan ikke være under 0 eller over 9.', "error");
                        } elseif ($rel_days < 0 || $rel_days > 6) {
                            ess::$b->page->add_message('Antall dager kan ikke være under 0 eller over 6.', "error");
                        } elseif ($rel_hours < 0 || $rel_hours > 23) {
                            ess::$b->page->add_message('Antall timer kan ikke være under 0 eller over 23.', "error");
                        } elseif ($rel_mins < 0 || $rel_mins > 59) {
                            ess::$b->page->add_message('Antall minutter kan ikke være under 0 eller over 59.', "error");
                        } else {
                            // ok
                            $expire = time() + $rel_weeks * 604800 + $rel_days * 86400 + $rel_hours * 3600 + $rel_mins * 60;
                        }
                    }
                    // sjekke videre?
                    if ($expire) {
                        // sjekk at datoen er minst 1 min fremover i tid
                        if ($expire < time() + 60) {
                            ess::$b->page->add_message('Du kan ikke legge til en blokkering for mindre enn 1 minutt.', "error");
                        } else {
                            // kontroller begrunnelse og intern informasjon
                            $log = trim(postval("log"));
                            $note = trim(postval("note"));
                            // mangler begrunnelse?
                            if ($log == "") {
                                ess::$b->page->add_message('Mangler begrunnelse.', "error");
                            } elseif ($note == "") {
                                ess::$b->page->add_message("Mangler intern informasjon", "error");
                            } else {
                                // forsøk å legg til blokkeringen
                                $add = blokkeringer::add(page_min_side::$active_user->id, $type_id, $expire, $log, $note);
                                if ($add !== true) {
                                    ess::$b->page->add_message("Det er allerede en blokkering på brukeren som varer til " . ess::$b->date->get($add['ub_time_expire'])->format() . ".", "error");
                                } else {
                                    // legg til crewlogg
                                    crewlog::log("user_ban_active", page_min_side::$active_player->id, $log, array("type" => $type_id, "time_end" => $expire, "note" => $note));
                                    ess::$b->page->add_message('Brukeren er nå blokkert til ' . ess::$b->date->get($expire)->format() . '. (' . htmlspecialchars($type['title']) . ')');
                                    redirect::handle();
                                }
                            }
                        }
                    }
                } elseif (isset($_POST['edit']) && !$active) {
                    // ingen blokkering å redigere?
                    ess::$b->page->add_message("Brukeren har ikke lengre denne blokkeringen.", "error");
                } elseif (isset($_POST['edit'])) {
                    // godkjent handling?
                    if (isset($_POST['log_change'])) {
                        // kontroller verdier
                        $date = postval("date");
                        $time = postval("time");
                        // kontroller datoen
                        if (!($date_m = check_date($date, "%y-%m-%d"))) {
                            ess::$b->page->add_message('Datoen du skrev inn er ikke gyldig.', "error");
                        } elseif (!($time_m = check_date($time, "%h:%i:%s"))) {
                            ess::$b->page->add_message('Tidspunktet du skrev inn er ikke gyldig.', "error");
                        } else {
                            $date = ess::$b->date->get();
                            $date->setTime($time_m[1], $time_m[2], $time_m[3]);
                            $date->setDate($date_m[1], $date_m[2], $date_m[3]);
                            $expire = $date->format("U");
                            // sjekk at datoen er minst 1 min fremover i tid
                            if ($expire < time() + 60) {
                                ess::$b->page->add_message('Du kan ikke legge til en blokkering for mindre enn 1 minutt.', "error");
                            } else {
                                // kontroller begrunnelse for utestengelse, begrunnelse for endring og intern informasjon
                                $log_ban = trim(postval("log_ban"));
                                $log_change = trim(postval("log_change"));
                                $note = trim(postval("note"));
                                // mangler begrunnelse for endring?
                                if ($log_change == "") {
                                    ess::$b->page->add_message('Mangler begrunnelse for endring.', "error");
                                } elseif ($log_ban == "") {
                                    ess::$b->page->add_message('Mangler begrunnelse for utestengelse.', "error");
                                } elseif ($note == "") {
                                    ess::$b->page->add_message('Mangler intern informasjon.', "error");
                                } elseif ($expire == $info['ub_time_expire'] && $log_ban == $info['ub_reason'] && $note == $info['ub_note']) {
                                    ess::$b->page->add_message('Ingen endringer ble utført.', "error");
                                } else {
                                    // oppdater blokkeringen
                                    $edit = blokkeringer::edit($active['ub_id'], $expire, $log_ban, $note);
                                    if ($edit == 0) {
                                        ess::$b->page->add_message("Blokkeringen kunne ikke bli oppdatert. Den er mest sannsynlig ikke lengre aktiv.", "error");
                                    } else {
                                        // legg til crewlogg
                                        $data = array("type" => $type_id, "time_end_old" => $info['ub_time_expire'], "log_old" => $info['ub_reason'], "note_old" => $info['ub_note']);
                                        if ($expire != $info['ub_time_expire']) {
                                            $data["time_end_new"] = $expire;
                                        }
                                        if ($log_ban != $info['ub_reason']) {
                                            $data["log_new"] = $log_ban;
                                        }
                                        if ($note != $info['ub_note']) {
                                            $data["note_new"] = $note;
                                        }
                                        crewlog::log("user_ban_change", page_min_side::$active_player->id, $log_change, $data);
                                        ess::$b->page->add_message('Du har oppdatert blokkeringen. Brukeren er nå blokkert til ' . ess::$b->date->get($expire)->format() . '. (' . htmlspecialchars($type['title']) . ')');
                                        redirect::handle();
                                    }
                                }
                            }
                        }
                    }
                } elseif (isset($_POST['delete']) && !$active) {
                    // ingen blokkering å slette?
                    ess::$b->page->add_message("Brukeren har ikke lengre denne blokkeringen.", "error");
                } elseif (isset($_POST['delete'])) {
                    // godkjent handling?
                    if (isset($_POST['log'])) {
                        $log = trim(postval("log"));
                        // mangler logg?
                        if ($log == "") {
                            ess::$b->page->add_message('Mangler begrunnelse.', "error");
                        } else {
                            // fjern blokkeringen
                            $delete = blokkeringer::delete($active['ub_id']);
                            if ($delete == 0) {
                                ess::$b->page->add_message("Blokkeringen kunne ikke bli oppdatert. Den er mest sannsynlig ikke lengre aktiv.", "error");
                            } else {
                                // legg til crewlogg
                                crewlog::log("user_ban_delete", page_min_side::$active_player->id, $log, array("type" => $type_id, "time_end" => $info['ub_time_expire'], "log" => $info['ub_reason'], "note" => $info['ub_note']));
                                ess::$b->page->add_message('Du har fjernet blokkeringen. (' . htmlspecialchars($type['title']) . ')');
                                redirect::handle();
                            }
                        }
                    }
                }
                echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Blokkering: ' . htmlspecialchars($type['title']) . '<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<boxes />
			<p class="r">Tilgangsnivå: ' . access::name($type['access']) . '</p>
			<p><u>Hensikt:</u> ' . $type['description'] . '</p>';
                // blokkert?
                if ($active) {
                    echo '
			<p>Brukeren er blokkert.</p>
			<dl class="dd_right">
				<dt>Lagt til</dt>
				<dd>' . ess::$b->date->get($info['ub_time_added'])->format(date::FORMAT_SEC) . '<br />' . game::timespan($info['ub_time_added'], game::TIME_ABS | game::TIME_ALL, 5) . '</dd>
				<dt>Utestengt til</dt>
				<dd>' . ess::$b->date->get($info['ub_time_expire'])->format(date::FORMAT_SEC) . '<br />' . game::counter($info['ub_time_expire'] - time()) . '</dd>
			</dl>
			<div class="section">
				<h2>Begrunnelse</h2>
				<div class="p">' . (($reason = game::bb_to_html($info['ub_reason'])) == "" ? 'Ikke oppgitt.' : $reason) . '</div>
				<h2>Intern informasjon</h2>
				<div class="p">' . (($note = game::bb_to_html($info['ub_note'])) == "" ? 'Ikke oppgitt.' : $note) . '</div>
			</div>';
                    // handling: redigere blokkering
                    if (isset($_POST['edit'])) {
                        echo '
			<p>Du er i ferd med å endre blokkeringen til brukeren.</p>
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Til</dt>
					<dd>
						Dato:
						<input type="text" name="date" id="ban_date" value="' . htmlspecialchars(postval("date", ess::$b->date->get($info['ub_time_expire'])->format("Y-m-d"))) . '" class="styled w80" />
						<input type="text" name="time" id="ban_time" value="' . htmlspecialchars(postval("time", ess::$b->date->get($info['ub_time_expire'])->format("H:i:s"))) . '" class="styled w80" />
					</dd>
					<dt>Begrunnelse for endring</dt>
					<dd><textarea name="log_change" cols="30" rows="5">' . htmlspecialchars(postval("log_change")) . '</textarea></dd>
					<dt>Begrunnelse for blokkering</dt>
					<dd><textarea name="log_ban" cols="30" rows="5">' . htmlspecialchars(postval("log_ban", $info['ub_reason'])) . '</textarea></dd>
					<dt>Intern informasjon</dt>
					<dd><textarea name="note" cols="30" rows="5">' . htmlspecialchars(postval("note", $info['ub_note'])) . '</textarea></dd>
					<dd>
						' . show_sbutton("Lagre endringer", 'name="edit"') . '
						' . show_sbutton("Avbryt") . '
					</dd>
				</dl>
			</form>';
                    } elseif (isset($_POST['delete'])) {
                        echo '
			<p>Du er i ferd med å fjerne blokkeringen til brukeren.</p>
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Begrunnelse for fjerning</dt>
					<dd><textarea name="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
					<form action="" method="post">
						<dd>
							' . show_sbutton("Fjern", 'name="delete"') . '
							' . show_sbutton("Avbryt") . '
						</dd>
					</form>
				</dl>
			</form>';
                    } else {
                        echo '
			<form action="" method="post">
				<p>
					' . show_sbutton("Endre", 'name="edit"') . '
					' . show_sbutton("Fjern", 'name="delete"') . '
					<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=blokk")) . '" class="button">Tilbake</a>
				</p>
			</form>';
                    }
                } else {
                    $date_type = isset($_POST['type']) && $_POST['type'] == "abs" ? "abs" : "rel";
                    $hide_rel = $date_type == "rel" ? '' : ' hide';
                    $hide_abs = $date_type == "abs" ? '' : ' hide';
                    echo '
			<p>Brukeren har ingen aktiv blokkering.</p>
			<form action="" method="post">
				<input type="hidden" name="date_type" value="' . $date_type . '" />
				<dl class="dd_right dl_2x">
					<dt class="date_rel' . $hide_rel . '">Varighet (<a href="#" onclick="handleClass(\'.date_abs\', \'.date_rel\', event, this.parentNode.parentNode); $(\'date_type\').value=\'abs\'">velg dato</a>)</dt>
					<dd class="date_rel' . $hide_rel . '">
						<input type="text" name="rel_weeks" class="styled w30 r" style="width: 10px" value="' . intval(postval("rel_weeks")) . '" maxlength="1" /> uker
						<input type="text" name="rel_days" class="styled w30 r" style="width: 10px" value="' . intval(postval("rel_days")) . '" maxlength="1" /> dager
						<input type="text" name="rel_hours" class="styled w30 r" style="width: 17px" value="' . intval(postval("rel_hours")) . '" maxlength="2" /> timer
						<input type="text" name="rel_mins" class="styled w30 r" style="width: 17px" value="' . intval(postval("rel_mins")) . '" maxlength="2" /> minutter
					</dd>
					<dt class="date_abs' . $hide_abs . '">Til (<a href="#" onclick="handleClass(\'.date_rel\', \'.date_abs\', event, this.parentNode.parentNode); $(\'date_type\').value=\'rel\'">velg varighet</a>)</dt>
					<dd class="date_abs' . $hide_abs . '">
						Dato:
						<input type="text" name="abs_date" value="' . htmlspecialchars(postval("abs_date", ess::$b->date->get()->format("Y-m-d"))) . '" class="styled w80" />
						<input type="text" name="abs_time" value="' . htmlspecialchars(postval("abs_time", ess::$b->date->get()->format("H:i:s"))) . '" class="styled w60" />
					</dd>
					<dt>Begrunnelse</dt>
					<dd><textarea name="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
					<dt>Intern informasjon</dt>
					<dd><textarea name="note" cols="30" rows="5">' . htmlspecialchars(postval("note")) . '</textarea></dd>
					<dd>
						' . show_sbutton("Legg til blokkering", 'name="add"') . '
						<a href="' . htmlspecialchars(page_min_side::addr(NULL, "a=blokk")) . '" class="button">Tilbake</a>
					</dd>
				</dl>
			</form>';
                }
                echo '
		</div>
	</div>';
            } else {
                // filtrer ut de blokkeringene vi har tilgang til å sette
                $types = blokkeringer::$types;
                $links = array();
                foreach ($types as $id => $type) {
                    if (!access::has($type['access'])) {
                        continue;
                    }
                    $links[$type['title']] = '
				<li><a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=blokk&t={$id}")) . '" title="' . htmlspecialchars($type['description']) . '">' . htmlspecialchars($type['title']) . '</a></li>';
                }
                // sorter
                ksort($links);
                $links = implode('', $links);
                // vis oversikt
                echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Blokkeringer<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<p>Velg type:</p>';
                if ($links == '') {
                    echo '
			<p>Du har ikke tilgang til noen blokkeringstyper.</p>';
                } else {
                    echo '
			<ul>' . $links . '
			</ul>';
                }
                echo '
		</div>
	</div>';
                // hent alle aktive blokkeringer
                $result = \Kofradia\DB::get()->query("SELECT ub_type, ub_time_expire, ub_reason FROM users_ban WHERE ub_u_id = " . page_min_side::$active_user->id . " AND ub_time_expire > " . time() . " ORDER BY ub_time_expire");
                if ($result->rowCount() > 0) {
                    echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Aktive blokkeringer<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<table class="table tablem" style="width: 100%">
				<thead>
					<tr>
						<th>Type</th>
						<th>Dato</th>
						<th>Begrunnelse</th>
					</tr>
				</thead>
				<tbody>';
                    $i = 0;
                    while ($row = $result->fetch()) {
                        $type = blokkeringer::get_type($row['ub_type']);
                        $access = access::has($type['access']);
                        echo '
					<tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '>
						<td>' . ($access ? '<a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=blokk&t={$row['ub_type']}")) . '">' : '') . htmlspecialchars($type['title']) . ($access ? '</a>' : '') . '</td>
						<td>
							' . ess::$b->date->get($row['ub_time_expire'])->format(date::FORMAT_SEC) . '<br />
							(' . game::timespan($row['ub_time_expire'], game::TIME_ABS | game::TIME_ALL, 5) . ')
						</td>
						<td>' . game::format_data($row['ub_reason'], "bb-opt", "Ingen begrunnelse gitt.") . '</td>
					</tr>';
                    }
                    echo '
				</tbody>
			</table>
		</div>
	</div>';
                }
            }
        } elseif ($subpage2 == "send_email") {
            ess::$b->page->add_title("Send e-post");
            // har tekst?
            $show_form = true;
            if (isset($_POST['text']) && !isset($_POST['edit'])) {
                $subject = trim(postval("subject"));
                $text = trim(postval("text"));
                // mangler emne?
                if (empty($subject)) {
                    ess::$b->page->add_message("Du må fylle ut emnefeltet.", "error");
                } elseif (empty($text)) {
                    ess::$b->page->add_message("Du må fylle ut innholdet.", "error");
                } else {
                    $email_subject = $subject;
                    $email_text = $text . "\n\n--\n" . login::$user->player->data['up_name'] . "\nwww.kofradia.no\n\nDenne meldingen ble sendt til " . page_min_side::$active_user->data['u_email'] . " som tilhører " . page_min_side::$active_player->data['up_name'];
                    // godkjent?
                    if (isset($_POST['send'])) {
                        // send e-posten
                        $email = new email();
                        $email->text = $email_text;
                        $email->headers['BCC'] = "*****@*****.**";
                        $email->headers['Reply-To'] = "*****@*****.**";
                        $email->send(page_min_side::$active_user->data['u_email'], $email_subject);
                        // legg til crewlogg
                        crewlog::log("user_send_email", page_min_side::$active_player->id, NULL, array("email" => page_min_side::$active_user->data['u_email'], "email_subject" => $email_subject, "email_content" => $email_text));
                        ess::$b->page->add_message("E-posten ble sendt til " . htmlspecialchars(page_min_side::$active_user->data['u_email']) . ".");
                        redirect::handle(page_min_side::addr(""));
                    }
                    echo '
	<div class="bg1_c" style="width: 400px">
		<h1 class="bg1">Send e-post<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<p><b>Mottaker:</b> ' . htmlspecialchars(page_min_side::$active_user->data['u_email']) . '</p>
			<p><b>Emne:</b> ' . htmlspecialchars($email_subject) . '</p>
			<p style="font-family: monospace">' . nl2br(htmlspecialchars($email_text)) . '</p>
			<form action="" method="post">
				<input type="hidden" id="email_subject" name="subject" value="' . htmlspecialchars($subject) . '" />
				<input type="hidden" id="email_text" name="text" value="' . htmlspecialchars($text) . '" />
				<p>' . show_sbutton("Send e-posten", 'name="send"') . ' ' . show_sbutton("Tilbake / endre", 'name="edit"') . '</p>
			</form>
		</div>
	</div>';
                    $show_form = false;
                }
            }
            if ($show_form) {
                ess::$b->page->add_js_domready('$("email_subject").focus();');
                echo '
	<div class="bg1_c" style="width: 400px">
		<h1 class="bg1">Send e-post<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<boxes />
			<p>Her sender du e-post til brukeren på vegne av Kofradia. Avsender vil være den normale avsendere all e-post fra Kofradia blir sendt fra.</p>
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Mottaker</dt>
					<dd>' . htmlspecialchars(page_min_side::$active_user->data['u_email']) . '</dd>
					<dt>Emne</dt>
					<dd><input type="text" value="' . htmlspecialchars(postval("subject")) . '" name="subject" id="email_subject" class="styled w200" /></dd>
					<dt>Innhold</dt>
					<dd><textarea name="text" id="email_text" cols="50" rows="10">' . htmlspecialchars(postval("text", "Hei,\n\n")) . '</textarea></dd>
					<dd>' . show_sbutton("Forhåndsvis / fortsett") . '</dd>
				</dl>
			</form>
		</div>
	</div>';
            }
        } elseif ($subpage2 == "warning") {
            ess::$b->page->add_title("Gi advarsel til brukeren");
            $types = crewlog::$user_warning_types;
            // legge til advarsel?
            if (isset($_POST['log'])) {
                $log = trim(postval("log"));
                $note = trim(postval("note"));
                $type = postval("type");
                $priority = (int) postval("priority");
                $notify = isset($_POST['notify']);
                if (empty($log) || empty($note)) {
                    ess::$b->page->add_message("Både begrunnelse og intern informasjon må fylles ut.", "error");
                } elseif (!isset($types[$type])) {
                    ess::$b->page->add_message("Ugyldig kategori.", "error");
                } elseif ($priority < 1 || $priority > 3) {
                    ess::$b->page->add_message("Ugylig alvorlighet.", "error");
                } else {
                    $data = array("type" => $types[$type], "note" => $note, "priority" => $priority);
                    // legge til spillerlogg?
                    if ($notify) {
                        $data['notified'] = 1;
                        $data['notified_id'] = player::add_log_static(gamelog::$items['advarsel'], urlencode($types[$type]) . ':' . urlencode($log), NULL, page_min_side::$active_player->id);
                        ess::$b->page->add_message("Advarselen ble lagret. Brukeren ble informert.");
                    } else {
                        ess::$b->page->add_message("Advarselen ble lagret. Du har ikke informert brukeren om denne advarselen.");
                    }
                    // legg til advarselen
                    crewlog::log("user_warning", page_min_side::$active_player->id, $log, $data);
                    redirect::handle();
                }
            }
            echo '
	<div class="bg1_c" style="width: 400px">
		<h1 class="bg1">Gi advarsel til brukeren<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<form action="" method="post">
				<boxes />
				<p>Dette kan benyttes som et verktøy for å gi advarsler til brukere. Det kan velges om brukeren skal motta advarselen eller ikke. Hvis man ikke velger å informere brukeren om noe, blir det alikevel søkbart i crewloggen for brukeren.</p>
				<p>Alvorligheten av advarselen blir benyttet for å automatisere en poengsum brukeren får avhengig av antall advarseler. En advarsel med høy alvorlighet varer lenger og teller mer enn en med lav alvorlighet.</p>
				<dl class="dd_right">
					<dt>Kategori</dt>
					<dd>
						<select name="type">';
            $type = isset($_POST['type']) && isset($types[$_POST['type']]) ? intval($_POST['type']) : false;
            if ($type === false) {
                echo '
							<option value="">Velg ..</option>';
            }
            foreach ($types as $key => $row) {
                echo '
							<option value="' . $key . '"' . ($key === $type ? ' selected="selected"' : '') . '>' . htmlspecialchars($row) . '</option>';
            }
            echo '
						</select>
					</dd>
					<dt>Alvorlighet/prioritet</dt>
					<dd>
						<select name="priority">';
            $priority = isset($_POST['priority']) && is_numeric($_POST['priority']) && $_POST['priority'] >= 1 && $_POST['priority'] <= 3 ? $_POST['priority'] : 2;
            echo '
							<option value="1"' . ($priority == 1 ? ' selected="selected"' : '') . '>Lav</option>
							<option value="2"' . ($priority == 2 ? ' selected="selected"' : '') . '>Moderat</option>
							<option value="3"' . ($priority == 3 ? ' selected="selected"' : '') . '>Høy</option>
						</select>
					</dd>
				</dl>
				<p>Begrunnelse:</p>
				<p><textarea name="log" rows="10" cols="30" style="width: 98%">' . htmlspecialchars(postval("log")) . '</textarea></p>
				<p>Intern informasjon:</p>
				<p><textarea name="note" rows="10" cols="30" style="width: 98%">' . htmlspecialchars(postval("note")) . '</textarea></p>
				<p><input type="checkbox" name="notify"' . ($_SERVER['REQUEST_METHOD'] == "POST" && !isset($_POST['notify']) ? '' : ' checked="checked"') . ' id="warning_notify" /><label for="warning_notify"> Gi brukeren informasjon om denne advarselen. Kun kategori og begrunnelse vil bli oppgitt til brukeren som en logg i hendelser.</label></p>
				<p class="c">' . show_sbutton("Lagre") . '</p>
			</form>
		</div>
	</div>';
            // analyser advarsler
            $lca_id = crewlog::$actions['user_warning'][0];
            $pagei = new pagei(pagei::ACTIVE_GET, "side", pagei::PER_PAGE, 15);
            $result = $pagei->query("\n\t\t\t\tSELECT lc_id, lc_up_id, lc_time, lc_log, lcd_data_int\n\t\t\t\tFROM log_crew\n\t\t\t\t\tJOIN users_players ON lc_a_up_id = up_id AND up_u_id = " . page_min_side::$active_user->id . "\n\t\t\t\t\tLEFT JOIN log_crew_data ON lcd_lc_id = lc_id AND lcd_lce_id = 5\n\t\t\t\tWHERE lc_lca_id = {$lca_id} AND (lcd_data_int IS NULL OR lcd_data_int = 0)\n\t\t\t\tORDER BY lc_time DESC");
            $data = array();
            while ($row = $result->fetch()) {
                $data[$row['lc_id']] = $row;
            }
            // sett opp data
            $data = crewlog::load_summary_data($data);
            echo '
	<div class="bg1_c ' . (count($data) == 0 ? 'xsmall' : 'medium') . '">
		<h1 class="bg1">Tidligere advarsler<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">';
            if (count($data) == 0) {
                echo '
			<p>Brukeren har ingen tidligere advarsler.</p>';
            } else {
                ess::$b->page->add_css('
.advarsel { border: 1px solid #292929; margin: 10px 0; padding: 0 10px }');
                foreach ($data as $row) {
                    $priority = $row['data']['priority'] == 1 ? "lav" : ($row['data']['priority'] == 2 ? "moderat" : "høy");
                    echo '
			<div class="advarsel">
				<p><b>' . ess::$b->date->get($row['lc_time'])->format() . '</b>: ' . $row['data']['type'] . ' (alvorlighet: <b>' . $priority . '</b>):</p>
				<ul>
					<li>' . game::format_data($row['lc_log']) . '</li>
					<li>Internt notat: ' . game::format_data($row['data']['note']) . '</li>
				</ul>
				<p>' . (empty($row['data']['notified']) ? 'Ble IKKE varslet.' : 'Ble varslet.') . ' Av <user id="' . $row['lc_up_id'] . '" /></p>
			</div>';
                }
                echo '
			<p class="c">' . $pagei->pagenumbers() . '</p>';
            }
            echo '
		</div>
	</div>';
        } elseif ($subpage2 == "enote") {
            ess::$b->page->add_title("Endre notat for bruker");
            // lagre endringer?
            if (isset($_POST['notat'])) {
                $notat = postval("notat");
                if ($notat == page_min_side::$active_user->data['u_note_crew']) {
                    ess::$b->page->add_message("Ingen endringer ble utført.", "error");
                } else {
                    \Kofradia\DB::get()->exec("UPDATE users SET u_note_crew = " . \Kofradia\DB::quote($notat) . " WHERE u_id = " . page_min_side::$active_user->id);
                    // legg til crewlogg
                    crewlog::log("user_note_crew", page_min_side::$active_player->id, NULL, array("note_old" => page_min_side::$active_user->data['u_note_crew'], "note_diff" => diff::make(page_min_side::$active_user->data['u_note_crew'], $notat)));
                    ess::$b->page->add_message("Notatet ble endret.");
                    redirect::handle();
                }
            }
            echo '
	<div class="bg1_c" style="width: 400px">
		<h1 class="bg1">Endre crewnotat for bruker<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<form action="" method="post">
				<p>Dette endrer notatet som er tilknyttet brukeren. Du kan også tilknytte <a href="' . htmlspecialchars(page_min_side::addr(NULL, "b=enote", "player")) . '">informasjon til spilleren</a>, hvis det heller er ønskelig.</p>
				<p>Notat:</p>
				<p><textarea name="notat" rows="10" cols="30" style="width: 98%">' . htmlspecialchars(page_min_side::$active_user->data['u_note_crew']) . '</textarea></p>
				<p class="c">' . show_sbutton("Lagre") . '</p>
			</form>
		</div>
	</div>';
        } elseif ($subpage2 == "level" && access::has("admin")) {
            // nivåer man kan bytte til
            static $levels = array(1 => "Vanlig bruker", 14 => "Skjult nostat (crewtilgang)", -4 => "Ressurs", 12 => "Ressurs (nostat)", 13 => "Utvikler", 4 => "Forummoderator", 6 => "Forummoderator (nostat)", 5 => "Moderator", 11 => "Seniormoderator");
            if (access::has("sadmin")) {
                $levels[7] = "Administrator";
            }
            if (access::has("sadmin")) {
                $levels[8] = "Superadministrator";
            }
            // kan vi ikke endre brukernivået til denne brukeren?
            if (!isset($levels[page_min_side::$active_user->data['u_access_level']])) {
                ess::$b->page->add_message("Du har ikke rettigheter til å endre tilgangsnivået til denne brukeren.", "error");
                redirect::handle(page_min_side::addr());
            }
            // endre brukernivå?
            if (isset($_POST['level'])) {
                $level = intval($_POST['level']);
                $log = trim(postval("log"));
                // samme brukernivå?
                if ($level == page_min_side::$active_user->data['u_access_level']) {
                    ess::$b->page->add_message("Du må velge et nytt tilgangsnivå.", "error");
                } elseif (!isset($levels[$level])) {
                    ess::$b->page->add_message("Ugyldig tilgangsnivå.");
                } elseif (empty($log)) {
                    ess::$b->page->add_message("Mangler begrunnelse.");
                } else {
                    // endre tilgangsnivå
                    $old = page_min_side::$active_user->data['u_access_level'];
                    if (page_min_side::$active_user->change_level($level, isset($_POST['no_update_up']))) {
                        // e-post logg
                        sysreport::log("Endring av tilgangsnivå: " . login::$user->player->data['up_name'] . " endret tilgangsnivået til " . page_min_side::$active_user->data['u_email'] . " (" . page_min_side::$active_player->data['up_name'] . ") fra {$levels[$old]} til {$levels[$level]} {$__server['path']}/min_side?u_id=" . page_min_side::$active_user->id . "\n\nBegrunnelse: " . strip_tags(game::format_data($log)), "Kofradia: Endring av tilgangsnivå for " . page_min_side::$active_user->data['u_email'] . " (" . page_min_side::$active_player->data['up_name'] . ")");
                        // finn totalt beløp spilleren har
                        $result = \Kofradia\DB::get()->query("SELECT up_cash + up_bank FROM users_players WHERE up_id = " . page_min_side::$active_player->id);
                        $money = $result->fetchColumn(0);
                        // crewlogg
                        $data = array("level_old" => $old, "level_old_text" => $levels[$old], "level_new" => $level, "level_new_text" => $levels[$level], "money" => $money, "points" => page_min_side::$active_player->data['up_points']);
                        if (page_min_side::$active_player->active && !isset($_POST['no_update_up'])) {
                            $data['up_id'] = page_min_side::$active_player->id;
                        }
                        crewlog::log("user_level", page_min_side::$active_player->id, $log, $data);
                        putlog("CREWCHAN", "%bEndring av tilgangsnivå%b: " . login::$user->player->data['up_name'] . " endret tilgangsnivået til " . page_min_side::$active_user->data['u_email'] . " (" . page_min_side::$active_player->data['up_name'] . ") fra {$levels[$old]} til {$levels[$level]} {$__server['path']}/min_side?u_id=" . page_min_side::$active_user->id);
                        ess::$b->page->add_message('Tilgangsnivået ble endret fra <b>' . htmlspecialchars($levels[$old]) . '</b> til <b>' . htmlspecialchars($levels[$level]) . '</b>.');
                    } else {
                        ess::$b->page->add_message("Tilgangsnivået kunne ikke endres.", "error");
                    }
                    redirect::handle();
                }
            }
            echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Endre tilgangsnivå for bruker<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">' . (page_min_side::$active_player->active ? '
			<p>Dette vil automatisk berøre spilleren ' . page_min_side::$active_player->profile_link() . '.<p>' : '
			<p>Dette vil kun ha innvirkning på brukeren, siden det ikke er noen aktiv spiller.</p>') . '
			<form action="" method="post">
				<dl class="dd_right">
					<dt>Nåværende tilgangsnivå</dt>
					<dd>' . $levels[page_min_side::$active_user->data['u_access_level']] . '</dd>
					<dt>Nytt tilgangsnivå</dt>
					<dd>
						<select name="level">';
            $level = intval(postval("level", page_min_side::$active_user->data['u_access_level']));
            foreach ($levels as $id => $name) {
                echo '
							<option value="' . $id . '"' . ($level == $id ? ' selected="selected"' : '') . '>' . htmlspecialchars($name) . '</option>';
            }
            echo '
						</select>
					</dd>
					<dt>Begrunnelse</dt>
					<dd><textarea name="log" id="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
				</dl>' . (page_min_side::$active_player->active ? '
				<p><input type="checkbox" id="no_update_up" name="no_update_up"' . (isset($_POST['no_update_up']) ? ' checked="checked"' : '') . ' /><label for="no_update_up"> Ikke oppdater det visuelle tilgangsnivået til ' . page_min_side::$active_player->profile_link() . '</label></p>' : '') . '
				<p class="c">' . show_sbutton("Endre tilgangsnivå") . '</p>
			</form>
		</div>
	</div>';
        } elseif ($subpage2 == "banka" && access::has("mod")) {
            // lagre nytt passord
            if (isset($_POST['bank_auth'])) {
                $bank_auth = postval("bank_auth");
                $log = trim(postval("log"));
                // for kort?
                if (mb_strlen($bank_auth) < 6) {
                    ess::$b->page->add_message("Passordet må inneholde minst 6 tegn.", "error");
                } elseif (password::verify_hash($bank_auth, page_min_side::$active_user->data['u_bank_auth'], 'bank_auth')) {
                    ess::$b->page->add_message("Passordet er det samme som nåværende.", "error");
                } elseif ($log == "") {
                    ess::$b->page->add_message("Mangler begrunnelse.", "error");
                } else {
                    $newpass = password::hash($bank_auth, null, 'bank_auth');
                    \Kofradia\DB::get()->exec("UPDATE users SET u_bank_auth = " . \Kofradia\DB::quote($newpass) . " WHERE u_id = " . page_min_side::$active_user->id);
                    // crewlogg
                    crewlog::log("user_bank_auth", page_min_side::$active_player->id, $log, array("pass_old" => page_min_side::$active_user->data['u_bank_auth'], "pass_new" => $newpass));
                    ess::$b->page->add_message("Bankpassordet ble endret.");
                    redirect::handle();
                }
            }
            ess::$b->page->add_title("Endre bankpassord");
            echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Endre bankpassord<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<form action="" method="post" autocomplete="off">
				<dl class="dd_right">
					<dt>Nytt bankpassord</dt>
					<dd><input type="password" id="bank_auth" class="styled w120" /></dd>
					<dt>Begrunnelse for endring</dt>
					<dd><textarea name="log" id="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
				</dl>
				<p class="c">' . show_sbutton("Lagre") . '</p>
			</form>
		</div>
	</div>';
        } elseif ($subpage2 == "phone" && access::has("mod")) {
            // lagre nytt nummer?
            if (isset($_POST['phone'])) {
                $phone = postval("phone");
                $log = trim(postval("log"));
                if (!preg_match("/^47\\d{8}\$/Du", $phone) && $phone != "") {
                    ess::$b->page->add_message("Ugyldig telefonnummer. Må bestå av 10 tall inkludert 47 først.", "error");
                } else {
                    // kontroller at nummeret ikke er lagt inn fra før
                    $result = \Kofradia\DB::get()->query("SELECT u_id, u_email, up_id, up_name, up_access_level FROM users, users_players WHERE u_phone = " . \Kofradia\DB::quote($phone) . " AND u_id != " . page_min_side::$active_user->id . " AND up_id = u_active_up_id LIMIT 1");
                    if ($result->rowCount() > 0) {
                        $row = $result->fetch();
                        ess::$b->page->add_message('Nummeret er allerede i bruk av <a href="min_side?u_id=' . $row['u_id'] . '">' . htmlspecialchars($row['u_email']) . '</a> (' . game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level']) . ').', "error");
                    } elseif ($phone == page_min_side::$active_user->data['u_phone']) {
                        ess::$b->page->add_message("Nummeret er det samme som nåværende nummer.", "error");
                    } elseif ($log == "") {
                        ess::$b->page->add_message("Mangler logg melding.");
                    } else {
                        // lagre nytt nummer
                        \Kofradia\DB::get()->exec("UPDATE users SET u_phone = " . \Kofradia\DB::quote($phone) . " WHERE u_id = " . page_min_side::$active_user->id);
                        crewlog::log("user_phone", page_min_side::$active_player->id, $log, array("phone_old" => page_min_side::$active_user->data['u_phone'], "phone_new" => $phone));
                        ess::$b->page->add_message('Mobilnummeret ble endret fra <b>' . (empty(page_min_side::$active_user->data['u_phone']) ? 'tomt' : htmlspecialchars(page_min_side::$active_user->data['u_phone'])) . '</b> til <b>' . (empty($phone) ? 'tomt' : $phone) . '</b>.');
                    }
                }
            }
            ess::$b->page->add_title("Endre mobilnummer");
            echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Endre mobilnummer<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<p>Her endrer du mobilnummeret til brukeren. Dette kan bli brukt til å sende ut forskjellig informasjon.</p>
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Nåværende nummer</dt>
					<dd>' . (empty(page_min_side::$active_user->data['u_phone']) ? 'Tomt' : htmlspecialchars(page_min_side::$active_user->data['u_phone'])) . '</dd>
					<dt>Nytt nummer</dt>
					<dd><input type="text" maxlength="10" value="' . htmlspecialchars(postval("phone", page_min_side::$active_user->data['u_phone'])) . '" name="phone" class="styled w80" /></dd>
					<dt>Begrunnelse for endring</dt>
					<dd><textarea name="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
				</dl>
				<p class="c">' . show_sbutton("Lagre") . '</p>
			</form>
		</div>
	</div>';
        } elseif ($subpage2 == "birth" && access::has("mod")) {
            // lagre ny fødselsdato?
            if (isset($_POST['birth_day']) && isset($_POST['birth_month']) && isset($_POST['birth_year'])) {
                $birth = postval("birth");
                // sjekk fødselsdato
                $birth_day = intval(postval("birth_day"));
                $birth_month = intval(postval("birth_month"));
                $birth_year = intval(postval("birth_year"));
                $date = ess::$b->date->get();
                $n_day = $date->format("j");
                $n_month = $date->format("n");
                $n_year = $date->format("Y");
                $age = $n_year - $birth_year - ($n_month < $birth_month || $birth_month == $n_month && $n_day < $birth_day ? 1 : 0);
                $birth = $birth_year . "-" . str_pad($birth_month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($birth_day, 2, "0", STR_PAD_LEFT);
                // sjekk om fødselsdatoen er gyldig
                $birth_date = ess::$b->date->get();
                $birth_date->setDate($birth_year, $birth_month, $birth_day);
                $birth_valid = $birth_date->format("Y-m-d") == $birth;
                $log = trim(postval("log"));
                // ugyldig dag?
                if ($birth_day < 0 || $birth_day > 31) {
                    ess::$b->page->add_message("Du må velge en gyldig dag.", "error");
                } elseif ($birth_month < 0 || $birth_month > 12) {
                    ess::$b->page->add_message("Du må velge en gyldig måned.", "error");
                } elseif (($birth_year < 1900 || $birth_year > $n_year) && $birth_year !== 0) {
                    ess::$b->page->add_message("Du må velge et gyldig år.", "error");
                } elseif (!$birth_valid && $birth !== '0-00-00') {
                    ess::$b->page->add_message("Datoen du fylte inn for fødselsdatoen din eksisterer ikke.");
                } elseif ($birth == page_min_side::$active_user->data['u_birth']) {
                    ess::$b->page->add_message("Fødselsdatoen ble ikke endret.", "error");
                } elseif ($log == "") {
                    ess::$b->page->add_message("Mangler begrunnelse.", "error");
                } else {
                    // oppdater
                    \Kofradia\DB::get()->exec("UPDATE users SET u_birth = " . \Kofradia\DB::quote($birth) . " WHERE u_id = " . page_min_side::$active_user->id);
                    // legg til crewlogg
                    crewlog::log("user_birth", page_min_side::$active_player->id, $log, array("birth_old" => page_min_side::$active_user->data['u_birth'], "birth_new" => $birth));
                    // alder
                    if ($age < 13) {
                        ess::$b->page->add_message("Fødselsdatoen ble satt til <b>{$birth}</b> ({$age} år). Brukeren oppfyller <u>ikke</u> kravet om alder jf. betingelsene.");
                    } else {
                        ess::$b->page->add_message("Fødselsdatoen ble satt til <b>{$birth}</b> ({$age} år).");
                    }
                    redirect::handle();
                }
            }
            $birth = explode("-", page_min_side::$active_user->data['u_birth']);
            $birth_day = isset($birth[2]) ? intval($birth[2]) : 0;
            $birth_month = isset($birth[1]) ? intval($birth[1]) : 0;
            $birth_year = isset($birth[0]) ? intval($birth[0]) : 0;
            ess::$b->page->add_title("Endre fødselsdato");
            echo '
	<div class="bg1_c" style="width: 350px">
		<h1 class="bg1">Endre fødselsdato<span class="left2"></span><span class="right2"></span></h1>
		<div class="bg1">
			<form action="" method="post">
				<dl class="dd_right dl_2x">
					<dt>Nåværende fødselsdato</dt>
					<dd>' . (empty(page_min_side::$active_user->data['u_birth']) ? 'Ikke registrert' : htmlspecialchars(page_min_side::$active_user->data['u_birth'])) . '</dd>
					<dt>Ny fødselsdato</dt>
					<dd>
						<select name="birth_day">
							<option value="">Dag</option>
							<option value="0">0</option>';
            $active = postval("birth_day", $birth_day);
            for ($i = 1; $i <= 31; $i++) {
                echo '
							<option value="' . $i . '"' . ($i == $active ? ' selected="selected"' : '') . '>' . $i . '</option>';
            }
            echo '
						</select>
						<select name="birth_month">
							<option value="">Måned</option>
							<option value="0">Tom</option>';
            $active = postval("birth_month", $birth_month);
            for ($i = 1; $i <= 12; $i++) {
                echo '
							<option value="' . $i . '"' . ($i == $active ? ' selected="selected"' : '') . '>' . ucfirst($_lang['months'][$i]) . '</option>';
            }
            echo '
						</select>
						<select name="birth_year">
							<option value="">År</option>
							<option value="0">0000</option>';
            $active = postval("birth_year", $birth_year);
            for ($i = ess::$b->date->get()->format("Y"); $i >= 1900; $i--) {
                echo '
							<option value="' . $i . '"' . ($i == $active ? ' selected="selected"' : '') . '>' . $i . '</option>';
            }
            echo '
						</select>
					</dd>
					<dt>Begrunnelse for endring</dt>
					<dd><textarea name="log" id="log" cols="30" rows="5">' . htmlspecialchars(postval("log")) . '</textarea></dd>
				</dl>
				<p class="c">' . show_sbutton("Lagre") . '</p>
			</form>
		</div>
	</div>';
        }
    }
Ejemplo n.º 18
0
<?php

require_once dirname(__FILE__) . "/diff.class.php";
$config = array();
$config = diff::loadConfig(dirname(__FILE__) . '/config.php');
$productlist = $config['product'];
$smartyConfig = diff::getConfig('smarty');
require_once $smartyConfig['dir'] . '/Smarty.class.php';
foreach ($productlist as $pro => $value) {
    $diff = new Diff($pro);
    //    $diff->build();
    //    $diff->analyze();
    $diff->Display();
    $productlist[$pro]['url'] = diff::getConfig('url') . str_replace("/home/work/repos/", "", $smartyConfig['templatedir'] . $pro . "_difflist.html");
}
$smarty = new Smarty();
$smarty->assign('productsdiff', $productlist);
$html = $smarty->fetch($smartyConfig['templatedir'] . "/productsdiff.tpl");
File::write($smartyConfig['templatedir'] . "productsdiff.html", $html);
Ejemplo n.º 19
0
 /**
  * Rediger forumsvar
  * @param \Kofradia\Forum\Reply $reply
  * @param array $old_data array med data som ble erstattet (text)
  */
 public static function add_reply_edited(Reply $reply, $old_data)
 {
     // legg til som vanlig logg
     $location = $reply->topic->forum->id >= 5 && $reply->topic->forum->id <= 7 ? 'CREWCHAN' : 'LOG';
     self::putlog($reply->topic->forum, $location, "FORUMSVAR REDIGERT: '" . \login::$user->player->data['up_name'] . "' redigerte forumsvaret med ID {$reply->id} i forumtråden med ID {$reply->topic->id} ({$reply->topic->info['ft_title']}) " . \ess::$s['path'] . "/forum/topic?id={$reply->topic->id}&replyid={$reply->id}");
     // legg til crewlogg
     if (self::is_crewlog($reply->topic->forum, $reply->info['fr_up_id'])) {
         self::crewlog($reply->topic->forum, "forum_reply_edit", $reply->info['fr_up_id'], NULL, array("topic_id" => $reply->topic->id, "reply_id" => $reply->id, "topic_title" => $reply->topic->info['ft_title'], "reply_content_old" => $old_data['fr_text'], "reply_content_diff" => \diff::make($old_data['fr_text'], $reply->info['fr_text'])));
     }
 }