Jump to content

OldManRiver

Members
  • Posts

    88
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

OldManRiver's Achievements

Member

Member (2/5)

0

Reputation

  1. All, Also wrote this up at: http://wordpress.org/support/topic/xml-rpc-question?replies=11#post-1775378 and now down to just finding the "Decode" option in the wp.xml-rpc library that envokes the "html_entity_decode()" PHP function to restore the encoded HTML. Since XML requires the encoding or it errors, I'm sure the WP programmers did not overlook this option, so just need to know what it is and how to call it so my code is right once uploaded. If you know this option, please post ASAP! Thanks! OMR
  2. Neil, There might be a easier way. If WordPress has an XML-RPC option to decode my HTML, then encoding is fine. I'm looking to see if that option exists; it should. OMR
  3. Neil, Ah yes you mean add the "debug" line like so: $client = new IXR_Client($url); $client->debug = true; Ah but what I found is this code resolves, when I feed my source to this function: function xml_entities($text, $charset = 'Windows-1252'){ $text = htmlentities($text, ENT_COMPAT, $charset, false); // Encode html chars $arr_xml_special_char = array (""","&","'", "<",">"); $arr_xml_special_char_regex = "(?"; // Build the regex foreach($arr_xml_special_char as $key => $value){ $arr_xml_special_char_regex .= "(?!$value)"; } $arr_xml_special_char_regex .= ")"; $pattern = "/$arr_xml_special_char_regex&(". "[a-zA-Z0-9]+;)/"; // Scan for non XML $replacement = '&${1}'; // Replace non XML return preg_replace($pattern, $replacement, $text); } // end function and I can even fix with this abbreviated function of: function fix_xml ($text, $charset = 'Windows-1252'){ $text = htmlentities($text, ENT_COMPAT, $charset, false); // Encode html chars //$text = htmlspecialchars($text, ENT_COMPAT, $charset, false); // Encode html chars return $text; } // end function I tried fixing it with just the "htmlspecialchars" but still get the errors and when the code/context from this is submitted to WordPress all the html formatting is lost, and it must be maintained. Appears I am looking only to convert specific HTML codes to their "&xxx;" equivalents. Any ideas on which codes actually need converting to meet the XML formatting rules? Thanks! OMR
  4. Neil, Please be specific. I found one post, searching google, that says this is due to the content containing the '#' symbol, so wrote this function: function fix_pound($myline) { $q_idx = 0; $q_pos = strpos($myline,"#",$q_idx); while ($q_pos) { $f_str = substr($myline,0,$q_pos); $e_str = substr($myline,$q_pos); $myline = $f_str.trim("\ ").$e_str; $q_idx = $q_pos; $q_pos = strpos($myline,"#",$q_idx+2); } return $myline; } // end function but still get the error. When I set the content value blank or to a fixed string I hand enter it works fine so know it is not a server parse error, which some posts I found suggested. Just need to understand all the special characters the XML parser blows on. Thanks! OMR
  5. All, Was needing to write to ISP and index into Joomla and WordPress for several sites. Originally opened thread: http://www.phpfreaks.com/forums/index.php/topic,313496.0.html I found the XML-RPC code libraries and it seems to be the answer to my problem. I downloaded the 'IXR_Library.php' library from: http://scripts.incutio.com/xmlrpc/ Installed and tweaked. Ran this sample test code: <?php echo "Beginning the process! <br>"; include ('IXR_Library.php'); $url_lnk = 'http://mysite.com/xmlrpc.php'; $uid_val = 'myuser'; $pwd_val = 'mypwd'; $title="XML-RPC Test Page - Test Draft Entry"; $body="Some test text."; $catg="Uncategorized"; $client = new IXR_Client($url_lnk); if (!$client->query('wp.getCategories','', $uid_val,$pwd_val)) { die ('An error occurred - '.$client->getErrorCode().":". $client->getErrorMessage()); } $res = $client->getResponse(); $content = array('title'=>$title, 'description'=>"$body<p>Hello World!</p>", 'mt_allow_comments'=>0, // 1 to allow comments 'mt_allow_pings'=>0, // 1 to allow trackbacks 'post_type'=>'page', 'post_parent'=>52, 'mt_keywords'=>$keywords, 'categories'=>$catg); if (!$client->query('metaWeblog.newPost','',$uid_val,$pwd_val,$content, false)) { die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage()); } $res = $client->getResponse(); //with Wordpress, will report the ID of the new post echo "Process Ended! <br>"; ?> which ran fine. I then put this into my other code as a function of: function put_wp_xml($parm_ray) { // Called from line 1185 $url = $parm_ray['L']; $uid = $parm_ray['U']; $pwd = $parm_ray['P']; $bod = $parm_ray['B']; include_once('IXR_Library.php'); $client = new IXR_Client($url); $client->debug = true; if (!$client->query('wp.getCategories','', $uid,$pwd)) { die ('An error occurred - '.$client->getErrorCode().":". $client->getErrorMessage()); } $res = $client->getResponse(); $cot = array ('title'=>$parm_ray['T'], 'description'=>$parm_ray['B'], // Content/Article 'mt_allow_comments'=>$parm_ray['M'], // 1 to allow comments 'mt_allow_pings'=>$parm_ray['G'], // 1 to allow trackbacks 'post_type'=>$parm_ray['Y'], // Type = Post or Page 'post_parent'=>$parm_ray['I'], // Parent ID for subpage 'mt_keywords'=>$parm_ray['K'], // Keyword Array 'categories'=>$parm_ray['C']); // Category Array if (!$client->query('metaWeblog.newPost','',$uid,$pwd,$cot, false)) { die ("An error occurred - ".$client->getErrorCode(). ":".$client->getErrorMessage()); } $res = $client->getResponse(); //with Wordpress, will report the ID of the new post } // end function and call it with: foreach ($fls as $file) { // loop through the files $lines = file($file); $fil_lns = ""; foreach ($lines as $lval) { //$fil_lns .= $lval."\n"; $fil_lns .= htmlspecialchars($lval); } // end foreach $lines $row_val = $row_lin[$n]; $url_sit = $row_val['seo_site']; $url_lnk = $row_val['seo_thst']; $uid_val = $row_val['seo_tuid']; $pwd_val = $row_val['seo_tpwd']; if (strpos($url_lnk,'abcarz')) { continue; } $title = get_title($file); $catg = "Uncategorized"; //$body="Some test text."; $put_lin = array (L=>$url_lnk,U=>$uid_val,P=>$pwd_val, T=>$title,B=>$fil_lns,M=>0,G=>0,Y=>'page', I=>'',K=>'',C=>$catg); $rc = put_wp_xml($put_lin); $x++; if ($x==$lm) { break; } // Break on file limit } // end foreach Originally I did not have the nested "foreach loop", so was only getting the filename transferred. When I added the nested foreach loop to get the file contents, I started getting this error: An error occurred - -32700:parse error. not well formed I've searched around for help on this error and as of now have nothing. Hope someone can help with insite to this. Thanks! OMR
  6. All, I solved my problem, more or less. Since the ISP would not let me use an IP address or URL to access the MySQL DB and since trying to resolve that by putting the code on the ISP hosted site, would not let me get local drive control, I found the XML-RPC tool set, downloaded the 'IXR_Library.php' from: http://scripts.incutio.com/xmlrpc/ and wrote code to run locally and get my files to the web through XML. I got the sample with simple code to work, then got it to work with uploading my .html file as a page to WordPress but now getting an error. But I quess my forum rules I need to open a separate thread on that, so I quess I close this one. Thanks!
  7. All, I have a script I wrote that works off a local machine directory, scans it for .html files and uploads those to the server. This works fine in test on my machine with WAMP installed and running localhost, but the activities are for reading/posting the files into my WordPress website and when I move the script to the host, the directory listings are now always the directory on the host machine and I have not figured out how to transfer the directory control back to the local machine. I captured the local directory setting into a 'tools' table I installed into the host MySQL DB. I have searched online for a good example of how to do this, both in the PHP libraries and the JavaScript libraries and have not found a good solution yet. I'm sure there is an example out there, but sure I just do not have the right keywords to find it, so would appreciate a link from anyone who has knowledge on where such a resource might be. Thanks! OMR
  8. mjdamato, Loved your answer and have seen this with single input field and "Browse" button where click on button give pop-up with your "current path" and "directories" inputs, for selection, back to the main form, which is where I'm trying to get. Was thinking it was done with call that opened this in Windows on that OS or other directory pop-up on Linux side. Just do not remember if it was invoked with JavaScript or not. Sorry about not describing the problem clearly; was clear to me. Thanks! OMR
  9. All, You see forms that do this all the time. I'm using the code: $filn = $fdir.'\file'.$fcnt.'.html'; where $fdir is the directory and putting this together with: ftp_get($rmt_con, $rm_file, $filn, FTP_ASCII); where I download the files from the internet, so yes I am controlling the directory 100% and no OS has anything to do with what I am telling the system to do. Thanks! OMR
  10. jayarsee, Well now that we are starting to get and understanding and yes <input type='text'> is in a form, I need to be able to browse for an empty directory with a "Browse" button on the form. I have this code: <input type='text' name='land' size='32'> <input type='button' value='Browse' onClick='GetDirectory();'> but the javascript I found for "GetDirectory()" assumed that I would use type='file' in my first input field, and just parses off the directory from there, that method requires that there is at least one file in the directory to select. There is a way, in javascript, and also in PHP to actually create/call a popup "Browse" window that just looks for a directory, which is what is needed when the directory you are searching for is empty. That is my problem. Slept since I did this about ten years ago, and forgot. Thanks! OMR
  11. jayarsee, Sorry, you sure do not know your coding. When creating a form the coder does have the opportunity to put in a path and send all files being downloaded to that directory and/or subdirectories there under. I quess you never played with any of the FTP, SFTP or SCP functions that are available to you. Cheers! OMR
  12. jayarsee, No user must select empty directory for download operation. OMR
  13. All, Looking for source exampe that lets you select between FTP, SFTP and SCP for file downloads, including ability to catalog all subdirectories and their files. Would appreciate quick shout with URL. Thanks! OMR
  14. All, Looking for a way to browse and get empty directory. All the examples I see are using the: <input type='file'> with extra button, but that means you can not browse for an empty directory. I'm sure there are good examples of this so would appreciate a quick shot with link to some source. Thanks! OMR
  15. All, Hey looking for some code that will let me automate searching the Linux and Ubuntu Man Pages for specific applications. Anyone know of code or a way to do this? I found a "dman" script on the Ubuntu help pages, that uses the "wget" command, but since I need this to work for all OSs, I need to stay away from specific Linux shell commands. I was looking around and think the: $lines = file(URL) might work? Just not sure, since I need to let the search do a wildcard search to find the right manpage. Would appreciate some direction here, never tried URL interrogation before. Thanks! OMR
×
×
  • 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.