* @version 1.0 * @package annonces * @subpackage includes */ /** * Wordpress - Ajax functionnality activation */ DEFINE('DOING_AJAX', true); /** * Wordpress - Specify that we are in wordpress admin */ DEFINE('WP_ADMIN', true); /** * Wordpress - Main bootstrap file that load wordpress basic files */ require_once('../../../../wp-load.php'); /** * Wordpress - Admin page that define some needed vars and include file */ require_once(ABSPATH . 'wp-admin/includes/admin.php'); /** * First thing we define the main directory for our plugin in a super global var */ DEFINE('ANNONCES_PLUGIN_DIR', basename(dirname(__FILE__))); /** * Include the different config for the plugin */ require_once(WP_PLUGIN_DIR . '/' . ANNONCES_PLUGIN_DIR . '/includes/config/config.php' ); /** * Include the file which includes the different files used by all the plugin */ require_once( ANNONCES_INC_PLUGIN_DIR . 'includes.php' ); /* Get the different resquest vars to sanitize them before using */ $method = tools::IsValid_Variable($_REQUEST['post']); $action = tools::IsValid_Variable($_REQUEST['action']); /* Element code define the main element type we are working on */ $elementCode = tools::IsValid_Variable($_REQUEST['elementCode']); /* Element code define the secondary element type we are working on. */ $elementType = tools::IsValid_Variable($_REQUEST['elementType']); $elementIdentifier = tools::IsValid_Variable($_REQUEST['elementIdentifier']); /* First look at the request method Could be post or get */ switch($method) { case 'true': {/* In case request method is equal to true, it means that we are working with post request method */ /* Look at the element type we have to work on */ switch($elementCode) { case 'annonce_map_marker': case 'url_radio_maisons': case 'url_radio_terrains': case 'url_radio_toutes': case 'url_budget': case 'url_superficie': case 'url_recherche': { if($elementCode != 'annonce_map_marker'){ $finalDir = explode('_', $elementCode); $the_final_dir = 'searchPicto/' . $finalDir[count($finalDir) - 1]; } else{ $the_final_dir = 'gmapMarker'; } switch($action) { case 'frontend_picto_upload': if(!is_dir(str_replace('\\', '/', WP_CONTENT_DIR . WAY_TO_PICTURES_AOS . $the_final_dir . '/'))){ mkdir(str_replace('\\', '/', WP_CONTENT_DIR . WAY_TO_PICTURES_AOS . $the_final_dir . '/'), 0755, true); exec('chown -R 0755 ' . WP_CONTENT_DIR . '/uploads'); } $target_path = str_replace('\\', '/', WP_CONTENT_DIR . WAY_TO_PICTURES_AOS . $the_final_dir . '/') . basename( $_FILES['new_picto_for_frontend']['name']); if(move_uploaded_file($_FILES['new_picto_for_frontend']['tmp_name'], $target_path)) { echo sprintf(__('Le fichier %s a bien été envoyé sur le serveur', 'annonces'), basename( $_FILES['new_picto_for_frontend']['name'])); } else{ echo sprintf(__('Une erreur est survenue lors de l\'envoi du fichier %s sur le serveur', 'annonces'), basename( $_FILES['new_picto_for_frontend']['name'])); } break; case 'loadPictureUploadForm': $picture_form = '
'; echo $picture_form; break; case 'loadPictureDirContent': $output = ''; $i = 1; $options = get_option('annonces_options'); $directoryToRead = str_replace('\\', '/', WP_CONTENT_DIR . WAY_TO_PICTURES_AOS . $the_final_dir . '/'); if(is_dir($directoryToRead)) { $directory = opendir($directoryToRead); while($element = readdir($directory)) { if(($element != '.') && ($element != '..')) { if(is_file($directoryToRead . $element)) { $checked = (str_replace($finalDir[count($finalDir) - 1] . '//', $finalDir[count($finalDir) - 1] . '/', $options[$elementCode]) == $the_final_dir . '/' . $element) ? ' checked="checked" ' : ''; $output .= ''; $i++; } } } } else { $output .= __('Aucun fichier n\'a été envoyé pour le moment', 'annonces'); } $output .= ''; echo $output; break; } } break; case 'urlRewriteFormat': { switch($action) { case 'loadUrlPossibleParams'; { $output = $script = ''; $output .= __('Liste des paramètres possible pour la réécriture d\'url', 'annonces') . '