How to implement CSS to powershell conver to html Output? - css

I have found interesting code that highlights a rows in table if the output is not desired
Source - https://www.youtube.com/watch?v=QdK3qM5jnYw&feature=youtu.be
$headLinkcheck += #'
<style>
body
{
background-color:white;
font-family:Arial;
font-size:8pt;
}
td,th
{
border:1px solid black;
border-collapse:collapse;
}
th
{
color:white;
background-color:black;
}
table, tr, td, th {padding:5px; margin: 0px;}
table {margin-left:50px;width: 80%;height:35%}
.danger {background-color:yellow;font-weight:bold}
.warn {background-color:blue}
</style>
'#
Ok now i have code that checks webistes and their status
function GetSiteStatus(){
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
[hashtable]$WebSiteInfo
)
process{
$Response = New-Object System.Collections.ArrayList
$WebSiteInfo.GetEnumerator() | %{
$Item = $_
try{
$status = Invoke-WebRequest -Uri $_.Value | %{
if(#('404','503','403') -match $_.StatusCode){
"$($Item.Key) The Site may be down, please check. - status is $($_.StatusCode)"
}else{
"OK"
}
}
$Response.Add([PSCustomObject]#{"Name"= $Item.Key; "Value"=$Item.Value; "Status"=$Status; "Link"=$($Item.value)}) | out-null
}catch{
$Status = "$($Item.Key), $_."
$Response.Add([PSCustomObject]#{"Name"= $Item.Key; "Value"=$Item.Value; "Status"=$Status; "Link"=$($Item.value)}) | out-null
}
}
return $Response
}
}
$html_url1 = #{
"Calendar" = "http:/";
} | GetSiteStatus | ConvertTo-Html -Head $headLinkcheck -Property Name,Value,Status,#{Label="Link";Expression={"<a href='$($_.Value)'>$($_.Name)</a>"}}
Add-Type -AssemblyName System.Web
[System.Web.HttpUtility]::HtmlDecode($html_url) | Out-File "\\servertest\xpbuild$\IT\Level0\scresult\servicecheck$global:servicecheckdate.htm" -Append # have to use it to creates clickable links
Now the last piece is second part of code which i found ,that checks each line in rows -theorically
[array]$html_url += $html_url1 i quess this might help code below to read values
[xml]$html = $html_url | ConvertTo-Html -Fragment
for ($i = 1; $i -le $html.table.tr.Count-1;$i++){
$class = $html.CreateAttribute("class")
if(($html.table.tr[$i].td[-1]) -ne "OK"){
$class.Value = "danger"
$html.table.tr[$i].attributes.append($class) | Out-Null
}
}
$body += #"
$($html.innerxml)
"#
Now the problem with this is i am not sure how to implement this last part to my code
I got variable- $html_url1 that contains all needed values from my function that checks webistes.
I am not sure how to add this piece - should I add it to my $html_url1 pipe? I tried and it fails. Can you suggest hopw to implement this ?

You can always just make the page from scratch and build whatever you want from there an example
$Sites = #{
"Google"="http://google.com";
"ErrorTest"="I Am Fake";
"Yahoo" = "http://Yahoo.com";
}
$OutFile = "C:\Test\Test.htm"
function GetSiteStatus(){
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
[hashtable]$WebSiteInfo
)
process{
$WebSiteInfo.GetEnumerator() | %{
$Item = $_
$Type
try{
$status = Invoke-WebRequest -Uri $_.Value | %{
if(#('404','503','403') -match $_.StatusCode){
"$($Item.Key) The Site may be down, please check. - status is $($_.StatusCode)"
$Type = "Warning"
}else{
"OK"
$Type = "Good"
}
}
return [PSCustomObject]#{"Name"= $Item.Key; "Value"=$Item.Value; "Status"=$Status; "Link"=$($Item.value); "Type"=$Type}
}catch{
$Type = "Error"
$Status = "$($Item.Key), $_."
return [PSCustomObject]#{"Name"= $Item.Key; "Value"=$Item.Value; "Status"=$Status; "Link"=$($Item.value); "Type"=$Type}
}
}
}
}
$HTML = #"
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
body{
background-color:white;
font-family:Arial;
font-size:8pt;
}
td,th{
border:1px solid black;
border-collapse:collapse;
}
th{
color:white;
background-color:black;
}
table, tr, td, th {
padding:5px;
margin: 0px;
}
table {
margin-left:50px;
width: 80%;
height:35%
}
.Warning {
background-color:yellow;
font-weight:bold
}
.Error {
background-color:#d9534f;
color:#ffffff;
}
</style>
</head>
<body>
<table>
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Value</th>
<th>Status</th>
<th>Link</th>
</tr>
$($Sites | GetSiteStatus | %{
$item = $_
switch($_.Type){
"Good" {
"<tr class='Good'><td>$($item.Name)</td><td>$($item.Value)</td><td>$($item.Status)</td><td><a href='$($item.Value)'>$($item.Name)</a></td></tr>"
}
"Warning" {
"<tr class='Warning'><td>$($item.Name)</td><td>$($item.Value)</td><td>$($item.Status)</td><td><a href='$($item.Value)'>$($_item.Name)</a></td></tr>"
}
"Error" {
"<tr class='Error'><td>$($item.Name)</td><td>$($item.Value)</td><td>$($item.Status)</td><td><a href='$($item.Value)'>$($item.Name)</a></td></tr>"
}
}
})
</tbody>
</table>
</body>
</html>
"# | out-file $OutFile

Related

How to pass variables to SuiteQL

I am trying to pass parameters from the current record to an embedded Suitelet though cannot find the right syntax to do this anywhere
My starting point was using the Suitelet code here: https://timdietrich.me/blog/netsuite-suiteql-query-results-custom-tabs/
The result from my modified version is per this screencap
When the page loads, the SuiteQL record field is populated using the current record's internal Id.
What I want to do is pass this value as a variable to the embedded SuiteQL Suitelet so that the search results are only in relation to the stated record (in this case, the record with the internal id=24486).
Is this actually possible?
If it is possible, how do I pass this value to the SQL query parameters?
This is the full modified version of the code:
/**
* #NApiVersion 2.1
* #NScriptType UserEventScript
* #NModuleScope Public
*/
/*
*/
var log, query, serverWidget;
define([
"N/log",
"N/query",
"N/ui/serverWidget",
"N/record",
"N/runtime",
"N/recordContext",
], main);
function main(
logModule,
queryModule,
serverWidgetModule,
recordModule,
runtimeModule,
recordContextModule
) {
log = logModule;
query = queryModule;
serverWidget = serverWidgetModule;
record = recordModule;
runtime = runtimeModule;
recordContext = recordContextModule;
return {
beforeLoad: beforeLoad,
};
}
function beforeLoad(context) {
if (context.type !== context.UserEventType.VIEW) {
return;
}
var suiteqlTab = context.form.addTab({
id: "custpage_sql_tab",
label: "SuiteQL Tab",
});
context.form.insertTab({
tab: suiteqlTab,
nexttab: "items",
});
var recordId = runtime.getCurrentScript();
log.debug({
title: "recordId",
details: recordId,
});
var parms = context.request.parameters;
log.debug("params", parms);
log.debug("recordid", parms.id);
var id = parms.id;
var recordField = context.form.addField({
id: "custpage_suiteql_record",
type: serverWidget.FieldType.TEXT,
label: "SuiteQL Record",
container: "custpage_sql_tab",
});
recordField.defaultValue = id;
var suiteqlField = context.form.addField({
id: "custpage_suiteql_field",
type: serverWidget.FieldType.TEXT,
label: "SuiteQL Query Results",
container: "custpage_sql_tab",
});
var records = sqlQueryRun();
context.newRecord.setValue({
fieldId: "custpage_suiteql_field",
value: sqlResultsTableGenerate(records),
});
}
function sqlQueryRun() {
var sql = `
SELECT
Transaction.type
FROM
Transaction
Where Transaction.type like 'SalesOrd'
`;
return query.runSuiteQL({ query: sql, params: [] }).asMappedResults();
}
function sqlResultsTableGenerate(records) {
if (records.length === 0) {
return "<div><p>No records were found.</p></div>";
}
let thead = `
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Phone #</th>
</tr>
</thead>`;
var tbody = "<tbody>";
for (r = 0; r < records.length; r++) {
var record = records[r];
tbody += `
<tr>
<td></td>
<td></td>
<td>${record.email}</td>
<td>${record.phone || ""}</td>
</tr>`;
}
tbody += "</tbody>";
let stylesheet = `
<style type = "text/css">
/* Styled Table */
/* https://dev.to/dcodeyt/creating-beautiful-html-tables-with-css-428l */
.styled-table {
border-collapse: collapse;
margin: 25px 0;
font-size: 0.9em;
font-family: sans-serif;
min-width: 400px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
width: 100%;
}
.styled-table th,
.styled-table td {
padding: 6px;
}
.styled-table thead tr {
background-color: #607799;
color: #ffffff;
text-align: left;
}
.styled-table tbody tr {
border-bottom: thin solid #dddddd;
}
.styled-table tbody tr:nth-of-type(even) {
background-color: #f3f3f3;
}
.styled-table tbody tr.active-row {
font-weight: bold;
color: #009879;
}
.styled-table tbody tr:hover {
background-color: #ffff99;
}
</style>
`;
return `
${stylesheet}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
<div style="margin-top: 6px; border: 1px solid #ccc; padding: 24px;">
<table id="sqlResultsTable" class="styled-table" style="width: 100%;">
${thead}
${tbody}
</table>
</div>
<script>
window.jQuery = window.$ = jQuery;
$('#sqlResultsTable').DataTable( { "pageLength": 10, "lengthMenu": [ 10, 25, 50, 75, 100 ] } );
</script>
`;
}
The original author of the SuiteQL tool: Timothy Dietrich

CSS media prints 3 blank pages

I use Bootstrap 3, just to know. I cannot get rid of 3 blank pages after the first one. Don t know what is causing this problem.
HTML:
<table class="table table-bordered table-hover text-center" id="post_accesorii">
<thead>
<tr>
<th>Cod</th>
<th>Denumire</th>
<th>Cantitate</th>
<th>U.M.</th>
</tr>
</thead>
<tbody>
<form method="post" action="" autocomplete="off">
<?php
while($rowD = mysqli_fetch_assoc($query)) {
foreach ($rowD as $col => $val) {
if($val != "" && $val != "0" && $col != "nr_fisa" && $col != "id") {
$findum = mysqli_query($mysqli, "SELECT * FROM `stocuri` WHERE `cod` = '$col' AND `post1` = 'Accesorii'") or die(mysqli_error($mysqli));
$rowum = mysqli_fetch_array($findum);
echo "<tr class='piesa_folosita'>";
if($col == $rowum['cod'])
{
echo "<td>" . $col . "</td>";
echo "<td>" . $rowum['denumire'] . "</td>";
echo "<td>" . $val . "</td>";
echo "<td>" . $rowum['um'] . "</td>";
}
echo "</tr>";
} else {
}
}
}
?>
</tbody>
<tfoot>
<tr>
<th>Cod</th>
<th>Denumire</th>
<th>Cantitate</th>
<th>U.M.</th>
<tr>
</tfoot>
</table>
PRINT
print.css:
#media print {
html, body {
visibility: hidden;
height: 99% !important;
}
#post_accesorii, #post_accesorii * {
visibility: visible;
height: 99% !important;
}
#post_accesorii+#post_accesorii {
page-break-before: always;
}
}
In print preview, I have 3 blank pages after the first page with my table. I tried several solutions to remove them but none worked.
What can be the problem?
Your height: 99% !important; might be the problem, because the <body/> does not have parent
Your last print rule implies that there is more than one element that has the ID #post_accesorii . This should not be the case and is invalid HTML: IDs must only appear once in a page. So maybe that's the reason for your problems (I don't know what is around the code you posted, so that's all I can say).
To avoid that, make it a class instead of an ID: .post_accesorii and assign that to the HTML table tag/s via <table class="post_accesorii">

Change td style based on value in angular

I have a column where the style of each td needs to be changed based on value. There are five status's, so there has to be five different border-colors and font-colors. How do I do this in angular script without hard-coding (new to angular)?
What I am doing is:
In html:
<table st-table = "tenants" class="table table-striped table-bordered">
<tbody>
<tr dir-paginate="t in tenants | orderBy:sortColumn:reverseSort | filter:searchText | itemsPerPage:itemsPerPage" current-page="currentPage" >
<td ng-if="t.status.color==2"><b class = 'td_status'>{{t.status.id}}<b></td>
In css:
.td_status {
border-radius: 20px;
width: auto;
height: auto;
min-width: 100px;
display: inline-block;
text-align: center;
border: 1px solid red;
padding: 5px;
}
In js:
datax.forEach(function(obj,i){
if (obj.last_paid) {
if (obj.stripe_status == "active") {
obj.status = {
'id' : "Paid: Last Paid " + $filter('date')(obj.last_paid, 'MM-dd-yyyy'),
'value': "Paid: Last Paid " + $filter('date')(obj.last_paid, 'yyyy-MM-dd HH:mm:ss Z'),
'color' : 0
}
}
else if (obj.stripe_status == "past_due" || obj.stripe_status == "unpaid") {
obj.status = {
'id' : "Past Due: Last Paid " + $filter('date')(obj.last_paid, 'MM-dd-yyyy'),
'value': "Past Due: Last Paid " + $filter('date')(obj.last_paid, 'yyyy-MM-dd HH:mm:ss Z'),
'color' : 4,
}
}....
I made an example since it is a little slow at work.
Here you can see my use of ng-class. I give it a function and pass the status which is defined in $scope.data item.status comes from my ng-repeat
<div ng-app="TestApp" ng-controller="TestController">
<p ng-repeat="item in data" ng-class="getBorderColor(item.status)">
{{item.name}}
</p>
</div>
Below I have my controller and some sample data. The getBorderColor runs through its conditions and returns className based off of status.
var app = angular.module('TestApp', []);
app.controller('TestController', function($scope) {
$scope.data = [
{
name:'Ronnie',
status:1
},
{
name:'Chance',
status:2
},
{
name:'Mike',
status:1
},
{
name:'Mark',
status:3
}];
$scope.getBorderColor = function(status) {
var className = '';
if (status == 1) {
className = 'status1';
} else if (status == 2) {
className = 'status2';
} else if (status == 3) {
className = 'status3';
}
return className;
};
});
And my simple css is:
.status1 {
border:1px solid red;
}
.status2 {
border:1px solid blue;
}
.status3 {
border:1px solid green;
}
https://jsfiddle.net/ojzdxpt1/7/

Multiple anchor styles using classes not ID [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a site that's using a two layered navigation menu. The top navigation goes to physical pages, while the filter navigation reloads the content in a div (#main) on the current page. This is done using jquery, and the "current" class style for each link is set (and hence the corresponding data is called) even on the first visit. In other words, what loads and where the "current" class style is set to is all managed by javascript and php every time.
This works beautifully Here
My problem is that the client now wants the Top Navigation to have different background colors for hover and "current" for each link.
I know I can do this with ID's.. but I'd rather do it using classes.. Is this possible?
for reference:
The css for the top nav list:
#nav_container {
position: relative;
float: left;
width: 100%;
}
#top_nav {
display: table;
table-layout: fixed;
list-style: none;
margin: 0px;
padding: 0px;
width: 100%;
font-family: mbaskerville-semibold;
overflow: hidden;
-webkit-box-shadow: 0 8px 6px -7px #666;
-moz-box-shadow: 0 8px 6px -7px #666;
box-shadow: 0 8px 6px -7px #666;
border-top: 2px solid #CCC;
border-bottom: 0.5px solid #CCC;
}
#top_nav li {
display: table-cell;
*float: left; /* improve IE7 */
height: 25px;
text-align: center;
line-height: 25px;
font-weight: bold;
border-right: 0.5px solid #CCC;
}
#top_nav li a {
display: block;
text-decoration: none;
color: #021020;
background-color: #FFFFFF;
}
#top_nav li a.current {
color: #FFFFFF;
background-color: #766A5A;
}
#top_nav li a:hover {
color: #FFFFFF;
background-color: #766A5A;
}
#top_nav li:first-child {
padding-left: 0;
border-left: 0.5px solid #CCC;
}
The javascript:
$(document).ready(function(){
// current page
var $current_page = window.location.pathname;
// top navigation
$(function() {
// set link to current page
if ( $current_page ) {
$('#top_nav a[href$="' + $current_page + '"]').attr('class', 'current');
}
// if link is root, set first child (home)
if ( $current_page.length <= 1) {
$('#top_nav a:first').addClass('current');
}
// if no filter set, set all as filter
if ($('#filter_nav a').hasClass('current')) {
// do nothing
}
else {
$('#filter_nav a:first').addClass('current');
// load new data when filter is changed
$filter = "all";
$(".page_header").load("test.php?", {page: $current_page, filter: $filter}, function(response, status, xhr) {
if(status == 'success') {
$('.page_header').html(response);
}
else if(status == 'error') {
var emsg = '<i>There was an error: ' + xhr.status + ' ' + xhr.statusText + '</i>';
$('.page_header').html(emsg);
}
else { alert(status); }
});
return false
}
});
// filter navigation
var $filter;
$('#filter_nav li a').click(
function(e) {
// prevent the default action & bubbling
e.preventDefault();
e.stopPropagation();
// handle filter change styles
$(this).closest('ul').find('.current').removeClass('current');
$(this).addClass('current');
// load new data when filter is changed
$filter = $(this).attr('href');
$(".page_header").load("test.php?", {page: $current_page, filter: $filter}, function(response, status, xhr) {
if(status == 'success') {
$('.page_header').html(response);
}
else if(status == 'error') {
var emsg = '<i>There was an error: ' + xhr.status + ' ' + xhr.statusText + '</i>';
$('.page_header').html(emsg);
}
else { alert(status); }
});
return false
});
});
The php class:
<?php
/**
* _document: /lib/omc_frmwrk/present/NavMan.php
*
* = Navigation Management class
* Management of standard navigational elements
*
* ** TO DO:
*
*
*/
// class definition
class NavMan {
/*
* class parameters
*
*/
private static $links;
private static $nav_style;
/**
* Getters
*
*/
/**
* Setters
*
*/
public static function setLinks($x) { self::$links = $x; }
public static function setNavStyle($x) { self::$nav_style = $x; }
/*
* __construct()
* PUBLIC method
* = empty
*
*/
public function __construct() {}
/*
* Navigation Menu:
* PUBLIC method
* = unordered list, css styled, dop-down capable
*
*/
public function setNav() {
// open unordered list
echo '<ul id="' . self::$nav_style . '">';
// set layer
$layer = 0;
// place array content into variables
for ($i = 0; $i < count(self::$links); $i++) {
$this_layer = self::$links[$i][0];
$class = self::$links[$i][1];
$link = self::$links[$i][2];
$page = self::$links[$i][3];
// check if layer is current
if ($layer < $this_layer) {
// open sub list
echo '<ul><li>';
// increase variable
$layer++;
}
else if ($layer == $this_layer) {
// open sub-layer
echo '</li><li>';
}
else if ($layer > $this_layer) {
// open sub-layer
echo '</li></ul><div class="clear"></li><li>';
// decrease variable
$layer--;
}
// place link
echo '<a class="' . $class . '" href="' . $page . '">' . $link . '</a>';
}
// close unordered list
echo '</li></ul><div class="clear"></div>';
}
}
?>
With jQuery you can use the following functions:
hasClass to check which class an element has, use it here instead of
$('#top_nav a[href$="' + $current_page + '"]').attr('class', 'current');`
addClassto add a class to a dom element
removeClass to remove a class from an element. Before you add a class, you have to first of all remove the previous one always e.g. here you did not remove the unwanted class first before adding a new one.
if ( $current_page.length <= 1) {
$('#top_nav a:first').addClass('current');
}
toggleClass to alternate between two classes.
The styling can be different depending on which class is active.
For further reading:
http://jquerybyexample.blogspot.com/2011/08/addclass-removeclass-hasclass-and.html
http://api.jquery.com/
To reference the a:hover class:
jQuery to target CSS a:hover class
http://api.jquery.com/hover/

Installing existing site Navigation into blog script?

You will probably consider me a spoil sport for not working with wordpress for this purpose.
However I just want to use a flatfile blog system for a small site. I am using ozjournals-3.2 blog system.
I am seeking to install a header and a site navigation at the top of the blog page so that it coordinates with the existing site. I have had some success with the header but the navigation is making me struggle! I want navigation to position underneath the header as attached image demonstrates. Currently the task is presenting two problems that i need to find a work around for:
Nav will not center on page but keeps left even when I margin:auto; ?
Cannot get it to position at the foot of the header image!
My nav css is as follows:
.nav {
width: 950px;
float: left;
margin: 0 0 1em 0;
padding: 0;
background-color: #3b3b44; /*Navigation Active Background*/
border-top: 1px solid #ccf;
border-bottom: 1px solid #ccf;}
.nav ol {
list-style: none;
width: 950px;
margin: 0 auto;
padding: 0; }
.nav li {
float: left; }
.nav li a {
display: block;
padding: 2px 20px;
text-decoration: none;
font-family: Helvetica, arial, sans-serif;
font-size: 16px;
font-weight: bold;
color: #fff; /*Active Text Color*/
border-right: 1px solid #ccf; }
.nav li:first-child a {
border-left: 0px solid #ccf; }
.nav li a:hover {
color: #000; /*Active Hover Color*/
background-color: #8db3ff; } /*Navigation Hover Background*/
#header {
height: 185px;
margin-top: 15px;
background: url(zitemplateChange.jpg);
border-bottom: 30px solid #cc0; /*showing where I want navigation to position*/
}
and the index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="themes/default/zitemplateChange.css" type="text/css" media="screen" />
</head>
<body>
<div class="nav">
<ol>
<li>Home</li>
<li>About</li>
<li>Book Preview</li>
<li>Guestbook</li> <li>Tell a Friend</li>
<li>Contact</li>
<li>Support</li>
</ol>
</div>
<?php
/********************************************************************************************************
OZJournals Version 3.2 released by Online Zone <https://sites.google.com/site/onlinezonejournals>
Copyright (C) 2006-2011 Elaine Aquino <elaineaqs#gmail.com>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your option)
any later version.
********************************************************************************************************/
# For the session
ob_start();
# For function file inclusion
include "functions.php";
# For language file inclusion
$langfile = file_get_contents("lang/index.php");
$eachlang = explode("\t", $langfile);
$oklang = $eachlang[1];
$uselang = file_get_contents("lang/$oklang.php");
$lang = explode("\n", $uselang);
# Clean the GET variablezzz
$clean['show'] = string_filter_nospace($_GET['show']);
$clean['id'] = int_filter($_GET['id']);
$clean['p'] = string_filter_nospace($_GET['p']);
$clean['f'] = int_filter($_GET['f']);
$clean['pn'] = int_filter($_GET['pn']);
# Printer-friendly view
if($clean['show'] == "printpreview") {
if(isset($clean['id'])) {
$id = super_filter($clean['id']);
if(file_exists("$datadirectory/$id.php")) {
$pfile = file_get_contents("$datadirectory/$id.php");
$what = explode("\t", $pfile);
die("<html><head><title>$what[1]</title></head><body onload=\"window.print()\"><h1>$what[1]</h1><h5>Posted by $what[4] [ $what[5] ]<br />Date: ".date($timeformat, $what[2])."<br />Category: $what[6]</h5><p>$what[3]</p><h5>Source URL: <script>document.writeln(self.location)</script></h5></body></html>");
}
}
}
# RSS view
if($clean['show'] == "rss") {
die(generaterss());
}
# Theme Picker
$themefile = file_get_contents("themes/index.php");
$eachtheme = explode("\t", $themefile);
$oktheme = $eachtheme[1];
include "themes/$oktheme/advanced.php";
$header = implode(" ", file("themes/$oktheme/header.php"));
$header = str_replace("{blogtitle}", $blogtitle, $header);
$header = str_replace("{subtitle}", subtitle($clean["show"], $clean["p"], $clean["f"]), $header);
$header = str_replace("{metakeywords}", $metakeywords, $header);
$header = str_replace("{metadescription}", $metadescription, $header);
$header = str_replace("{author}", $auth, $header);
//$header = str_replace("{header}", $blogheader, $header);
$header = str_replace("{mainlinks}", $mainlinks, $header);
$header = str_replace("{add-ons}", $addons, $header);
$header = str_replace("{search}", $search, $header);
$header = str_replace("{categories}", $categories, $header);
$header = str_replace("{archives}", $archives, $header);
$header = str_replace("{miscellaneous}", $miscellaneous, $header);
$header = str_replace("{adminmenu}", "", $header);
$header = str_replace("{usermenu}", "", $header);
$header = str_replace("{footer}", $blogfooter, $header);
echo $header;
# Signing out Initial
if($clean['show'] == "signout") {
session_start();
session_destroy();
header("Location: index.php?show=signout2");
}
# Signing out Part 2
if($clean['show'] == "signout2") {
adminpanel("$lang[1]<br /><br />");
}
# Sign-in
elseif($clean['show'] == "signin") {
echo "<h3>$lang[2]</h3>\n";
echo "<form name=\"e\" method=\"post\" action=\"index.php?show=signinok\">\n";
echo "<table border=\"0\">\n";
echo "<tr><td width=\"40%\">$lang[3]</td>";
echo "<td width=\"60%\"><input type=\"radio\" name=\"mode\" value=\"admin\" checked=\"checked\" /> $lang[4] \n";
echo "<input type=\"radio\" name=\"mode\" value=\"user\"> $lang[5] </td></tr>\n";
echo "<tr><td width=\"40%\"> $lang[6] </td>";
echo "<td width=\"60%\"><input type=\"text\" name=\"username\" /></td></tr>\n";
echo "<tr><td width=\"40%\"> $lang[7] </td>";
echo "<td width=\"60%\"><input type=\"password\" name=\"password\" /></td></tr>\n";
echo "</table><br />\n";
echo "<button type=\"submit\"> $lang[8] </button> \n";
echo "<button type=\"reset\"> $lang[9] </button> \n";
echo "</form><br /><br />\n";
}
# Blog
elseif($clean['show'] == "" OR $clean['show'] == "main" OR $clean['show'] == "index") {
$fortitle=$tagline;
$pn = $clean['pn'];
if($total > 0) {
if($total >= $displaynumber) {
if($pn == "") {
$pn = $total;
echo display ($displaynumber, $datadirectory, $total, $pn);
echo "<p> </p>\n";
}
else {
$pn = $clean['pn'];
echo display ($displaynumber, $datadirectory, $total, $pn);
echo "<p> </p>\n";
}
}
else {
echo display ($displaynumber, $datadirectory, $total, $pn);
echo "<p> </p>\n";
}
}
else {
blogviewer("$lang[10]<br />\n\n", $blogtitle);
}
}
# Pages
elseif($clean['show'] == "pages") {
$totalpages = countfiles("pages");
$currentpage = super_filter($clean['f']);
if(file_exists("pages/$currentpage.php")) {
$cc = file_get_contents("pages/$currentpage.php");
$eachcc = explode("\t", $cc);
if($totalpages > 0) {
echo "<h3>".$eachcc[1]."</h3>\n";
echo "<h5>$lang[12] ".$eachcc[4]." $lang[11] ".date($timeformat, $eachcc[2])." </h5>\n";
echo "<p> ".stripslashes($eachcc[3])." </p>\n\n";
}
else {
blogviewer("$lang[13]<br />\n\n", $blogtitle);
}
}
else {
blogviewer("$lang[81]<br />\n\n", $lang[80]);
}
}
# Complete archives
elseif($clean['show'] == "archives") {
if($total > 0) {
$theyear = int_filter($_GET['y']);
$themonth = $_GET['m'];
$thecategory = $_GET['c'];
$p = $clean['p'];
if($p == "main") {
echo adisplayall ($datadirectory, $total);
}
else {
if(isset($theyear) AND isset($themonth)) {
echo adisplaymonthandyear ($datadirectory, $total, $themonth, $theyear);
}
elseif(isset($thecategory)) {
echo adisplaycategory ($datadirectory, $total, $thecategory);
}
elseif(file_exists("$datadirectory/$p.php")) {
for($e=1; $e <= $total; $e++) {
if($p == $e) {
echo displayeach($datadirectory, $p);
}
}
}
else {
blogviewer("$lang[81]<br />\n\n", $lang[80]);
}
}
}
else {
blogviewer("$lang[14]<br />\n\n", $blogtitle);
}
}
# Comment poster
elseif($clean['show'] == "postcomments") {
$date = date_and_time($timezone, "", "", "", "", "", "", "");
$name = string_filter($_POST['vname']);
$vemail = string_filter_email($_POST['vemail']);
$location = string_filter_url($_POST['vlocation']);
$comment = string_filter_comment($_POST['vcomment']);
$verify = string_filter_nospace($_POST['verify']);
$p = $clean['p'];
// (1) Block if there's no name, email and comment
if($name !== "" && $vemail !== "" && $comment !== "") {
// (2) Block if it doesn't have a valid email addie
if(ValidEmail($vemail)) {
$filecont = file_get_contents("comments/$p.php");
if($location == "") {
$all = "<?php /*\t".str_replace("\r\n", "<br />", $comment)."\t".$name."\t".$date."\tnone\t".$vemail."\t*/ ?>\n";
}
else {
if(substr($location, 0, 7)!=="http://") {
$all = "<?php /*\t".str_replace("\r\n", "<br />", $comment)."\t".$name."\t".$date."\thttp://".$location."\t".$vemail."\t*/ ?>\n";
}
else {
$all = "<?php /*\t".str_replace("\r\n", "<br />", $comment)."\t".$name."\t".$date."\t".$location."\t".$vemail."\t*/ ?>\n";
}
}
// (3) Block if the referrer is different from blog address in settings
if($_SERVER["HTTP_REFERER"]=="$blog/index.php?show=archives&p=$p") {
// (4) Verify session first before posting the comment.
if($verify!=="") {
session_start();
if($verify==$_SESSION['verify']) {
// (5) Block comment if it contains bad words
if(!strpos($comment, $badwords)) {
// (6) Do not post comment if the exact same comment and name already exists.
if(!preg_match("/\\t$comment\\t$name/", file_get_contents("comments/$p.php"))) {
$handle = fopen ("comments/$p.php", "a+");
fwrite ($handle, $all);
fclose ($handle);
// Email after comment has been posted. Negative (-) if not emailed.
if($emailcomments!=="yes") {
blogviewer($name.", $lang[15]<br />$lang[16]. -<br />\n\n", $blogtitle);
}
else {
$comment = str_replace("<br />", "\r\n", $comment);
if(mail($vemail, $lang[84], "$lang[85] $user,\r\n\r\n$name ($vemail) $lang[86] ($blogtitle). $lang[87]:\r\n\r\n------------\r\n\r\n$comment\r\n\r\n------------\r\n\r\n$lang[88]:\r\n$blog/admin.php?show=editdeletecomments\r\n\r\n$lang[89]\r\n\r\n$lang[90]", "From: $blogtitle <$email>")) {
blogviewer($name.", $lang[15]<br />$lang[16]. +<br />\n\n", $blogtitle);
}
else {
blogviewer($name.", $lang[15]<br />$lang[16]. -<br />\n\n", $blogtitle);
}
}
}
else {
blogviewer("$name, $lang[92]<br />$lang[21]<br />\n", $blogtitle);
}
}
else {
blogviewer("$name, $lang[93]<br />$lang[21]<br />\n", $blogtitle);
}
}
else {
blogviewer("$lang[17]<br />$lang[21]<br />\n", $blogtitle);
$session_degenerate_id;
}
}
else {
blogviewer("$lang[18]<br />$lang[21]<br />\n", $blogtitle);
$session_degenerate_id;
}
}
else {
blogviewer("$lang[19]<br />$lang[21]<br />\n", $blogtitle);
$session_degenerate_id;
}
}
else {
blogviewer("$lang[20]<br /><br />$lang[21]<br />\n", "$blogtitle");
$session_degenerate_id;
}
}
else {
blogviewer("$lang[22] <b>$lang[23]</b>, <b>$lang[24]</b>, $lang[25] <b>$lang[26]</b>.<br /> $lang[27]<br /><br />$lang[21]", "$blogtitle");
}
}
# Signed in
elseif($clean['show'] == "signinok") {
$mode = string_filter_nospace($_POST['mode']);
if($_POST['username'] !== '' AND $_POST['password'] !== '') {
# Administrator Mode
if($mode == "admin") {
$newsessionuser = md5($_POST['username'].mktime());
$newsessionpass = md5($_POST['password'].mktime());
if($newsessionuser == md5($user.mktime()) AND $newsessionpass == md5($pass.mktime())) {
session_destroy();
session_start();
$_SESSION['user'] = $user;
$_SESSION['mode'] = "admin";
adminpanel("$lang[28], <b>$auth</b>! <br /><br /> $lang[29]<br />$lang[30] $lang[31].<br />\n\n");
session_write_close();
}
else {
adminpanel ("$lang[32]<br />$lang[33] $lang[34].<br />\n\n");
$session_degenerate_id;
}
}
# User Mode
elseif($mode == "user") {
$usersdb = file_get_contents("usersdb.php");
$ida = explode($_POST['username']."\t", $usersdb);
$idb = str_replace("<?php /*\t", "", $ida[0]);
$idc = $idb - 1;
$passa = explode("\n", $usersdb);
$passb = explode("\t", $passa[$idc]);
$passc = $passb[4];
if(strpos($usersdb, $_POST['username']) !== FALSE AND $passc == md5($_POST['password'])) {
session_destroy();
session_start();
$_SESSION['user'] = $_POST['username'];
$_SESSION['mode'] = "user";
blogviewer("$lang[28], <b>".$_SESSION['user']."</b>! <br /><br /> $lang[29]<br /> $lang[30] $lang[35].<br />\n\n", "User's Panel");
session_write_close();
}
else {
blogviewer("$lang[32]<br />$lang[33] $lang[34].<br />\n\n", "User's Panel");
$session_degenerate_id;
}
}
# Anything else is invalid
else {
blogviewer("$lang[83] <br />\n\n", $lang[82]);
}
}
else {
blogviewer("$lang[36] <br />$lang[33] $lang[34].<br />\n\n", $lang[82]);
}
}
# Load 404 Page
else {
blogviewer("$lang[81]<br />\n\n", $lang[80]);
}
# Simple statistics
if(file_exists("counter.php")) {
$counterfile = file_get_contents("counter.php");
$counterdata = explode("|", $counterfile);
$countermagic = count($counterdata);
$h = fopen("counter.php", "a+");
fwrite($h, $_SERVER['REMOTE_ADDR']."|");
}
# Footer
$footer = implode(" ", file("themes/$oktheme/footer.php"));
$footer = str_replace("{blogtitle}", $blogtitle, $footer);
$header = str_replace("{subtitle}", subtitle($clean["show"], $clean["p"], $clean["f"]), $header);
$footer = str_replace("{metakeywords}", $metakeywords, $footer);
$footer = str_replace("{metadescription}", $metadescription, $footer);
$header = str_replace("{author}", $auth, $header);
$footer = str_replace("{header}", $blogheader, $footer);
$footer = str_replace("{mainlinks}", $mainlinks, $footer);
$footer = str_replace("{add-ons}", $addons, $footer);
$footer = str_replace("{search}", $search, $footer);
$footer = str_replace("{categories}", $categories, $footer);
$footer = str_replace("{archives}", $archives, $footer);
$footer = str_replace("{miscellaneous}", $miscellaneous, $footer);
$footer = str_replace("{adminmenu}", "", $footer);
$footer = str_replace("{usermenu}", "", $footer);
$footer = str_replace("{footer}", $blogfooter, $footer);
echo $footer;
# End flush for the session
ob_end_flush();
?>
All help appreciated.
Here's a fiddle with what I think is working.
Your problem was you had the div with a width of 950px, and inside that was a ol of 950px. When there's no room for a margin, auto will pick 0.
To fix this, remove the float from the outside div and set it to width:100%;. Then put all the background stuff in the ol. Finally put something at the end of the ol with clear: both;. A <br /> is the most common choice.
UPDATE:
Here's a full screen preview, in case the regular fiddle doesn't give you 950px.

Resources