-
Member
[PHP} - Need some help in recoding a script
Hey guys. I got a Problem with a script that did the following Things:
In Germany there are many house-dealers which are using CRM Systems like OnOffice.com or Flowfact. These are Management-Systems. You can enter all Details for an house and can spread it onto different Portals like immoscout24.de , Immonet.de etc... These CRMS have the Option to Export the data onto own Portals like wordpress etc. This is called OpenImmo.
There is where the Trouble starts. the customer got a script which has worked as the following:
PHP Code:
foreach ( $folder_names as $real_estate_id ) :
$folder_path = $this->open_immo_path . $real_estate_id;
$xml_path = $folder_path . '/' . $real_estate_id . '.xml';
$xml_obj = simplexml_load_file( $xml_path );
open_immo_path has been declared and this has worked already. But the customer has Chosen to leave OnOffice and move to FlowFact and they are exoprting the same way but the XML has got an another Name than the Folder so the script does not work.
However, i am not a pro at this. I Need help - Of Course not for free!.
What i Need now is something like that:
PHP Code:
foreach ( $folder_names as $real_estate_id ) :
$folder_path = $this->open_immo_path . $real_estate_id;
$xml_path = $folder_path . '/' . $real_XML_name.;
$xml_obj = simplexml_load_file( $xml_path );
$real_XML_Name - Can somebody help me to fill it?
i tried to mess around with glob a bit but only got full Errors which stopped wordpress at all.
-
Active Member
That code snippet should stay the same, what you need to do is change the value's in the $folder_names array to the new ones.
-
Post Thanks / Like - 3 Thanks
-
Member
No because the $Folder_names are generated from the zipfile´s Name. in this zipfile should be an XML file which has the same Name but thats not the case anymore. only way is to find the right Name of the XML file and load it for parsing.
How can i find out the Name ? is there a load all Feature or something?
-
Active Member
http://php.net/manual/en/function.rename.php
To rename the .xml
And
function chopExtension($filename) {
return substr($filename, 0, strrpos($filename, '.'));
}
to get the name of the .zip without the extension.
Last edited by Tronux; 10-06-2015 at 07:08 AM.
-
Post Thanks / Like - 3 Thanks
-
Member
Originally Posted by
Tronux
PHP: rename - Manual
To rename the .xml
And
function chopExtension($filename) {
return substr($filename, 0, strrpos($filename, '.'));
}
to get the name of the .zip without the extension.
hm. no renaming is needed. i Need to find the Name of the XML . then i can save it in $real_xml_name and edit it to:
PHP Code:
foreach ( $folder_names as $real_estate_id ) :
$folder_path = $this->open_immo_path . $real_estate_id;
$xml_path = $folder_path . '/' . $real_XML_name.;
$xml_obj = simplexml_load_file( $xml_path );
-
Active Member
This is a function to read the zip file. I hope you can locate the .xml you need or otherwise call flowfact for how that .xml file is getting named when put in the .zip.
<?php
/*
* PHP Zip - Open a zip archive and list files
*/
//create a ZipArchive instance
$zip = new ZipArchive;
//open the archive
if ($zip->open('data/test112.zip') === TRUE) {
//iterate the archive files array and display the filename or each one
for ($i = 0; $i < $zip->numFiles; $i++) {
echo 'Filename: ' . $zip->getNameIndex($i) . '<br />';
}
} else {
echo 'Failed to open the archive!';
}
?>
-
Post Thanks / Like - 3 Thanks
-
Member
Originally Posted by
Tronux
This is a function to read the zip file. I hope you can locate the .xml you need or otherwise call flowfact for how that .xml file is getting named when put in the .zip.
<?php
/*
* PHP Zip - Open a zip archive and list files
*/
//create a ZipArchive instance
$zip = new ZipArchive;
//open the archive
if ($zip->open('data/test112.zip') === TRUE) {
//iterate the archive files array and display the filename or each one
for ($i = 0; $i < $zip->numFiles; $i++) {
echo 'Filename: ' . $zip->getNameIndex($i) . '<br />';
}
} else {
echo 'Failed to open the archive!';
}
?>
could you download anydesk from anydesk.de? so i can Show you the exact Problem
-
Active Member
Sry I couldn't help you, I wont be able to make time today to help you further.
-
Member
-
OwnedCore News Correspondent