*
 * @category  Content Management System
 * @package   HotaruCMS
 * @author    Nick Ramsay <*****@*****.**>
 * @copyright Copyright (c) 2009, Hotaru CMS
 * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @link      http://www.hotarucms.org/
 */
//$json_array = array('result'=>'test_okay');
//echo json_encode($json_array); exit;
require_once '../../../hotaru_settings.php';
require_once '../../../Hotaru.php';
// Not the cleanest way of getting to the root...
$h = new Hotaru();
$h->start();
$h->includeLanguage('updown_voting', 'updown_voting');
if ($h->cage->post->keyExists('post_id')) {
    $post_id = $h->cage->post->testInt('post_id');
    $vote_rating = $h->cage->post->testInt('rating');
    $user_ip = $h->cage->server->testIp('REMOTE_ADDR');
    $undo = false;
    // track whether we're adding a vote or undoing one.
    //get vote settings
    $updown_voting_settings = unserialize($h->getSetting('updown_voting_settings', 'updown_voting'));
    vote($h, $post_id, $vote_rating, $user_ip, $undo, $updown_voting_settings);
}
function vote($h, $post_id, $vote_rating, $user_ip, $undo, $updown_voting_settings)
{
    // Only proceed if the user is logged in
    if (!$h->currentUser->loggedIn) {
        return false;
 *
 * @category  Content Management System
 * @package   HotaruCMS
 * @author    Nick Ramsay <*****@*****.**>
 * @copyright Copyright (c) 2009, Hotaru CMS
 * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @link      http://www.hotarucms.org/
 */
//$json_array = array('result'=>'test_okay');
//echo json_encode($json_array); exit;
require_once '../../../hotaru_settings.php';
require_once '../../../Hotaru.php';
// Not the cleanest way of getting to the root...
$h = new Hotaru();
$h->start();
$h->includeLanguage('vote', 'vote');
if ($h->cage->post->keyExists('post_id')) {
    $post_id = $h->cage->post->testInt('post_id');
    $vote_rating = $h->cage->post->testInt('rating');
    $user_ip = $h->cage->server->testIp('REMOTE_ADDR');
    $referer = $h->cage->post->testAlnum('referer');
    //get vote settings
    $vote_settings = unserialize($h->getSetting('vote_settings', 'vote'));
    vote($h, $post_id, $vote_rating, $user_ip, $referer, $vote_settings);
}
function vote($h, $post_id, $vote_rating, $user_ip, $referer, $vote_settings)
{
    // Only proceed if the user is logged in
    if (!$h->currentUser->loggedIn) {
        return false;
    }
 * @package   HotaruCMS
 * @author    Nick Ramsay <*****@*****.**>
 * @copyright Copyright (c) 2009, Hotaru CMS
 * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @link      http://www.hotarucms.org/
 */
//$json_array = array('result'=>'test_okay');
//echo json_encode($json_array); exit;
//echo $_SERVER['DOCUMENT_ROOT'];
require_once '../../../hotaru_settings.php';
require_once '../../../Hotaru.php';
// Not the cleanest way of getting to the root...
$h = new Hotaru();
$h->start();
if ($h->cage->post->testAlpha('plugin') == 'widgets') {
    $h->includeLanguage('widgets');
    // Get widget settings from the database...
    $widgets_settings = $h->getSerializedSettings('widgets');
    $this_widget_function = $h->cage->post->testAlnumLines('widget');
    // get the name of this widget, e.g. widget_text_widget (function) -> text_widget (widget name)
    $this_widget_name = strstr($this_widget_function, '_');
    // get every thing after "widget_" (returns the underscore)
    $this_widget_name = ltrim($this_widget_name, '_');
    // strip the underscore off the front
    // get the name of the supporting plugin
    $this_plugin_name = $h->getPluginFromFunction($this_widget_function);
    if ($h->cage->post->testAlpha('action') == 'enable') {
        // enable a widget if plugin is active
        if ($h->isActive($this_plugin_name)) {
            $widgets_settings['widgets'][$this_widget_name]['enabled'] = true;
            $json_array = array('enabled' => 'true', 'message' => $h->lang['widgets_order_enabled'], 'color' => 'green');