HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/selfanalyse/wp-content/plugins/psychometrics/api/psy_classes.php
<?php

/***
 * @purpose : Used for selfanalyse classes
 * @author Rohit Kashyap
 * @since 22/07/2020 >> dd/mm/yyyy
 * @version 0.1
 * @copyright Copyright (C) 2020 Graposs Edutech Ltd. All rights reserved.
 * @license Graposs Edutech Ltd.
 */

/***
 * define header and include config
 */
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include("../../../../wp-config.php");

global $wpdb;
$PSY_ABILITY_CLASS = $wpdb->prefix . PSY_ABILITY_CLASS;

$type = $_REQUEST['type'];

if ($type == 'single') {
    $class_id = $_REQUEST['wht_class'];

    if ($class_id != '' && is_numeric($class_id) && strlen($class_id) <= 20) {

        $getClass = $wpdb->get_row("SELECT class_id, class_name FROM $PSY_ABILITY_CLASS where class_id='$class_id' and status='1'");

        $classArray = array();
        // foreach($getClass as $c){

        $classArray[] = array("class_id" => $getClass->class_id, "class_name" => $getClass->class_name);
        // }
    } else {
        $classArray[] = array("error" => "No data found");
    }
}

if ($type == 'select') {

    $getClass = $wpdb->get_results("SELECT class_id, class_name FROM $PSY_ABILITY_CLASS where status='1'");

    $classArray = array();
    foreach ($getClass as $c) {

        $classArray[] = array("class_id" => $c->class_id, "class_name" => $c->class_name);
    }
}


echo json_encode($classArray);