includes/comment.php
changeset 334 c72b545f1304
parent 328 dc838fd61a06
child 345 4ccdfeee9a11
equal deleted inserted replaced
333:32429702305e 334:c72b545f1304
    78    */
    78    */
    79    
    79    
    80   function process_json($json)
    80   function process_json($json)
    81   {
    81   {
    82     global $db, $session, $paths, $template, $plugins; // Common objects
    82     global $db, $session, $paths, $template, $plugins; // Common objects
    83     $parser = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
    83     $data = enano_json_decode($json);
    84     $data = $parser->decode($json);
       
    85     $data = decode_unicode_array($data);
    84     $data = decode_unicode_array($data);
    86     if ( !isset($data['mode']) )
    85     if ( !isset($data['mode']) )
    87     {
    86     {
    88       $ret = Array('mode'=>'error','error'=>'No mode defined!');
    87       $ret = Array('mode'=>'error','error'=>'No mode defined!');
    89       echo $parser->encode($ret);
    88       echo enano_json_encode($ret);
    90       return $ret;
    89       return $ret;
    91     }
    90     }
    92     if ( getConfig('enable_comments') == '0' )
    91     if ( getConfig('enable_comments') == '0' )
    93     {
    92     {
    94       $ret = Array('mode'=>'error','error'=>'Comments are not enabled on this site.');
    93       $ret = Array('mode'=>'error','error'=>'Comments are not enabled on this site.');
    95       echo $parser->encode($ret);
    94       echo enano_json_encode($ret);
    96       return $ret;
    95       return $ret;
    97     }
    96     }
    98     $ret = Array();
    97     $ret = Array();
    99     $ret['mode'] = $data['mode'];
    98     $ret['mode'] = $data['mode'];
   100     $ret['avatar_directory'] = getConfig('avatar_directory');
    99     $ret['avatar_directory'] = getConfig('avatar_directory');
   344         {
   343         {
   345           $ret = Array(
   344           $ret = Array(
   346           'mode' => 'error', 
   345           'mode' => 'error', 
   347           'error' => 'You are not authorized to moderate comments.'
   346           'error' => 'You are not authorized to moderate comments.'
   348           );
   347           );
   349           echo $parser->encode($ret);
   348           echo enano_json_encode($ret);
   350           return $ret;
   349           return $ret;
   351         }
   350         }
   352         
   351         
   353         $cid = (string)$data['id'];
   352         $cid = (string)$data['id'];
   354         if ( !preg_match('#^([0-9]+)$#i', $cid) || intval($cid) < 1 )
   353         if ( !preg_match('#^([0-9]+)$#i', $cid) || intval($cid) < 1 )
   381           'mode' => 'error', 
   380           'mode' => 'error', 
   382           'error' => $data['mode'] . ' is not a valid request mode'
   381           'error' => $data['mode'] . ' is not a valid request mode'
   383           );
   382           );
   384         break;
   383         break;
   385     }
   384     }
   386     echo $parser->encode($ret);
   385     echo enano_json_encode($ret);
   387     return $ret;
   386     return $ret;
   388   }
   387   }
   389   
   388   
   390 } // class Comments
   389 } // class Comments
   391 
   390