For a few weeks/months I’ve been struggling with the following matter at hand.

Old environment:
– Joomla website in “/
–  Smf installation in “/forum

Joomla was simply the front-end, providing news to our users while Smf was responsible for registrations, logins and maintenances of  members.

for years this worked perfectly but as time moved on a change for our site was necessary. Regarding the important use of Smf in this case  it was clear where our starting point would come from.

New environment: 

– WordPress installation in”/
– Smf installation in “/forum

I wanted to make sure that:

  1. users from Smf were able to login to WordPress
  2. users from Wp were able to login to Smf
  3. information from Smf could be used in Wp
  4. and the forum was integrated in WordPress

And so began an epic struggle:

Step 1. A bridge

bridgeSince Smf and WordPress are too different handling registration, logins, logouts and managing their “content”, we need something to overlap this, hence a bridge.

A search revealed that  a lot of these “bridges” are available for different types of blogs, forums and/or CMSs and most of them provide a basic functionality to sync the different databases so a login eg is possible in both.

Let’s see what’s out there.

My first approach was using a wp bridge for smf:  SMF Bridge

WP-SMF-Bridge is a simple user registration and logon bridge between WordPress and Simple Machine Forum. To get this working, it is highly recommended that you have a fresh, unmodified install of SMF 1.1 or higher installed and running alongside an install of WordPress. It must be installed in a subdirectory under your WP install and should not be being accessed through a sumdomain. For example, if your website’s address is mysite.mydomain.com, your forums should be somewhere like mysite.mydomain.com/myforum. Also, WordPress must be able to access your SMF configuration files, otherwise it won’t work!

Unfortunately, this plugin has not been updated since 2010-5-26 and didn’t make me use the SSI.php functions in wordpress.

Second approach: SMF2WP

SMF2WP is a simple one way bridge from Simple Machine Forum (v2.0.1 tested) to WordPress (v3.2.1 tested). This means, this one uses databases of SMF Forum and sync to WP database every time a user performs log-in action in both WP and SMF. […]

This plugin will do these following tasks:

  1. If a user log in WP, then that user will be logged in SMF using SMF2API.
  2. If a user logout WP, then that user will be logged out SMF using SMF2API.
  3. If a user log in SMF, will be logged in WP as well.
  4. If a user log out SMF, will be loged out WP as well.

When I was busy with this project, SMF 2.0RC came out and at that time SMF2WP didn’t work for me, so I was pushed in another way of achieving my goals.

Instead of using a WordPress plugin, why not go the other way around ? Use a Smf plugin which does the same. Since SMf was our basis from the beginning, this deemed to be a good solution.

Third approach: BlogBridger

BlogBridger is an Open Source PHP Application to bridge WordPress 3.0+ with SMF 2.0. It is released under the Mozilla Public License v1.1. BlogBridger makes no code changes to SMF, operating soley on it’s integration hooks. It is easy to install, uninstall and manage.
Features:

  1. Installable on new OR existing SMF and WordPress installations
  2. Migrates users to both SMF or WordPress if they do not exist in the other
  3. When a user logs into SMF, they are also logged into WordPress (vice versa)
  4. Assign WordPress roles to SMF member groups when exporting users from SMF
  5. Assign SMF Member groups to WordPress roles when importing users from WordPress

This could work ! After setup and installation I tried to login with wordpress and: Success! I was able to login using my smf credentials.

With this I was one step closer for reaching my goal.

2. How do you want your login sir ?

Login of SMF

I wanted to get rid of the login page that wordpress provides, so a few files needed some adjustments: ssi.php and header.php. (Ofcourse the wp-login.php can still be used, I simply did not let it show in my widget structure.)

This also allowed me to use the functions residing in smf.

ssi.php can be found in “/forum” and header.php can be found in
your “/wp-content/themes/<themename>” folder.

header.php

We need to change the  first lines. by adding ssi.php.
Change

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  4.  
  5. <head profile="http://gmpg.org/xfn/11">
  6. <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
  7.  
  8. [...]

to

  1. <?php
  2. require_once('/forum/SSI.php');
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  7.  
  8. <head profile="http://gmpg.org/xfn/11">
  9. <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

With this added line we can use variables from smf, let say: the loginbox

<div id=loginbox>
<?php  ssi_login(); ?>
</div>

But this gives us the entire loginform, we only need the username and password textfields. Thus requiring a little adjustment in ssi.php

Ssi.php

Change

  1. // Shows a login box.
  2. function ssi_login($redirect_to = '', $output_method = 'echo')
  3. {
  4. global $scripturl, $txt, $user_info, $context, $modSettings;
  5.  
  6. if ($redirect_to != '')
  7. $_SESSION['login_url'] = $redirect_to;
  8.  
  9. if ($output_method != 'echo' || !$user_info['is_guest'])
  10. return $user_info['is_guest'];
  11.  
  12. echo '
  13. <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '">
  14. <table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
  15. <tr>
  16. <td align="right"><label for="user">', $txt['username'], ':</label>&nbsp;</td>
  17. <td><input type="text" id="user" name="user" size="9" value="', $user_info['username'], '" class="input_text" /></td>
  18. </tr><tr>
  19. <td align="right"><label for="passwrd">', $txt['password'], ':</label>&nbsp;</td>
  20. <td><input type="password" name="passwrd" id="passwrd" size="9" class="input_password" /></td>
  21. </tr>';

to

  1. // Shows a login box.
  2. function ssi_login($redirect_to = '', $output_method = 'echo')
  3. {
  4. global $scripturl, $txt, $user_info, $context, $modSettings;
  5.  
  6. if ($redirect_to != '')
  7. $_SESSION['login_url'] = $redirect_to;
  8.  
  9. if ($output_method != 'echo' || !$user_info['is_guest'])
  10. return $user_info['is_guest'];
  11.  
  12. echo '
  13. <form id="loginform" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '">
  14.  
  15. <label for="user">USERNAME</label>
  16. <input type="text" id="user" name="user" size="9" value="', $user_info['username'], '" class="input_text" />
  17.  
  18. <label for="passwrd">PASSWORD</label>
  19. <input type="password" name="passwrd" id="passwrd" size="9" class="input_password" />
  20. <!--
  21. <select name="cookielength">
  22. <option value="60">for 1 Hour</option>
  23. <option value="1440">for 1 Day</option>
  24. <option value="-1" selected="selected">until you log out</option>
  25. </select>
  26. -->
  27. ';

Et voila ! Now we only have our needed textfields.

So, what’s our status so far ? Users can login with their forum credentials and are automatically added to the wp_users table in the database.

From this point on you have 2 choices:

You continue to use this combination of blog and forum or start over with your freshly added users, who are now “imported” in wordpress.
I choosed the first.

 

This little script helps to locate a (cisco) switch which has multiple connections on one port.
The result is a txtfile with the name, ip and port of the switch.

Software used:

  1. cut.exe
  2. sort.exe
  3. uniqe.exe
  4. tst10.exe aka Telnet Scripting Tool

The first 3 files can found in the CoreUtils archive.

The Telnet Scripting Tool can be found on Jerry Mannel’s blog

Preparations:

  1. Create a folder and place the files
  2. Create a file, eg switches.txt
  3. Save the source code, which can be found at the bottom of this article, as something.vbs

– Switches.txt should be in the following format:

ip-address;serietype;fullname (in most cases serietype=2950)

10.10.10.1;2950;switch-01
10.10.10.2;2950;switch-02

To run: open a commandprompt and type “wscript something.vbs”

The Code:

We begin by setting up our environment.

set wshshell = createobject("wscript.shell")
set fso= createobject("scripting.filesystemobject")
set switchlist = fso.opentextfile("switches.txt")
 
if fso.fileExists("result.txt") then
	fso.deleteFile "result.txt", true
end if
 
set result = fso.openTextFile("result.txt",8,true)

We loop switches.txt until all items are processed and make sure that previous created files are removed.

do until switchlist.atendofstream
 
	'--- Remove all previous files ---
 
	if fso.fileExists("output.txt") then
		fso.deleteFile "output.txt", true
	end if
	if fso.fileExists("temp.txt") then
		fso.deleteFile "temp.txt", true
	end if
	if fso.fileExists("double.txt") then
		fso.deleteFile "double.txt", true
	end if
 
	switch = switchList.readLine
	matrix = split(switch, ";")
	ip = matrix(0)
	typeswitch = matrix(1)
	switchname = matrix(2)
 
	if fso.filEexists("script.txt") then
		fso.deleteFile "script.txt", true
	end if

Since not every IOS uses the same commands, we split our code up.

if typeswitch = "2950" then
 
	set script = fso.openTextFile("script.txt",8,true)
		script.writeline ip & " 23"
		script.writeline "send " & """<passwd>\m"""
		script.writeline "wait " & """>"""
		script.writeline "send " & """term len 0\m"""
		script.writeline "wait " & """>"""
		script.writeline "send " & """show mac-address-table | include Fa0/\m"""
		script.writeline "wait " & """>"""
		script.writeline "send " & """quit\m"""
	script.close
 
	else 'type=2948
 
	set script = fso.openTextFile("script.txt",8,true)
		script.writeline ip & " 23"
		script.writeline "send " & """<passwd>\m"""
		script.writeline "wait " & """>"""
		script.writeline "send " & """set len 0\m"""
		script.writeline "wait " & """>"""
		script.writeline "send " & """show cam dyn | exclude 2/49\m"""
		script.writeline "wait " & """>"""
		script.writeline "send " & """quit\m"""
	script.close
 
	end if

The code above is necessary for using the Telnet Scripting Tool. More information about its use can be found on this blog.

commandoTelnet = "TST10 /r:script.txt /o:output.txt"
	wshshell.run commandoTelnet, ,True	
 
	wscript.sleep 3000
 
	if typeswitch = "2950" then
 
	commandoGrep = "cmd /c " & """grep -e " & """DYNAMIC""" & " -e " & """STATIC""" & " output.txt > temp.txt"""
	wshshell.run commandoGrep, , True
 
	commandoCut = "cmd /c " & """cut -c 39- temp.txt > test.txt"""
	wshshell.run commandoCut, , True
 
	else '=2948
 
	commandoGrep = "cmd /c " & """grep -e " & """[ALL]""" & " output.txt > temp.txt"""
	wshshell.run commandoGrep, , True
 
	commandoCut = "cmd /c " & """cut -c 39- temp.txt > test.txt"""
	wshshell.run commandoCut, , True
 
	end if
 
	commandoFindDuplicates = "cmd /c" & """sort test.txt |uniq -d > double.txt"""
	doubles = wshshell.run(commandoFindDuplicates, ,True)
 
	if fso.fileExists("double.txt") then
		set readDoubleTxt = fso.openTextFile("double.txt")
		do until readDoubleTxt.atendofstream
			routerOpPort = readDoubleTxt.readline
			result.writeline switchname & "(" & ip & ")" & "->" & routerOpPort
		loop
	readDoubleTxt.close
	end if
 
loop
result.close
Wscript.Echo "Script finished !"

The resulting output is:

switch-02(10.10.10.1)->Fa0/45
switch-02(10.10.10.2)->Fa0/46
switch-03(10.10.10.3)->Fa0/2
switch-06(10.10.10.4)->Fa0/33
switch-07(10.10.10.5)->Fa0/41
switch-08(10.10.10.6)->Fa0/24

Although this script can be further optimized, it does the job for me 🙂

The fullcode :


 

yeah, this blog still has some issues with IE8, but works fine under:
– Opera >9
– Firefox
– Chrome
– Safari

Work work.

 

Reminder to myself: make blog opera 9 compatible (Update Extjs ;))

wrong

 

It came to my attention that the http://www.ceeke.be/feed in chrome gave a rather garbled result. Further research showed that it *could* be a wordpress or a chrome issue, since in fact it is still a beta product.

A quick checkup of the feed via http://beta.feedvalidator.org/ showed that it is a valid rss feed.

So, how can this be fixed ?

Auto-Detect RSS in Chrome

On the web page http://www.feeds.ramisp.org, there are two bookmarklets available: “View RSS Feed” and Auto-Detect RSS.” Drag each of these bookmarklets to Chrome’s bookmark bar. Then, whenever you’re on a page that has an RSS feed, you just have to hit the “Auto-Detect RSS” button. This will take you to a page where the feed is displayed along with several auto-subscription links up at the top. Alternately, you can just hit “view RSS feed,” if you want to see the RSS feed in the browser.  (Source: ReadWriteWeb )

I hope that in the future this issue will be fixed, either by Chrome or by WordPress.

© 2012 Ceekes boarderline Suffusion theme by Sayontan Sinha