erreur php génère 404 et non inscription avec MLM (Créer un compte)

  • Statut : non résolu
3 sujets de 1 à 3 (sur un total de 3)
  • Auteur
    Messages
  • #550714
    gafguy
    Participant
    Padawan WordPress
    58 contributions

    Bonjour,

    Ma configuration WP actuelle
    – Version de WordPress : 4.2.2
    – Version de PHP/MySQL : 5.5
    – Thème utilisé : Twenty Thirten
    – Extensions en place : Aksimet + Autoptimize + Comment Reply Notification +MLM (Maxprog’s Mailing List Manager plugin for WordPress) + ZenCache
    – Nom de l’hebergeur : elephant-rouge.fr
    – Adresse du site : guypoursin.com

    Problème(s) rencontré(s) :
    J’ai installé le widget (List Manager) correspondant à MLM dans ma zone secondaire de widgets.
    En principe, toute personne qui indique son prénom et son adresse mail est inscrit automatiquement sur la liste qui correspond, dans un dossier du logiciel qui s’appelle lm et qui peut recevoir plus de 250.000 adresses.
    Je vois plusieurs problèmes :
    1 – impossible d’avoir les deux boîtes l’une en-dessous de l’autre (voir imageviewer.php?id=1371505701.png, s’il vous plaît) ;
    2 – quelque chose ne fonctionne pas dans mon code et je ne vois pas quoi, mais toute tentative d’inscription n’arrive pas sur la liste et débouche sur une erreur 404.
    Voici mon code :

    <?php
    
    /*
    Plugin Name: MLM
    Plugin URI: http://maxprog.com
    Description: Maxprog's Mailing List Manager plugin for WordPress 
    Version: 1.0
    Author: Wessley Roche
    Author URI: http://wpguy.com/
    License: GPL
    */
    
    function mlm_init() {
    	
    	// Check for widget compatibility
    	if (!function_exists('register_sidebar_widget')) {
    		return;
    	}
    	
    	// Helper function to extract the parameters of a list or field
    	function mlm_extract_params($string)
    	{
    		$string = trim($string);
    			
    		if(strstr($string, "["))
    		{
    			$params = strstr($string, "[");
    			$params = substr($params, 1, strlen($params)-2);
    			
    			$params = explode("&", $params);
    			
    			$param_array = array();
    			
    			foreach($params as $param)
    			{
    				
    				$to = strpos($param, "=");
    				$param_name = substr($param, 0, $to);
    				
    				$param_value = strstr($param, "=");
    				$param_value = substr($param_value, 1, strlen($param_value));
    				$param_array[$param_name] = $param_value;
    				
    			}
    			
    			$to = strpos($string, "[");
    			$string_name = substr($string, 0, $to);
    			
    			return array($string_name, $param_array);
    		}
    		else
    		{
    			return array($string, false);
    		}
    	}
    	
    	// Helper function to extract the title of a list or field
    	function mlm_get_title($string)
    	{
    		$params = mlm_extract_params($string);
    		
    		if($params[1]["title"])
    		{
    			return $params[1]["title"];
    		}
    		else
    		{
    			return ucfirst($params[0]);
    		}
    	}
    	
    	// Helper function to extract the required value of a field
    	function mlm_get_required($string)
    	{
    		$params = mlm_extract_params($string);
    		
    		if($params[1]["required"])
    		{
    			if($params[1]["required"] == "no")
    			{
    				return false;
    			}
    			else
    			{
    				return true;
    			}
    		}
    		else
    		{
    			return true;
    		}
    	}
    	
    	// Helper function to extract the name of a list or field
    	function mlm_get_name($string)
    	{
    		$params = mlm_extract_params($string);
    		
    		return $params[0];
    	}
    	
    	/* The widget function */
    	function widget_mlm($args) {
    		
    		// Get settings from the database
    		extract($args);
    		$options = get_option('widget_mlm_options');
    		$fields = $options['fields'];
    		$title = $options['title'];
    		$lists = $options['lists'];
    		$multiple = $options['multiple'];
    		$lm_url = $options['lm_url'];
    		$unsubscribe = $options['unsubscribe'];
    		
    		// Echo widget header
    		echo $before_widget;
    		echo $before_title . $title . $after_title;
    		
    		// Set basic settings, in case they have not been set yet. E.g. when you just installed the plugin.
    		if(!$options){
    			$title = "Inscrivez-vous";
    			$fields = "Votre prénom, Votre email";
    			$lists = "GP-pro";
    			$multiple = "no";
    			$lm_url = "/lm/lm.php";
    			$unsubscribe = "yes";
    		}
    		
    		// Set basic values, in case they're empty
    		if(trim($fields) == "") { $fields="email"; }
    		if(trim($lists) == "") { $lists = "list1"; }
    		
    		
    		// Error checking
    		// ** Not in use right now, as the form is sent directly to lm.php
    		if(isset($_POST['mlm-submit']))
    		{
    			$separated_fields = explode(',', $fields);
    			$separated_lists = explode(',', $lists);
    			
    			$errors = array();
    			
    			foreach($separated_fields as $field)
    			{
    				$field_name = mlm_get_name($field);
    				$field_title = mlm_get_name($field);
    				$field_required = mlm_get_required($field);
    				
    				if($field_required && $_POST[$field_name] == "")
    				{
    					$errors[] = "The field <strong>“.$field_title.”</strong> is a required field.”;
    				}
    				elseif($field_required && !isset($_POST[$field_name]))
    				{
    					$errors[] = “The field <strong>“.$field_title.”</strong> is a required field.”;
    				}
    			}
    			
    		}
    		
    		// Open <form> tag
    		echo “<form id="MLM_subscription" action="".$lm_url."" method="post" name="MLM_subscription">“;
    		
    		// Echo all the fields
    		$separated_fields = explode(‘,’, $fields);
    		foreach($separated_fields as $field)
    		{
    			
    			if(trim($field) != “”)
    			{
    				// Get field parameters
    				$field_name = mlm_get_name($field);
    				$field_title = mlm_get_title($field);
    				$field_required = mlm_get_required($field);
    				
    				echo “<div class="mlm_row mlm_field_$field_name"><label for="".$field_name."">“.$field_title.”:</label><input type="text" name="".$field_name."" value="".$_POST[$field_name]."" />“;
    				if($field_required){
    					echo “<small>*</small>“;
    				}
    				echo “</div>“;
    			}
    			
    		}
    		
    		// Echo the list selection
    		if(strlen(trim($lists)) != 0)
    		{
    			$separated_lists = explode(‘,’, $lists);
    			
    			// If there is more than one list
    			if(count($separated_lists) > 1)
    			{
    				
    				echo “<div class="mlm_list_selection">“;
    				
    				echo “<label for="list">Subscribe to:</label>“;
    				
    				// If the user can choose to subscribe to more than one list at a time. Use checkboxes.
    				// ** Not in use at the moment.
    				if($multiple == “yes”)
    				{
    					$list_count = “”;
    					foreach($separated_lists as $list)
    					{
    						if(trim($list) != “”)
    						{
    							// Get list parameters
    							$list_name = mlm_get_name($list);
    							$list_title = mlm_get_title($list);
    							
    							echo “<input type="checkbox" name="list".$list_count."" value="".trim($list_name).""";
    							if($_POST["list".$list_count] == trim($list_name))
    							{
    								echo " checked";
    							}
    							echo " />“;
    							
    							
    							echo “<label for="".$list_name."">“.$list_title.”</label>“;
    							
    							if($list_count == “”){ $list_count = 0; }
    							$list_count++;
    						}
    					}
    				}
    				// If the user can subscribe to just one list at a time. Use drop-down menu.
    				else
    				{	
    					echo “<select name="list">“;
    					
    					foreach($separated_lists as $list)
    					{
    						if(trim($list) != “”)
    						{
    							// Get list parameters
    							$list_name = mlm_get_name($list);
    							$list_title = mlm_get_title($list);
    							
    							echo “<option value="".$list_name.""";
    							
    							if($_POST['list'] == $list_name)
    							{
    								echo " selected ";
    							}
    							
    							echo ">“.$list_title.”</option>“;
    						}
    					}
    					
    					echo “</select>“;
    				}
    				
    				echo “</div>“;
    			}
    			// If there is just one list. Use a hidden input field.
    			else
    			{
    				$list_name = mlm_get_name($lists);
    				echo “<input type="hidden" name="list" value="".trim($list_name)."" />“;
    			}
    		}
    		// If the Admin didn’t specify a list, use default list “list1”.
    		else
    		{
    			echo “<input type="hidden" name="list" value="list1" />“;
    		}
    		
    		// Subscribe, unsubscribe radio buttons
    		if($unsubscribe == “yes”)
    		{
    			echo “<div class="mlm_function"><input type="radio" name="cmd" value="subscribe" checked="checked" /> <label for="cmd">Subscribe</label> <input type="radio" name="cmd" value="unsubscribe" /> <label for="cmd">Unsubscribe</label></div>“;
    		}
    		else
    		{
    			echo “<input type="hidden" name="cmd" value="subscribe" />“;
    		}
    		
    		
    		// Required indication
    		echo “<div class="mlm_required"><small>* Required</small></div>“;
    		
    		// Submit button
    		echo “<div class="mlm_submit"><input type="submit" name="mlm-submit" value="Submit" /></div>“;
    		
    		// End of form
    		echo “</form>“;
    		
    		// Error box
    		// ** Not in use at the moment.
    		if(isset($errors) && count($errors) > 1)
    		{
    			echo “<div class="mlm_error">“;
    			echo “<h2>Sorry but we can’t process your request.</h2><h3>Please fix the following issues:</h3>“;
    			echo “<ul>“;
    			foreach($errors as $error)
    			{
    				echo “<li>$error</li>“;
    			}
    			echo “</ul>“;
    			echo “</div>“;
    		}
    		
    		// Widget footer
    		echo $after_widget;
    	}
    	
    	
    	/* The widget options panel */
    	function widget_mlm_control() {
    		$options = get_option(‘widget_mlm_options’);
    		
    		// Get settings from the database
    		if (!is_array($options)) {
    			$options = array(
    				“title” => “Subscribe”,
    				“fields” => “email, firstname, lastname”,
    				“lists” => “list1”,
    				“multiple” => “no”,
    				“lm_url” => “/lm/lm.php”,
    				“unsubscribe” => “yes”
    			);
    		}
    		
    		// Get settings from $_POST if the form was submitted
    		if ( $_POST[‘mlm-submit’] ) {
    			// Remember to sanitize and format user input appropriately.
    			$options[‘title’] = strip_tags(stripslashes($_POST[‘mlm-title’]));
    			$options[‘fields’] = strip_tags(stripslashes($_POST[‘mlm-fields’]));
    			$options[‘lists’] = strip_tags(stripslashes($_POST[‘mlm-lists’]));
    			$options[‘multiple’] = strip_tags(stripslashes($_POST[‘mlm-multiple’]));
    			$options[‘lm_url’] = strip_tags(stripslashes($_POST[‘mlm-lm_url’]));
    			$options[‘unsubscribe’] = strip_tags(stripslashes($_POST[‘mlm-unsubscribe’]));
    			update_option(‘widget_mlm_options’, $options);
    		}
    		
    		$title = htmlspecialchars($options[‘title’], ENT_QUOTES);
    		$fields = htmlspecialchars($options[‘fields’], ENT_QUOTES);
    		$lists = htmlspecialchars($options[‘lists’], ENT_QUOTES);
    		$multiple = htmlspecialchars($options[‘multiple’], ENT_QUOTES);
    		$lm_url = htmlspecialchars($options[‘lm_url’], ENT_QUOTES);
    		$unsubscribe = htmlspecialchars($options[‘unsubscribe’], ENT_QUOTES);
    		
    		// Echo fields
    		echo ‘<p>
    				<label for="mlm-lm_url">‘ . __(‘MLM URL:’) . ‘
    				<input class="widefat" id="mlm-lm_url" name="mlm-lm_url" type="text" value="'.$lm_url.'" />
    				</label>
    				<small>The URL to the lm.php script.</small></p>‘;
    		echo ‘<p>
    				<label for="mlm-title">‘ . __(‘Title:’) . ‘
    				<input class="widefat" id="mlm-title" name="mlm-title" type="text" value="'.$title.'" />
    				</label>
    				<small>The widget title.</small></p>‘;
    		echo ‘<p>
    				<label for="mlm-fields">‘ . __(‘Fields:’) . ‘
    				<input class="widefat" id="mlm-fields" name="mlm-fields" type="text" value="'.$fields.'" />
    				</label>
    				<small>List of fields, separated by commas.</small></p>‘;
    		echo ‘<p>
    				<label for="mlm-lists">‘ . __(‘Lists:’) . ‘
    				<input class="widefat" id="mlm-lists" name="mlm-lists" type="text" value="'.$lists.'" />
    				</label>
    				<small>The lists, separated by commas.</small></p>‘;
    		echo ‘<p>
    				<label for="mlm-unsubscribe">
    				<input class="checkbox" id="mlm-unsubscribe" name="mlm-unsubscribe" type="checkbox"';
    				if($unsubscribe=="yes"){ echo " checked "; }
    		echo 'value="yes" />
    				‘ . __(‘User can unsubscribe from widget’) . ‘
    				</label></p>‘;
    // This is commented right now because lm.php doesn’t support the subscription to multiple lists at once.
    /*
    		echo ‘<p>
    				<label for="mlm-multiple">
    				<input class="checkbox" id="mlm-multiple" name="mlm-multiple" type="checkbox"';
    				if($multiple=="yes"){ echo " checked "; }
    		echo 'value="yes" />
    				‘ . __(‘User can subscribe to multiple lists’) . ‘
    				</label></p>‘;
    */
    		echo ‘<input type="hidden" id="mlm-submit" name="mlm-submit" value="1" />‘;
    		
    	}
    	
    	
    	/* Register the widget */
    	register_sidebar_widget(array(‘List Manager’, ‘widgets’), ‘widget_mlm’);
    	
    	/* Register the control panel */
    	register_widget_control(array(‘List Manager’, ‘widgets’), ‘widget_mlm_control’, 200, 200);
    	
    }
    
    // Adds stylesheet
    function mlm_style(){
    	echo “<link rel="stylesheet" href="".get_bloginfo("wpurl")."/wp-content/plugins/mlm_widget/style.css" type="text/css" media="screen" />“;
    }
    
    // Hook the widget function
    add_action(‘widgets_init’, ‘mlm_init’);
    
    // Hoook the stylesheet function
    add_action(‘wp_print_styles’, ‘mlm_style’);
    
    ?>

    Si parmi vous quelqu’un peut m’expliquer… merci d’avance !

    #1008757
    Lumiere de Lune
    Participant
    Maître WordPress
    19367 contributions

    J’ai mis le code entre balise codes (le C noir) et un titre plus explicite à ta demande

    #1008758
    gafguy
    Participant
    Padawan WordPress
    58 contributions

    Merci beaucoup !
    Je viens de regarder de nouveau et je n’ai rien trouvé.

3 sujets de 1 à 3 (sur un total de 3)
  • Vous devez être connecté pour répondre à ce sujet.