Example #1
0
function blog_form_ajax_callback()
{
    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && isset($_POST) && $_POST['blogform'] == 'newpost') {
        // if has error i.e. "(bool)true" return the result from validate_blog_form()
        $valid_res = validate_blogform();
        if ($valid_res['status'] > 0) {
            // returns valid params
            $store_post = array('post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => $_POST['blogtextarea'], 'post_status' => 'publish', 'post_date' => date('Y-m-d H:i:s'), 'post_author' => 1, 'post_category' => null);
            $post_id = wp_insert_post($store_post);
            $response = wp_remote_get(esc_url_raw(get_permalink(13)));
            // DB table holds ID#13<<< for /blog pageid | no need to escape entities
            if (!is_wp_error($response)) {
                $page_src = wp_remote_retrieve_body($response);
            } else {
                $page_src = '';
            }
            $patternlp = '/(?<=startlistposts-ajaxcall9382 -->)(.*)(?=<!-- endlistposts-ajaxcall9382)/s';
            preg_match($patternlp, $page_src, $listposts);
            exit_json(array('status' => $post_id, 'post_url' => get_permalink($post_id), 'msg' => $valid_res['msg'], 'page_src' => $listposts[0]));
        } else {
            exit_json($valid_res);
        }
    }
    exit;
}
Example #2
0
 /**
  *  If this is an ajax request, we exit json
  *  Otherwise redirect to the page we either came from, or $_GET[return_uri]
  */
 public function finish()
 {
     $p = $this->page;
     if ($p->is_ajax_request) {
         exit_json($this->response);
     }
     $to = $_GET['return_uri'] ?: $_SERVER['HTTP_REFERER'];
     $get = $this->response['status'] == 'OK' ? array('status' => 'OK') : $this->response;
     $get = '?return=' . rawurlencode(serialize($get));
     $p->redirect($to . $get, 302);
 }
Example #3
0
$tab_parametres['version_base']               = VERSION_BASE_STRUCTURE;
$tab_parametres['webmestre_uai']              = $WS_uai;
// $tab_parametres['webmestre_denomination']     = $denomination;
  /* AJOUT DEBUT */
$tab_parametres['etablissement_denomination'] = $tab_etablissement['denomination'];
$tab_parametres['connexion_departement'] = '69';
$tab_parametres['connexion_mode']        = 'cas';
$tab_parametres['connexion_nom']         = 'laclasse';
$tab_parametres['cas_serveur_host']      = 'www.laclasse.com';
$tab_parametres['cas_serveur_port']      = '443';
$tab_parametres['cas_serveur_root']      = 'sso';
  /* AJOUT FIN */

/*
 * ****************************************************************************************************
 *  Point d'entrée du mode api
 * 
 * La démarche est la suivante :
 *  1. Création d'un établissement
 *  2. Paramétrage automatique du sso cas, en fonction de la configuration
 *  3. Nomination des administrateurs SACoche (les administrateurs d'établissement de l'ENT et les Superadmins, s'il y en a)
 *  4. Création des élèves
 *  5. création des Personnels de l'Education Nationale
 *  6. Création des parents
 * 
 * ***************************************************************************************************
 */

exit_json(200, "OK");

?>
Example #4
0
                         $list[] = $a . $d['N'] . '/';
                     }
                     kv_delete($kv, $a);
                 }
                 unset($node['D'][$it[0]]);
                 $done = true;
                 // kv_set($kv, $dir, serialize($node));
                 // exit_redirect('home.php?path=' . $dir);
             }
         }
     }
     if ($done) {
         kv_set($kv, $dir, serialize($node));
         exit;
     } else {
         exit_json(1, 'No such file or directory.');
     }
     break;
 case 'rename':
     check_field('name', 'value');
     $name = $_REQUEST['name'];
     $value = $_REQUEST['value'];
     foreach ($node['R'] as $f) {
         if (!strcasecmp($f['N'], $value)) {
             exit_print("New name already exists. <a href=\"home.php?path=" . $dir . "\">Back home</a>?");
         }
     }
     foreach ($node['D'] as $f) {
         if (!strcasecmp($f['N'], $value)) {
             exit_print("New name already exists. <a href=\"home.php?path=" . $dir . "\">Back home</a>?");
         }
 /**
  * @return Model       $this
  * @throws Exception
  */
 public function makeProperties()
 {
     if ($this->getStoredAql()) {
         $this->makeAqlArray();
         $i = 0;
         foreach ($this->getStoredAqlArray() as $table) {
             if ($i == 0) {
                 $this->_primary_table = $table['table'];
                 $this->addProperty($this->_primary_table . '_id');
             }
             $this->tableMakeProperties($table);
             $i++;
         }
     } else {
         $e = sprintf(self::E_INVALID_MODEL, $this->_model_name);
         if (!is_ajax_request()) {
             throw new Exception($e);
             return $this;
         } else {
             exit_json(array('status' => 'Error', 'errors' => array($e)));
         }
     }
     return $this;
 }
Example #6
0
<?php

$errors = array();
$email = trim($_POST['email_address']);
$clause_array = array('where' => array("person.email_address != ''", "person.email_address is not null", "person.email_address ilike '{$email}'"), 'limit' => 1);
$person = person::getByClause($clause_array);
if (!$person->person_id) {
    $errors[] = 'The email address you entered is not registered with us. Try creating a new account.';
}
if ($errors) {
    exit_json(array('status' => 'Error', 'errors' => $errors));
}
$re = $person->saveProperties(array('password_reset_hash' => sha1(mt_rand())));
if ($re['status'] != 'OK') {
    exit_json($re);
}
$mlr = new Mailer();
$mlr->addTo($person->email_address)->inc('includes/Mailers/reset-password.php', array('person' => $person, 'host' => $_SERVER['HTTP_HOST']))->send();
exit_json($re);
function exit_json_errors($errors, $extra = array())
{
    $arr = array('status' => 'Error', 'errors' => $errors);
    $arr = array_merge($arr, $extra);
    exit_json($arr);
}
Example #8
0
<?php

if (!$_POST['sql'] || !$_POST['db_name']) {
    exit_json(array('error' => "Missing required POST values 'sql' and/or 'db_name'."));
}
$needle = '/pages/';
$end = strrpos(__FILE__, $needle);
$prefix = substr(__FILE__, 0, $end);
$jar_path = $prefix . '/lib/db/apgdiff-2.3.jar';
\Cms\Apgdiff::$jar_path = $jar_path;
$sql = \Cms\Apgdiff::getDump();
$db_name = \Cms\Apgdiff::getDatabaseName();
$pull = \Cms\Apgdiff::getUpgradeScript($_POST['sql'], $sql);
$pull_filtered = \Cms\Apgdiff::stripDrops($pull);
$push = \Cms\Apgdiff::getUpgradeScript($sql, $_POST['sql']);
$push_filtered = \Cms\Apgdiff::stripDrops($push);
$data = array('local_database' => $_POST['db_name'], 'remote_database' => $db_name, 'tabs' => array(array('tab' => 'Pull', 'tab_caps' => 'PULL', 'left_arrow' => true, 'left_sql' => $pull_filtered, 'right_sql' => $pull), array('tab' => 'Push', 'tab_caps' => 'PUSH', 'right_arrow' => true, 'left_sql' => $push_filtered, 'right_sql' => $push), array('tab' => 'Dump', 'tab_caps' => 'DUMP', 'dump' => true, 'left_sql' => $_POST['sql'], 'right_sql' => $sql)));
json_headers();
exit(json_beautify(json_encode($data)));
 */
$selectFieldsArray = array('CityId', 'LandingPageURL', 'GASkipText', 'ImagePath', 'StartDate', 'ExpireDate', 'UploadedTime', 'Status');
$selectResource = $dbClassSelect->select($DBNAME['IPADMIN'], $TABLE['IPROADBLOCKBANNERS'], $selectFieldsArray, $whereClause);
if ($selectResource[1] > 0) {
    $fetchedRecords = $dbClassSelect->fetchArray('MYSQL_ASSOC', $selectResource[0], 1);
}
$dbClassSelect->dbClose();
// close DB connection
/**
 * get the city name from city list and append to the array
 * the final array should be in the form of 
 * 	[0] => Array
 *       (
 *          [TransactionId] => 4
 *          [CityId] => 4761
 *          [CityName] => Dafahat 	<--- New 
 *          [ImagePath] => /home/indiaproperty/www/images/RB_images/asdf_Dafahat.jpg
 *          [StartDate] => 0000-00-00
 *          [ExpireDate] => 0000-00-00
 *          [UploadedTime] => 2014-07-24 01:06:50
 *          [Status] => 1
 *      )
 *
 */
require_once "{$DOCROOTBASEPATH}/iplib/ipgenericfunctions.cil14";
foreach ($fetchedRecords as $recordNo => $record) {
    $cityid = $record['CityId'];
    $fetchedRecords[$recordNo]['CityName'] = $CITYHASH[$cityid];
}
exit_json($fetchedRecords);
Example #10
0
<?php

$obj = new \Crave\Model\ct_notify_me();
//$obj->birthdate = $_POST['birthdate'];
$obj->ct_holiday_id = $this->website->holiday_id;
//$_POST['ct_holiday_id'];
$obj->email_address = $_POST['email'];
$obj->fname = $_POST['fname'];
$obj->lname = $_POST['lname'];
$obj->phone = $_POST['phone'];
$obj->venue_id = $_POST['venue_id'];
$obj->market_id = decrypt($_POST['market_ide'], 'market');
$obj->save();
$response = $obj->getResponse();
exit_json($response);
<?php

// ini_set("display_errors","1");
// error_reporting(E_ALL);
$str = (require_once "../basicFunctions.php");
$DOCROOTPATH = $_SERVER['DOCUMENT_ROOT'];
$DOCROOTBASEPATH = dirname($_SERVER['DOCUMENT_ROOT']);
if (!(require_once $DOCROOTBASEPATH . "/iplib/ipsqlclass.cil14")) {
    // include mysqlclass
    exit_json(array("err" => array("errText" => "ipsqlclass.cil14 not found", "contProc" => 0, "fileName" => __FILE__)));
}
if (isset($_POST['cityID'])) {
    $flagSearch = 1;
    $cityID = $_POST['cityID'];
} else {
    $flagSearch = 0;
}
// open and set slave connection class
$dbClassSelect = new db();
$dbClassSelect->connect("S", $DBNAME['IPADMIN'], $DBINFO['USERNAME'], $DBINFO['PASSWORD']);
$selectFieldsArray = array('COUNT(1)');
$whereClause = '1';
$selectResource = $dbClassSelect->select($DBNAME['IPADMIN'], $TABLE['IPROADBLOCKBANNERS'], $selectFieldsArray, $whereClause);
if ($selectResource[1] > 0) {
    $fetchData = $dbClassSelect->fetchArray('MYSQL_ASSOC', $selectResource[0], 1);
}
echo_json($fetchData[0]['COUNT(1)']);
$dbClassSelect->dbClose();
// close DB connection
exit;
Example #12
0
<?php

$_GET['curl_timeout'] = 20;
$handler = new \Sky\VF\UploadHandler($_POST, $_FILES);
// makes sure that upload is proper
$handler->validate();
// will not run if there are errors
exit_json($handler->doUpload());
Example #13
0
                        $temp[$it[0]]['X'] = $index;
                        echo json_encode(array('code' => 0, 'size' => strlen($raw)));
                    }
                }
            }
        }
        kv_set($kv, ':temp', serialize($temp));
        exit;
        break;
    case "finish":
        for (reset($temp); $it = each($temp);) {
            $f = $it[1];
            if ($f['D'] == $dir && $f['N'] == $name) {
                $num = (int) ($f['S'] / 3145728) + ($f['S'] % 3145728 == 0 ? 0 : 1);
                if ($f['X'] != $num - 1) {
                    exit_json(5, 'Not complete. ' . $f['X'] . '/' . ($num - 1));
                }
                $node = unserialize(kv_get($kv, $dir));
                $node['R'][] = array('N' => $f['N'], 'T' => time(), 'A' => $node['A'], 'S' => $f['S'], 'I' => $f['I']);
                kv_set($kv, $dir, serialize($node));
                unset($temp[$it[0]]);
                kv_set($kv, ':temp', serialize($temp));
                exit_json(0, 'OK');
            }
        }
        exit_json(6, 'No such item');
        break;
    default:
        exit_json(7, 'Unkown action.');
        break;
}
            // close slave connection
            exit_json(array("err" => array("errText" => "DB Insert Fail", "contProc" => 0, "fileName" => __FILE__)));
        }
        unlink($file);
    } else {
        if ($status == 0) {
            // currently inactive, change to active
            $insertData = array('Status' => 1, 'ImagePath' => $response);
            $dbClassInsert->update($DBNAME['IPADMIN'], $TABLE['IPROADBLOCKBANNERS'], $insertData, $whereClause);
            // insert data first for transaction safety
            if ($dbClassInsert->error > 0) {
                $dbClassInsert->dbClose();
                // close master connection
                $dbClassSelect->dbClose();
                // close slave connection
                exit_json(array("err" => array("errText" => "DB Insert Fail", "contProc" => 0, "fileName" => __FILE__)));
            }
            // get data from database
            $selectFieldsArray = array('LandingPageURL', 'GASkipText', 'GAClickCode', 'GASkipCode', 'StartDate', 'ExpireDate', 'UploadedBy');
            $selectResource = $dbClassSelect->select($DBNAME['IPADMIN'], $TABLE['IPROADBLOCKBANNERS'], $selectFieldsArray, $whereClause);
            $fetchedRecord = $dbClassSelect->fetchArray('MYSQL_ASSOC', $selectResource[0], 1);
            $fetchedRecord = $fetchedRecord[0];
            $jsonData = array('CityId' => $cityID, 'LandingPageURL' => $fetchedRecord['LandingPageURL'], 'CityName' => $cityName, 'ImagePath' => $response, 'GASkipText' => $fetchedRecord['GASkipText'], 'GAClickCode' => $fetchedRecord['GAClickCode'], 'GASkipCode' => $fetchedRecord['GASkipCode'], 'StartDate' => $fetchedRecord['StartDate'], 'ExpireDate' => $fetchedRecord['ExpireDate'], 'UploadedBy' => $fetchedRecord['UploadedBy']);
            file_put_contents($DOCROOTPATH . "/search/RBData/{$cityID}.json", json_encode($jsonData));
        }
    }
    echo_json(1);
    // success
}
$dbClassInsert->dbClose();
// close master connection
<?php

// ini_set("display_errors","1");
// error_reporting(E_ALL);
$str = (require_once "../basicFunctions.php");
if (!isset($_GET)) {
    exit_json(0);
}
$DOCROOTPATH = $_SERVER['DOCUMENT_ROOT'];
$DOCROOTBASEPATH = dirname($_SERVER['DOCUMENT_ROOT']);
require_once "{$DOCROOTBASEPATH}/iplib/ipgenericfunctions.cil14";
$term = $_GET['term'];
$requestedBy = $_GET['requestedBy'];
if ($requestedBy == 'city') {
    $decodedList = $CITYHASH;
} else {
    if ($requestedBy == 'state') {
        $decodedList = $INDIANSTATEHASH;
    }
}
foreach ($decodedList as $k => $v) {
    if (stripos($v, $term) !== false) {
        $responseArray[] = array("idOfThis" => $k, "label" => $v, "value" => $v);
    }
}
if ($responseArray == null) {
    echo json_encode(array(0));
} else {
    echo json_encode($responseArray);
}
exit;
    $DB_ROW = DB_STRUCTURE_PUBLIC::DB_recuperer_user_for_new_mdp('user_id', $user_id);
    if (empty($DB_ROW)) {
        $_SESSION['FORCEBRUTE'][$PAGE]['DELAI']++;
        $_SESSION['FORCEBRUTE'][$PAGE]['TIME'] = $_SERVER['REQUEST_TIME'];
        exit_json(FALSE, 'Utilisateur inconnu ! Nouvelle tentative autorisée dans ' . $_SESSION['FORCEBRUTE'][$PAGE]['DELAI'] . 's.');
    }
    // On vérifie que l'adresse mail concorde
    if ($DB_ROW['user_email'] != $courriel) {
        $_SESSION['FORCEBRUTE'][$PAGE]['DELAI']++;
        $_SESSION['FORCEBRUTE'][$PAGE]['TIME'] = $_SERVER['REQUEST_TIME'];
        exit_json(FALSE, 'Adresse mail non concordante ! Nouvelle tentative autorisée dans ' . $_SESSION['FORCEBRUTE'][$PAGE]['DELAI'] . 's.');
    }
    // On enregistre un ticket pour cette demande
    $user_pass_key = crypter_mdp($DB_ROW['user_id'] . $DB_ROW['user_email'] . $DB_ROW['user_password'] . $DB_ROW['user_connexion_date']);
    $code_mdp = $BASE ? $user_pass_key . 'g' . $BASE : $user_pass_key;
    DB_STRUCTURE_PUBLIC::DB_modifier_user_password_or_key($DB_ROW['user_id'], '', $user_pass_key);
    // On envoi le courriel à l'utilisateur
    $mail_contenu = 'Bonjour,' . "\r\n";
    $mail_contenu .= "\r\n";
    $mail_contenu .= 'Une demande de nouveaux identifiants a été formulée pour le compte SACoche de ' . $DB_ROW['user_prenom'] . ' ' . $DB_ROW['user_nom'] . '.' . "\r\n";
    $mail_contenu .= "\r\n";
    $mail_contenu .= 'Pour confirmer la génération d\'un nouveau mot de passe, veuillez cliquer sur ce lien :' . "\r\n";
    $mail_contenu .= URL_DIR_SACOCHE . '?code_mdp=' . $code_mdp . "\r\n";
    $mail_contenu .= Sesamail::texte_pied_courriel(array('excuses_derangement', 'info_connexion', 'no_reply', 'signature'), $DB_ROW['user_email']);
    $courriel_bilan = Sesamail::mail($DB_ROW['user_email'], 'Demande de nouveaux identifiants', $mail_contenu, $DB_ROW['user_email']);
    if (!$courriel_bilan) {
        exit_json(FALSE, 'Erreur lors de l\'envoi du courriel !');
    }
    // OK !
    exit_json(TRUE);
}
Example #17
0
<?php

// delete media items_id
$items_id = $_POST['items_id'];
if (!$items_id) {
    exit_json(array('status' => 'Error', 'errors' => array('Invalid ID')));
}
$re = vf::removeItem($items_id);
exit_json(array('status' => 'OK', 'data' => $re));
if($_SESSION['SESAMATH_ID']==ID_DEMO) {exit('Action désactivée pour la démo...');}

$action          = (isset($_POST['f_action'])) ? Clean::texte($_POST['f_action']) : '';
$notification_id = (isset($_POST['f_id']))     ? Clean::entier($_POST['f_id'])    : 0;

// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Mémoriser qu'une notification a été consultée
// ////////////////////////////////////////////////////////////////////////////////////////////////////

if( ($action=='memoriser_consultation') && $notification_id )
{
  $is_modif = DB_STRUCTURE_NOTIFICATION::DB_modifier_statut( $notification_id , $_SESSION['USER_ID'] , 'consultée' );
  // Afficher le retour
  if($is_modif)
  {
    exit_json( TRUE );
  }
  else
  {
    exit_json( FALSE , 'Erreur : notification non trouvée ou pas associée à ce compte !' );
  }
}

// ////////////////////////////////////////////////////////////////////////////////////////////////////
// On ne devrait pas en arriver là !
// ////////////////////////////////////////////////////////////////////////////////////////////////////

exit_json( FALSE , 'Erreur avec les données transmises !' );

?>
    // Notification (qui a la particularité d'être envoyée de suite, et avec tous les admins en destinataires du mail)
    $abonnement_ref = 'contact_externe';
    $DB_TAB = DB_STRUCTURE_NOTIFICATION::DB_lister_destinataires_avec_informations($abonnement_ref);
    $destinataires_nb = count($DB_TAB);
    if (!$destinataires_nb) {
        // Normalement impossible, l'abonnement des admins à ce type de de notification étant obligatoire
        exit_json(FALSE, 'Aucun destinataire trouvé.');
    }
    $tab_destinataires = array();
    $notification_contenu = 'Message de ' . $prenom . ' ' . $nom . ' (' . $courriel . ') :' . "\r\n\r\n" . $message . "\r\n";
    foreach ($DB_TAB as $DB_ROW) {
        $notification_statut = COURRIEL_NOTIFICATION == 'oui' && $DB_ROW['jointure_mode'] == 'courriel' && $DB_ROW['user_email'] ? 'envoyée' : 'consultable';
        DB_STRUCTURE_NOTIFICATION::DB_ajouter_log_visible($DB_ROW['user_id'], $abonnement_ref, $notification_statut, $notification_contenu);
        if ($notification_statut == 'envoyée') {
            $tab_destinataires[] = $DB_ROW['user_prenom'] . ' ' . $DB_ROW['user_nom'] . ' <' . $DB_ROW['user_email'] . '>';
        }
    }
    if (count($tab_destinataires)) {
        /**
         * L'envoi d'un contact externe depuis la page d'authentification est une exception à plusieurs titres :
         * - le numéro de base n'est pas en session
         * - envoi possible à plusieurs destinataires simultanéments
         * - notification obligatoire et immédiate
         * Du coup, le paramètre 'notif_individuelle' n'est pas transmis dans le tableau pour texte_pied_courriel().
         */
        $notification_contenu .= Sesamail::texte_pied_courriel(array('no_reply', 'signature'));
        $courriel_bilan = Sesamail::mail($tab_destinataires, 'Notification - Contact externe', $notification_contenu, $tab_destinataires);
    }
    $admin_txt = $destinataires_nb > 1 ? 'aux ' . $destinataires_nb . ' administrateurs' : 'à l\'administrateur';
    exit_json(TRUE, $admin_txt);
}