Tag Archives: password

how to: boot a vmware machine via command line

19 Dec

I’m using vmware 6, so I don’t know if this works in 5 or server editions.

vmware installs a script called vmrun that allows you to perform almost anything you need to do on a vmware machine pragmatically.

sidney@my-host:~> /usr/bin/vmrun
vmrun version 6.0.4 build-93057

Usage: vmrun COMMAND [PARAMETERS]

Authentication flags
-gu
-gp

POWER COMMANDS           PARAMETERS           DESCRIPTION
start                    Path to vmx file     Start a VM or Team
                         or vmtm file
                         [gui|nogui]
stop                     Path to vmx file     Stop a VM or Team
                         or vmtm file
                         [hard|soft]
reset                    Path to vmx file     Reset a VM or Team
                         or vmtm file
                         [hard|soft]
suspend                  Path to vmx file     Suspend a VM or Team
                         or vmtm file
                         [hard|soft]

SNAPSHOT COMMANDS        PARAMETERS           DESCRIPTION
listSnapshots            Path to vmx file     List all snapshots in a VM
snapshot                 Path to vmx file     Create a snapshot of a VM
                         Snapshot name
deleteSnapshot           Path to vmx file     Remove a snapshot from a VM
                         Snapshot name
revertToSnapshot         Path to vmx file     Set VM state to a snapshot
                         Snapshot name

GUEST OS COMMANDS        PARAMETERS           DESCRIPTION
runProgramInGuest        Path to vmx file     Run a program in Guest OS
                         Program
                         [Program arguments]
fileExistsInGuest        Path to vmx file     Check if a file exists in Guest OS
                         Path to file in guest
setSharedFolderState     Path to vmx file     Modify a Host-Guest shared folder
                         Share name
                         New host path
addSharedFolder          Path to vmx file     Add a Host-Guest shared folder
                         Share name
                         Host path
removeSharedFolder       Path to vmx file     Remove a Host-Guest shared folder
                         Share name
listProcessesInGuest     Path to vmx file     List running processes in Guest OS
killProcessInGuest       Path to vmx file     Kill a process in Guest OS
                         process id
runScriptInGuest         Path to vmx file     Run a script in Guest OS
                         Interpreter path
                         script_text
deleteFileInGuest        Path to vmx file     Delete a file in Guest OS
                         File
createDirectoryInGuest   Path to vmx file     Create a directory in Guest OS
                         Directory path
deleteDirectoryInGuest   Path to vmx file     Delete a directory in Guest OS
                         Directory path
listDirectoryInGuest     Path to vmx file     List a directory in Guest OS
                         Directory path
copyFileFromHostToGuest  Path to vmx file     Copy a file from host OS to guest OS
                         Path on host
                         Path in guest
copyFileFromGuestToHost  Path to vmx file     Copy a file from guest OS to host OS
                         Path in guest
                         Path on host
renameFileInGuest        Path to vmx file     Rename a file in Guest OS
                         Original name
                         New name

GENERAL COMMANDS         PARAMETERS           DESCRIPTION
list                                          List all running VMs
upgradevm                Path to vmx file     Upgrade VM file format, virtual hw
installtools             Path to vmx file     Install Tools in Guest OS

Examples:
  vmrun list
  vmrun upgradevm w2k.vmx
  vmrun reset w2k.vmx soft
 

Yippie!

Php: how to get base domain

8 May

The problem: take a url (in this case, we’ll specify an absolute url,
http and all) and return only the base domain. For instance, given
www.domain.com’ or ’sub.subdomain.domain.com’, it should return
‘domain.com’.

Simple
enough, but now consider: ‘http://www.example_site.com.pk’ or
http://damnlimies.co.uk’ or
‘http://username:password@this.is.a.worst.shortly.subdomain.thisIsMyMainWebsite.com.cl

It is an anvil upon which many a hammer has been broken:

http://lists.evolt.org/archive/Week-of-Mon-20031201/152316.html
http://www.webmasterworld.com/forum88/10656.htm

Anyway,
I think I have a solution. I won’t bother with the details of how I
arrived at it. Suffice to say, you just need to break down your own url
parsing process. It passed the battery of tests at the end:

Phosphorus and Lime: PHP: Get Base Domain

How to: Install electroserver on media-temple dv and similar centos setups

11 Mar

Before you start

Before starting anything you should be sure that you have the developer tools package installed. If your not sure, then you don’t. No worries: submit a request to install the developer tools package and you’ll be ready in about 45min to a hour.

Get started

first login as root

next download electroserver:

wget http://www.electro-server.com/downloads/builds/ElectroServer_4_0_4_linux.rpm

next install the rpm:

rpm -iv ElectroServer_4_0_4_linux.rpm

You should now have a /opt/ElectroServer_4_0_4/ directory. browse around it and we’ll continue from there.

I had no issues up to this point, but feel free to post any problems and I’ll try to help.

Testing the install

in the /opt/ElectroServer_4_0_4/ you’ll notice a few files. to test your install run the ElectroServer command

If your lucky you’ll have no errors or issues getting the server running. I encountered an issue related to memory available. a quick reboot of the server fixed this.

Configuring the server

For this tutorial we’ll use port 8080 for the web admin, and port 9898 for our chat server. if you need to use other ports just follow along. you can also repeat this process to enable additional ports.

we’ll need to enable access to port 8080 and 9898. port 8080 will be used for the web admin, port 9898 will be used for the text (chat) connection.

to open your ports run the following:

port 8080

/sbin/iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp --dport 8080 -j ACCEPT

port 9898

/sbin/iptables -A INPUT -p tcp --dport 9898 -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp --dport 9898 -j ACCEPT 

next edit your ES4Configuration.xml which can be found at: <install directory>/server/config. if your following this tutorial on a media temple dv server this directory is /opt/ElectroServer_4_0_4/server/config/ES4Configuration.xml

ES4Configuration.xml your default configuration should look like this:

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?><ElectroServerConfiguration>

<!– This is the name of the node –>
<Name>StandAlone</Name>

<!– Defines the host and port on which the web server will listen for inbound connections –>
<WebListeners>
<WebListener>
<Host>127.0.0.1</Host>
<Port>8080</Port>
<Ssl enabled=”true”/>
</WebListener>
</WebListeners>

</ElectroServerConfiguration>

to get our server live we’ll need to give it an ip address, change 127.0.0.1 to an ip that is live on your server

Getting the server running and listening

before we can actually test our install we need to make sure that we’ve placed a crossdomain.xml at the root of the website listening at the ip used. if the ip is shared place the crossdomain file in the root of the default domain. the crossdomain.xml should be viewable at http://<electroserver ip>/crossdomain.xml, replace <electroserver ip> with the ip used in your ES4Configuration.xml.

be sure that you create allows for your running host, and any other domains that will access the server.

now restart electroserver if its already running and test if electroserver is excepting connections using telnet.

test that electroserver is running and able to listen by running telnet <electroserver ip> 8080

telnet should successfully connect. if not try shutting down all electroserver processes and start electroserver again. we’re now ready to get moving with getting our chat server running.

Use electroserver admin

the configuration used in this guide uses ssl, if your not using it then remember to use http where the guide says https.

access admin at https://<electroserver ip>:8080/admin

default user name: administrator
default password: password

once logged in go to gateways and edit the default gateway. change 127.0.0.1 to <electroserver ip>, save and restart the gateway

Test Chat Access

Electroserver by default runs chat on port 9898. restart electroserver and telnet to your electroserver ip, this time testing port 9898. your should recieve the contents of your crossdomain file as a response.

Almost Done

we’ll also need to add electroserver to our server startup. First create a file named: StartElectroServer, next  add the following to that file:

/usr/bin/nohup /usr/local/bin/ElectroServer &
exit

Place the script in you opt/electroserver directory with read and execute permissions. Now the final step link your file so it’s called at startup

ln -s /opt/ElectroServer_4_0_4/StartElectroServer /etc/rc.d/init.d/StartElectroServer

thats it, you should now be all set to run electro server.

Also to run electroserver without it closing when your console closes use: nohup ElectroServer &

Got questions? post a comment, or just post a comment to let me know this was helpful.

Sid

integrating wordpress into existing site – part 2

11 Mar

I realized I left out alot while reading part1, so i’m covering more here, an possibly in additional posts

disable plugins if not in wordpress 

You’ll need to use wordpress on the backend from time to time, mostly for login / logout functionality. You should build a connector class to handle this. When using wordpress via your class outside of your actual wordpress install you should disable you wordpress plugins. why? less to load, and i’ve found some plugins have issues when loaded by wordpress outside of the actual wordpress installation.

 in wp-settings.php near line 231 replace

if ( get_option(‘active_plugins’) ) {
$current_plugins = get_option(‘active_plugins’);
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if (” != $plugin && file_exists(ABSPATH . PLUGINDIR . ‘/’ . $plugin))
include_once(ABSPATH . PLUGINDIR . ‘/’ . $plugin);
}
}
}

with

if(!defined(‘NO_PLUGINS’)){

if ( get_option(‘active_plugins’) ) {
$current_plugins = get_option(‘active_plugins’);
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if (” != $plugin && file_exists(ABSPATH . PLUGINDIR . ‘/’ . $plugin))
include_once(ABSPATH . PLUGINDIR . ‘/’ . $plugin);
}
}
}
}

What we just did was change the plugin loading portion of wordpress to not load plugins if we define the NO_PLUGINS flag.

Loading wordpress for your connector class 
In your class file you should load the required wordpress files before your class. Something like:

if(!defined(‘DB_NAME’)) {
define(‘NO_PLUGINS’,true);
require_once(FS_WORDPRESS.’/wp-config.php’);

}

 I’m checking for wordpress by looking to see if the DB_NAME is defined. This check will tell if we’re already in wordpress, its not rocket scienece just a check for a wordpress only varibale. If it’s not defined then plugins are disabled. simple right?

 login user to wordpress at site login.

When a user logs into your site, they should automaticly be logged into wordpress. this is of course assuming that your not trying to actually keep wordpress seprated, but then again that defeats the purpose of this thing that somehow turned into a tut (pardon me i seriously need some sleep)

 wordpress was loaded via the previous code, now we’ll still need to load the specific files that contain our required wordpress functions.

require_once( ABSPATH . WPINC . ‘/registration.php’);
require_once(FS_LIBRARY.’/User.inc’);

By loading the registration.php file we’ll now have all the functions needed for handling wordpress login, logout, and registration functions. Why do we want to register a user? simple new users (or old users if you don’t want to write an import script.

the following is of course assuming that your site is setup correctly.  when a new or current user attempts to login we’ll check to see if that user can in fact login or exists. if the user exists its safe to assume that they have updated their password on the main site, so we’ll update their password, and attempt to login again. for users who aren’t already in the wordpress db, we’ll run the wordpress registration functions ( removing their validation requirement of course ). because wordpress is running as an addon to your current saite, your actual site should be handling user checking etc, and only allow valid users access to this area, and only if their username matches the user session ( sorry not covering all that right now).

heres some sample code, please note your passwords shouldn’t be in plain text format, but this sampleuses plain text passcodes to show how. you can remove the md5 functions and do your own thing from there

    /*this function adds a user to wordpress, their is no error checking as users are checked, updated, created at login*/
function register($username, $password, $email){
global $wpdb;
//make sure we have a user

if(!empty($username) && !username_exists( $username )){
/*create user and update their wordpress account to not require activation*/
@create_user($username, $password, $email);
$wpdb->query(“UPDATE $wpdb->users SET user_pass = MD5(‘$password’), user_activation_key = ” WHERE user_login = ‘$username’”);
}
}

/*this function is only called from the login function in your  site user class
at the point its called we have a valid user, so we need to make sure the user can access wordpress*/
function login($user_login, $user_pass){
global $wpdb, $_SERVER;

//attempt login
$logged_in=@wp_login($user_login, $user_pass);
/*if login fails but user name exist
then user was created by an admin
so we’ll reset their wordpress password and update their email address, just in case they changed it*/
if(!$logged_in && username_exists( $user_login )){
$user    =&new YourUserClass($user_login);

$wpdb->query(“UPDATE $wpdb->users SET user_pass = MD5(‘$user_pass’), user_email=’”.$user->emailAddress().”‘ WHERE user_login = ‘$user_login’”);
}else{
/*the user hasn’t been added to wordpress, add them */
$user    =&new YourUserClass($user_login);

WordPressConnector::register($user->userName(), $user->password(), $user->emailAddress());

}
do_action_ref_array(‘wp_authenticate’, array(&$user_login, &$user_pass));

//ok we now have a valid wordpress user
//if not logged in then login user
$logged_in=(!$logged_in) ? @wp_login($user_login, $user_pass) : $logged_in;

if($logged_in){
wp_setcookie($user_login, $user_pass, false, ”, ”, true);
do_action(‘wp_login’, $user_login);


}

return $logged_in;
}

function logout(){
global $_SERVER;
wp_clearcookie();
do_action(‘wp_logout’);  


your_site_redirect_function();
}

 

If you have any questions, leave a comment, or just leave a comment if this was helpful.

 

Sid

OpenId gets a boost

7 Feb

IBM, Google, Microsoft, Verisign and Yahoo have joined the corporate board of the OpenID Foundation, giving a boost to the group’s efforts to simplify the process of signing into Web sites.

The OpenID framework allows people to use a single user name and password to sign into sites that support it.

More than 10,000 Web sites now support OpenID log-ins, according to the foundation. Last month, Yahoo announced its 248 million active registered users could begin using their handle and password to login to non-Yahoo Web sites that support the OpenID 2.0 framework.

PC World – Major Vendors Join OpenID Board

Powered by ScribeFire.

integrating wordpress into existing site

25 Dec

this is more for my reference than anything, but I cover the areas i modified to integrate wordpress in to a clients current site. I’m posting this, mainly to keep me from having to compare files everytime i do a wp upgrade. its by no means a solid tut as there are additional site classes / templates I’ve made to integrate the look / site functionality / security that are also used and not mentioned / documented here. as i said it’s written for myself, so i’m assuming you understand php / wordpress

wp-config.php

on the very first line of config.php include either the db config file, or the site wide control include (file that handles all of the general includes, etc)

set wordpress db config to use the globally defined vars. ex: define(‘DB_NAME’,SITE_DB_NAME);

any additional wordpress only includes should be included at the end of this file.

i also added in a secondary check to see if the current site user is logged in to wordpress, you can gt the current user as follows :
$the_user= wp_get_current_user();
$user_ego=$the_user->user_login;

if the current user is logged in to the actual site, but not into wordpress, i attempt to log them in using a login function in my custom site to wordpress connector class.

wp-db

bottom of file change :
if ( ! isset($wpdb) )
$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);

to
if ( ! isset($wpdb) ){
global $wpdb;

$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
}

this will fix issues you run into when including the wordpress connections into a site / custom class.

Admin Area

open wp-admin/admin.php, setup any globals that are needed to require a vliad user for an area. ex: define(‘REQ_VALID_USER’,true)

wp-config will be included immediately after this. look for the line that says $posts_per_page, and add the something like following to limit access to the actual admin area:

global $current_user;

wp_get_current_user();

if(!empty($current_user)){
if(intval($current_user->user_level)< =WORDPRESS_LIMIT_ACCESS){//this var should be defined in your site wide define file
global $_SERVER;
$url=$_SERVER['REQUEST_URI'];
if(strpos($url,”?”)!==false){
$url=substr($url,0,strpos($url,”?”));
}
if(strpos($url,WORDPRESS_ADMIN)!==false && strpos($url,WORDPRESS_LIMIT_ADMIN_STR)===false){
header(‘location: ‘.WORDPRESS_LIMIT_PAGE) ;
exit;
}
}

}

the above code will check the curent url against the allowed urls for general users in admin, as well as redirect them to they limit page (write post) if they aren’t at the proper level. everyone else will be able to use the admin according to their level.

limiting post categories
either wp-admin/admin-functions.php or wp-admin/include/template.php

look for : function write_nested_categories( $categories ) {

limit categories as needed for general users, but be sure to leave an unmodified version for admin users.

remove nav for general users
replace : require(ABSPATH . ‘wp-admin/menu.php’); with
if(intval($current_user->user_level)>WORDPRESS_LIMIT_ACCESS){
require(ABSPATH . ‘/wp-admin/menu.php’);
}

customise nav header
wp-admin/admin-header.php

peace, sid

how to: mysql commandline dumps

6 Nov

dump to a file :

mysqldump db_name –user=user –password=password > /path/filename

add dump data to mysql database:

mysql db_name –user=user –password=password < /path/dumpfile

answers: why is myspace posting videos in my name

9 Oct

found this search term in my stats. if your searching for this you have one of three issues.

  1. your profile was harvested to make spam accounts
  2. your profile is hacked
  3. you get drunk and forget you posted them

if #1

message the account telling them to stop, add it to friends, comment as much as possible letting everyone know it’s a spammers account, and flag them ( hell have friends do it to). your issues should end there.

#2

change your password!, i recommend from a different computer in case your system is compromised. use a strong password using at least 2 of each of the following:
uppercase
lowercase
symbols
numbers

if you have problems creating one

http://www.itsimpl.com/
http://elsid.net/hi-my-name-is-coded/

#3

stop drinking so much, pick up a hobby, realize you have rain man like abilities in new said talent. get rich and famous, make big donation to elsid beer fund :)

mythbuntu : myth tv focused distro built on ubuntu

8 Oct

Can’t wait for my card to finally get supported.

Providing an Ubuntu based MythTV distribution that is easy to configure, maintain, and use. Mythbuntu 7.10 Public Beta Posted October 3rd, 2007 by Daviey The Mythbuntu team is pleased to announce the Beta of Mythbuntu-7.10. Together with this release, we’re opening the gates of our very own Mythbuntu forums at http://ubuntuforums.org/forumdisplay.php?f=301.

Please feel free to discuss and seek help with Mythbuntu. Please continue to report bugs to Launchpad https://launchpad.net/mythbuntu.
We’ve fixed a lot of bugs since Alpha 4 and also introduced some new features. Please see below for a list of new features and known problems. New Features For a quick summary of what you’ll see on this disk:

    *
  • Xfce based setup. No more openbox, it’s not even installed on the disk
  • *

  • Network Manager included. You can do wifi networks both during and after install with ease.
  • *

  • When quiting mythfrontend, you are brought back to an Xfce desktop. You can administer the machine from here and change all settings.
  • *

  • On CD Repository works properly
  • *

  • VNC can be installed from multiple locales on disk
  • *

  • Video drivers don’t pull from webhosts during install in any cases
  • *

  • ubuntu-mythtv-frontend isn’t used at all. All sessions are Xfce sessions, but all the benefits from the ubuntu-mythtv-frontend package have been merged into mythbuntu-default-settings
  • *

  • Lots of additional features for mythbuntu-control-centre. Extra administration options, package updates, reloading package lists.
  • *

  • Mythbuntu Installation can be performed directly from an existing Gutsy installation now via Firefox. See http://www.mythbuntu.org/existing-ubuntu for more information.
  • *

  • LIRC enhanced to support USB device hotplugging. The LIRC service will be automatically restarted. (You still need to restart client apps though such as myth and video playback applications)
  • *

  • New GTK theme. Based off of a clearlooks engine now instead
  • *

  • New usplash artwork.
  • Correct color scheme and placement are now used
  • *

  • mythbuntu-control-centre:

Check it out:
Mythbuntu

Powered by ScribeFire.

activate vista admin account

9 Sep

here’s the steps i took to activate admin on vista

Click start, type cmd, and right right the command promt, select run as admin, then run the following commands.

I added the extra password set, because for some reason the password didn’t take until i ran it again, so hopefully if you run it right after making the account active you should be good, if not just log back in and run it.

Net user administrator password
Net user administrator activate:yes
Net user administrator /active:yes
Net user administrator password

I’m still having issues with flex 2 builder, but maybe it’s because i have uac turned off? anyways, hope this helps