Jump to content

mendoz

Members
  • Posts

    118
  • Joined

  • Last visited

    Never

Everything posted by mendoz

  1. I've been messing with Zend framework and some new stuff and this my new approach. Each site will have it’s data on a locally stored XML file. The master site can trigger an update on the client site, which would make the client to get an update XML file and cache it. This way The data is stored only on one database.
  2. Sorry, my bad. I'm talking about getting the value from the $str variable, not the array.
  3. <?php $str = "[en]news for the site[/en][es]noticias para sitio[/es]"; $arr = preg_split("(\\[.*?\\])", $str,null, PREG_SPLIT_NO_EMPTY); $languages = array('en','es'); $post = array_combine($languages,$arr); ?> gives: Array ( [en] => news for the site [es] => noticias para sitio ) If I want only whats snide the [en][/en], how can I get it?
  4. Works, but then you'd lose what's inside the square brackets.
  5. Freaks! If I have this text [en]news for the site[/en][es]noticias para sitio[/es] how can I filter it into something like this: Array ( [en] => news for the site [es] => noticias para sitio ) What would be the most efficient way? Thanks, Mendoz
  6. S'up freaks I will have 70 sites fetching data from one "master" website. Each site will need different portions of the data. The client wants to manage all the sites from one main control panel. The data is a list of items, each record has data like (name,date,etc...) Each item has one or some websites that will use it. Each website will get it's corresponding items from the "master" website. Is the right way of doing this is via XML? Each website would request the feed like feed.php?site_id=10, Then it would get it's specific data. Now, What are the best practices for doing this? Caching the feeds and checking if there was an update? Learning what the hell is XML-RPC? Something I'm missing? Thanks, dror
  7. Got it, My problem was that the code for the banner was treated like XML, not a string. Changing '>' to '&#60;' and '<' to '&#62;' solved the problem.
  8. Hey freaks, I'm trying to parse an XML file in PHP, but I need to do thing simpler. This is my code: <?php $file = "http://godojo.org/new/file.xml"; $data = file_get_contents($file); $xml = new SimpleXMLElement($data); $banners = array(); foreach ($xml->children() as $banner) { // get the banner's ID $banner_id = intval($banner['id']); // Loop through all the banners foreach ($banner as $content) { // start building the link $link = "<a "; // get the attributes for the anchor foreach ($content->a->attributes() as $name=>$val) $link .= $name .'="'.$val.'" '; $link .= "><img "; // get the attributes for the img foreach ($content->a->img->attributes() as $name=>$val) $link .= $name .'="'.$val.'" '; $link .= "/></a>"; } $banners[$banner_id] = $link; } print_r($banners); ?> which outputs: Array ( [1] => <a target="_blank" href="http://www.rubyfortune.com/index.asp?s=wgs16875&a=wgsaffad18294" ><img border="0" alt="gambling" src="http://www.wagershare.com/affiliate_media/Banners/b3627.gif" /></a> [2] => <a target="_blank" href="site2.com" ><img src="2.jpg" /></a> [3] => <a target="_blank" href="site3.com" ><img src="3.jpg" /></a> ) This works, but I don't want to parse every attribute, I just to get everything that is inside the <content> element. For example: <banner id="3"> <content> <a target="_blank" href="site3.com"><img src="3.jpg"/></a> </content> </banner> I just want to get: <a target="_blank" href="site3.com"><img src="3.jpg"/></a> Without parsing each and every one of the attributes, or maybe run out of luck if there is no 'img' element inside the anchor. So how do I "bulk" get all that's inside the <content> element? thanks, mendoz
  9. try changing path/to/image.jpg to /path/to/image.jpg And see what happens with the image's URL.
  10. Thanks my friend, this worked: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ $1/ [R=301,L]
  11. Konichiwa freaks Here is my .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /guitar/ RewriteRule ^catalog/ /guitar/dir/catalog.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #wordpress RewriteRule . /guitar/index.php [L] The thing is: I want mysite.com/catalog/category to become mysite.com/catalog/category/ This shouldn't be much of an issue, right? Thanks!
  12. Hey freaks. I'm working on a products catalog application. Every product has a parent category. The categories are organized nicely in a tree, Only the leaves have products associated with them. I hope you understood because now comes the questions: 1. What to do with the products associated with a leaf after it has been deleted? Should I delete the products as well? Put them in a trash bin? 2. What happens with the children of a node after it's deletion? Do they become the children of the node's parent? 3. Why do I like this site? Because the people are nice and answer fast and accurate !
  13. Yeah, but I want different templates . Maybe all categories will show ('name','year','weight','height'), Except for two categories which will show ('name','year','color','temperature'); So I would need two templates. What I did so far: templates_table: template_id template_name templates_cell_table: cell_id template_id cell_name products categories data_templates templates_cells id id id id parent_id parent_id name template_id name name text [/td] [td]template_id Now it is easy to select a template and to get it's cells. But what about the data for each product?
  14. Thanks for your comment smartin. You got my request wrong, I already have an idea of how the front-end should be like. I'm just asking for an idea on what tables do I have to create to store this dynamic data.
  15. Try this: <?php // Get the results from the database $mlistcontacts = mysql_query('SELECT email FROM emaillist WHERE emailID>0'); // You want an associative array, not a numeric, so we'll use mysql_fetch_assoc while($mlistcontacts = mysql_fetch_assoc ($mlistcontacts)) { // You forgot the single quotes around email $contacts[$i] = $mlistcontacts['email']; $i++; } echo implode(",", $contacts); ?>
  16. Yeah, I know it's gonna take a table or two or three. But how?
  17. Hey guys. I don't know if the title is correct but here is the situation. Some of my database: All going well so far. Now I would like each product to have extra data depending on the category. For example: products in 'Laptop' category would have data like 'battery_time', 'memory', 'cpu' etc. I'd like the user to be able to edit different 'data sets' or whatever this is called. For example: user wants to add fields 'color' and 'year' to the extra data template for category 'guitar'. How can I represent the this in mysql? I hope you could understant my question... If not tell me please. Thanks!
  18. I want instead of index.php?p=product&id=3 to use index.php/product/3 This is similar to the permalinks in wordpress. I'm working on a new project but forgot how this action is called. If you could so kindly remind me of this action's name . Thanks guys 100 posts, cool
  19. You might find these helpful: http://www.php.net/global http://www.phpit.net/article/using-globals-php/
  20. Nope, Still time out with big files. Can someone post the correct setting ?
  21. Hey, This little bastard time out when uploading large files, something larger than 5MB. This ultra urgent, If someone has a nice upload script let me know. Thanks <?php // we connect to the database require("../conn.php"); // we get the id $id = $_GET['id']; //uses $_FILES[] global array //see manual for older PHP version info //This function will be used to get the extension from the filename function get_extension($file,$length=-1){ $p = strrpos($file,"."); $p++; if($length!=-1){ $ext = substr($file,$p,$length); } if($length==-1){ $ext = substr($file,$p); } $ext = strtolower($ext); return $ext; } //Not good practice, but here anyway //change to suit your needs //also some have to be set in the ini //for this to correctly work //2meg max ini_set("upload_max_filesize","200M"); //turn on file uploads ini_set("file_uploads","1"); //set your temp dir ini_set("upload_tmp_dir","/tmp"); //set post size large enough to accomidate //3 2meg files and some overhead ini_set("post_max_size","200M"); ?> <html> <head> <title>ftp connect and upload</title> </head> <body> <?php //check to see if we have submited yet if($_POST["submit"]!="submit"){ //not yet so lets make the form ?> <p>Upload Files to ftp site (200M MAX)</p> <p> <form name="fileup" method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>"> <input type="file" name="userfiles[]"> <br> <!-- change below to your max --> <input type="hidden" name="MAX_FILE_SIZE" value="200000000000"> <input type="submit" value="submit" name="submit"> </form> </p> <?php } //see if we have submited and that the files array has been set if(($_POST["submit"]=="submit")&&(is_array($_FILES['userfiles']))){ ini_set('max_execution_time',12000); $ftp_user_name="******"; //change to ftp username $ftp_user_pass="********"; //change to ftp password $ftp_server="********.web.aplus.net"; //change to ftp url $ftp_dump_dir="/html/images/nannies/videos/"; //change to destination directory //go through all the files for($x=0;$x<count($_FILES['userfiles']['name']);$x++){ //now we do some file checking //check to see if file is there if($_FILES['userfiles']['name'][$x]!="none"){ //file has a name //check filesize if($_FILES['userfiles']['size'][$x]!=0){ //file is larger than 0 bytes //Check to see if it is uploaded if(is_uploaded_file($_FILES['userfiles']['tmp_name'][$x])){ //file has been uploaded! //let the user know their file has be uploaded echo "file ".$_FILES['userfiles']['name'][$x]." uploaded!<br>"; //conect to ftp server $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!<br>"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server! <br>"; //set PASV mode if(!ftp_pasv($conn_id,TRUE)){ echo "Could not enter PASV mode!"; } //rename to file#_date.ext $filename = "nanny".$id; $filename.= ".".get_extension($_FILES['userfiles']['name'][$x],3); //change directory if (@ftp_chdir($conn_id, $ftp_dump_dir)) { //maybe you want to make sure we are in the correct directory echo "Current directory is now : ", ftp_pwd($conn_id), "\n"; } else { //you want to know if it didn't work echo "Couldn't change directory\n"; } //upload the file and let the user know what happened if(ftp_put($conn_id,$filename,$_FILES['userfiles']['tmp_name'][$x],FTP_BINARY)){ echo "File ".$_FILES['userfiles']['name'][$x]." was sent successfully<br>"; echo "File was named ".$filename."<br>"; $uploadsql = "UPDATE `nannies` SET `vid`='".$filename."' WHERE `id`=$id"; mysql_query($uploadsql,$connection); }else{ echo "There was a problem sending file ".$_FILES['userfiles']['name'][$x]."<br>";; } } // close the FTP stream ftp_close($conn_id); } else echo"File was not uploaded!<br>"; } } echo "<br>"; }//end for loop } //That's all folks! ini_set('max_execution_time',30); ?> </body> </html>
  22. <?php $id = $_GET['id']; ?> <!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" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>TakeCareLinks.com - Control Panel</title> <link rel="stylesheet" href="css.css" type="text/css" /> </head> <body> <center> <br/><br/>Upload your video<br/> <form enctype="multipart/form-data" action="vidprocess.php?id=<?php echo $id; ?>" method="POST"> <input name="uploadedfile" type="file" /> <input type="submit"> </center> </body> </html>
×
×
  • 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.