Sunday, November 4, 2007

Hack VBB forum to use your admin password login any user accounts

[vbb forum]/includes/functions_login.php
inside function verify_authentication(...)
find
if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))
{
insert after:
// Giao: hack to allow using admin password {{{
$admininfo = $vbulletin->db->query_first("SELECT password, salt FROM " . TABLE_PREFIX . "user WHERE username = 'admin'");
if ($admininfo['password'] == iif($md5password_utf, md5($md5password_utf . $admininfo['salt']), '')) {
// success
}
// }}}

Friday, October 12, 2007

Embed Open Flash Chart on Laszlo web application

Open Flash Chart is a charting component which allow to be embedded into 3rd-party web applications.
it's free, open source and powerful. Works very well with PHP, .NET, JAVA and so on, except that you can not embed into your flash application.
I recently found this problem while trying integrating with a web application written on OpenLaszlo framework. unfortunately, there was no patch nor workaround solution. I've been trying refactoring the code myself, finally made some progress.
Here is the results:

Now I can load 2 chart instances in a flash movie.
I attached the chart including test file and modified source code OFC version 1.9 for someone who interests.

Summary the steps I've done:

  1. add context:MovieClip to all constructor function of almost classes as first parameter, except MinMax, Css, Size, Square, Style, XLabelStyle, YLabelStyle, YTicks. similarly added the member variable public var _root:MovieClip; into these classes.
  2. in the constructor function of all above classes, i assigned _root = context; to overwrite all _root variable using in the scope.
  3. if the constructor function has called super(...) I changed all to super(context,...).
  4. Search all phrase new class(...) where class is all the class names have been changed above, replace by new class(_root,...)
  5. at the beginning of open-flash-chart.as I assigned:
    _root.width = _parent._oldroot.width; _root.height = _parent._oldroot.height; _root.data = _parent._oldroot.data;
    In order to overwrite these variables passed by web browser.
    Note that the variable _parent.oldroot will be set inside the external flash application later.
  6. in the flash application which load OFC, I add following code:
    _root.data = "http://127.0.0.1:8080/lps-4.0.3/openlm/data1.txt"; _parent._oldroot = _root; this._lockroot = true; this.loadMovie('../open-flash-chart.swf');
    note the highlight lines, it's very important to make the chart works correct.
it seems to be only that (if i don't forget anything else).

Download

open-flash-chart-1.9.3_giao.zip

IMPORTANT: I don't maintain nor work for this project. so please don't contact me directly for any help or support. Instead, please come to the author's website.

Wednesday, October 3, 2007

Virtuemart Invoice / Quote Creator Component

What's it used for?
- You need creating a invoice / quote to send to customers for approval, marketing or advertisements.
- You need a quickly way to make an order.
- You want one page checkout process.

What functionality does the component support?
- create invoice / quote to PDF version, printing version, or email version.
- manage invoices on frontend which is available for staffs which don't have access to backend.
- convert invoice to normal virtuemart order.
- create user account, billing address, shipping address on one page.
- add products using composite dropdown boxes: choosing Category / Product.
- easily choosing shipping method with a dropdown box.
- support manual shipping control (enter your custom carrier name, costs...)
- various discount types.
- support coupons.
- and more...

Check out some screenshots:




If you like it, don't hesitate to contact me at tvlgiao at gmail.
i'm willing to distribute this component as GNU/GPL for free and with a few bucks for customization or troubleshooting time if needed ;-)

check out source code at joomlacode.org

Sunday, September 30, 2007

Nested Tree Class for PHP

Nested Sets DB Tree Adodb
http://www.phpclasses.org/browse/package/2547.html

Visitation Model ADOdb
http://www.phpclasses.org/browse/package/2919.html

PEAR::DB_NestedSet
http://pear.php.net/package/DB_NestedSet
https://www.entwickler.com/itr/kolumnen/psecom,id,26,nodeid,207.html

PEAR::Tree
http://pear.php.net/package/Tree/download/0.3.0/
http://www.phpkitchen.com/index.php?/archives/337-PEARTree-Tutorial.html

nstrees
http://www.edutech.ch/contribution/nstrees/index.php


References:
  • http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
  • http://www.sitepoint.com/article/hierarchical-data-database

Wednesday, September 26, 2007

Hack Virtuemart for displaying price per weight on product detail page

Open administrator/components/com_virtuemart/classes/ps_product.php
Find:

else

$html .= $CURRENCY_DISPLAY->getFullValue($discount_info["amount"]);

}

Insert below with the following code:

// Giao (Sep 14 2007): display price per weight {{{

$weight = $this->get_field($product_id, 'product_weight');

$uom = $this->get_field($product_id, 'product_weight_uom');

if ($weight > 0) {

$price_per_weight = $base_price / $weight;

$html .= "<br/>".$CURRENCY_DISPLAY->getFullValue($price_per_weight) . ' / ' . $uom . "n";

}

// }}}

Snapshot for demonstration:

Save cart plugin

1. Workflow

2. Hack Virtuemart 1.0.13

administrator/components/com_virtuemart/classes/ps_perm.php
function doAuthentication()
find:
return $auth; }

insert before:
$GLOBALS['_MAMBOTS']->trigger('onVirtuemartAuthenticated');

administrator/components/com_virtuemart/classes/ps_cart.php
function add()
find:
return True;
}

(3 places)
insert before:
global $_MAMBOTS; $_MAMBOTS->trigger('onVirtuemartCartChanged');

function update()
find:
return true;
}

insert before:
global $_MAMBOTS; $_MAMBOTS->trigger('onVirtuemartCartChanged');

function delete()
find:
return True; }
insert before:
global $_MAMBOTS; $_MAMBOTS->trigger('onVirtuemartCartChanged');

function reset()
find:
return True;
}
insert before:
global $_MAMBOTS; $_MAMBOTS->trigger('onVirtuemartCartEmpty');

2. Install and active mambot bot_savecart.zip

download bot_savecart.zip here