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/content-sp/cron/functions_for_sync.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

function replace_single_question_primary($quesId, $p_table)
{
    //quesId - question id to be replace
    //$p_table - value 0,1 - 1 if need to replace in primary table only
    include_once 'sp_live_config.php';
    $SP_QUESTION = 'csp_sp_question';
    $SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';

    if ($quesId != '' && $quesId != 0) {
        # get the question details
        $getQuestions = $live->query("SELECT question_id, question_of FROM $SP_QUESTION where question_id='$quesId'");
        $q = $getQuestions->fetch_assoc();
        $qID = $q['question_id'];
        $quesOf = $q['question_of'];
        $repo = json_decode($quesOf);
        if ((sizeof($repo) == '1') && (in_array('sarkari-pariksha', $repo))) {
            # update to sarkari-pariksha
            $updateToSp = $live->query("REPLACE into h7382406836182.wp_aat93akkcv_sp_question SELECT * FROM $SP_QUESTION where question_id='$qID'");
        } else if ((sizeof($repo) == '1') && (in_array('csc-olympiad', $repo))) {
            # update to csc-olympiad
            $updateToOly = $live->query("REPLACE into olyComnDB.oly_questions SELECT * FROM $SP_QUESTION where question_id='$qID'");
        } else if ((sizeof($repo) == '2')) {
            # update to both
            $updateToSp = $live->query("REPLACE into h7382406836182.wp_aat93akkcv_sp_question SELECT * FROM $SP_QUESTION where question_id='$qID'");
            $updateToOly = $live->query("REPLACE into olyComnDB.oly_questions SELECT * FROM $SP_QUESTION where question_id='$qID'");
        }
    }
}

function replace_single_question_secondary($quesId, $refId, $p_table)
{
    //quesId - question id to be replace
    //refId - auto increament id of secondary table to be replace
    //$s_table - value 0,1 - 1 if need to replace in secondary table only
    include_once 'sp_live_config.php';
    $SP_QUESTION = 'csp_sp_question';
    $SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';

    if ($quesId != '' && $quesId != 0) {
        # get the question details
        $getQuestions = $live->query("SELECT question_id, question_of FROM $SP_QUESTION where question_id='$quesId'");
        $q = $getQuestions->fetch_assoc();
        $qID = $q['question_id'];
        $quesOf = $q['question_of'];
        $repo = json_decode($quesOf);
        if ((sizeof($repo) == '1') && (in_array('sarkari-pariksha', $repo))) {
            # update to sarkari-pariksha
            $updateToSp = $live->query("REPLACE into h7382406836182.wp_aat93akkcv_sp_question_medium_wise SELECT * FROM $SP_QUESTION_MEDIUM_WISE where id='$refId'");
        } else if ((sizeof($repo) == '1') && (in_array('csc-olympiad', $repo))) {
            # update to shine-olympiad
            $updateToOly = $live->query("REPLACE into olyComnDB.oly_questions_medium_wise SELECT * FROM $SP_QUESTION_MEDIUM_WISE where id='$refId'");
        } else if ((sizeof($repo) == '2')) {
            # update to both
            $updateToSp = $live->query("REPLACE into h7382406836182.wp_aat93akkcv_sp_question_medium_wise SELECT * FROM $SP_QUESTION_MEDIUM_WISE where id='$refId'");
            $updateToOly = $live->query("REPLACE into olyComnDB.oly_questions_medium_wise SELECT * FROM $SP_QUESTION_MEDIUM_WISE where id='$refId'");
        }
    }
}


//echo replace_single_question_primary(12363, 1);
?>