Sidestørrelse 

Playing with my Camera

HuwR

HuwR

Forum Administrator

Obviously I am still not allowed to go out that much, so currently limited to taking pics in the garden. We get a surprising variety of wildlife considering we live on a very large housing estate.

Les mer

Upgrading from Classic Snitz to MVC Snitz

HuwR

HuwR

Forum Administrator

If you are upgrading from Classic ASP version of Snitz, you SHOULD run the SQL script below against your forums database, this is to fix some inconsistencies found in some versions of the classic forum.
If you are unable to run the SQL below, please post in the Forums before attempting the upgrade.

Code:

delete  from FORUM_CONFIG_NEW where ID is null;

WITH CTE AS
(
SELECT *
,ROW_NUMBER() OVER
(PARTITION BY C_VARIABLE
ORDER BY C_VARIABLE,ID ASC
) AS RowNum
FROM FORUM_CONFIG_NEW

)

DELETE FROM CTE WHERE RowNum > 1 -- uncomment this row for the final DELETE

Alter Table dbo.FORUM_CONFIG_NEW Add Id_new Int Identity(1, 1)

Alter Table dbo.FORUM_CONFIG_NEW Drop Column ID

Exec sp_rename 'dbo.FORUM_CONFIG_NEW.Id_new', 'ID', 'Column'

ALTER TABLE dbo.FORUM_CONFIG_NEW ADD CONSTRAINT
PK_FORUM_CONFIG_NEW PRIMARY KEY CLUSTERED
(
ID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

When you have run the above script. you can install the files using the instructions
Here

Les mer

So, what am I up to

HuwR

HuwR

Forum Administrator
Just in case you thought nothing was going on, I am still actively working on the code smile
I have fixed some bugs in the upgrade process from classic Snitz, and discovered a few gotchas which may require a sql fix for some. Many thanks to SimonE for being a Guinea pig, hopefully you will be up and running with this soon.
Once again some thanks to Torborg for stressing out the code with her forum, I have made some tweaks to the photoalbum Gallery code which was causing IIS performance issues (they have > 300,000 images)
Les mer

Userfields Plugin Preview

HuwR

HuwR

Forum Administrator
The Userfields plugin allows Administrators to add new fields to the Members profile. It supports the following Field types
  • S = Simple Input
  • N = Number Input
  • T = Text Area
  • C = Check Box
  • D = Date
  • X = Time
  • Z = DateTime
  • O = Select Box
  • M = Multi-Select Box
  • H = Horizontal Radio Buttons
  • V = Vertical Radio Buttons
The fieldname is used as the key for the language resources to translate the field label
OptionsString is a pipe | delimited list of options for radio buttons and select lists. Fields can be required or private, and can be displayed individually
or all at once
Les mer

Installing Snitz™ Forums MVC on a shared hosting plan

HuwR

HuwR

Forum Administrator

Instructions for installing the Snitz™ Forums MVC code on shared hosting.

Firstly, ensure that HTTP Compression is turned of, I don't know why this affects the code, but it seems to cause problems. Next, make sure your site supports ASP.Net v4.x.
Before uploading any files to your website, you should follow the instructions below.
If you are using MySQL for your database, delete the web.config file and rename the web.config.mysql file to web.config.
Now, open the web.config file in a text editor and add the required information to the two connection strings that you see, they will look similar to below .. connectionString="Data Source=SERVER;Initial Catalog=DATABASE;UID=USERNAME;PWD=PASSWORD;"

Replace the text in CAPITALS with the correct information for your database in both of the connection strings.
If you already have a website configured on your shared hosting, you should create a new '.NET Application', you will be asked to supply a folder that the .NET application should use as the root folder for your forum (you may need to create this).
If the forum is going in the root of your website you may skip this step.
Now, upload all the folders + files in the release zip to either your website root or to the new .NET applications folder that you just created.
Open the forum in your browser using it's URL, either http://mywebsiteaddress/ or http://mywebsiteadress/.netappfolder/
After a short delay (.NET will be loading stuff when you first open) you will be presented with the setup page for the forum. Follow the instructions as presented to you.
If all goes well, you should end up being redirected to your new forum. The forum once installed will be in the 'Offline' state, you should now open the Admin pages and setup all the options and settings for your forum before putting the forum into 'Online' mode.
If anything goes wrong, copy the content of the output window and post it here so that we may offer some assistance.

Les mer

Installation notes

HuwR

HuwR

Forum Administrator
  1. Download the zip files and extract the main forum zip to a folder on your local machine or server, do not unzip the mod files, they must be installed after the forum is set up.
  2. Edit the web.config file as detailed below.
    1. Database Connection
      1. Under <connectionStrings> add the required info for your database connection, you will find examples for various database types. We currently support MSSQL (server/express or local) and MySQL.
        Code:
        <connectionStrings>
        <add name="SnitzConnectionString" connectionString="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|\SnitzForumMvc.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
        <add name="SnitzMemberShip" connectionString="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|\SnitzForumMvc.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
        </connectionStrings>
      2. If using MySQL you will also need to make the following changes to web.config. Change the entityFramework section to match the one below
        Code:
        <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
        <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
        </providers>
        </entityFramework>
        You will also need to uncomment the block beneath it
        Code:
        <system.data>
        <DbProviderFactories>
        <remove invariant="MySql.Data.MySqlClient" />
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
        </system.data>
    2. Email Settings You can leave these, you can set them under admin options after installation
  3. Edit the snitz.config file as detailed below
    Once you have edited the web.config file, open the snitz.config file to edit the global appsettings
    Code:
    <appSettings>
    <add key="boolRunSetup" value="1"/>
    <add key="LanguageConnectionString" value="SnitzConnectionString"/>
    <add key="forumTablePrefix" value="FORUM_"/>
    <add key="memberTablePrefix" value="FORUM_"/>
    <add key="filterTablePrefix" value="FORUM_"/>
    <add key="customTablePrefix" value="FORUM_"/>
    <add key="LandingPage" value="Index" />
    <add key="strForumDescription" value="Snitz™ Forums community support forum, Mvc version." />
    <add key="strForumUrl" value="http://localhost:8080/ForumMvc" />
    <add key="strForumTitle" value="Snitz Forums 2000 MVC" />
    <add key="strForumImage" value="logo.png" />
    <add key="strCookiePath" value="/" />
    <add key="boolDisablePosting" value="0" />
    <add key="boolProhibitNewMembers" value="0" />
    <add key="strUniqueId" value="Snitz00" />
    <add key="boolAllowSearchAllForums" value="1" />
    <add key="boolFullTextSearch" value="0" />
    <add key="strAnonMembers" value="Administrator" />
    <add key="boolShowAvatar" value="1" />
    </appSettings>
    These can normally be left as is, unless you are upgrading and your forum tables are using a different prefix, if so, set as appropriate. You can also change the LandingPage from Index to AllForums depending on your preference.
  4. Copy all the files and folders to either your website root, or set up an application folder to copy them to. The application pool should be set up as below.
  5. You will need to give edit/create permissions on the App_Data and Content Folder and sub folders. Also allow edit for the snitz.config file in the forum root folder.
  6. Open a browser and point it at the root of your site/app e.g. http://localhost or http://localhost/forum etc.
  7. After a short delay (.Net will be loading stuff when you first load) you will be presented with either A or B below.
    1. Setup a new Forum.
    2. Upgrade an existing Forum.
  8. Once the setup/upgrade has finished you should be redirected to the home page of the new forum where you can log in. You will probably need to login twice if this is an upgrade as the code has to map your existing log in to the new membership tables, first login will fail with incorrect user/password, just log in again and you should be in.
Upgrade Gotchas
  1. FORUM_CONFIG_NEW
    On a couple of upgrades, this table was found to have duplicate C_VARIABLE records, this causes the forum to error when loading, it will complain about duplicate key values in dictionary. Check the table and remove any duplicates.
  2. Private Messaging
    If you already have the PM mod installed, the upgrade process will attempt to rename your existing tables to avoid incompatibilities with existing table structures. If this fails, the new tables will not be created and you may experience problems using the PM functions. If this occurs, try running the PMFix script which you can find under Admin | Extras | DbsScripts
Installing Plugins
Plugins should be self installing, simply extract the files in the plugin zip to their respective folders under the forum root (make sure you copy the plugins subfolder last).
Now navigate to Admin | Other Config | Tools and press the ‘Reset Application’ button to recycle the application and load the new plugin.
Les mer

Site layout and page templates part 1

HuwR

HuwR

Forum Administrator

In this series of posts I will start detailing the components of the MVC forum and how you can modify it to suit your own site. ASP.NET MVC does not include anything that directly corresponds to a page. In an ASP.NET MVC application, there is not a page on disk that corresponds to the path in the URL that you type into the address bar of your browser. The closest thing to a page in an ASP.NET MVC application is something called a view.

The look and feel of the forum is controlled by a set of template files which you can find in the Views folder, and css files which are located in the Content folder. If all you want to do is change colours and fonts etc, then you just need to edit the css files. Under the Views folder you will find several subfolders, each subfolder contains template files specific to a certain area/function of the site, Home, Forum,Topic etc. You will also see a subfolder called Shared, this subfolder contains the main base layout template together with common include templates for formatting specific items on a page, I will go into this as we go along.

All public/member web pages are based on a main _Layout.cshtml template (admin pages use a different _layout.cshtml), this template can be found in the Shared folder.

Main Layout template

The layout template contains elements common to every page (menu etc) as well as defining the basic page layout, header, footer columns etc. The file also contains placeholders where you can inject code from the other views, these are defined as sections and may or may not be required, a required section means you must define it in the view. The code sample below shows the forums _layout page to illustrate the layout and sections, other code/css/javascript has been removed for clarity.

Code:
@using System.Globalization
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using SnitzCore.Service.MiddleWare
@using SnitzCore.Service.TagHelpers
@{
string[] rtlLangs = new string[] { "ar", "arc", "dv", "fa", "ha", "khw", "ks", "ku", "ps", "ur", "yi", "he" };

//check the culture so we can set the page direction and language
var cookielang = SnitzCookie.GetCookieValue("CookieLang");
CultureInfo ci = CultureInfo.CurrentUICulture;
string clang = ci.TwoLetterISOLanguageName;

if (cookielang != null)
{
var cultureInfo = new CultureInfo(cookielang);
CultureInfo.CurrentUICulture = cultureInfo;
clang = cultureInfo.TwoLetterISOLanguageName;
}
Context.Session.SetString("culture", clang);
bool isRighToLeft = rtlLangs.Contains(clang);
MemberService.SetLastHere(User);
}
<!DOCTYPE html>
<html lang="@clang" dir="@(isRighToLeft ? "rtl" : "ltr" )">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forum</title>
@await RenderSectionAsync("MetaData", required: false)
@if (isRighToLeft)
{
<link rel="stylesheet" href="~/css/bootstrap.rtl.min.css">

}else{
<link rel="stylesheet" href="~/css/bootstrap.min.css" />

}

<link rel="stylesheet" href="~/lib/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="~/css/site.min.css">
@await Component.InvokeAsync("SnitzThemeCss")
<link rel="stylesheet" href="~/css/busy.min.css">
@await RenderSectionAsync("Styles", required: false)

</head>
<body>
<partial name="_BusyPartial" />
<div class="d-flex flex-column" style="min-height: 100vh;">
<partial name="MainNav"/>
<div class="container flex-grow-1">
<partial snitz-if="@(SnitzConfig.GetIntValue("STRSHOWANNOUNCE") == 1)" name="Announcement" />
<partial snitz-if="@(SnitzConfig.GetIntValue("INTREQUIRECONSENT") == 1)" name="CookieConsentPartial" />
<main role="main" class="pb-3 mt-6">
@RenderBody()
</main>
</div>

<partial name="Footer"/>
</div>

<script type="text/javascript" src="~/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="~/js/jquery.min.js"></script>
<script type="text/javascript" src="~/lib/jquery/dist/jquery-ui.min.js"></script>
<script type="text/javascript" src="~/lib/jquery/jquery.timeago.min.js"></script>

<partial name="GlobalJs" />
<partial name="ValidationScriptsPartial" />
<script type="text/javascript" src="~/js/site.min.js" asp-append-version="true"></script>
<script type="text/javascript" src="~/js/jquery.cookie.js"></script>

@if (!clang.Contains("en"))
{
var src = $"timeago.{clang}.js";
<script type="text/javascript" src="~/js/timeago/@src"></script>
}

@await RenderSectionAsync("Scripts", required: false)
<renderstoredcontent asp-key="cookie-consent"></renderstoredcontent>
<renderstoredcontent asp-key="password-toggle"></renderstoredcontent>

@if (User.IsInRole("Administrator"))
{
<div id="confirmRestart" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger">
<a href="#" data-bs-dismiss="modal" aria-hidden="true" class="btn btn-danger">X</a>
<h4 class="text-bg-danger">Application Restart!</h4>
</div>
<div class="modal-body">
<p>You are about to Restart the Application.</p>
<p>Do you wish to proceed?</p>
</div>
<div class="modal-footer">
<a href="#" id="btnRestartYes" class="btn btn-danger">@Localizer["btnOk"]</a>
<a href="#" data-bs-dismiss="modal" aria-hidden="true" class="btn btn-secondary">@Localizer["btnCancel"]</a>
</div>
</div>
</div>
</div>
<div id="forumAlert" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger">
<a href="#" data-bs-dismiss="modal" aria-hidden="true" class="btn btn-danger">X</a>
<h4 class="text-bg-danger">Alert!</h4>
</div>
<div class="modal-body">
<p>There are pending member registrations.</p>
</div>
</div>
</div>
</div>
}

<script type="text/javascript">
$(document).on('click', '.confirm-restart', function (e) {
e.preventDefault();
var href = $(this).attr('href');
$('#confirmRestart').data('url', href).modal('show');

$('#confirmRestart').on('click', '#btnRestartYes', function (e) {
e.preventDefault();
$.post(href,'',
function(data, status){
if (!data) {
alert("There was a problem!");
} else {
$('#confirmRestart .modal-body').html("<p>Application is restarting, please wait ...</p>");
$('#btnRestartYes').hide();
setTimeout(function () {
$('#confirmRestart').modal('hide');
location.reload(true);
}, 25000);

}
});
});
});
$(document).ready(function () {
if (SnitzVars.pending > 0) {
$('#forumAlert').modal('show');
setTimeout(function () {
$('#forumAlert').modal('hide');
}, 3000);
}
});
$(window).on('beforeunload', function(){
displayBusyIndicator();
});
window.addEventListener( "pageshow", function ( event ) {
var historyTraversal = event.persisted ||
( typeof window.performance != "undefined" &&
window.performance.navigation.type === 2 );
if ( historyTraversal ) {
// Handle page restore. window.location.reload();
}
});

$(document).on('submit', 'form', function () {
displayBusyIndicator();
});
function displayBusyIndicator() {
$('.loading').show();
}
$(document).ajaxComplete(function(event, xhr, settings) {
$('.loading').hide();
});
if(SnitzVars.showPageTimer == '1'){
window.addEventListener('load', () => {
//debugger;
const [pageNav] = performance.getEntriesByType('navigation');
const footer = document.getElementById('loadTime');

let workerTime = 0;

if (pageNav.responseEnd > 0) {
workerTime = (pageNav.responseEnd - pageNav.workerStart)/1000;

if (footer) {
var test = (workerTime).toLocaleString(
undefined, // leave undefined to use the visitor's browser
// locale or a string like 'en-US' to override it. { minimumFractionDigits: 2 }
);
footer.textContent = `Page loaded in ${test} s`;
}
}
});
}


</script>
</body>
</html>

You will also see a few lines like @Html.Partial("_LoginPartial") in the actual _layout file, these lines are including other view templates much like the classic asp include files. In general these 'partial views' will start with an underscore and will either be in the same subfolder as the view template, or in the shared folder if included in multiple views.

Les mer
type forum script view src p Database the web btn modal have folder page code config class application you href this j your css table upgrade can Edit use function be partial file snitz that div should below template to javascript with install text main in name require a will