* @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();
if ($h->cage->post->keyExists('comment_id')) {
    $user_ip = $h->cage->post->testIp('user_ip');
    $post_id = $h->cage->post->testInt('post_id');
    $comment_id = $h->cage->post->testInt('comment_id');
    $cvote_rating = $h->cage->post->testInt('rating');
    //get comment_voting settings
    $comments_settings = $h->getSerializedSettings('comments');
    if (isset($comments_settings) && isset($comments_settings['comment_bury'])) {
        $bury = $comments_settings['comment_bury'];
    }
    // Only proceed if the user is logged in
    if ($h->currentUser->loggedIn) {
        $user_id = $h->currentUser->id;
        // get comment_voting history for this comment:
        $sql = "SELECT cvote_rating FROM " . TABLE_COMMENTVOTES . " WHERE cvote_comment_id = %d AND cvote_user_id = %d";
        $comment_voting = $h->db->get_var($h->db->prepare($sql, $comment_id, $user_id));
        if ($comment_voting == $cvote_rating) {
            // Repeat comment vote. Must be from a double-click. Return false and
            $json_array = array('result' => $h->lang['comment_voting_already_voted']);
            echo json_encode($json_array);
            return false;
        }
 * @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');
        } else {
            // don't enable it if the plugin is inactive