Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7018 Articles
article-image-remote-installation-and-managing-user-profiles-using-joomla
Packt
20 Jul 2010
7 min read
Save for later

Remote Installation and Managing User Profiles using Joomla!

Packt
20 Jul 2010
7 min read
Migrating the site from a local to remote server We have reached the stage in the development of our social network where we will migrate our site to a remote host. The migration process involves backing up our entire site, downloading the backup files, and then using them to restore our site in a different hosting environment. This same backup process can be used for routine backups of a Joomla! site as a security measure. It can also be used for the restoration of a site or for switching a site from an old to a new hosting account. These processes are invaluable to a Joomla! website developer. Backing up the local site using Akeeba Backup Following are the steps necessary to create an Akeeba Backup: Download Akeebabackup and the kickstart.php script from the AkeebaBackup website: http://www.akeebabackup.com/download.html. The Kickstart download is a .zip package. We will have to extract the files to access the kickstart.php file. Install the Akeebabackup component through the regular Joomla! extension installation process. Akeebabackup is designed to back up the entire website, including database data and website configuration. Configure the Akeebabackup component by going to Components Akeebabackup | Configuration|. As shown in the previous screenshot, most of the default settings work well.We should pay attention to the Output Directory and the Archiver engine.The Output Directory is the folder where the backup will be saved; this can be changed if necessary. Take note of this directory, as we will download the archived file after backing up the site. The Archiver engine determines the backup format. The JPA format is recommended for backing up from a Linux environment and restoring it also in a Linux environment. We used ZIP format for our backup. Akeeba comes with detailed instructions that can be found in the documentation files. More information can be found on the Akeeba Backup website: http://www.akeebabackup.com/documentation/index.html. Click on Backup Now to prepare for the backup. This step allows us to name the backup and provide a description of it. We will keep the defaults here.Click on the Backup Now button (on the right) to initiate the backup process.The duration of the backup depends on the size of the website. We will see the following message if the backup process is successful. Click on Administer Backup Files to download the ZIP file. Creating a live website from the backup Akeeba Backup provides us with a seamless process for restoring websites from backups. The restoration process requires the backup file and a hosting environment, that meets the Joomla! installation requirements. But before we restore our site, we need to log in to our remote server and create a database. To run the restoration, we will need the database name, server information (this could be localhost or a unique hostname), and a database username and password. Make sure that the database user has been assigned all privileges on the database. We have purchased a hosting account from http://www.hostmonster.com and, as we can see from the following screenshot, the domain is parked. Hostmonster has a good array of open source and proprietary software. One of our favorite Hostmonster services is Simplescript, which is accessible through the Hostmonster Cpanel. This service simplifies the installation and upgrade processes of a select number of open source software applications. Let's create a live site from the local backup: Upload the Akeebabackup.zip file (site backup file) and the kickstart.php file into the root folder of our hosting account. The remote root folder could be public_html, www, htdocs, or a sub-folder, depending on the hosting setup. The upload of the Akeebabackup.zip (site backup file) and the kickstart. php files can be done by using the Control Panel of the hosting account, or through an FTP (File Transfer Protocol) client such as FileZilla. FileZilla is an open source FTP client that can be downloaded from the official website: http://filezilla-project.org/. Run the kickstart.php script by browsing to the site address, for instance, http://www.yourwebsite.com/kickstart.php—in our case, this is http://www.kifari.com/kickstart.php. This will activate the website's restoration wizard online. Keep the default settings and click on Start, as illustrated in the following screenshot. The wizard will walk us through the extraction of the backup files, and complete the migration process. We are not using FTP Options, so we will not put any information in here.Click on Start, and let the wizard do its thing. The wizard will prompt us to enter the correct details as needed. We will be required to enter the database name, hostname, database username, and password. If the installation is successful, we will be prompted to remove the installation directory. Although the system provides a link to remove the installation directory, we need to check the root folder to make sure that the installation folder has been deleted. We may need to manually remove the folder. Our website address is http://www.kifari.com; browse to this address. Congratulations! We have migrated our site from the local server to a remote server. Note that our site is restored with its configuration, and administrator username and password intact. We do not have to install Joomla! for the migration process. The backup file contains all of the necessary files for the complete migration of the website from the local server to the remote server. Once the backup has been installed, we will have the same Joomla! version as we did when the backup was created. In review, we have restored our development website on a remote server by using the Joomla! backup and restoration component Akeebabackup. Signing up for an account It is important to understand the user profile settings as a way of determining what tools are available to users to facilitate their interaction with others in the network. Also, as an administrator we have to understand that interaction among site users depends on how we configure the site, especially in terms of the default user profile settings and the applications that we make available to the users. Let's create a new profile, by signing up for an account: Click on Sign Up--Become a Reviewer. Sign up for an account by clicking on JOIN US NOW, IT'S FREE. Enter the required registration information, and then click on Next. Notice that some of the information is marked with an asterix (*) alongside it. This means that those fields are required. Complete the requirements as set by the administrator. The registration process also encourages us to upload our image or avatar. We can skip this process and change our image later. We may want to pay attention to the maximum file size and width of the image that we can upload. The maximum file size for uploads that shows here is the maximum size defined in the php.ini file. we set the maximum image upload size to 8 MB? This means that users cannot upload images larger than 8 MB. After we click on Skip, we will get a message stating that an activation link has been sent to our e-mail account. This serves as a verification of the account and an anti-spam mechanism. If we want users to start working on their profile without activating their account, the settings can be changed from the administrative back-end by going to Site Global Configurations | System | User settings|. Click on the Sign Up--Become a Reviewer link. Notice that there are now two users in the system. Managing an account In this section, we are going to manage a user profile by editing the profile, changing profile pictures and profile privacy settings, and adding applications and privacy settings for those applications.
Read more
  • 0
  • 0
  • 1773

article-image-jailbreaking-ipad-ubuntu
Packt
20 Jul 2010
3 min read
Save for later

Jailbreaking the iPad - in Ubuntu

Packt
20 Jul 2010
3 min read
(For more resources on Ubuntu, see here.) What is jailbreaking? Jailbreaking an iPhone or iPad allows you to run unsigned code by unlocking the root account on the device. Simply, this allows you to install any software you like - without the restriction of having to be in the main Apple app store. Remember, jailbreaking is not SIM unlocking. Jailbreaking voids the Apple-supplied warranty. What does this mean for developers? The mass availability of jailbreaking for these devices allows developers to write apps without having to shell out Apple's developer fees. Previously a one-off payment of $300 US, an "official" developer must now pay $100 US each year to keep the right to develop applications. What jailbreaks are available? Arguably the most advanced jailbreak available now is called Spirit. Though unlike a few others, which can now hack iOS 4.0, Spirit differs in a few key features. Not only is Spirit the first to be able to jailbreak the iPad, but this jailbreak also allows an "untethered" jailbreak - you won't have to plug it into a computer every boot to "keep" it jailbroken. Support for jailbreaking iOS 4.0 is coming soon for Spirit. There are tutorials on jailbreaking using Spirit, like this one, but they generally skip over the fact that there's a Linux version, and only talk about Windows and/or OS X. Jailbreaking the iPad A very simple process, you can now jailbreak the iPad very quickly thanks to excellent device support and drivers in Ubuntu. Please note that from now on, you should only plug in the device to iTunes 9 before 9.2, or better still, just use Rhythmbox or gtkpod to manage your library. Install git if you haven't already got it: sudo apt-get install git Clone the Spirit repository: git clone http://github.com/posixninja/spirit-linux.git Install the dev package for libimobiledevice: sudo apt-get install libimobiledevice-dev Enter the Spirit directory and build the program: cd spirit-linux make I've noticed that though Ubuntu has excellent Apple device support, and you can mount these devices just fine, that the jailbreak program won't detect the device without iFuse. Install this first: sudo apt-get install ifuse Now for the fun! Plug in your iPad (you'll see it under the Places menu) and run the jailbreak: ./spirit You'll see output similar to this: INFO: Retriving device listINFO: Opening deviceINFO: Creating lockdownd clientINFO: Starting AFC serviceINFO: Sending files via AFC.INFO: Found version iPad1,1_3.2INFO: Read igor/map.plistINFO: Sending "install"INFO: Sending "one.dylib"INFO: Sending "freeze.tar.xz"INFO: Sending "bg.jpg"INFO: Sending files completeINFO: Creating lockdownd clientINFO: Starting MobileBackup serviceINFO: Beginning restore processINFO: Read resources/overrides.plistDEBUG: add_fileDEBUG: Data size 922:DEBUG: add_fileDEBUG: Data size 0:DEBUG: start_restoreDEBUG: Sending fileDEBUG: Sending fileINFO: Completed restoreINFO: Completed successfully The device will reboot, and if all went well, you'll see a new app called Cydia on the home screen. This is the app that allows you to install other apps. Open Cydia. Cydia will ask you to choose what kind of user you are. There's no harm in choosing Developer; you'll just see more information. Also, if you choose the bottom level (User) console packages like OpenSSH will be hidden from you. You'll also receive some updates; install them. Interestingly, Cydia uses the deb package format, just like Ubuntu: That's it! Wasn't that quick?
Read more
  • 0
  • 0
  • 30306

article-image-configuring-apache-and-nginx
Packt
19 Jul 2010
8 min read
Save for later

Configuring Apache and Nginx

Packt
19 Jul 2010
8 min read
(For more resources on Nginx, see here.) There are basically two main parts involved in the configuration, one relating to Apache and one relating to Nginx. Note that while we have chosen to describe the process for Apache in particular, this method can be applied to any other HTTP server. The only point that differs is the exact configuration sections and directives that you will have to edit. Otherwise, the principle of reverse-proxy can be applied, regardless of the server software you are using. Reconfiguring Apache There are two main aspects of your Apache configuration that will need to be edited in order to allow both Apache and Nginx to work together at the same time. But let us first clarify where we are coming from, and what we are going towards. Configuration overview At this point, you probably have the following architecture set up on your server: A web server application running on port 80, such as Apache A dynamic server-side script processing application such as PHP, communicating with your web server via CGI, FastCGI, or as a server module The new configuration that we are going towards will resemble the following: Nginx running on port 80 Apache or another web server running on a different port, accepting requests coming from local sockets only The script processing application configuration will remain unchanged As you can tell, only two main configuration changes will be applied to Apache as well as the other web server that you are running. Firstly, change the port number in order to avoid conflicts with Nginx, which will then be running as the frontend server. Secondly, (although this is optional) you may want to disallow requests coming from the outside and only allow requests forwarded by Nginx. Both configuration steps are detailed in the next sections. Resetting the port number Depending on how your web server was set up (manual build, automatic configuration from server panel managers such as cPanel, Plesk, and so on) you may find yourself with a lot of configuration files to edit. The main configuration file is often found in /etc/httpd/conf/ or /etc/apache2/, and there might be more depending on how your configuration is structured. Some server panel managers create extra configuration files for each virtual host. There are three main elements you need to replace in your Apache configuration: The Listen directive is set to listen on port 80 by default. You will have to replace that port by another such as 8080. This directive is usually found in the main configuration file. You must make sure that the following configuration directive is present in the main configuration file: NameVirtualHost A.B.C.D:8080, where A.B.C.D is the IP address of the main network interface on which server communications go through. The port you just selected needs to be reported in all your virtual host configuration sections, as described below. The virtual host sections must be transformed from the following template <VirtualHost A.B.C.D:80> ServerName example.com ServerAlias www.example.com [...]</VirtualHost> to the following: <VirtualHost A.B.C.D:8080> ServerName example.com:8080 ServerAlias www.example.com [...]</VirtualHost> In this example, A.B.C.D is the IP address of the virtual host and example.com is the virtual host's name. The port must be edited on the first two lines. Accepting local requests only There are many ways you can restrict Apache to accept only local requests, denying access to the outside world. But first, why would you want to do that? As an extra layer positioned between the client and Apache, Nginx provides a certain comfort in terms of security. Visitors no longer have direct access to Apache, which decreases the potential risk regarding all security issues the web server may have. Globally, it's not necessarily a bad idea to only allow access to your frontend server. The first method consists of changing the listening network interface in the main configuration file. The Listen directive of Apache lets you specify a port, but also an IP address, although, by default, no IP address is selected resulting in communications coming from all interfaces. All you have to do is replace the Listen 8080 directive by Listen 127.0.0.1:8080; Apache should then only listen on the local IP address. If you do not host Apache on the same server, you will need to specify the IP address of the network interface that can communicate with the server hosting Nginx. The second alternative is to establish per-virtual-host restrictions: <VirtualHost A.B.C.D:8080> ServerName example.com:8080 ServerAlias www.example.com [...] Order deny,allow allow from 127.0.0.1 allow from 192.168.0.1 eny all</VirtualHost> Using the allow and deny Apache directives, you are able to restrict the allowed IP addresses accessing your virtual hosts. This allows for a finer configuration, which can be useful in case some of your websites cannot be fully served by Nginx. Once all your changes are done, don't forget to reload the server to make sure the new configuration is applied, such as service httpd reload or /etc/init.d/ httpd reload. Configuring Nginx There are only a couple of simple steps to establish a working configuration of Nginx, although it can be tweaked more accurately as seen in the next section. Enabling proxy options The first step is to enable proxying of requests from your location blocks. Since the proxy_pass directive cannot be placed at the http or server level, you need to include it in every single place that you want to be forwarded. Usually, a location / { fallback block suffices since it encompasses all requests, except those that match location blocks containing a break statement. Here is a simple example using a single static backend hosted on the same server: server { server_name .example.com; root /home/example.com/www; [...] location / { proxy_pass http://127.0.0.1:8080; }} In the following example, we make use of an Upstream block allowing us to specify multiple servers: upstream apache { server 192.168.0.1:80; server 192.168.0.2:80; server 192.168.0.3:80 weight=2; server 192.168.0.4:80 backup;} server { server_name .example.com; root /home/example.com/www; [...] location / { proxy_pass http://apache; }} So far, with such a configuration, all requests are proxied to the backend server; we are now going to separate the content into two categories: Dynamic files: Files that require processing before being sent to the client, such as PHP, Perl, and Ruby scripts, will be served by Apache Static files: All other content that does not require additional processing, such as images, CSS files, static HTML files, and media, will be served directly by Nginx We thus have to separate the content somehow to be provided by either server. Separating content In order to establish this separation, we can simply use two different location blocks—one that will match the dynamic file extensions and another one encompassing all the other files. This example passes requests for .php files to the proxy: server { server_name .example.com; root /home/example.com/www; [...] location ~* .php.$ { # Proxy all requests with an URI ending with .php* # (includes PHP, PHP3, PHP4, PHP5...) proxy_pass http://127.0.0.1:8080; } location / { # Your other options here for static content # for example cache control, alias... expires 30d; }} This method, although simple, will cause trouble with websites using URL rewriting. Most Web 2.0 websites now use links that hide file extensions such as http://example.com/articles/us-economy-strengthens/; some even replace file extensions with links resembling the following: http://example.com/useconomy- strengthens.html. When building a reverse-proxy configuration, you have two options: Port your Apache rewrite rules to Nginx (usually found in the .htaccess file at the root of the website), in order for Nginx to know the actual file extension of the request and proxy it to Apache correctly. If you do not wish to port your Apache rewrite rules, the default behavior shown by Nginx is to return 404 errors for such requests. However, you can alter this behavior in multiple ways, for example, by handling 404 requests with the error_page directive or by testing the existence of files before serving them. Both solutions are detailed below. Here is an implementation of this mechanism, using the error_page directive : server { server_name .example.com; root /home/example.com/www; [...] location / { # Your static files are served here expires 30d; [...] # For 404 errors, submit the query to the @proxy # named location block error_page 404 @proxy; } location @proxy { proxy_pass http://127.0.0.1:8080; }} Alternatively, making use of the if directive from the Rewrite module: server { server_name .example.com; root /home/example.com/www; [...] location / { # If the requested file extension ends with .php, # forward the query to Apache if ($request_filename ~* .php.$) { break; # prevents further rewrites proxy_pass http://127.0.0.1:8080; } # If the requested file does not exist, # forward the query to Apache if (!-f $request_filename) { break; # prevents further rewrites proxy_pass http://127.0.0.1:8080; } # Your static files are served here expires 30d; }} There is no real performance difference between both solutions, as they will transfer the same amount of requests to the backend server. You should work on porting your Apache rewrite rules to Nginx if you are looking to get optimal performance.
Read more
  • 0
  • 0
  • 16506

article-image-creating-content-social-networking-using-joomla
Packt
19 Jul 2010
9 min read
Save for later

Creating Content in Social Networking using Joomla!

Packt
19 Jul 2010
9 min read
We want our website (http://www.kifari.com) to be the next most discussed thing in the blogosphere. Our site is a social networking site that can list and review cell phone applications.Cell phone applications are currently grouped into Apple and Droid apps, and one needs to visit a specific brand or cell phone company site to find out more about these applications. The Apple store provides product overviews of their apps and identifies staff picks and the pick of the week. There are also some customer reviews.A rating system for Droid apps with any of the mobile phone companies is yet to be set up by any of the cell phone companies. The idea here is to set up a social networking system that will offer a system for rating iPhone and Droid apps that is independent of the companies that sell or manufacture these products. The site is aimed at providing an open and transparent social networking environment for the exchange of listings and reviews. This information sharing and rating system will provide users with a platform on which to showcase what they have done or can do with the specific apps they have on their phones. The information from this network could provide app developers with insightful information about specific apps. And it could help provide users and potential buyers with valuable information regarding product capabilities and limitations.Such a service has the potential to provide users with information and thereby offer potential users of specific apps the opportunity to make informed purchases. It may also provide developers with insight to product capabilities and limitations, which could be used to improve existing products or facilitate the creation of new apps. Installing SOBI2 SOBI is a free GPL Joomla! component that allows for the creation of professional directory and review systems for Joomla!-driven sites. And it integrates seamlessly with JomSocial through the requisite plugins. SOBI can be downloaded from the official website, at http://www.sigsiu.net. To perform this installation and integration, we will need the following: SOBI2 for Joomla! 1.5 (com_sobi2-RC2.9.2.4.j15). The Latest Reviews Module (SOBI2_LatestReviewed_Module). We may need to unzip this file and upload the one for Joomla! 1.5. The Latest Entries Module (SOBI2_Latest_Module). We may also need to unzip this file and upload the one for Joomla! 1.5. The SOBI2 Reviews & Ratings Plugin (reviews_plugin), this should be the one compatible with SOBI2 (2.9.x). This plugin should be installed through the SOBI2 plugin system, and not through the regular Joomla! extension installation system. A plugin to integrate SOBI2 with JomSocial, which can be found on the JomSocial website (under Addons). The My SOBI2 Entries plugin will enable users to display their listings under their profile (plg_sobiposts-0.2.zip). The SOBI2 component, modules, and plugins are installed just like any other Joomla! extension. As with similar Joomla! components, it is always good to configure the extension before using it. To configure SOBI, we need to do the following: Go to the administrative back-end, and then click on Components | SOBI2 | General Configuration. Most of the default configuration settings work well. The SOBI2 Configuration has various options, namely: Custom Fields Manager: This allows us to edit, add, or remove information fields that we want users to include in their entries. General Configuration: Some of the notable features that we may want to change under General Configuration include the Component Name, which will be the name of our directory. We will name ours "Rate, Share and Review Apps". The other thing would be how many entries per line; the default is 1; this can always be changed depending on the intended final look. Entry Configuration: These settings define how we want entries to be categorized. This also includes an option to charge a fee for entries. All our entries are free. View Configuration: This includes how we want entries to appear. Payment Options: If users are charged, this provides options for payment. Language Manager: This comprises of the languages that we want to use on the site. Registry Editor: Leave it as it is. Recount Categories: To re-count how many categories are available. Uninstall SOBI2: To uninstall SOBI2. We also want to categorize apps by phone type, such as Droid, Apple,Blackberry, or Others, with other broad categories such as games, business,books, music, shopping, fitness, and so forth. Click on Entries & Categories | Add Category. We can also add brief descriptions of each category. Here are the categories that we have created. Click on Configuration | Custom Fields Manager. This allows us to customize the types of reviews and items that we want users to write about on our site. Our listings will include: Name of the app Cost Brief description of what it does In the end, users will have the ability to select the categories that the app belongs to. We can specify that users can put in apps up to five categories, or whatever the settings may determine. Now, let's install the SOBI2 ratings and review system. This is done through the SOBI Configuration | Plugins | Plugin Manager. Install the reviews plugin. Click on the plugin to configure it. Towards the end of the configuration settings, there are additional things that need to be done to the code. This shows us different files where we need to insert specific codes. Let's take the first line, and break it down: Place "<?php echo $plugins['reviews']; ?>" in your Details View Template on the place where you want to show the reviews and the add review/ ratings form.   This is telling us to place the part in quotes "<?php echo $plugins['reviews'];?>" in a specific template called Details View Template. To do that: First, save this configuration. Go to Templates & CSS, and then click on the Details View Template, as illustrated in the following screenshot.   This will open the editable code of the Details View Template. (Note that the Details View Template is what appears after users complete the forms list apps.) This will make a review link appear on each entry. We want the form to appear at the end of the description. <?php /** * @version $Id: sobi2.details.tmpl.php 5379 2010-02-26 17:30:01Z Sigrid Suski $ * @package: Sigsiu Online Business Index 2 * =================================================== * @author * Name: Sigrid & Radek Suski, Sigsiu.NET GmbH * Email: sobi[at]sigsiu.net * Url: http://www.sigsiu.net * =================================================== * @copyright Copyright (C) 2006 - 2010 Sigsiu.NET GmbH (http:// www.sigsiu.net). All rights reserved. * @license see http://www.gnu.org/licenses/old-licenses/gpl- 2.0.html GNU/GPL. * You can use, redistribute this file and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. */ /*please do not remove this line */ defined( '_SOBI2_' ) || ( trigger_error("Restricted access", E_ USER_ERROR) && exit() ); /* -------------------------------------------------------------- * This is the template for the Details View * ------------------------------------------------------- */ ?> <?php HTML_SOBI::renewal( $config,$mySobi ); ?> <table class="sobi2Details" <?php echo $style; ?> > <tr> <td><?php echo $ico; ?><h1><?php echo $mySobi->title; ?></ h1></td> </tr> <tr> <td><?php echo $img; ?></td> </tr> <tr> <td><?php HTML_SOBI::showGoogleMaps($mySobi, $config); ?></td> </tr> <tr> <td> <div id="sobi2outer"> <?php HTML_SOBI::waySearchUrl( $waySearchLink,$config ); ?> <?php echo HTML_SOBI::customFieldsData( $fieldsFormatted );?> <br /> </div> </td> </tr> </table> <table class="sobi2DetailsFooter" width="100%"> <tr> <td> <?php HTML_SOBI::addedDate($config,$mySobi); ?> &nbsp;&nbsp; <?php HTML_SOBI::showHits($config,$mySobi);?> </td> <td><?php HTML_SOBI::editButtons($config,$mySobi); ?></td> </tr> </table> <?php echo $plugins['reviews']; ?> Place "<?php echo $this->plugins['reviews']->showRating($mySobi->id);?>" in your Details View Template on the place where you want to show the rating results (stars). We want this to appear alongside the title: Save and go to the V-Card Template. Place "<?php echo $plugins['reviews']; ?>" in your V-Card Template on the place where you want to show the reviews (numbers) and ratings(stars) results. We placed the code below the title. We saved any changes that we made. Comprehensive documentation is available on the SOBI2 website (http://www.sigsiu.net/). After setting up SOBI2, we need to activate the SOBI2's JomSocial plugins, similar to activating any plugin. This can be done by clicking on Components | JomSocial | Applications. We will rename My SOBI Entries to My Listings. Because the main goal of this site is for users to provide app reviews, we will make My Listings part of the core profile applications (that is, all users will have this as part of their core profile, and cannot remove it).   A Joomla! component cannot be used without a link to it. So we need to go to our menu manager and create a link to our SOBI2 component. To create a link to our new component, carry out the steps below: Create a link to the SOBI2 component and call it Listings. Go to Menu | Main Menu | New SOBI2 | Latest entries. SOBI2 provides us with various menu options. We will create a menu for visitors to our site to view listings ,as shown in the following screenshot: Save, refresh, and let's view what we have on the front-end. Notice that we have a new link. When we click on this link as a guest to the site, we will see the latest app review listings. There are no apps listed at this time because we have not entered any. We have configured the SOBI component and it is ready for use.
Read more
  • 0
  • 0
  • 1582

article-image-use-templates-report-using-birt
Packt
19 Jul 2010
2 min read
Save for later

Use of Templates in Report using BIRT

Packt
19 Jul 2010
2 min read
Templates Templates are predesigned report layouts. Building a report from a template Templates, for the most part, take the leg work out of having to recreate the same layout over and over again.With templates, we could either use the existing, canned Listing Report template or build our own, saving your time for more complex tasks. It's as simple as creating a new report, using a template, and following the Cheat Sheets. In this example, we are going to use a Grouped Listing report template to create a simple Employee Sales Detail report, which we will use as a target for a drill down report. Create a new report called Employee Sales Details Report.rptDesign.Do not go through the wizard; stop at the template selection dialog. On the New Report – Template screen, select Grouped Listing report. When the report design opens, the Cheat Sheet is open on the right-hand side. It lays out a series of steps to create a basic report. As we already have the data source created in our library, go ahead and add the data source from the library, and click on the skip option for the data source hint. For the dataset, click on the Click to perform option. Name the dataset Get Employee Sales, and use the following query: select EMPLOYEES.EMPLOYEENUMBER, EMPLOYEES.LASTNAME || ', ' || EMPLOYEES.FIRSTNAME name, ORDERDETAILS.PRICEEACH sales, ORDERS.ORDERDATEfrom EMPLOYEES, CUSTOMERS, ORDERS, ORDERDETAILSwhere ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER and EMPLOYEES.EMPLOYEENUMBER = CUSTOMERS. SALESREPEMPLOYEENUMBER and ORDERS.CUSTOMERNUMBER = CUSTOMERS.CUSTOMERNUMBER and ORDERS.ORDERDATE between ? and ? Create two report parameters called startDate and endDate, and bind them to the data set parameters. For startDate, use the default value of 2005-01-01, and for endDate, use the default parameter of 2005-04-01. When we are back at the Cheat Sheet, we click on Click to Complete for the dataset. For the Edit Date Binding cheat sheet section, drag the fields over like next screenshot. Make the Group Header row appear with a silver background and the text appear in bold. When we drag EmployeeNumber over, it will automatically create the group on the EmployeeNumber express. Just be sure to drag it to the GroupHeader section as illustrated in the screenshot. Select the column with the Name and OrderDate fields, and select Suppress duplicates.
Read more
  • 0
  • 0
  • 3086

article-image-creating-themes-report-using-birt
Packt
17 Jul 2010
3 min read
Save for later

Creating Themes for a Report using BIRT

Packt
17 Jul 2010
3 min read
Creating themes Using the power of stylesheets and libraries, one has the ability to apply general formatting to an entire report design using themes and reuse these among different reports. Themes provide a simple mechanism to apply a wide range of styles to an entire report design without the need to manually apply them. The following example will move the styles that we have created in our library and will show how to apply them to our report using a theme. For each of the styles we have created, select them under the Outline tab and choose Export to Library…. Choose the ClassicCarsLibrary.rptLibrary file. All of the styles will reside under the defaultTheme themes section, so select this from the drop-down list that appears next to the Theme option. Repeat these steps for all styles we have created in Customer Orders.rptDesign. Delete all of the styles stored in the Customer Orders.rptDesign file. You will notice all the styles disappear from the report designer. In the Outline tab, under the Customer Orders.rptDesign file, select the root element titled Customer Orders.rptDesign. Right-click the element and select Refresh Library. The library should already be shared since we built the report using the library's data source and datasets. If it is not, open the Resource Explorer, choose ClassicCarsLibrary.rptLibrary, right-click and choose Use Library. Under the Property Editor, change the Themes drop down to ClassicCarsLibrarydefaultTheme. When we apply the theme, we will see the detail table header automatically apply the style for table-header. Apply the remaining custom styles to the two columns in the customer information section and the order detail row. Now, we know that we can create several different themes by grouping styles together in libraries. So, when developing reports, you can create several different looks that can be applied to reports, simply by applying themes to reports with the help of libraries. Using external CSS stylesheets Another stylesheet feature is the ability to use external stylesheets and simply link to them. This works out very well when report documents are embedded into existing web portals by using the portals stylesheets to keep a consistent look and feel. This creates a sense of uniformity in the overall site. Imagine that our graphics designer gives us a CSS file and asks us to design our reports around it. There are two ways one can use CSS files in BIRT: Importing CSS files Using CSS as a resource In the following examples we are going to illustrate both scenarios. I have a CSS file containing six styles—five styles that are for predefined elements in reports and one style that is a custom style. The following is the CSS stylesheet for the given report: .page { background-color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 24px; color: #336699;}.table-group-footer-1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 24px; color: #333333; background-color: #FFFFCC;}.title { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 24px; line-height: 40px; background-color: #99CC00; color: #003333; font-weight: bolder;}.table-header { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; background-color: #669900; color: #FFFF33;}.table-footer { font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; line-height: 22px; color: #333333; background-color: #CCFF99;}
Read more
  • 0
  • 0
  • 5108
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-use-stylesheets-report-designing-using-birt
Packt
17 Jul 2010
3 min read
Save for later

Use of Stylesheets for Report Designing using BIRT

Packt
17 Jul 2010
3 min read
Stylesheets BIRT, being a web-based reporting environment, takes a page from general web development toolkits by importing stylesheets. However, BIRT stylesheets function slightly differently to regular stylesheets in a web development environment. We are going to add on to the Customer Orders report we have been working with, and will create some styles that will be used in this report. Open Customer Order.rptDesign. Right-click on the getCustomerInformation dataset and choose Insert into Layout. Modify the table visually to look like the next figure. Create a new dataset called getCustomerOrders using the following query: //insert code 1 Link the dataset parameter to rprmCustomerID. Save the dataset, right-click on it, and select Insert to layout. Select the first ORDERNUMBER column. Under the Property Editor, Select Advanced. In the Property Editor, go to the Suppress duplicates option, and change it to true. This will prevent the OrderNumber data item from repeating the value it displays down the page. In the Outline, right-click on Styles and choose New Style…. In the Pre-Defined Style drop down, choose table-header. A predefined style is an element that is already defined in the BIRT report. When selecting a predefined style, this will affect every element of that type within a report. In this case, for every table in the report, the table header will have this style applied. Under the Font section, apply the following settings: Font: Sans-Serif Font Color: White Size: Large Weight: Bold Under the Background section, set the Background Color to >b>Black. Click OK. Now, when we run the report, we can see that the header line is formatted with a black background and white font. Custom stylesheets In the example we just saw, we didn't have to apply this style to any element, it was automatically applied to the header of the order details table as it was using a predefined style. This would be the case for any table that had the header row populated with something and the same is the case for any of the predefined styles in BIRT. So next, let's look at a custom defined style and apply it to our customer information table. Right-click on the Styles section under the Outline tab and create a new style. Under the Custom Style textbox, enter CustomerHeaderInfo. Under the Font section, enter the following information: Font: Sans Serif Color: White Size: Large Weight: Bold Under the Background section, set the Background Color to Gray. Under the Box section, enter 1 points for all sections. Under the Border section, enter the following information: Style (All): Solid Color (All): White Width (All): Thin Click OK and then click Save. Select the table which contains the customer information. Select the first column. Under the Property Editor, in the list box for the Styles, select CustomerHeaderInfo. The preview report will look like the following screenshot: Right-click on the Styles section, and create a new custom style called CustomerHeaderData. Under Box, put in 1 points for all fields. Under Border, enter the following information: Style – Top: Solid Style – Bottom: Solid Color (All): Gray Click OK. Select the Customer Information table. Select the second column. Right-click on the column selector and select Style | Apply Style | CustomHeaderData. The finished report should look something like the next screenshot:
Read more
  • 0
  • 0
  • 6694

article-image-yui-28-rich-text-editor
Packt
16 Jul 2010
9 min read
Save for later

YUI 2.8: Rich Text Editor

Packt
16 Jul 2010
9 min read
(For more resources on YUI, see here.) Long gone are the days when we struggled to highlight a word in an e-mail message for lack of underlining or boldfacing. The rich graphic environment that the web provides has extended to anything we do on it; plain text is no longer fashionable. YUI includes a Rich Text Editor (RTE) component in two varieties, the basic YA-HOO.widget.SimpleEditor and the full YAHOO.widget.Editor. Both editors are very simple to include in a web page and they enable our visitors to enter richly formatted documents which we can easily read and use in our applications. Beyond that, the RTE is highly customizable and allows us to tailor the editor we show the user in any way we want. In this article we’ll see: What each of the two editors offers How to create either of them Ways to retrieve the text entered How to add toolbar commands   The Two Editors Nothing comes for free, features take bandwidth so the RTE component has two versions, SimpleEditor which provides the basic editing functionality and Editor which is a subclass of SimpleEditor and adds several features at a cost of close to 40% more size plus several more dependencies which we might have already loaded and might not add to the total. A look at their toolbars can help us to see the differences: The above is the standard toolbar of SimpleEditor. The toolbar allows selection of fonts, sizes and styles, select the color both for the text and the background, create lists and insert links and pictures. The full editor adds to the top toolbar sub and superscript, remove formatting, show source, undo and redo and to the bottom toolbar, text alignment, &ltHn> paragraph styles and indenting commands. The full editor requires, beyond the common dependencies for both, Button and Menu so that the regular HTML &ltselect> boxes can be replaced by a fancier one: Finally, while in the SimpleEditor, when we insert an image or a link, RTE will simply call window.prompt() to show a standard input box asking for the URL for the image or the link destination, the full editor can show a more elaborate dialog box such as the following for the Insert Image command: A simple e-mail editor It is high time we did some coding, however I hope nobody gets frustrated at how little we’ll do because, even though the RTE is quite a complex component and does wonderful things, there is amazingly little we have to do to get one up and running. This is what our page will look like: This is the HTML for the example: <form method="get" action="#" id="form1"> <div class="fieldset"><label for="to">To:</label> <input type="text" name="to" id="to"/></div> <div class="fieldset"><label for="from">From:</label> <input type="text" name="from" id="from" value="me" /></div> <div class="fieldset"><label for="subject">Subject:</label> <input type="text" name="subject" id="subject"/></div> <textarea id="msgBody" name="msgBody" rows="20" cols="75"> Lorem ipsum dolor sit amet, and so on </textarea> <input type="submit" value=" Send Message " /></form> This simple code, assisted by a little CSS would produce something pretty much like the image above, except for the editing toolbar. This is by design, RTE uses Progressive Enhancement to turn the &lttextarea> into a fully featured editing window so, if you don’t have JavaScript enabled, you’ll still be able to get your text edited, though it will be plain text. The form should have its method set to “post”, since the body of the message might be quite long and exceed the browser limit for a “get” request, but using “get” in this demo will allow us to see in the location bar of the browser what would actually get transmitted to the server. Our page will require the following dependencies: yahoo-dom-event.js, element-min.js and simpleeditor-min.js along its CSS file, simpleeditor.css. In a <script> tag right before the closing </body> we will have: YAHOO.util.Event.onDOMReady(function () { var myEditor = new YAHOO.widget.SimpleEditor('msgBody', { height: '300px', width: '740px', handleSubmit: true }); myEditor.get('toolbar').titlebar = false; myEditor.render();}); This is all the code we need turn that &lttextarea> into an RTE; we simply create an instance of SimpleEditor giving the id of the &lttextarea> and a series of options. In this case we set the size of the editor and tell it that it should take care of submitting the data on the RTE along the rest of the form. What the RTE does when this option is true is to set a listener for the form submission and dump the contents of the editor window back into the &lttextarea> so it gets submitted along the rest of the form. The RTE normally shows a title bar over the toolbar; we don't want this in our application and we eliminate it simply by setting the titlebar property in the toolbar configuration attribute to false. Alternatively, we could have set it to any HTML string we wanted shown on that area Finally, we simply render the editor. That is all we need to do; the RTE will take care of all editing chores and when the form is about to be submitted, it will take care of sending its data along with the rest. Filtering the data The RTE will not send the data unfiltered, it will process the HTML in its editing area to make sure it is clean, safe, and compliant. Why would we expect our data to contain anything invalid? If all text was written from within the RTE, there would be no problem at all as the RTE won't generate anything wrong, but that is not always the case. Plenty of text will be cut from somewhere else and pasted into the RTE, and that text brings with it plenty of existing markup. To clean up the text, the RTE will consider the idiosyncrasies of a few user agents and the settings of a couple of configuration attributes. The filterWord configuration attribute will make sure that the extra markup introduced by text pasted into the editor from MS Word does not get through. The markup configuration attribute has four possible settings: semantic: This is the default setting; it will favor semantic tags in contrast to styling tags, for example, it will change &ltb> into &ltstrong>, &ltti&g into &ltem> and &ltfont> into &ltspan style="font: …. css: It will favor CSS style attributes, for example, changing &ltb> into &ltspan style="font-weight:bold">. default: It does the minimum amount of changes required for safety and compliance. xhtml: Among other changes, it makes sure all tags are closed such as &ltbr />, &ltimg />, and &ltinput />.   The default setting, which is not the default, offers the least filtering that will be done in all cases; it will make sure tags have their matching closing tags, extra whitespace is stripped off, and the tags and attributes are in lower case. It will also drop several tags that don't fit in an HTML fragment, such as &lthtml> or &ltbody>, that are unsafe, such as &ltscript> or &ltiframe>, or would involve actions, such as &ltform> or form input elements. The list of invalid tags is stored in property .invalidHTML and can be freely changed. More validation We can further validate what the RTE sends in the form; instead of letting the RTE handle the data submission automatically, we can handle it ourselves by simply changing the previous code to this: YAHOO.util.Event.onDOMReady(function () { var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event; var myEditor = new YAHOO.widget.SimpleEditor('msgBody', { height: '300px', width: '740px' }); myEditor.get('toolbar').titlebar = false; myEditor.render(); Event.on('form1', 'submit', function (ev) { var html = myEditor.getEditorHTML(); html = myEditor.cleanHTML(html); if (html.search(/<strong/gi) > -1) { alert("Don't shout at me!"); Event.stopEvent(ev); } this.msgBody.innerHTML = html; });}); We have dropped the handleSubmit configuration attribute when creating the SimpleEditor instance as we want to handle it ourselves. We listen to the submit event for the form and in the listener we read the actual rich text from the RTE via .getEditorHTML(). We may or may not want to clean it; in this example, we do so by calling .cleanHTML(). In fact, if we call .cleanHTML() with no arguments we will get the cleaned-up rich text; we don't need to call .getEditorHTML() first. Then we can do any validation that we want on that string and any of the other values. We use the Event utility .stopEvent() method to prevent the form from submitting if an error is found, but if everything checks fine, we save the HTML we recovered from the RTE into the &lttextarea>, just as if we had the handleSubmit configuration attribute set, except that now we actually control what goes there. In the case of text in boldface, it would seem easy to filter it out by simply adding this line: myEditor.invalidHTML.strong = true; However, this erases the tag and all the content in between, probably not what we wanted. Likewise, we could have set .invalidHTML.em to true to drop italics, but other elements are not so easy. RTE replaces a &ltu> (long deprecated) by &ltspan style="text-decoration:underline;"> which is impossible to drop in this way. Besides, these replacements depend on the setting of the markup configuration attribute. This example has also served us to see how data can be read from the RTE and cleaned if desired. Data can also be sent to the RTE by using .setEditorHTML(), but not before the editorContentLoaded event is fired, as the RTE would not be ready to receive it. In the example, we wanted to manipulate the editor contents, so we read it and saved it back into the &lttextarea> in separate steps; otherwise, we could have used the .saveHTML() method to send the data back to the &lttextarea> directly. In fact, this is what the RTE itself does when we set handleSubmit to true.
Read more
  • 0
  • 0
  • 5623

article-image-creating-reporting-site-using-birt-extension
Packt
16 Jul 2010
3 min read
Save for later

Creating a Reporting Site using BIRT-An Extension

Packt
16 Jul 2010
3 min read
Bug status The next report we are going to undertake is the report to show open issues compared to all bugs. What we are trying to build here is a graph that shows, by category, the bugs that are open in relation to the total number of bugs for that category. No other grouping is required. Under the graph, we also want to show a list of open bugs that we can click on and have them drill down to the detail for that bug so that we can see the history of changes to that bug. What this means is we need a bar graph showing all the status. Open BugzillaReportsTemplate.rptTemplate and save as bugStatusReport.rptDesign. Drag getAllBugs over to the Report Designer. Delete all columns except the bug_status field and short_desc field. In the table, group data by the components' name. With the new category created in the Table, insert a new column on the right. Delete the header labels. Move the data fields to look like the following screenshot: In the Outline tab, select the root element. Apply bugZillaTheme. In the group header row with the name, apply the DetailTableHeader style. In the Detail row, apply the DetailTableRow style. In the header row, select all the cells and merge them. In to the new merged cell, insert a chart. Select a Bar Chart and change the Output Format to PNG. Open the Select Data tab. Set the Inherit Data from Container drop-down list to Inherit Columns Only. Drag the bug_status field to the Optional Y Series Grouping slot. Drag the name field to the Category (X) Series slot. Click on the Edit group and sorting button. In the Group and sorting dialog, check the Enabled checkbox. Set the Type to Text. Set the Interval to 0. Set the Aggregate Expression to Count. As the Value (Y) Series, enter 1. Under the Format Chart tab, go to Title. Enter the title as Bug Status Report. Select the Axis option. Under X-Axis, check the Stagger checkbox. Click Finish. Resize the chart to fit the number of categories. The last thing we need to do is add the drill-through from the descriptions to the bug detail. Select the short_desc data item in the report designer. Under the Property Editor, select the Hyperlink tab. Click on the Edit... button next to Link To. From the Hyperlink dialog, select the Drill-through as Hyperlink type. Select BugzillaDetailReport.rptDesign as the target report. Set up the target report parameter bugID to be linked to row["bug_id"]. Click OK and save the report.
Read more
  • 0
  • 0
  • 2243

article-image-creating-reporting-site-using-birt
Packt
16 Jul 2010
4 min read
Save for later

Creating a Reporting Site using BIRT

Packt
16 Jul 2010
4 min read
The environment In this setup, we are utilizing a Bugzilla 2.22.1 instance set up on Ubuntu 7.10 Gutsy Gibbon. Bugzilla has been set up to run under Apache and is connected to a MySQL 5 database. While newer versions of Bugzilla and Ubuntu are available, the steps should remain the same. There is a single product, called BIRT Book. Under this product, there are several components as illustrated in the following screenshot: Requirements The most important thing to have prior to building reports is the requirements. Imagine being a carpenter trying to build a house without any blueprints. We need to have some idea what we are trying to build before we undertake the task of building reports. The following list shows a set of requirements that we have for this project. These are actually fairly sparse in terms of requirements. In my experience, requirements range from an extremely detailed set of Use Case documents, to mock-ups done in spreadsheets or some graphic format. These are the reports the users are looking for: Detailed report about bug. Show who it is assigned to, take in bug ID as a parameter, will be target for all drill down hyperlinks in other reports. Report to show overall status of issues. This report will drill down to a detailed list of issues. A report showing list of bugs assigned to a developer when provided with login details. Performance report for users, showing percentage of issues in the form of finished state versus open state. Creating libraries In the case of these reports, we have a pretty good idea what kinds of things we want reusable. First, we know that all of these reports will contain the same data source, a MySQL connection to the Bugzilla database. We will also want to create a consistent header and layout for the reports. So, we will create a library containing the data source and the header, and create a template containing both. We will also create the stylesheets we want to use to make things consistent throughout the reports. Let's get on with this: Create a new reporting project called Bugzilla Reports. Create a new library called bugzillaReportsLibrary.rptLibrary in the newly created project. Switch to the Outline view in bugzillaReportsLibrary.rptLibrary. Create a new JDBC data source called bugzillaDataSource. As we are using MySQL, we need to use the Manage Drivers dialog under the Data Source setup to install the MySQL JDBC driver. The following is the dialog screen where we edit the MySQL Connector-J driver to have a description and template JDBC URL: Input the correct JDBC URL and driver for Bugzilla. Select the Themes option under the Outline tab. Change the name of the theme to bugZillaTheme. Create a new custom style called masterPageHeader. Input the following parameters for the Style: Under the Font tab: Background color: White Weight: Bold Font: Sans-Serif Under the Background tab: Background color: RGB(64,0,128) Select the Master Pages element under the Outline tab. Change the name of the Master Page from Simple Master Page to BugzillaMasterPage. Select the Master Page tab in the Report Designer. Insert a grid into the header with 1 column and 1 row. Insert a Label component into the grid cell. Enter the text as Bugzilla Reports. In the Report Designer, right-click on the Grid, and select Style. Under Style, select Apply Style | bugzillaTheme.masterPageHeader. The following is the master page with the grid and style applied: Create a new dataset called getAllBugs. Use the following query: SELECT bugs.bug_id, bugs.bug_severity, bugs.bug_status, bugs.short_desc, profiles.userid, profiles.login_name, profiles.realname, components.id, components.name, components.descriptionFROM bugs, profiles, componentsWHERE bugs.component_id = components.id AND bugs.assigned_to = profiles.userid In the project, create a new template called BugzillaReportsTemplate.rptTemplate. In the newly created template, open the Resource Explorer tab and the Outline tab. Drag-and-drop the bugzillaDataSource, getAllBugs, and BugzillaMasterPage components from the library to the template. From the Outline, delete the Simple Master Page from the template. Save the template.
Read more
  • 0
  • 0
  • 1653
article-image-flash-10-multiplayer-game-introduction-lobby-and-room-management
Packt
14 Jul 2010
7 min read
Save for later

Flash 10 Multiplayer Game: Introduction to Lobby and Room Management

Packt
14 Jul 2010
7 min read
(For more resources on Flash and Games, see here.) A lobby, in a multiplayer game, is where people hang around before they go into a specific room to play. When the player comes out of the room, the players are dropped into the lobby again. The main function of a lobby is to help players quickly find a game room that is suited for them and join. When the player is said to be in a lobby, the player will be able to browse rooms within the lobby that can be entered. The player may be able to see several attributes and the status of each game room. For example, the player will be able to see how many players are in the room already, giving a hint that the game in the room is about to begin. If it is a four-player game and three are already in, there is a greater chance that the game will start soon. Depending on the game, the room may also show a lot of other information such as avatar names of all the players already in the room and who the host is. In a car race game, the player may be able to see what kind of map is chosen to play, what level of difficulty the room is set to, etc. Most lobbies also offer a quick join functionality where the system chooses a room for the player and enters them into it. The act of joining a room means the player leaves the lobby, which in turn means that the player is now unaware or not interested in any updates that happen in the lobby. The player now only receives events that occur within the game room, such as, another player has entered or departed or the host has left and a new host was chosen by the server. When a player is in the lobby, the player constantly receives updates that happen within the lobby. For example, events such as new room creation, deletion, and room-related updates. The room-related updates include the players joining or leaving the room and the room status changing from waiting to playing. A sophisticated lobby design lets a player delay switching to the room screen until the game starts. This is done so as to not have a player feel all alone once they create a room and get inside it. In this design, the player can still view activities in the lobby, and there's an opportunity for players to change their mind and jump to another table (game room) instantaneously. The lobby screen may also provide a chatting interface. The players will be able to view all the players in the lobby and even make friends. Note that the lobby for a popular game may include thousands of players. The server may be bogged down by sending updates to all the players in the lobby. As an advanced optimization, various pagination schemes may be adopted where the player only receives updates from only a certain set of rooms that is currently being viewed on the screen. In some cases, lobbies are organized into various categories to lessen the player traffic and thus the load on the server. Some of the ways you may want to break down the lobbies are based on player levels, game genres, and geographic location, etc. The lobbies are most often statically designed, meaning a player may not create a lobby on the fly. The server's responsibility is to keep track of all the players in the lobby and dispatch them with all events related to lobby and room activity. The rooms that are managed within a lobby may be created dynamically or sometimes statically. In a statically created room, the players simply occupy them, play the game, and then leave. Also in this design, the game shows with a bunch of empty rooms, say, one hundred of them. If all rooms are currently in play state, then the player needs to wait to join a room that is in a wait state and is open to accepting a new player into the room. Modeling game room The game room required for the game is also modeled via the schema file (Download here-chap3). Subclassing should be done when you want to define additional properties on a game room that you want to store within the game room. The properties that you might want to add would be specific to your game. However, some of the commonly required properties are already defined in the GameRoom class. You will only need to define one such subclass for a game. The following are the properties defined on the GameRoom Class: Property Notes Room name Name of the game room typically set during game room creation Host name The server keeps track of this value and is set to the current host of the room. The room host is typically the creator. If the host leaves the room while others are still in it, an arbitrary player in the room is set as host. Host ID Is maintained by the server similar to host name. Password Should be set by the developer upon creating a new game room. Player count The server keeps track of this value as and when the players enter or leave the room. Max player count Should be set by the developer upon creating a new game room. The server will automatically reject the player joining the room if the player count is equal to the max player count Room status The possible values for this property are GameConstants.ROOM_STATE_WAITING or GameConstants.ROOM_STATE_PLAYING The server keeps track of these value-based player actions such as PulseClient.startGame API. Room type The possible values for this property are value combinations of GameConstants.ROOM_TURN_BASED and GameConstants.ROOM_DISALLOW_POST_START The developer should set this value upon creating a new room. The server controls the callback API behavior based on this property. Action A server-reserved property; the developer should not use this for any purpose. The developer may inherit from the game room and specify an arbitrary number of properties. Note that the total number of bytes should not exceed 1K bytes. Game room management A room is where a group of players play a particular game. A player that joins the room first or enters first is called game or room host. The host has some special powers. For example, the host can set the difficulty level of the game, set the race track to play, limit the number of people that can join the game, and even set a password on the room. If there is more than one player in the room and the host decides to leave the room, then usually the system automatically chooses another player in the room as a host and this event is notified to all players in room. Once the player is said to be in the room, the player starts receiving events for any player entering or leaving the room, or any room-property changes such as the host setting a different map to play, etc. The players can also chat with each other when they are in a game room. Seating order Seating order is not required for all kinds of games, for example, a racing game may not place as much importance on the starting position of the player's cars, although the system may assign one automatically. This is also true in the case of two-player games such as chess. But players in a card game of four players around a table may wish to be seated at a specific position, for example, across from a friend who would be a partner during the game play. In these cases, a player entering a room also requests to sit at a certain position. In this kind of a lobby or room design, the GUI shows which seats are currently occupied and which seats are not. The server may reject the player request if another player is already seated at the requested seat. This happens when the server has already granted the position to another player just an instant before the player requested and the UI was probably not updated. In this case, the server will choose another vacant seat if one is available or else the server will reject the player entrance into the room.
Read more
  • 0
  • 0
  • 12867

article-image-managing-certificates-tcl
Packt
14 Jul 2010
8 min read
Save for later

Managing Certificates from Tcl

Packt
14 Jul 2010
8 min read
(For more resources on Tcl, see here.) Once we know how to create and sign certificates, the next step is to create a simple solution that would allow us to build an infrastructure using these keys. We'll create a server that handles creating certificates for clients and exports a simple service over HTTPS. The following is a diagram of how communication from the client will look like: Our example will be performing the following steps: The client requests a new key and certificate from the server; the client will check if the other side is valid by comparing the server's certificate against certificate authority's certificate, which the client needs to already have The server provides the client with new key and certificate The client can request information over HTTPS using newly created key and certificate The server will be able to authenticate the other side by checking if the certificate is signed by certificate authority All further communication can use HTTPS as a proper key has been provided to the client. Our example will have a server that can create a complete certificate authority, create, and sign its own key. It will also offer a HTTPS server that will only accept requests from clients using a valid certificate. We will use the recently mentioned code for managing CA and server / client keys. Additionally, our server will provide an SSL-enabled server for clients to request certificates. This server will not require a valid certificate. This would allow any client to request a certificate that would then be used for communicating over HTTPS. This is needed because the HTTPS server will not allow any incoming connections without a valid certificate. We'll create a dedicated service just for creating the key and a signed certificate that accepts connections without a valid certificate. While the server will not be able to authenticate clients at this point, client will be able to use CA certificate to verify that a server can be trusted. In a typical application, the client would start by requesting a new certificate if it does not have it. The HTTPS server would be used for communication, once the certificate has been issued. In order to simplify the example, the protocol for requesting a certificate is very simple. A client connects over the SSL-encrypted socket. At this point the client does not have a valid certificate yet, so this will not be checked. It sends a single line specifying the command, common name, and e-mail address for the certificate. The server generates it and sends a response. It sends a single line containing a result, which is true or false, followed by the size of the key and certificate file in bytes. Next the key and certificate are sent as binary data. Since the client knows their sizes, it reads this back to key and certificate files. After retrieving a valid certificate, the client can now connect over HTTPS using a valid certificate and issue other commands. In many cases, the infrastructure could also be extended to provide multiple servers. In this case, only one server would offer certificate creation—for both clients and servers. From then on communication could be made with all servers. Server side Let's start by creating server side of our sample application. It will be built up from two things—a server for issuing certificates and the HTTPS server for invoking commands for clients with valid certificates. The server side of the application will store all keys and certificates in the keys subdirectory. It will keep CA key and certificate, its own key and certificate, and certificates of all other systems in the network. Although keeping all certificates is not necessary, it is used as a mechanism for detecting whether a specified client has already had its key generated or not. First we'll set up our server name, create a Certificate Authority, and create this server's certificate, if it does not exist yet: set server "server1"sslkeys::initialize CN "CertificateAuthority"set sslkey [file join $sslkeys::keydirectory $server.key]set sslcert [file join $sslkeys::keydirectory $server.crt]if {![file exists $sslkey]} { sslkeys::createAndSign server $server CN $server} Next, we'll set up a tls package to use these keys and that requires a valid certificate: tls::init -keyfile $sslkey -certfile $sslcert -cafile [file join $sslkeys::keydirectory ca.crt] -require true Now let's set up the HTTPS server along with a very small application serving all requests: package require tclhttpdinitHttpd_SecureServer 9902proc secureWebServerHandle {sock suffix} { set certinfo [dict get [tls::status $sock] subject] set client "" foreach item [split $certinfo ,/] { if {[regexp "^CN=(.*)$" $item - client]} { break } } set text "Clock: [clock seconds]; Client: $client" Httpd_ReturnData $sock text/plain $text}Url_PrefixInstall / secureWebServerHandle Our server will listen for HTTPS requests on port 9902 and return information about the current time and client identifier, extracted from the SSL certificate. Since we require the certificate to be signed by a valid CA, we can assume that we can trust its value. We can now proceed to creating code for requesting certificates. We'll start by setting up an SSL-enabled server socket that, as an exception from the tls::init invocation shown in the preceding code, does not require a valid SSL certificate. It will listen on port 9901 and run the certRequestAccept command for each new connection: tls::socket -require false -server certRequestAccept 9901 Whenever a connection comes in, we configure the channel as non-blocking, set up binary translation, and set up an event each time it is readable: proc certRequestAccept {chan host port} { fconfigure $chan -blocking 0 -buffering none -translation binary fileevent $chan readable [list certRequestHandle $chan]} Every time a channel is readable, our command will try to read a line from it. If it fails, we close the channel and do nothing: proc certRequestHandle {chan} { if {[catch {gets $chan line} rc]} { catch {close $chan} } else { If reading a line did not produce an error, we proceed with checking whether the end of the file has been reached for this channel or not. If it has, we also close it: set eof 1 catch {set eof [eof $chan]} if {$eof} { catch {close $chan} } else { Otherwise we check if a line has been read successfully. The variable rc stores whatever the gets command returned; if a complete line has been read, it will contain the number of characters read. Otherwise it will be set to 1: if {$rc < 0} { return } If reading the line succeeds, we split the text on each white space to a list and assign each element of the list to variables. The first one is the command, only certificate being supported, followed by the common name and e-mail values to be used in certificate. set line [split $line] lassign $line command commonName email if {$command != "certificate"} { close $chan return } We'll also use the common name as the filename for the keys. Usually common names would be identifiers used throughout the system, such as GUIDs. The next step is to create a full path to the destination key and certificate files, and check if the certificate file exists: set keyfile [file join $sslkeys::keydirectory $commonName.key] set certfile [file join $sslkeys::keydirectory $commonName.crt] if {[file exists $certfile]} { If it exists, a client with this identifier has already requested this certificate. In this case, we send information that we refused to create a certificate and close the channel. if {[catch { puts $chan "false 0 0" flush $chan close $chan }]} { catch {close $chan} } } else { If a certificate has not been created yet, we create it and get the size of both files. sslkeys::createAndSign client $commonName CN $commonName EMAIL $email set keysize [file size $keyfile] set certsize [file size $certfile] Then, we send a response to the client specifying that a certificate has been generated and the size of both files. if {[catch { puts $chan "true $keysize $certsize" The next step is to send the contents of both files and flush the channel to make sure it gets sent: set fh [open $keyfile r] fconfigure $fh -translation binary fcopy $fh $chan close $fh unset fh set fh [open $certfile r] fconfigure $fh -translation binary fcopy $fh $chan close $fh unset fh flush $chan If writing the response produced an error, we assume that unless all data was sent, an error might have occurred. We close the socket and remove both keys and the certificate file. }]} { catch {close $fh} catch {close $chan} catch {file delete -force $keyfile} catch {file delete -force $certfile} } else { We also try to close the file handle first—if an operation such as fcopy failed, the handle might have been left open and we need to close the file handle in order to delete it. If the operation succeeds, we close the connection and only remove the private key. The certificate is left on the server for reference purposes, and for checking if it has already been passed to a client. catch {close $chan} file delete -force $keyfile } } } }} Finally we need to enter Tcl's event loop: vwait forever We now have a complete server that allows the creation of SSL keys and certificates, and offers functionality over HTTPS protocol only to authenticated peers.
Read more
  • 0
  • 0
  • 12823

article-image-organizing-microsoft-dynamics-gp-2010-extension
Packt
14 Jul 2010
7 min read
Save for later

Organizing Microsoft Dynamics GP 2010: An Extension

Packt
14 Jul 2010
7 min read
(For more resources on Microsoft, see here.) Gaining additional reporting control with Account Rollups Microsoft Dynamics GP provides great functionality for analyzing and reviewing individual accounts and sequential groups of accounts. Many users don't know that it also provides impressive functionality for analyzing non-sequential groups of accounts via a feature known as Account Rollup. Account Rollups are inquiries built to allow users to see different GP accounts rolled up together and to provide drill back capability to the details. Additionally, these queries can include calculations for things such as budget versus actual comparisons and calculations. FRx Reporter provides similar functionality and Account Rollup allows users to access this functionality without the wait time of starting up FRx. Let's see how to mix up some account rollups in this recipe. Getting ready Before using Account Rollups it's important to understand how to set them up. To set up Account Rollups, select Financial from the Navigation Pane. Then select Account Rollup in the Inquiry section to open the Account Rollup Inquiry Options window. In the Option ID field enter the name Actual vs. Budget and press Tab. Select Yes to add the option. On the right, set the number of columns to 3. In the first row type Actual in the Column Heading field and set the Type to Actuals. In the second row type Budget in the Column Heading field and set the Type to Budget. In the Selection column click on the lookup button (indicated by a magnifying glass) and select BUDGET 2008. In the third row type Difference in the Column Heading field. Set the Type to Calculated. Click on the blue arrow next to Selection to open up the Account Rollup Inquiry Calculated Column window. In the Column field select Actual and click on the double arrow (>>). Then click on the minus (-) button. Back in the Column field select Budget and click on the double arrow (>>). Click on OK. Back on the Account Rollup Inquiry Options window, select the Segment field, and then select Segment2. Use the lookup buttons (indicated by a magnifying glass) in the From and To fields to add account 4130 and click on Insert. Repeat this process to insert 4120 and then 4100 into the Restrictions box below. Click on Save and close the window Notice when looking up these accounts for selection that these numbers are not sequential; there are a number of accounts in between. How to do it... Now that we've built an account rollup let's see how to make it work: Select Account Rollup under Inquiry on the Financial Area Page. In the Option ID field look up Actual vs. Budget with the help of the lookup button (indicated by a magnifying glass). The screen will show Actual, Budget, and Difference for each period in this year. The year can be changed at the top and the Display can be changed to show either Net Change or the Period Balance for each period in the year along with a Total at the bottom, using the controls next to the Year. The Difference field is the Actual minus Budget calculation that we created when setting up the rollup: Click on a period with an amount in the Actual column and select the blue Actual link at the top. A new window will open with the included accounts and the actual amounts for each account. On drilling down to the Account Rollup Detail Inquiry Zoom window, Dynamics GP provides a checkbox option to show accounts even if these have zero balance. Additionally, an option at the top controls the printing of Account Rollup information. The rollup can be printed in Summary or in Detail. Selecting a line and clicking on Balance from the Account Rollup Detail Inquiry Zoom window drills back to the detailed transactions behind the balance: How it works... Account Rollups combine the account totals from disparate accounts for reporting. This is great for tying back multiple accounts that roll up into a single line on the financial statements. Account Rollups also work well for analyzing a single segment, such as a department, across multiple accounts. In the past, I've used this for easy comparisons of Fixed Asset general ledger accounts to the subledger and for rolling up full-time equivalent of unit accounts to get the number of employees across the company with drill back to the employees in each department. Remembering processes with an Ad hoc workflow Dynamics GP provides options for robust workflow functionality integrated with Microsoft Office SharePoint Server (MOSS) or Windows SharePoint Services (WSS). However, for many users this is more functionality than they need. Additionally, many organizations don't feel they are ready for the cost and complexity of MOSS. For users who only need a simple workflow to ensure that they remember the steps for a particular task, a basic workflow can be built using shortcuts and folders. This process works well for irregular tasks such as month-end or quarter-end processes where tasks are performed infrequently enough, thus making it easy to forget the steps. For this recipe, we'll look at setting up a basic month-end workflow. Getting ready The basic steps of this task are to create a folder to hold the workflow and then to add the steps in order to that folder. For our example, we will assume that a month-end financial closing workflow includes posting a Quick Journal, processing a Clearing Entry, and closing the month. How to do it... Here are the steps to create a basic Ad hoc workflow: Click on the Home button from the Navigation Pane on the left. This makes the Shortcut Bar available on the top left. Right-click on the Shortcut Bar and select Add | Folder to add a folder to the Shortcut Bar that can be used to organize entries. Name the folder Month End and press the Enter key. Now, there is a folder to hold month-end entries. The next step is to add our three sample entries. Select the Month End folder on the Shortcut Bar. Right-click on the folder and select Add | Add Window: Click on the plus sign (+) next to Microsoft Dynamics GP. Click on the plus sign (+) next to Financial and select the window named Quick Journal Entry. Change the name at the top to 1) Quick Journal Entry. Click on Add. Putting a number in front of the text prevents this shortcut from interfering if the same shortcut appears somewhere else on the Shortcut Bar: Next, select Clearing Entry also under Microsoft Dynamics GP and Financial. Rename it to 2) Clearing Entry in the Name field and click on Add. Finally, click on the plus sign (+) next to Company under Microsoft Dynamics GP and select Fiscal Periods Setup. Rename this to 3) Close Period and click on Add. Select Done to finish. These items will now appear on the Shortcut Bar on the left under the Month End folder. Selecting an item with the left mouse button will allow moving of these items around to adjust the order if necessary. How it works... Ad hoc workflows provide an option to group a set of steps together and make these all available in one place. Clicking on the arrow to the left of the folder closes it up and keeps the steps out of the way until these are needed. Clicking on the arrow again reopens the folder to run the steps. Some common uses include creating a basic set of steps for new users, monthend and quarter-end processes, and any other process where it is important to ensure that all of the steps are followed.
Read more
  • 0
  • 0
  • 1596
Packt
13 Jul 2010
5 min read
Save for later

Interview with Grady Brett Beaubouef—Author of Maximize Your Investment

Packt
13 Jul 2010
5 min read
How did you find the overall experience of writing your book for Packt? Even though I was a first-time author with plenty of learning opportunities, the people at Packt were there to guide me through the book writing process. Writing a book was a big dream of mine and Packt helped me realize this dream.   During the writing process, did you come across any issues/ difficulties that affected your writing and how did you overcome these? Absolutely! It is important to take document the issues/difficulties you experience and determine an action plan to address these challenges. Packt was an important part of identifying the responses to address key challenges. Key challenges I faced during writing included: marketing, organization, and positioning of key messages.   Whilst writing your book, did you find that it overshadowed personal life in any way? How did you deal with this? Yes, I think I probably spent at least 2 hours a day writing for 10 months. Writing a book is an iterative process (initial draft, 2nd draft, subject matter reviews). Having a strong family and support structure is key to success. Schedule down time between iterations to reflect and enjoy your family and friends – you will be surprised by the inspiration they can give you during your writing journey.   Was there anything interesting that happened during the writing of the book? I am living proof that anyone can write a book if they have the knowledge, experience, and the passion to translate their knowledge into words. Every individual has a least one good book in them.   How did our Acquisition Editors help you - what kind of things did they help you with and how did they support you throughout the writing process? They provided a lot of support around layouts and framing the conversation. There is a vast difference between saying something and saying something well.   Our authors usually have full-time jobs whilst writing for us. Was this the case for you and how did you approach managing your time? Managing the time was very hard work – splitting your mind between work and writing a book is a big challenge. To manage my time I made sure that I spent at least an hour writing or researching every day.   What benefits did writing a book bring to your specialist area? It brought together many experiences and tribal knowledge that were present in the minds of experienced consultants but never articulated and applied to the discipline of ERP/COTS implementations. It provided a challenge to the major players of ERP/COTS implementations to "think outside the box" and evolve to the next level of value generation. Develop implementation approaches that maximize packaged software advantages and minimize packaged software challenges Reduce implementation costs, increase knowledge generation, and reduce non-value-added implementation activities Enable customers to lead during the implementation to maximize long term success Follow the Ten Essential Principles for implementing a business solution and learn best practices, tips and tricks.   Do you have any tips for other authors, or tricks that you learned whilst writing, that you'd like to share? Be prepared to put the time in, you need to be committed and focused to write a book and it will inevitably take more time than you expect. Remember to factor in research time when doing the outline and timescale. Solicit feedback from your potential audience by writing blogs or giving presentations at events. Be prepared to make compromises, you need to work for both the publisher and the reader. Have a clear aim and don’t forget it! This is probably the single most important thing; you will not create a good book if you keep moving the goal posts. Network – Network – Network! Word of mouth and reader recommendations are a key marketing channel and may provide you with subject matter reviewers. Ask your family before committing; they will need to support you through the writing process.   Do you have any advice for other authors who may be interested in writing for Packt, but are still unsure? Have the right purpose for writing the book. If making a ton of money is your key objective then odds are this goal will not sustain you through the book writing process. However, if you are passionate about sharing knowledge and having a positive impact on others then the book writing process is a path of significant reward.   What projects, if any, are you working on at the moment? The key project I am working on is marketing my book. Writing the book is only half the battle. Key marketing activities include conducting presentations, writing blogs, and connecting with key stakeholders to get the message out. Adoption is not a one-time event but an iterative process that communicates the value your book provides.  
Read more
  • 0
  • 0
  • 1139

article-image-connecting-microsoft-sql-server-compact-35-visual-studio
Packt
13 Jul 2010
3 min read
Save for later

Connecting to Microsoft SQL Server Compact 3.5 with Visual Studio

Packt
13 Jul 2010
3 min read
SQL Server Compact Edition 3.5 can be used to create applications that are useful for a number of business uses such as: Portable applications; Occasionally connected clients and embedded applications and devices. SQL Server Compact differs from other SQL Servers in that there is just one file which can be password protected and features 128-bit file level encryption. It is referential integrity compliant; supports multiple connections; has transactions support with rich data types. In this tutorial by Jayaram Krishnaswamy, various scenarios where you may need to connect to SQL Server Compact using Visual Studio IDE (both 2008 and 2010) are described in detail. Connecting to SQL Server Compact 4.5 using Visual Studio 2010 Express (free version of Visual Studio) is also described. The connection is the starting point for any database related program and therefore mastering the connection task is crucial to work with the SQL Server Compact. (For more resources on Microsoft, see here.) If you are familiar with SQL Server you already know much of SQL Server Compact. It can be administered from SSMS and, using SQL Syntax and ADO.NET technology you can be immediately productive with SQL Server Compact.It is free to download (also free to deploy and redistribute) and comes in the form of just one code-free file. Its small foot print makes it easily deployable to a variety of device sizes and requires no administration. It also supports a subset of T-SQL and a rich set of data types. It can be used in creating desktop/web applications using Visual Studio 2008 and Visual Studio 2010. It also comes with a sample Northwind database. Download details Microsoft SQL Server Compact 3.5 may be downloaded from this site here. Make sure you download detailed features of this program from the same site. Also several bugs have been fixed in the program as detailed in the two SP's. Link to the latest service pack SP2 is here. By applying SP2 the installed version on the machine is upgraded to the latest version. Connecting to SQL Server Compact from Windows and Web projects You can use the Server Explorer in Visual Studio to drag and drop objects from SQL Server Compact provided you add a connection to the SQL Server Compact. In fact, in Visual Studio 2008 IDE you can configure a data connection without even starting a project from the View menu as shown here. When you click Add Connection... the following window will be displayed. This brings up the Add Connection dialog shown here. Click Change... to choose the correct data source for SQL Server Compact. The default is SQL Server client. The Change Data Source window is displayed as shown. Highlight Microsoft SQL Server Compact 3.5 and click OK. You are returned to Add Connection where you can browse or create a database or, choose also from a ActiveSync connected device such as a Smart phone which has a SQL Server Compact for devices installed. Presently connect to one on the computer (My Computer default option)-the sample database Northwind. Click Browse.... The Select SQL Server Compact 3.5 Database File dialog opens where your sample database Northwind is displayed as shown. Click Open. The database file is entered in the Add Connection dialogue. You may test the connection. You should get a Test connection succeeded message from Microsoft Visual Studio. Click OK. The Northwind.sdf file is displayed as a tree with Tables and View as shown in the next figure. Right click Northwind.sdf in the Server Explorer above and click Properties drop-down menu item. You will see the connection string for this conneciton as shown here.
Read more
  • 0
  • 1
  • 18109
Modal Close icon
Modal Close icon