Making joomla com_rokin component show a specific sub album/ gallery

Imho one of the greatest joomla components is com_rokin developed by pageworks.nl. The component makes it easy to integrate web albums in your joomla CMS, one of the great features is the integration with picassa and flickr. This means you can host your pictures on picassa or plickr and incorporate them in your local CMS.

One of the frustrating things however is that there is no default seperation in webalbums …like in picassa it is not possible to have your albums devided in subalbums…

I have changed the com_rokin component a little to make it aware of subalbums, by default com_rokin shows you all the galleries you have configured.

Things you have to do to get a page from com_rokin which displays only 1 gallery:

  • login to the database and see what albums you have configured: select * from jos_rokin_galleries you can use this data in your query you will use later on in this story
  • vi administrator/components/com_rokin/lib/rokin.common.php
  • edit the function get_rokin_request()
  • make up a variable which you will pass in your url and add it to your function, for example: $chrisParam = getReqParamVal(“chrisParam”);
  • change the query in the function get_rokin_request: $database->setQuery(“select * from #__rokin_galleries where 1=1 “); into $database->setQuery(“select * from #__rokin_galleries where username=’$chrisParam’ “);
  • in your menu create a link to the com_rokin component with the parameter you have defined above, for eg: http://beertjes.com/index.php?option=com_rokin&Itemid=21&chrisParam=bopuck

 

Making hosts trust eachother with keys

generate a key on your hosts…for example a .dsa key: ssh-keygen -t dsa this will generate a ~/.ssh/id_dsa.pub and a ~/.ssh/id_dsa file copy the contents of the .id_dsa.pub file and put it on the host you want to be trusted on…

scp ~/.ssh/id_dsa.pub @:/tmp login to the remote host append the contents of the public key to the authorized_keys file in the ~/.ssh directory cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys

Pasting text into vi without indenting

Ever wanted to copy some text from a client (for eg windows machine) and paste it into a text file on a linux machine using vi….then you get the text all messed up in your file…

just remove the identation in vi press escape type: :set paste

and then paste your text…et voila

How to start/stop Weblogic ALSB services with java code

With the following code you can connect to a Weblogic server get it’s context and manipulate it’s domain objects (starting/ stopping servers, change properties of the domain logging/ jdbc datasource properties etc etc)

In order to get the following code working you need to incorporate the following jar’s in your classpath:

  • weblogic.jar (from /bea alsb dir/modules)JMXServiceURL serviceURL = new JMXServiceURL(“t3”, hostname, port, “/jndi/” + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME); Hashtable h = new Hashtable(); h.put(Context.SECURITY_PRINCIPAL, username); h.put(Context.SECURITY_CREDENTIALS, password); h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, “weblogic.management.remote”); JMXConnectorFactory connection = JMXConnectorFactory.connect(serviceURL, h); MBeanServerConnection mbconn = connection .getMBeanServerConnection(); domainRuntimeServiceMBean = (DomainRuntimeServiceMBean) MBeanServerInvocationHandler.newProxyInstance(mbconn, new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME)); domainMBean = domainRuntimeServiceMBean.getDomainConfiguration();

 

// Now the ALSB specific related stuff:

// With the following code you can connect to an ALSB server (which is a weblogic server with ALSB templates/ deployments) get it’s context and manipulate it’s domain objects (starting/ stopping services, change properties etc etc)

// In order to get the following code working you need to incorporate the following jar’s in your classpath:

  • configfwk_1.1.0.0.jar (from /bea alsb dir/modules)
  • sb-kernel-api.jar (from /bea alsb dir/alsb/lib) SessionManagementMBean sm = (SessionManagementMBean) domainService.findService(SessionManagementMBean.NAME, SessionManagementMBean.TYPE, null); ALSBConfigurationMBean acmb =(ALSBConfigurationMBean)domainService.findService(ALSBConfigurationMBean.NAME + “.” + sessionName, ALSBConfigurationMBean.TYPE, null); // Create a session, it is wise to give the session a unique name sm.createSession(sessionName); // For Proxy services ProxyServiceQuery psQuery = new ProxyServiceQuery(); // For Business services BusinessServiceQuery bsQuery = new BusinessServiceQuery(); Set refs = acmb.getRefs(psQuery);

 

// configurationMBean for Proxy Services ProxyServiceConfigurationMBean proxyServiceConfigurationMBean = (ProxyServiceConfigurationMBean)domainService.findService(ProxyServiceConfigurationMBean.NAME + “.” + sessionName,ProxyServiceConfigurationMBean.TYPE, null); // configurationMBean for Business Services BusinessServiceConfigurationMBean businessServiceConfigurationMBean = (BusinessServiceConfigurationMBean)domainService.findService(BusinessServiceConfigurationMBean.NAME + “.” + sessionName,BusinessServiceConfigurationMBean.TYPE, null); // Iterate through a list of Busness Service and do stuff… refs = acmb.getRefs(bsQuery); for (Ref ref : refs) { // use the ref object to do things }

// When finished store your session to commit your changes String CLOSE_AND_COMMIT_REMARK = “some remark to identify your change with”; sm.activateSession(sessionName, CLOSE_AND_COMMIT_REMARK + sessionName);

Java yesterday’s date

Ever had to calculate yesterday’s date in a little java proggie… use the roll function of the Gregorian Caledar…

// Create the calendar object, default is todays date GregorianCalendar gc = new GregorianCalendar(); then go back… a day gc.roll(Calendar.DAY_OF_YEAR, -1);

Be aware …if it’s the 1st of January (new year…) then you need to roll back a year as well….

How to decrypt 3DES BEA Weblogic passwords

Weblogic stores its passwords in the config.xml and boot.properties using the 3DES encryption algorithm. Nice about it is that is not a hash algorithm…meaning if you know the key you can decrypt the encrypted 3DES string. So this part is the secret: Weblogic uses the SerializedSystemIni.dat file in the security directory of your domain as your key. This file was generated when the domain was created.

This piece of code can decrypt the 3DES string for you:

[java]

import weblogic.security.internal.SerializedSystemIni;
import weblogic.security.internal.encryption.ClearOrEncryptedService;

public class DrieDesDecrypter {

static ClearOrEncryptedService ces;

public static String decryptString(String securityDir, String encryptedString) throws Exception {
ces = new ClearOrEncryptedService(SerializedSystemIni.getEncryptionService(securityDir));
encryptedString = encryptedString.replace("\\", "");
return ces.decrypt(encryptedString);
}
}

[/java]

You need to have the weblogic.jar (the one which the domain is using) in your classpath. The securityDir parameter is the Directory where the SerializedSystemIni.dat resides, the encryptedString parameter is the encrypted String…the return value…is what you wanted…

Have fun,

Chris

Set Linux Runlevel

Almost every Linux system has the following 7 runlevels:

0 halt 1 Single-User Mode Does not configure network interfaces, start daemons, or allow non-root logins. 2 Multi-User Mode Does not configure network interfaces or start daemons. 3 Multi-User Mode with Networking Starts the system normally. 4 Not used/User-definable for special purposes 5 X11 As runlevel 3 + display manager 6 Reboot

In the versions of Linux I use you can change the startup runlevel in the following file: /etc/inittab the line you are looking for will be something like:

id:3:initdefault:

Reset Unix/ Linux root password

What do you do if you have a new system with no users with sudo rights and you don’t remember your root password.

One of the options is to restart your system in runlevel 1 and then type: ‘passwd’ to change your root password

You can get into runlevel 1 with a rescue cd or when you have the grub bootloader installed append the available bootline and put the runlevel at the end of the line…

grub append> ro root=/dev/VolGroup00/LogVol00 rhgb quiet becomes grub append> ro root=/dev/VolGroup00/LogVol00 rhgb quiet 1

you get this dialogue by pressing the ‘a’ button in the grub dialogue