1

I'm on a RedHat server, with a simple PHP page that has a form, with inputs for name, phone, and url.

When the form is submitted, I run a command to compile a swf using mxmlc. The command is this :

$generate_command1 = "export _JAVA_OPTIONS=\"-Xms32m -Xmx64m\"; /opt/flex/bin/mxmlc -define+=NAMES::Name,\"\'$name\'\" -define+=NAMES::Phone,\"\'$phone\'\" -define+=NAMES::Website,\"\'$url\'\" -output /path/to/my/webserver/httpdocs/swfbuilder/generated.swf DynamicTextTest.as";

$last_line = exec($generate_command1, $out);
print_r($last_line);

The result is always :

Loading configuration file /opt/flex/frameworks/flex-config.xml

When I run the same command from ssh into the server, I actually get a swf generated. I.e.

Picked up _JAVA_OPTIONS: -Xms32m -Xmx64m
Loading configuration file /opt/flex/frameworks/flex-config.xml
/var/www/vhosts/tag.domandtom.com/httpdocs/swfbuilder/generated.swf (945 bytes)
[root@htmlfive swfbuilder]# 

Both directory and files have been CHOWN'd for ownership and CHMOD'd for 775... So what am I doing wrong to get this to work from the web page? Should I have a forked process and wait until it's complete? Sleep?

EDIT:

I've looked into fcsh and other mxmlc / java related questions.

Community
  • 1
  • 1
Dominic Tancredi
  • 41,134
  • 7
  • 34
  • 50
  • Can I ask, what's the point of compiling your code over and over again on submitting the form? – J_A_X Aug 01 '11 at 23:14
  • It's a prototype, but essentially, the user is able to input those values, and dynamically generate a swf he or she can download. Additionally, they're able to preview that swf with those values. It's for flash banner ads, and I'm working on a system to make a part of the process more efficient. Does that make sense? – Dominic Tancredi Aug 02 '11 at 03:01
  • 1
    No, it doesn't. Why don't you just compile a swf that takes data as input and generates something for the user to view. Your way of doing it is extremely inefficient, uses resources and doesn't add much (if any) value. Plus, it'll *a lot* harder to debug. – J_A_X Aug 02 '11 at 03:04
  • 2
    The user is a buyer for flash ads. They need a collection of swfs, one for every car dealer, location, and link-out to that dealer's website. Instead of creating a single swf, that takes this data in dynamically (as originally proposed), they would like 100+ swfs. Instead of having a developer hand-compile these with the proper values, the user would like to go in and make the swfs themselves within our custom CMS for ad management (in case they add a new dealer on their list.) I understand the technical inefficiences. If you understand the requirements, could you help me solve the problem? – Dominic Tancredi Aug 02 '11 at 16:14
  • Probably a stupid question, but have you checked the obvious things like the PHP script execution limit? – Luke Van In Aug 08 '11 at 19:51
  • Also, here's a post using make to run mxml, which may cause more/less issues >> http://flashgamedojo.com/wiki/index.php?title=Make_And_MXMLC_For_Compilation – Luke Van In Aug 08 '11 at 19:57
  • Thanks lukvanin. I went in and tried that. Didn't work... but it made me re-look at my code and output my full command string. Can you believe it had to do with how I was escaping the single quotes? Turns out, I was escaping them but I didn't need to for the singles, since that's valid for the command but I DID need to for the double quotes. – Dominic Tancredi Aug 09 '11 at 01:46

1 Answers1

2

In re-reviewing the code, I noticed that I shouldn't have escaped the single-quotes. They're valid for the actual execution and I should only escape DOUBLE quotes for php in this instance...

The final code looks like this (for future reference) :

<?php 
$name = "generated";
$phone = "";
$url = "";

if(isset($_POST['name'])) {
    $name = $_POST['name'];
}
if(isset($_POST['phone'])) {
    $phone = $_POST['phone'];
}
if(isset($_POST['url'])) {
    $url = $_POST['url'];
}

$swfname = $name . ".swf";

$generate_command1 = "export _JAVA_OPTIONS=\"-Xms32m -Xmx64m\"; /opt/flex/bin/mxmlc -define+=NAMES::Name,\"'$name'\" -define+=NAMES::Phone,\"'$phone'\" -define+=NAMES::Website,\"'$url'\" -output /path/to/my/webserver/httpdocs/swfbuilder/$swfname DynamicTextTest.as";

exec($generate_command1, $out);
?>
Dominic Tancredi
  • 41,134
  • 7
  • 34
  • 50