Month: November 2013

Windows RDP and Remmina: “Unable to connect to RDP server”

If you’ve been using Remmina to RDP to a Windows machine for some time and then all of suddenly find yourself running into the error Unable to connect to RDP server <address>, take a minute to read my experience before you go through some possibly-unnecessary steps.

I occasionally reboot my modem and router, and after doing so tonight, I found I was unable to RDP into a machine running Windows 7 Ultimate on my LAN from Remmina. I immediately checked to see if I could RDP to a Windows Server machine on the same LAN from the same Remmina client and could. So, I ruled out Remmina being the problem – or so I thought.

My next check was at the network. I figured that maybe the machine was either not connected to the network or had been assigned a different IP. So I then connected a monitor the machine and checked via ipconfig to verify that the IP address was the same. I still decided to reboot my router again.

Next, I checked and rechecked the RDP settings on the Windows machine to ensure that RDP was enabled. Everything looked fine on that end, so I moved to the firewall settings. The firewall was set to allow access to RDP on the machine.

Next, I went to the net for support. I searched “unable to RDP into Windows” and naturally found lots of various explanations and solutions. Knowing that I have VirtualBox setup on the computer with network drivers installed, I decided to narrow my search to include that. That’s when I found explanations regarding issues caused by the Host-Only virtual network connection that Windows sees as an “unidentifiable” network connection type. Having had issues with this limiting my network access on a computer in the past due to Windows taking precautions in thinking it is connected to an insecure network, I jumped at several solutions that involved registry edits to tell Windows that the network connection was virtual and host-only – and that it terminated at the machine itself. Re-enabled the driver and found problem was not resolved.

I then decided to boot into Windows on my laptop and see if Windows’ own RDP client could connect to the machine. It did, but the connection seemed sluggish. I then became suspicious that either the network or the machine’s NIC were somehow at fault – which didn’t rule out in my mind that the connection on the machine created by VirtualBox could be to blame as well. I then went into the Network and Sharing settings on the machine and disabled the connection. Rebooted the machine and found myself facing the same problem.

Finally, I wisened up and searched for help: “unable to connecto to Windows RDP using Remmina” and found the solution to my problem. Again, there were several suggested solutions, but I did find the one that worked for me. One solution suggested changing the Advanced > Security value in the connection’s profile in Remmina to RDP. This not only didn’t fix my problem, but caused additional problems with connecting to the machine.

The solution, surprising enough, was as simple as removing an entry in a file. I simply opened .~./freerdp/known_hosts and removed the line that corresponded to the host. I restarted Remmina and tried to connect, getting prompted to accept the host’s key, and was happily connected. Was a little agitated that I spent so much time and work trying to resolve a problem that was so easily fixed, but happy to again have the ability to RDP into my machine.

Ubuntu Unity Dash: Removing Links

There are occasions when applications that have been removed have stale links left behind in the Unity Dash. Though it is harmless, it is annoying to see them popup as results to searches in the dash when they are useless – creating a problem by taking up search results that could lead to what you’re searching for more quickly.

Removing them is fairly simple, but it can be easy to forget if you haven’t done it before – or at least not for a while.

Most of the links in the Unity Dash are stored in the /share/applications folder. However, depending on if the application was installed for just one user or for all users determines which folder the links are stored at. If the application was installed on the system for all users, you will have to use root access to remove them from the /usr/share/applications directory. If they were installed by a user strictly for that user, they will be in the .local/share/applications directory within that user’s home.

Make sure you empty your Trash after you delete the links. They will not be removed from the Dash until you do.

Quantum Light Harvesting: Computing of the Future?

A recent suggested result in my DuckDuckGo search app on my Android phone brought this article to my attention yesterday. The article discusses some new theory on the way light is converted into energy in plant life and how understanding it may lead to more efficient technology. I’m not up to terms on the concepts, but that sounds a lot like the possibility of bio-driven technology, and that makes me think of Star Trek. Anyone who’s watched the Voyager series would likely remember the “gel packs” that drove the ship’s internal systems.

Maybe I’m completely misunderstanding the technology they’re suggesting can come from deciphering how this method of harvesting light energy works. Either way, technology has rapidly improved over the past decade. After all, we were using computers with 56k internet connections and hard drives smaller than the average modern thumb drive only thirteen years ago, and that isn’t a very long time considering how fast that technology was improved the two decades up until the year 2000. I really wonder how long the imaginations of science fiction writers can stay ahead of the engineering minds of the real world.

phpBB3: Last Post Subject on Board Index

This is a modification you can find easily in the Knowledge Base section on the phpBB website. However, I have made some slight alterations to the template edit, as well as increased the number of characters allowed for the subject to be displayed. Keep in mind that I only use proSilver-based styles, and so the smaller 10-character limit is more suitable for subSilber-based styles. On top of that, the difference in template changes are specifically for proSilver-based styles as well, and would not work for subSilver.

A sample of how the subject will look on the board index.phpBB3: Last Post Subject on Board Index

The link to the original mod article is here.

#
#—-[ OPEN ]———————————————————–
#

includes/functions_display.php

#
#—-[ FIND ]———————————————————–
#

			'LAST_POST_SUBJECT'		=> censor_text($last_post_subject),

#
#—-[ REPLACE WITH ]—————————————————
#

			'LAST_POST_SUBJECT'		=> (utf8_strlen(censor_text($last_post_subject)) > 30) ? utf8_substr(censor_text($last_post_subject), 0, 30) . '...' : censor_text($last_post_subject),

#
#—-[ OPEN ]———————————————————–
#

styles/prosilver/template/forumlist_body.html

#
#—-[ FIND ]———————————————————–
#

						<!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a><!-- ENDIF -->
						<!-- IF forumrow.LAST_POST_TIME --><dfn>{L_LAST_POST}</dfn> {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL}
						<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- ENDIF --><br />{forumrow.LAST_POST_TIME}<!-- ELSE -->{L_NO_POSTS}<br />&nbsp;<!-- ENDIF --></span>

#
#—-[ REPLACE WITH ]—————————————————
#

						<!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a><!-- ENDIF -->
						<!-- IF forumrow.LAST_POST_TIME --><a href="{forumrow.U_LAST_POST}">{forumrow.LAST_POST_SUBJECT}</a><dfn>{L_LAST_POST}</dfn>
						<br />{forumrow.LAST_POST_TIME} {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL}
						<!-- ELSE -->{L_NO_POSTS}<br />&nbsp;<!-- ENDIF --></span>

phpBB3: Auto-Resize Avatar

It makes no sense to me why the phpBB developers haven’t already included this functionality in phpBB by default, as the SMF board developers have done. But one great thing about SMF over phpBB is that after installing, you can simply set the dimension requirements for avatars and users who attempt to use larger images have those images resized to within the boundaries set on the board. Well, there is a mod for phpBB that allows it to do the same thing. Though the mod is listed as abandoned on the phpBB mod database, the mod still works well.

The mod was put together by Michal Poltyn. I have simply adjusted tabs and spaces to make the code more presentable to fit more neatly in the phpBB functions that are edited.

#
#—-[ OPEN ]———————————————————–
#

includes/function_upload.php

#
#—-[ FIND ]———————————————————–
#

		if (!$this->upload->valid_dimensions($this))
		{
				$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_SIZE'], $this->upload->min_width, $this->upload->min_height, $this->upload->max_width, //$this->upload->max_height, $this->width, $this->height);

			return false;
		}
		return true;
	}

#
#—-[ REPLACE WITH ]—————————————————
#

		if (!$this->upload->valid_dimensions($this))
   		{
      			$valid = $this->create_thumb();
      			if (!$valid)
      			{
         			$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_SIZE'], $this->upload->min_width, $this->upload->min_height, $this->upload->max_width, $this->upload->max_height, $this->width, $this->height);
         			return false;
      			}
   		}

   		return true;
	}

	/**
	* Create a thumb if uploaded image is too big.
	* This function was based mainly on MediaWiki's thumbnail creating process
	* and create_thumbnail function in functions_posting.php
	* @source MediaWiki
	*/
	function create_thumb()
	{
   		global $config;

   		if ($this->width > $this->height) 
   		{
      			$thumb_width = $this->upload->max_width;
      			$thumb_height = $this->height*($this->upload->max_height/$this->width);
   		}
   		else if ($this->width < $this->height) 
   		{
      			$thumb_width = $this->width*($this->upload->max_width/$this->height);
      			$thumb_height = $this->upload->max_height;
   		}
   		else /* $this->width == $this->height */
   		{
      			$thumb_width = $this->upload->max_width;
      			$thumb_height = $this->upload->max_height;
   		}

   		// Only use imagemagick if defined and the passthru function not disabled
   		if ($config['img_imagick'] && function_exists('passthru'))
   		{
      			$quality = '';
      			$sharpen = '';
      			$frame = '';
      			$animation = '';
      			if ( $this->mimetype == 'image/jpeg' )
      			{
         			$quality = '-quality 80'; // 80%
         			/** Reduction in linear dimensions below which sharpening will be enabled */
         			if ( ( $thumb_width + $thumb_height ) / ( $this->width + $this->height ) < 0.85 )
         			{
            				$sharpen = '-sharpen 0x0.4';
         			}
      			}
      			else if ($this->mimetype == 'image/png')
      			{
         			$quality = '-quality 95'; // zlib 9, adaptive filtering
      			}
      			else if ($this->mimetype == 'image/gif')
      			{
         			/**
          			* Force thumbnailing of animated GIFs above this size to a single
          			* frame instead of an animated thumbnail. ImageMagick seems to
          			* get real unhappy and doesn't play well with resource limits. 
          			* Defaulting to 1 megapixel (1000x1000)
          			*/
         			if($this->width * $this->height > 1.0e6)
         			{
            				// Extract initial frame only
            				$frame = '[0]';
         			}
         			else
         			{
            				// Coalesce is needed to scale animated GIFs properly (MediaWiki bug 1017).
            				$animation = ' -coalesce ';
         			}
      			}
      			# Specify white background color, will be used for transparent images
      			# in Internet Explorer/Windows instead of default black.

      			# Note, we specify "-size {$this->width}" and NOT "-size {$this->width}x{$this->height}".
      			# It seems that ImageMagick has a bug wherein it produces thumbnails of
      			# the wrong size in the second case.

      			if (substr($config['img_imagick'], -1) !== '/')
      			{
         			$config['img_imagick'] .= '/';
      			}
      			$cmd  = 
         			escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') .
         			" {$quality} -background white -size {$this->width} ".
         			escapeshellarg($this->destination_file . $frame) .
         			$animation .
         			// For the -resize option a "!" is needed to force exact size,
         			// or ImageMagick may decide your ratio is wrong and slice off
         			// a pixel.
         			' -thumbnail ' . escapeshellarg( "{$thumb_width}x{$thumb_height}!" ) .
         			" -depth 8 $sharpen " .
         			escapeshellarg($this->destination_file) . ' 2>&1';

      			@passthru($cmd);

      			// after converting let's check the file dimensions again
      			if (($this->image_info = @getimagesize($this->destination_file)) !== false)
      			{
         			$this->width = $this->image_info[0]; // the _real_ width
         			$this->height = $this->image_info[1]; // the _real_ height
         			if ($this->upload->valid_dimensions($this)) 
         			{
            				return true;
         			}
      			}
   		}
   		if (extension_loaded('gd'))
   		{
      			/* This code is greatly based on MediaWiki's thumbnail generation process */
      			$typemap = array(
         			'image/gif'          => array( 'imagecreatefromgif',  'palette',   'imagegif'  ),
         			'image/jpeg'         => array( 'imagecreatefromjpeg', 'truecolor', array( __CLASS__, 'imagejpegwrapper' ) ),
         			'image/png'          => array( 'imagecreatefrompng',  'bits',      'imagepng'  ),
         			'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette',   'imagewbmp'  ),
         			'image/xbm'          => array( 'imagecreatefromxbm',  'palette',   'imagexbm'  ),
      			);
      			if (!isset( $typemap[$this->mimetype] ))
      			{
         			return false;
      			}

      			list($loader, $color_style, $save_type) = $typemap[$this->mimetype];

      			if (!function_exists($loader))
      			{
         			return false;
      			}
      			$src_image = call_user_func( $loader, $this->destination_file );
      			$thumb = imagecreatetruecolor($thumb_width, $thumb_height);

      			// Initialise the destination image to transparent instead of
      			// the default solid black, to support PNG and GIF transparency nicely
      			$background = imagecolorallocate( $thumb, 0, 0, 0 );
      			imagecolortransparent( $thumb, $background );
      			imagealphablending( $thumb, false );

      			if( $color_style == 'palette' ) {
         			// Don't resample for paletted GIF images.
         			// It may just uglify them, and completely breaks transparency.
         			imagecopyresized( $thumb, $src_image,
            			0,0,0,0,
            			$thumb_width, $thumb_height, $this->width, $this->height );
      			} else {
         			imagecopyresampled( $thumb, $src_image,
            			0,0,0,0,
            			$thumb_width, $thumb_height, $this->width, $this->height );
      			}

			imagesavealpha( $thumb, true );

      			call_user_func( $save_type, $thumb, $this->destination_file );
      			imagedestroy($thumb);
      			imagedestroy($src_image);
      			$this->width = $thumb_width;
      			$this->height = $thumb_height;
      			return true;
   		}
   		return false;
	}

	static function imagejpegwrapper( $dst_image, $thumb_path ) {
   		imageinterlace( $dst_image );
   		imagejpeg( $dst_image, $thumb_path, 95 );
	}

 

phpFreeChat and SMF: User/Group Identifying

This post is a follow-up to a previous post I made regarding an (in my opinion) improved method of identifying users to be in certain groups for phpFreeChat when using user info from phpBB3 boards.

After doing some searching, I noticed that there wasn’t very much info about identifying users in phpFreeChat with SMF boards. At least not SMF 2.x. Maybe I missed something in my search. I don’t know. But I decided to use what I already had put together from getting user info in phpBB3 to help lead in the direction I needed to go – along with some tutorial info that the SMF guys have posted on the site for using the SSI stuff.

Surprisingly, the process of identifying someone to be logged into SMF and to be within a group (such as the Administrator group) was just as simple as what was used for phpBB.

First of all, you have to define the path to SMF’s SSI.php file and call it.

require_once('../forums/SSI.php');

In my case, I have my structure set up so that my chat and forums are within two separate sub-directories on my domain. Some people decide to place phpFreeChat on the domain as a sub-directory of their board’s directory.

Similar to what I did with my phpBB configuration, I decided to use a variable to alter whether or not guests could access the chat or be redirected to a login page.

$RequireLogin = false; // if true, will require chatter to be logged in on the SMF board
if ($context['user']['is_guest'])
{
	if($RequireLogin)
	{
		ssi_login();
		die();
	}
}

Either way, if the user isn’t a guest, we assign their SMF name as their phpFreeChat name.

if (!$context['user']['is_guest']) $params["nick"] = $user_info['name']; // SMF nick used

Lastly, we assign the board admin as administrator, along with anyone who is a member of any designated groups (based on group ID – as with the phpBB setup). In this step, I’m kind of being tedious (because the ‘is_admin’ and group 1 should both be returned true if the user is in the Administrator group), but it doesn’t cause any issues from what I’ve seen – and I feel it guarantees a board admin will be given admin authority in the chat, but you can leave out the group ID 1 if you wish.

// SMF groups:
// 1 = Administrator
// 2 = Global Moderator

if($context['user']['is_admin'])
{
	$params["isadmin"] = true;
}
else
{
	$allowed_groups = array(1, 2);
	foreach ($allowed_groups as $allowed)
	{
		if (in_array($allowed, $user_info['groups']))
		{
			$params["isadmin"] = true;
		}
	}
}

That’s all. 🙂

Ubuntu: Creating non-buntu Startup Disks

I ran into this problem while trying to create a startup disk for OpenSUSE in Ubuntu using the included Startup Disk Creator. I noticed that only Ubuntu and Ubuntu-based isos were being listed in the program, and even when browsing to the other isos, I found that clicking to open them in the program did nothing.

After some brief searching, I came across the following thread in Ubuntu Forums. The second post within the thread was extremely helpful to me, and following its instructions led to a successful bootable USB drive with which I was able to test OpenSUSE. On top of that, I learned from the post that the Startup Disk Creator software included in Ubuntu is actually limited to only Ubuntu-based isos.

So, I thought it would be worthwhile to repost the command here on my blog for both my own records and for anyone else who might not have managed to come across the use of dd to create bootable disks in Ubuntu. From what I understand, it should work for just about any type of bootable disk. However, I can only testify that it worked for the OpenSUSE disk from my own experience so far. As always, make sure you are certain of what you’re inputting when working with CLI, and this command could cause some serious pain in terms of data loss if you accidentally designated the wrong location.

sudo dd if=/path-to-iso of=/dev/sdX bs=4096

The command should be fairly straight-forward. The if argument should be the full path that points to the location of the iso. The of argument should be the device that is being written to as the startup disk. That’s probably obvious, but I felt it was necessary to clarify just in case. I’m assuming that bs is referring to the boot sector location of the device being written to, but that is purely speculation on my part and the value was simply left as-is when I used this method of creating the boot disk.

You can also use the mount  command to list all mounted devices currently connected to your computer. If you know the name of the device (which you can see by hovering over the USB drive’s icon on the Unity launcher) you can then look through the list of devices displayed from mount  and find what device it is so that you supply the right value for the of argument when using dd. A more graphical method would be to open the Disk Utility and find the USB drive listed in the left pane. Clicking on it will then display the device information in the right pane, including where the device is mounted.

I’ve been meaning to create a Windows boot disk using this, to at least see if it would work. I need to re-install Windows on a laptop that doesn’t have a disc drive built into it, and the USB method seems my best option. I’ll add a comment or update the post with the results once I run it.