Jump to content

post received edit save notworking for create email account..


antonyfal

Recommended Posts

Hi,

i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..:

basically the script allows the use to register an email account on a cpanel domain.

 

Everything works perfectly but then i added a option for banned words now i cant  get the script to work..

basically what happens is:

the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen

if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included..

what to note::

this is a function in a function..

 


$bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts';
$bannedmail=explode(',', $bannedemailwords);
$bannedmail = array_unique($bannedmail);
sort($bannedmail);
foreach($bannedmail as $noemail)	
//the selected username

if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){
	$cpuser = 'ausername'; 
	$cppass = 'apassword'; 
	$cpdomain = 'adomain'; 
	$cpskin = 'askin';  
	$epass = 'somepassword'; 
	$equota = 'somequota';

$euser = $_POST['cfg_enablemyemailappaddress_enable'];
$epass = $_POST['emailspassword_enable'];
$edomain = $_POST['cfg_enablemyemailappaddressdomain_enable'];

if (!empty($euser) && $euser !=='nomail')
while(true) {
  $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");
  if (!$f) {
$enablemyemailapp_enable = '0';
$enablemyemailappaddress_enable = 'Replace with a Name';
$enablemyemailappaddressdomain_enable = 'Select a domain';
    $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.';
break;
  } 
$enablemyemailapp_enable = '1';
$enablemyemailappaddress_enable =  $_POST['cfg_enablemyemailappaddress_enable'];
$enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable'];
        $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>';
  
   
  while (!feof ($f)) {
    $line = fgets ($f, 1024);
    if (ereg ("already exists", $line, $out)) {
$enablemyemailapp_enable = '0';
$enablemyemailappaddress_enable = 'Replace with a Name';
$enablemyemailappaddressdomain_enable = 'Select a domain';
    $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>';
break;
    }
  }
  
echo $msgemail;

$_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable;
$_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable;
$_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable;

  @fclose($f);
break;
}
}

Link to comment
Share on other sites

Admittedly, it would be easier if I could see the whole function, and the code that calls it; first lets simplify the code here

 

Instead of:

$bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts';
$bannedmail=explode(',', $bannedemailwords);
$bannedmail = array_unique($bannedmail);
sort($bannedmail);

 

Try:

 

$bannedemailwords=array('customerinformation','custinfo','customerinfo','custtext','custsupport','customersupport','admin','accounts');

 

Now, you'll want to redesign your loop logic. Instead of iterating through the $bannedemailwords list; simply use the in_array() construct to check if the posted/proposed email address is in the $bannedemailwords list. You'll see a performance increase too, by ditching the loop, although, not likely noticeable with such a small list.

Link to comment
Share on other sites

Thanks Ryan.

This worked perfectly..

my end result was written like this:

 

	
$bannedemailwords=array('customerinformation','custinfo','customerinfo','custtext','custsupport','customersupport','admin');

if (!in_array(''.$_POST['cfg_enablemyemailappaddress_enable'].'', $bannedemailwords)
{
then the rest.. 

 

I was wandering if you knew a better way for this code too?

in this example the url explodes at the "&" but i was trying out several ways to include more if statements if the url explodes at the "/" too.

also i dont always know the position of the specific word im looking for..

and to honest im not really sure this code actually works-- somtimes it does and sometimes it doesnt.. depends the page that is loaded.

 

$geturl = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$findurl=explode('&', $geturl);
$findurl = array_unique($findurl);
sort($findurl);
foreach($findurl as $foundurl)	
if ($foundurl == 'Female' )

 

Link to comment
Share on other sites

 

I was wandering if you knew a better way for this code too?

in this example the url explodes at the "&" but i was trying out several ways to include more if statements if the url explodes at the "/" too.

also i dont always know the position of the specific word im looking for..

and to honest im not really sure this code actually works-- somtimes it does and sometimes it doesnt.. depends the page that is loaded.

 

$geturl = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$findurl=explode('&', $geturl);
$findurl = array_unique($findurl);
sort($findurl);
foreach($findurl as $foundurl)	
if ($foundurl == 'Female' )

 

 

What are you actually trying to do, get the key/value pairs out of the url and then put them in an array? If that's the case, the $_GET variable is automatically set by PHP with all the URL key/value pairs in the URL that was used to reach the page, all you have to do is reference $_GET['xyz'].

 

<?php
foreach ($_GET as $key=>$value) {

        //DO SOME OPERATIONS HERE
        echo "Key: " . $key . " Value: " . $value . "<br />";
}
?>

 

 

Link to comment
Share on other sites

Thanks again for the replies Ryan.

 

I see i can use the code that you gave for the URL in this example, it will work great.. But what im looking for is a way to see if there are any specific words in the url, and then load parts of that page according to if the word is in the url or not.

 

I use the explode function and explode the url in parts IE "/" or "&" or ....

for example, but then i always have to know the parts and their positions

IE:

parts[0]='www.xxx.com';

if (parts[6] !=='someword'); 

 

is there not a better way to do the url thing regardless of the "/" or "&".. and without the get function?

 

like matching words to parts of a string, without the explode or the $GET?

 

when i saw the fix you gave me for my problem above i thought that there must be a better way for the url problem too.

this explode function i have works on some and doesnt work on others and to be honest is a headache.

 

i think what im looking for is a way to find if a word IS! or ISN'T in the url-- the word can be a user post or a variable. Also a way that will work 100% of the time and faster to load too.

if you can assist me with this great, otherwise im quite happy with what i got so far.

 

Best regards

Antony

 

 

Link to comment
Share on other sites

here is an actual example where i use the explode function-- problem is when i try to use it on another page it doesnt work. Is there a better way to do this: regardless of if there is a / or a & in the url..

 


$getstheurl = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$dontshowurl=explode("/", $getstheurl);
$findtheurl=explode('&', $getstheurl);
$findtheurl = array_unique($findtheurl);
sort($findtheurl);
foreach($findtheurl as $foundtheurl)	
if ($foundtheurl == 'gender=Female' && $foundtheurl !== 'gender=Male' && $foundtheurl !== 'Agency' || $_POST['searchgender'] == 'Female' && $_POST['searchgender'] !== 'Male' && $_POST['searchgender'] !== 'Agency'){
$style='<link rel="stylesheet" type="text/css" href="'.$templateUrl.'/css/templatefemale.css" />';
} else {
if ($foundtheurl == 'gender=Male' && $foundtheurl !== 'gender=Female' && $foundtheurl !== 'Agency' ||$_POST['searchgender'] == 'Male' && $_POST['searchgender'] !== 'Female' && $_POST['searchgender'] !== 'Agency'){
  $style='<link rel="stylesheet" type="text/css" href="'.$templateUrl.'/css/templatemale.css" />';
} else {
if ($foundtheurl !== 'gender=Female' && $foundtheurl !== 'gender=Male' && $foundtheurl == 'Agency' || $_POST['searchgender'] !== 'Female' && $_POST['searchgender'] !== 'Male' && $_POST['searchgender'] == 'Agency'){
  $style='<link rel="stylesheet" type="text/css" href="'.$templateUrl.'/css/templateagency.css" />';
  } else {
if ($foundtheurl !== 'gender=Female' && $foundtheurl !== 'gender=Male' && $foundtheurl !== 'Agency' || $_POST['searchgender'] !== 'Female' && $_POST['searchgender'] !== 'Male' && $_POST['searchgender'] !== 'Agency'){
  $style='<link rel="stylesheet" type="text/css" href="'.$templateUrl.'/css/templatenormal.css" />';
  }  
  }
  }
  }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.