mschroeder 251 Bestower of Knowledge Team Colleague

I would recommend PHPMailer or SwiftMailer for this task.

Both handle attachments and html emails etc seamlessly, but both are also much more frequently udpated/patched etc.

mschroeder 251 Bestower of Knowledge Team Colleague

then you should just be able to parse over $_POST as an array.

the implode example i provided will just display all the type values as a comma delimited string.

if you want to parse over the array use something like

foreach( $_POST['type'] as $sType )
{
   echo $sType . '<br />';
}
mschroeder 251 Bestower of Knowledge Team Colleague

how is your form setup?

generally you would want a series of checkbox fields all called type[] with unique values.

this way what you go to parse over the results in php, $_POST is an array of check values.

if(isset($_POST['type'])){
		$type = $_POST['type'];	
		echo 'You selected: ' . implode( ',', $type);

		// You selected: horror, sci-fi, romance
	}
mschroeder 251 Bestower of Knowledge Team Colleague

notepad++
zend studio, although i only prefer it over Eclipse PDT and Aptana because of its integration with PHPUnit.

mschroeder 251 Bestower of Knowledge Team Colleague

Glad to be of assistance. Please mark the thread as solved if we've resolved your issue

mschroeder 251 Bestower of Knowledge Team Colleague
<td width=""><p><?php echo nl2br(wordwrap($message, 75, PHP_EOL, true)); ?></p></td>

The wordwrap function breaks your content down with PHP_EOL which is a constant that is defined to match the proper end of line charachter for your operating system.

Then uses nl2br to convert them to <br>'s including any ones the user entered.

the only thing i caution is against using the last parameter of "true" as this will allow php to cut words in half instead of breaking at the nearest word break

mschroeder 251 Bestower of Knowledge Team Colleague

You could use the wordwrap function and break the string at however long you would like.

Although there are some shortcomings, as it will treat Mr. Smith as two words and would break between the prefix and last name. I also do not believe it to be utf-8 capable, but there are some good examples on the manual page on php.net.

I've also seen some functions in the past that alleviate the breaking between parts of a name (prefix and suffix) etc, just cant think of one at the moment.

mschroeder 251 Bestower of Knowledge Team Colleague

if you mean when typing in the textarea the text just continues on one long line, add wrap="physical" to the textarea markup. <textarea name="" cols="" rows="" wrap="physical" class="" id=""></textarea> This will make the textarea wrap at word breaks [spaces] that are close to the end of the line. If it is one large line of non broken text then it will cause the text area to scroll horizontally.

mschroeder 251 Bestower of Knowledge Team Colleague

Could you post an export of your table structure?

mschroeder 251 Bestower of Knowledge Team Colleague

You're positive you have a column named status in your table?

mschroeder 251 Bestower of Knowledge Team Colleague
$query = 'INSERT INTO user_notifications (`username`, `status` ) VALUES ("'.$username.'", "new to the site!" )';

mysql_query( $query ) or die( mysql_error() );

That is how I would handle the query, although the column names are not reserved words so they really dont need the backticks around them.

Here is the list of mysql 5.0 reserved keywords

mschroeder 251 Bestower of Knowledge Team Colleague

Try this example out. This uses jQuery to grab the css properties you want. Even on elements that do not have inline styles.

This is what matters, it serves the jquery library from googles cdn, but this could be from a local copy too. jQuery CSS Documentation
Sends two alerts to the browser the first with the padding-left value and the second with the margin-left value.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   alert( $("#someTable").css('padding-left') );
   alert( $("#someTable").css('margin-left') );
 });
</script>

This is the full example, but i gave my table and id of "someTable"
You could use whatever you wanted.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   alert( $("#someTable").css('padding-left') );
   alert( $("#someTable").css('margin-left') );
 });
</script>
<style>
table {
	padding-left: 10px;
	margin-left: 50px;
}
</style>
</head>

<body>
<table width="200" border="0" cellpadding="2" id="someTable" >
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
mschroeder 251 Bestower of Knowledge Team Colleague

Check out PHPMailer or Swift Mailer.
I prefer the prior, but u simply set the FROM address(es) or name(s), REPLY-TO etc...

Then when the user receives the email it looks like it came from whatever email or user you have specified.

Both libraries make sending complex emails a lot easier too.

http://www.swiftmailer.org/
http://phpmailer.codeworxtech.com/index.php?pg=examples

mschroeder 251 Bestower of Knowledge Team Colleague

Excellent glad i could be of assistance.
Don't forget to mark the thread as solved.

mschroeder 251 Bestower of Knowledge Team Colleague

What you're describing sounds like you're looking for something like the __call() magic method

mschroeder 251 Bestower of Knowledge Team Colleague

In the ops last post, they neglected a semicolon <? echo $_SESSION["seekerid"]?> should have been <? echo $_SESSION['seekerid']; ?> as illustrated in your response.

However as a word of advice, php short tags should be avoided as there is no guarantee that they are enabled if you were to move your code to a new server.

Also if you are going to use short tags <?=$_SESSION['seekerid']?> is a cleaner approach. but ONLY works with short tags.

mschroeder 251 Bestower of Knowledge Team Colleague

how about using some jQuery to simplify the code even further.

<html>
<head>
<title>test</title>
<!-- Let GOOGLE serve the ajax library via their CDN -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	//Run the hideall() function to hide all divs that have an id of divform
        //and are children of the node with id formContainer
	hideall();

	//Listen for a click event on ANY input with an id of formRadio
	$("input[id='formRadio']").click(function () { 
		//capture the value of the radio the click occurred on
		var value = $(this).val();
		
		//Run the hideall function again to make sure everything is collapsed
		hideall();
		
		//toogle the visibility of the div the click occurred on by its index value
		//index values start at 0 and increment by 1
		//first divform has index of 0 second has index of 1 etc etc
		$("div[id='divform']:eq(" + value + ")").toggle();  
	});	
	
	function hideall()
	{
		$("#formContainer > div[id='divform']").hide();
	}
});
</script>
<style>
#formContainer {
	position: relative;
	top: 100px;
}
</style>
</head>
<body >
<form id='myform'>
  <input type='radio' id='formRadio' name='formSel' value='0'>
  Form-1
  </input>
  <input type='radio' id='formRadio' name='formSel' value='1'>
  Form-2
  </input>
</form>
<div id="formContainer" style="border: 1px solid #000;">
  <div id="divform">
    <form id="form1">
      <h1>Form1</h1>
    </form>
  </div>
  <div id="divform">
    <form id="form2">
      <h1>Form2</h1>
    </form>
  </div>
</div>
</body>
</html>

In this example you can now add an infinite amount of forms and as long as a radio button exists they will all expand and contract on click without having to write any additional javascript.

There are some minor changes to the form as provided above.

mschroeder 251 Bestower of Knowledge Team Colleague

If you're familiar with what AJAX is this is a great way to switch form using jQuery. If you're going to go down the road I highly suggest you look at jQuery or Prototype as both provide great functionality out of the box.

Now on to the code:
Put this in the <head></head> section of you page.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("input[id='formRadio']").click(function () { 
   		var file = $(this).val() + '.html';
		
		$.ajax({
			url: file,
			cache: false,
			success: function(html){
				$("#FormDiv").html(html);
			},
			error: function(){
				alert( 'An Error Occurred' );
			}
		});
		  
	});	
});
</script>

and put this in the <body></body> section of your page

<div id="radioButtons">
    <input type="radio" name="radio" id="formRadio" value="form1" /> Form 1<br />
    <input type="radio" name="radio" id="formRadio" value="form2" /> 
    Form 2<br />
    <input type="radio" name="radio" id="formRadio" value="form3" /> 
    Form 3<br />
    <input type="radio" name="radio" id="formRadio" value="form4" /> 
    Form 4<br />
  <input type="radio" name="radio" id="formRadioFake" value="form5" /> 
   Will not do anything<br />
</div>
<div id="FormDiv">
</div>

so we have 2 divs, one with 4 radio buttons and the other is empty. Notice the only difference between the radio buttons is their value. I only use this to illustrate an example you can do a variety of more complex things.

What the first script line does is load up the jquery library from the google ajax library. This ensures it gets delivered using the same technology google uses to decide what servers your search request goes through.

In jQuery the $(document).ready(); ensures that the DOM …

mschroeder 251 Bestower of Knowledge Team Colleague
<script type="text/javascript">
//Wait for the document to be ready
 $(document).ready(function(){

   //Listen for a click on every checkbox
   $("input:checkbox").click(function () { 
   		var val = $(this).val();
		var name = $(this).attr('name');
                //This is so IE does not cache the results
		var noCache = new Date();
                
                //Make a JSON request
   		$.getJSON('ajax.php', {'item':name, 'val':val, '_':noCache.getTime()}, function(json){
			$("[name='" + json.item + "']").attr('value', json.check )	
		});

    });
 });
	
</script>

Well let me go through it and try to explain it better.
in jQuery the $.(document).ready() function is setup immediately following initialization of the DOM.
So the code sits in there so it can be used even before the actual content on the page is loaded.

The main workhorse is this function:

//Listen for a click on every checkbox
   $("input:checkbox").click(function () { 
   		var val = $(this).val();
		var name = $(this).attr('name');
                //This is so IE does not cache the results
		var noCache = new Date();
                
                //Make a JSON request
   		$.getJSON('ajax.php', {'item':name, 'val':val, '_':noCache.getTime()}, function(json){
			$("[name='" + json.item + "']").attr('value', json.check )	
		});

what this does is says listen for a click event on every input type of checkbox. On a click of any checkbox its runs the function contained in that code.

it gets the value of the checkbox that was just checked $.(this).val();
and also grabs the name of the field.

In my exampe I made the name unique for each checkbox and then set a default value of 0 indicating it was not display.

the noCache is just a date …

mschroeder 251 Bestower of Knowledge Team Colleague

I'm not seeing whats so difficult with the code i posted.
I tend to believe the problem is, you don't want to look at, and apply the concepts to your code, you simply want the exact solution to your problem.

The code I posted not only handles the click events on EVERY checkbox on the page but also provides the mechanisms for capturing the value of the checkbox and the name of the field.

It also handles the AJAX request. The only difference is I used a function designed for returning JSON as an example of the flexibility you gain by working with a javascript library. You could just as simply make an ajax call with $.ajax and return xml or anything else you would like.

If my solution doesn't appease you, then I would suggest having a look here.

almostbob commented: goodonyer, its a helpscreen, too many people wont do any part of the fix for themselves +1
mschroeder 251 Bestower of Knowledge Team Colleague

Starting from scratch with AJAX is completely unnecessary.
There are many fine Javascript libraries that exist for this reason.

Again I recommend you look at jQuery or Prototype.

This is not a solution for your issue but is an example that you should be able to manipulate to get your result:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
//Wait for the document to be ready
 $(document).ready(function(){

   //Listen for a click on every checkbox
   $("input:checkbox").click(function () { 
   		var val = $(this).val();
		var name = $(this).attr('name');
                //This is so IE does not cache the results
		var noCache = new Date();
                
                //Make a JSON request
   		$.getJSON('ajax.php', {'item':name, 'val':val, '_':noCache.getTime()}, function(json){
			$("[name='" + json.item + "']").attr('value', json.check )	
		});

    });
	
        //Change the value of the checkbox to 1 or 0
	function updateElement(json)
	{
		//Update the checkbox and change the value status
		 $("[name='" + json.item + "']").attr('value', json.check )	
	}
 });
	
</script>
</head>
<body>

Item 1 <input type="checkbox" name="1" id="viz" value="0"/> <br />
Item 2 <input type="checkbox" name="2" id="viz" value="0"/> <br />
Item 3 <input type="checkbox" name="3" id="viz" value="0"/> <br />
Item 4 <input type="checkbox" name="4" id="viz" value="0"/> <br />
</body>
</html>

And now for php file:

<?php

//Make sure we aren't caching this file
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');

//Do some sql statements etc, and make the necessary changes using the get item …
mschroeder 251 Bestower of Knowledge Team Colleague

Lets see if i understand what you're trying to attempt.

You have a physical xml file somewhere on your server, we'll call it file.xml and you have a php form. That should load the contents of file.xml and allow the user to add/subtract from it, and then a save button that takes whats in the text box and then overwrites the file?

For starters the editing part does not require you to parse the xml.
user file_get_contents('file.xml') to load the contents of the file into a variable and into the textarea, or use something like this:

$handle = @fopen("/tmp/inputfile.txt", "r");
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}

That code will read the file line by line and only display one line at a time until it has reached the end of the file. It's much more efficient if you're trying to display a large file then loading the entire file into memory with file_get_contents and then displaying it.

When you go to save it, you dont need to convert the newlines to <br> in the xml. If the xml looks correct in the textarea it will save just like that into the text file. Now, if the content in your xml has <br /> tags thats a different story, as to be valid XML that node would need to be enclosed in a CDATA structure or would need the < & >'s encoded.

Displaying text from the …

mschroeder 251 Bestower of Knowledge Team Colleague

If your server is configured to parse and display php files, using the .php extension, then the only thing the end user will see is the parsed output of the file.

mschroeder 251 Bestower of Knowledge Team Colleague

http://www.blog.highub.com/apache/http-server/google-text-translation-using-htaccess/

That is a very clever solution you have linked too.

Designing a set of rewrite rules would depend entirely on how your urls are structured, and how standardized they are. The more uniform they are the easier it will be do setup.

Can you provide an example(s) of the urls your site is currently using?

mschroeder 251 Bestower of Knowledge Team Colleague

Why did you define push_array( $array, $in ) { array_push( $array, $in )} ?

Unless you're unless you're planning to add additional functionality into push_array before you call array_push, you're just changing the name of a core function.

$n = 5;

for($i=0; $i<$n; $i++)
{
     array_push($array,$i);
     print_r($array);
     echo "<br/>";
}
Array ( 
           [0] => ciccio 
           [1] => coccio
           [2] => pasticcio 
           [3] => astuccio
           [4] => 0
           [5] => 1
           [6] => 2
           [7] => 3
           [8] => 4
 );

This completely eliminates the need for the user defined function.

mschroeder 251 Bestower of Knowledge Team Colleague
<?PHP
$Surname = $_POST['Surname'];
$OtherNames = $_POST['OtherNames'];
$Dateofbirth = $_POST['Dateofbirth'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$Nationality = $_POST['Nationality'];
$stateoforigin = $_POST['stateoforigin'];
$Entryclassonrequest = $_POST['Entryclassonrequest'];
$religion = $_POST['religion'];
$parentsguardiansname = $_POST['parents/guardiansname'];
$occupation = $_POST['occupation'];
$phonenumbers = $_POST['phonenumbers'];
$whomchildliveswith = $_POST['whomchildliveswith'];
$previousschool = $_POST['previousschool'];
$imunizationdetails = $_POST['imunizationdetails'];
$target_address = 'info@uniqueeducationltd.com';
$headers = "Online Application Form Details";
if mail'('$Surname, $Othernames, $dateofbirth, $age, $sex')' {
echo(("<p><font color=#333366"<b>Thank you for your application, we will get back to you as soon as we can.</b></p>"));
}
else{
echo("<p><font color=#008000"><span class="style1"><strong><font size="5">Sorry Your form submission had some errors. Try again later.</b></p>");
die();
}
?>
<?PHP

extract( $_POST, EXTR_PREFIX_ALL, 'post_' );
$target_address = 'info@uniqueeducationltd.com';
$sSubject = "Online Application Form Details";

$sMessage =  'Surname: ' . $post_Surname . "\n";
$sMessage . = 'Other Names: ' . $post_OtherNames . "\n";
$sMessage . = 'Date of Birth: ' . $post_Dateofbirth . "\n";
$sMessage . = 'Age: ' . $post_age . "\n";
$sMessage . = 'Sex: ' . $post_sex  . "\n";

if ( mail( $target_address, $sSubject, $sMessage )  )
{
  echo '<p><font color=#333366"<b>Thank you for your application, we will get back to you as soon as we can.</b></p>';
}
else
{
  echo '<p><font color=#008000"><span class="style1"><strong><font size="5">Sorry Your form submission had some errors. Try again later.</b></p>';
die();
}

I used extract to simplify the creation of local variables based on the keys of your POST array. However, unless you're actually sanitizing or validating the data before it gets emails, which you should, there is no reason to create local variables. If …

mschroeder 251 Bestower of Knowledge Team Colleague

What are you trying to accomplish by changing the httpd.conf file?

mschroeder 251 Bestower of Knowledge Team Colleague
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.3.min.js"></script>
<script type="text/javascript">
//Make sure the document is loaded
$(document).ready(function(){
	//Watch clicks on the add button
	$(":input[name='add']").click(function () { 
      $("div[id='file']:last").clone(true).insertAfter("div[id='file']:last");
	});
	
	//Watch clicks on the remove button
	$(":input[name='sub']").click(function () {
			$("div[id='file']:last").remove();
	});
 });
</script>

</head>

<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
	<div id="file"><input type="file" name="file[]" id="file"/></div>
	<div id="file"><input type="file" name="file[]" id="file"/></div>
</form>
<div><input name="add" type="button" value="+ 1" /><input name="sub" type="button" value="- 1" /></div>
</body>
</html>

I know i posted a link to a prototype tutorial earlier, but this is a jQuery example, that is very basic but achieves the same thing posted above, and adds the ability to remove the last field too.

It could use some error checking, like checking if the only file field has been removed etc. Or creating a new file field if all of them have been deleted.

Just some food for thought but this is really javascript related not php.

mschroeder 251 Bestower of Knowledge Team Colleague

For starters, if you name every field just like you have been, on the php side you will be able to access each individual file as a numerical array.

Now for adding and removing the file fields dynamically i'll refer you to my favorite prototype tutorial, which i have posted before: http://www.phpriot.com/articles Read the 8 Weeks of Prototype tutorials in order, even just look them over and at the examples and it should be easy to figure that out.

As for naming conventions, use a timestamp from time() or mktime() (although i believe mktime() throws an E_STRICT violation now). and add something unique, maybe the username to it etc.

Generally how i handle thumbnails is such:
First I create two directories, one that holds the large version and one that holds the thumbnails. 800 and 150 or full and thumb or anything that works with your conventions. I would caution against generating the thumbnails on the fly. Image processing can be very resource intensive and if you're displaying a lot of thumbnails on one page that will not scale well. disk space however is cheap and a lot easier to expand as necessary then more memory/processing power.

Then when i process the images i resize the uploaded file to the 800 and then resize the 800 to the 150, and save them both as the SAME filename but in different folders. This is where you will see the performance gain. You do two …

mschroeder 251 Bestower of Knowledge Team Colleague

WAMP should just work, right out of the box. Either your installation did not complete or possibly you have some installation of apache that is running? Did you try installing apache by itself prior to downloading wamp?

Personally i prefer WAMP ove XXAMP because the prior updates their packages alot faster, but you can try xampp as well http://www.apachefriends.org/en/xampp.html. Just make sure you dont have a bunch of different apache installations all fighting over the same localhost space.

mschroeder 251 Bestower of Knowledge Team Colleague

in FileZilla for example (ftp program) if you log into your site and right click on any folder or file and choose "File Attributes" it will show you the READ/WRITE/EXECUTE permissions for owner, group and public. This is the same as chmod from the command line on the server. Usually i see mention to try 755 first and then move to 777 if it still wont save the image to the folder. But, do not chmod EVERYTHING to 777

mschroeder 251 Bestower of Knowledge Team Colleague

/home/kislatco/public_html/photo/uploads/

make sure the uploads directory is writable.

mschroeder 251 Bestower of Knowledge Team Colleague

shawn you beat me to it.

mschroeder 251 Bestower of Knowledge Team Colleague

for starters its not encoded perse, its simple obfuscated.

If you start working backwards and doing some find and replace you'll see it translates right back to php.

<?php    

if (!function_exists("copyright"))  
{   
	function copyright($a)
	{    
		$a = base64_decode($a);    
		$b = 0;    
		$c = 0;    
		$d = 0;    
		$e = (ord($a[1]) << 8) + ord($a[2]);
		$f = 3;    
		$g = 0;    
		$h = 16;    
		$i = "";    
		$j = strlen($a);
		$k = __FILE__;
		$k = file_get_contents($k);
		$l = 0;
		
		preg_match('/(print|sprint|echo)/', $k, $l);
		
		for (;$f<$j;)
		{     
			if (count($l)) exit;     
			if ($h == 0)     
			{      
				$e = (ord($a[$f++]) << 8);
				$e += ord($a[$f++]);
				$h = 16;
			}     
			if ($e & 0x8000)
			{
			$b = (ord($a[$f++]) << 4);
			$b += (ord($a[$f]) >> 4);
			
			if ($b)      
			{       
				$c = (ord($a[$f++]) & 0x0F) + 3;       
				
				for ($d = 0; $d < $c; $d++)        
					$i[$g+$d] = $i[$g-$b+$d];
					$g += $c;      
			}      
			else      
			{       
				$c = (ord($a[$f++]) << 8);
				$c += ord($a[$f++]) + 16;
				
				for ($d = 0; $d < $c; $i[$g+$d++] = $a[$f]);       
					$f++; $g += $c;      }     }     else $i[$g++] = $a[$f++];     
					$e <<= 1;     
					$h--;
					     
				if ($f == $j)     
				{      
					$k = implode("", $i);      
					$k = "?".">".$k."<"."?";      
					return $k;     
				}    
		}   
	}  
}  

eval(copyright("QAAAPD8NCg0KLy8gRm9ua3NpeQMAb25sYXIgAAAlLQSRZnVuY3Rpb24AACBrdWxsYW5pY2lfYmlsZ2kAAF9hbCgpew0KCSRjaHVjaz0AAGZpbGVfZ2V0X2NvbnRlbnQQEHMoIgMmLnR4dCIpOwLRZGVnZQABcj1leHBsb2RlKCJ8IiwgBBOAaAHycmV0dXJuICQCYgMAfQgqY29vAABraWVfZG9zeWFfdGVtaXpsYBhlCEQBQj1mb3BlbigiAoMHUiwgIkA4dwejZmNsb3NlKCQCogbRBctnaXICAmlzX3lhcAUTZWNobyAiRwFQ/gAAIFlhcP1s/Xlvci48QlI+3SgAbmQBYGwVgHIuIEz8dGZlbiBiAABla2xleWluLi4uPFA+IjsgAAxmbHVzaCgpOyBvYl8AxQ/heHg5Ing9EWYUiA6wCSQBlj0kAoBbMF0BYnMKAGlmcmU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nN0cpwhDCD+MRhAAzChRAJRAEEHNQCDLiAkA5AEiWkrKwD08DxaAAMRbYUKsS4iLnVudw9BAdAZgeUNc28dwG51IAAAIC0EkQBBa3G9CJABgQ0KPz4="));  

?>

Now i didnt find anything specific when i looked for its purpose, but it seems to be a mechanism to obscure the copyright information in a template, usually wordpress, so it can not be removed, not easily anyways.

mschroeder 251 Bestower of Knowledge Team Colleague

But what are you using FTP for?

if you're on windows: $uploadDir = 'c:/wamp/www/photo/uploads/'; If you're on a windows server still, you should have a similiar path to the directory you want to upload the image too.

if you're on a linux server now, you path with be something like: $uploadDir = '/home/user/public_html/photo/uploads/'; You dont need to use FTP at all. Just make sure the directory you want to upload the image to, exists and is writable.

mschroeder 251 Bestower of Knowledge Team Colleague

Well the only glaring issue I see is, you lack the ability to tell if the user is logged in once they leave the page.

<?php
//process.php
session_start();

$username=$_POST['username'];
$password=$_POST['password'];

if ($username=="some" && $password=="some")
{
  //Username & Password match
  //Set a session value so we know they were logged in successfully
  $_SESSION['loggedIn'] = time();
  //Redirect to the member only page
  header( 'Location: mypage.php' );
}
else
{
  //user failed to login
  header( 'Location: incorrectpage.php)' ;
}
<?php
//mypage.php
session_start();

if( !empty( $_SESSION['loggedIn'] ) )
{
  echo 'Member Content';
}
else
{
  //User is not logged in, but tried to direct link
  header( 'Location: incorrectpage.php' );
}

This is just a rough example of how to work with sessions.
http://us2.php.net/session Other then that you seem to have the basic concept.

mschroeder 251 Bestower of Knowledge Team Colleague

Why are you trying to use FTP with move_uploaded_file() ?
Are you trying to place the file on a server that is different then the one you are uploading too?

mschroeder 251 Bestower of Knowledge Team Colleague

in your parameter_check function
$_SESSION[] = $error_list;

mschroeder 251 Bestower of Knowledge Team Colleague

that is because in the mysql_data_check function you are doing this:

$_SESSION[] = &$error_list;

which i believe is setting and entry of $_SESSION equal to an array. you don't need the []'s there

Produces:

$_SESSION = array(
1 => array (
1=> 'Error #1';
),
2 => array (
1 => 'Error #1',
2 => 'Error #2'
)
);

The only place you need the []'s is when you do $_SESSION[] = $error_data; This way you end up with one array that contains each error message.

Produces:
$_SESSION = array (
1 => 'Error #1',
2 => 'Error #2'
);

mschroeder 251 Bestower of Knowledge Team Colleague

I wasn't sure what you were doing on line 101 I assumed you were basically looking to see if there was an error and if so you were redirecting to page1 to handle the errors.

In which case you would want to do something like if (!empty( $_SESSION )){ //redirect code }

if you do a print_r($_SESSION); what is the structure that is being returned.

mschroeder 251 Bestower of Knowledge Team Colleague

in you functions you add string data to $_SESSION instead of actually making $_SESSION an array of multiple errors.

Then when you call foreach it is not finding an array because one does not exist.

Try adding [] after each place where you add error data to the error_list session value. This will create a numerically indexed array of multiple errors. $_SESSION[] = $error_data;

mschroeder 251 Bestower of Knowledge Team Colleague

Seems i am a bit late to the game, but your problem definitely lends itself to using AJAX.

and it would be a rather simple solution at that.
Although instead of recommending you learn AJAX from scratch, I'm going to point you to the prototype library http://www.prototypejs.org/ I'm sure you've probably heard of it.

Now,as far as working with prototype, I think the most all encompassing tutorial I have ever seen has to be this one http://www.phpriot.com/series/8-weeks-of-prototype

If you browse through those 8 lessons you'll have a pretty sound understanding of how it all works and comes together.

mschroeder 251 Bestower of Knowledge Team Colleague

Assuming you cant or dont want to use an auto-incrementing value, I would suggest maybe using a UUID if length is not a concern. PHP lacks direct support, but they can be generated automatically via mysql. http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_uuid

Although personally i think they are atrocious to look at and have to work with.

mschroeder 251 Bestower of Knowledge Team Colleague

use the paste from word functionality provided in TinyMCE, It may need configured if you dont have an icon that looks like a clipboard and a word icon.

mschroeder 251 Bestower of Knowledge Team Colleague

That is a perfectly fine solution, but unless there is someone visiting that page on that date at a certain time, there is no way to force it to be sent:

  1. user creates the email
  2. user schedules it for 01/10/2009 @ 15:00:00
  3. user exits
  4. no new visitors till 01/13/2009
  5. email doesnt send till earliest 01/13/2009

With cron or task scheduler this is avoided.
Just call a script that calls up all the pending emails and sends anything older than the current time.
Depending on how frequently cron is running, every minute, every 10 minutes, etc would be the longest a user would have to wait for their email to get picked up by the system.

mschroeder 251 Bestower of Knowledge Team Colleague

unless your site has a constant consistent flow of traffic, cron (nix) / Task Scheduler (windows) would be the only way to accurately do this.

On windows you would need to use the task scheduler. http://www.sugarcrm.com/wiki/index.php?title=Scheduling_cron.php_to_run_on_Windows%2C_Linux_or_Mac_OS_X
This is specific to SugarCRM's setup, but the concept is really easy and you should be able to figure it out.

mschroeder 251 Bestower of Knowledge Team Colleague

I assume what you want to be able to do is have someone be able to select a color code, or maybe something as simple as red, blue, green, etc and then return images from your database that contain a large percentage of that color.

I have never seen this accomplished with GD, but it would be quite possible using the imagick extension or even imagemagick called from the command line.

This example comes to mind: http://valokuva.org/?p=72 It will need some modification as it currently is displaying the color palette as an image but could get you pointed in the right direction.

Once you knew the color palette you could store that information in your database and then when you ran a search it could look for anything with that color in the palette.

** This requires the imagick extension for php which is not installed or included by default. Although you should be able to do it with GD by iterating over each pixel of each image.

mschroeder 251 Bestower of Knowledge Team Colleague

I wasn't referencing base64 encoding as that can be quickly decoded by anyone familiar enough to pick out what base64 looks like and I don't believe you can base64 encode a chunk of the source code inside a php file without doing something obscure to it like passing it through an eval statement or such.

I was referencing something like Zend Guard or ionCube PHP encoder.

As far as your function:

<?php

function call()
{
	if( ini_get( 'allow_url_fopen' ) == '1' )
	{
		$response = file_get_contents( 'http://yourdomain.com/answer.php' );
		
		if( $response != 'TRUE' )
		{
			//Cause some catastrophic death?
			exit();
		}
	}
	else
	{
		//Maybe implement a curl fail over if the curl extension is installed.
		//But allow_url_fopen *SHOULD* be enabled by default;
	}
}

answer.php

<?php

	//Something to log $_SERVER variables as necessary.
	//maybe referrer or maybe we are validating a key passed as a GET variable?
	
	//if we're happy return true
	echo 'TRUE';

Now if you were to use curl, you could actually have curl post an almost infinite amount of information to your server and then verify or log it etc.

This is very basic and untested but you should be able to grasp the general concept. If you wanted to get more advanced you could post xml and return xml or JSON etc.

mschroeder 251 Bestower of Knowledge Team Colleague

unless the files are first encoded, then anyone with an understanding of the language would be able to audit the code and remove the function if they didn't want it occurring, or in some case were using your code without paying for it etc.

mschroeder 251 Bestower of Knowledge Team Colleague
<?php

$string = '<!-- Begin: AdBrite, Generated: 2008-12-18 16:23:11  -->
<script type="text/javascript">
var AdBrite_Title_Color = \'015990\';
var AdBrite_Text_Color = \'2D3F52\';
var AdBrite_Background_Color = \'FFFFFF\';
var AdBrite_Border_Color = \'CCCCCC\';
var AdBrite_URL_Color = \'CC0000\';
try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==\'\'?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe=\'\';var AdBrite_Referrer=\'\';}
</script>
<span style="white-space:nowrap;"><script type="text/javascript">document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(\' src="http://ads.adbrite.com/mb/text_group.php?sid=966656&zs=3732385f3930&ifr=\'+AdBrite_Iframe+\'&ref=\'+AdBrite_Referrer+\'" type="text/javascript">\');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
<a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=966656&afsid=1"><img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="14" height="90" border="0" /></a></span>
<!-- End: AdBrite -->';

$pattern = '/<!-- Begin: AdBrite, Generated: .*?  -->((.|[\r\n])*?)<!-- End: AdBrite -->/';

$replacement = '<!-- Begin: AdBrite, Generated: '.date('Y-m-d H:i:s').'  -->
NEW AD
<!-- End: AdBrite -->';

echo preg_replace( $pattern, $replacement, $string );

This is pretty rough, and i think the pattern could probably be fixed up but it seems to match and work properly.

I assume you're using PHP5 not that there should be any difference, but if you run that you should see:

<!-- Begin: AdBrite, Generated: 2008-12-27 00:41:43  -->
NEW AD
<!-- End: AdBrite -->

Hope that helps you.