Jump to content

Utherr12

Members
  • Content Count

    107
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Utherr12

  • Rank
    Member

Previous Fields

  • Languages
    XHTML, CSS, JavaScipt with AJAX, PHP, MySql

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Location
    Romania
  1. I just found out why... because when only result is generated $plugin somehow is not an array, i just dumped $plugin and it gives me string(7) "fortune" (a result)So if I get multiple results my array looks like $json['plugin'][0]['id'] , if there was only one result it'd be like $json['plugin']['id']
  2. It's the same as the above:array(1) { ["plugin"]=> array(15) { ["id"]=> string(7) "fortune" ["dokulink"]=> string(14) "plugin:fortune" ["name"]=> string(14) "fortune Plugin" ["description"]=> string(26) "Show QOTD (Fortune cookie)" ["author"]=> string(11) "Otto Vainio" ["type"]=> string(6) "Syntax" ["lastupdate"]=> string(10) "2005-08-01" ["compatible"]=> array(0) { } ["securityissue"]=> array(0) { } ["securitywarning"]=> array(0) { } ["tags"]=> array(1) { ["tag"]=> array(2) { [0]=> string(6) "quotes" [1]=> string(6) "random" } } ["downloadurl"]=> string(44) "http://koti.mbnet.fi/oiv/pubtest/fortune.zip" ["bugtracker"]=> array(0) { } ["donationurl"]=> array(0) { } ["relations"]=> array(3) { ["similar"]=> array(1) { ["id"]=> string(8) "xfortune" } ["conflicts"]=> array(0) { } ["depends"]=> array(0) { } } } } Rofl, if i dump_var($plugin['tags']) before the second iteration it shows string(1) "f"omfg, WHY
  3. array(1) { ["plugin"]=> array(15) { ["id"]=> string(7) "fortune" ["dokulink"]=> string(14) "plugin:fortune" ["name"]=> string(14) "fortune Plugin" ["description"]=> string(26) "Show QOTD (Fortune cookie)" ["author"]=> string(11) "Otto Vainio" ["type"]=> string(6) "Syntax" ["lastupdate"]=> string(10) "2005-08-01" ["compatible"]=> array(0) { } ["securityissue"]=> array(0) { } ["securitywarning"]=> array(0) { } ["tags"]=> array(1) { ["tag"]=> array(2) { [0]=> string(6) "quotes" [1]=> string(6) "random" } } ["downloadurl"]=> string(44) "http://koti.mbnet.fi/oiv/pubtest/fortune.zip" ["bugtracker"]=> array(0) { } ["donationurl"]=> array(0) { } ["relations"]=> array(3) { ["similar"]=> array(1) { ["id"]=> string(8) "xfortune" } ["conflicts"]=> array(0) { } ["depends"]=> array(0) { } } } } This error only happens when ["plugin"] is an array of 1, if it's 2+, the error doesn't occur.
  4. Fatal error: Cannot use string offset as an arrayThe line that's being pointed at is $tags = "";foreach($json['plugin'] as $plugin) { //some code here foreach($plugin['tags']['tag'] as $tag) // this is the line with the fatal error $tags .= $tag." "; $tags = "";} i did var_dump for $plugin['tags']['tag'] and it's an array with two elements [0], [1]. I did this to the variable outside the functionIf i do var_dump on that array inside the function the same error occurs.
  5. Utherr12

    Exploding problem

    $archive_types = array('gz','bz','zip'); $url_explode = explode('.',$_REQUEST['url']); $ext = $url_explode[count($url_explode)-1]; if(!in_array($ext, $archive_types)) { echo $lang['error_badurl']; echo ' '.$ext; echo ' '.count($url_explode); exit(0); } the code above returns: "Suspect bad url - unable to determine file name from the url php?id=blogw:Aa_random_page_v2_for_2009 3"The url is fetched from a hidden input with the value http://massou.tk/v2/lib/exe/fetch.php?id=blogw%3Aa_random_page_v2_for_2009&cache=cache&media=blogw:random_page.zipIt has 4 parts.HMMM somehow now it works lol
  6. Thanks, I solved the problem, I hate how PHP handles global variables.
  7. include_once '../../../../inc/init.php';require_once '../lang/'.$conf['lang'].'/lang.php';echo $lang['name']; //this works and display 'Name: 'if(!isset($_REQUEST['action'])) exit(0);$ACTION = $_REQUEST['action'];switch ($ACTION) { case 'get_info': { --something-- break; } case 'search': { $search_string = trim(strip_tags($_REQUEST['string'])); $sort = $_REQUEST['sortBy']; $values = ""; //$xml is from SimpleXMLElement $json = json_encode($xml); $json_d = json_decode($json,true); $x = JSONtoHTML($json_d); echo $x; break; }}function JSONtoHTML($json){ $html = ""; $tags = ""; if(empty($json)) return 0; foreach($json['plugin'] as $plugin) { $html .= '<span name="plugin_search" p_name="'.$plugin['id'].'" p_author="'.$plugin['author'].'" p_type="'.$plugin['type'].'">'; $html .= ' <p><h4>'.$lang['name'].$plugin['name'].'</h4></p>'; $html .= ' <p><b>'.$lang['author'].'</b>'.$plugin['author'].'</p>'; $html .= ' <p><b>'.$lang['type'].'</b>'.$plugin['type'].'</p>'; $html .= ' <p><b>'.$lang['last_update'].'</b>'.$plugn['lastupdate'].'</p>'; $html .= ' <p><b>'.$lang['description'].'</b>'.$plugin['description'].'</p>'; foreach($plugin['tags'] as $tag) $tags .= $tag." "; $html .= ' <p><b>'.$lang['tags'].'</b>'.$tags.'</p>'; $html .= ' <input class="button" type="button" value="'.$lang['btn_download'].'" /><hr />'; $html .= '</span>'; $tags = ""; } return $html;}// the function works, except that $lang[''] is not displayed anywhere Help? (again) $lang array is taken from lang.php
  8. Omg, not the javascript again.... /ashamed
  9. function JSONtoHTML($json){ $html = ""; $tags = ""; var_dump($json['plugin']); //this shows the JSON structure correctly foreach($json['plugin'] as $plugin) { $html += '<span name="plugin_search" p_name="'.$plugin['id'].'" p_author="'.$plugin['author'].'" p_type="'.$plugin['type'].'">'; $html += '</span>'; echo $html; } return $html; //this function returns 0}$json = json_encode($xml);$json_d = json_decode($json,true);$x = JSONtoHTML($json_d);echo $x; // this will return the whole JSON structure + 9 of 0's because the array has 9 elements I have a problem with this piece of code, help :-s ?
  10. I have this piece of code: $plugin_tag = $xxml->children(); $xml->addChild($plugin_tag->asXML()); both of $xml and $xxml are retrieved from an URL.The structure of both in my particular case is xml: <repository></repository>xxml: <repository> <plugin> ... something here... </plugin></repository> What I want to do is to insert the plugin child of xxml to the repository parent of xml. The above code doesn't work unfortunately. I also need all the "plugin" elements if repository has more then 1 plugin node child of repository, is it different from my particular case?
  11. Utherr12

    Get remote XML doc

    omg... Damn javascript, sorry. It happens a lot when I switch from javascript to php (but not the other way around).Nevermind ... i got the last error because i didn't include http://
  12. Utherr12

    Get remote XML doc

    $plugin = isset($_REQUEST['_plugin']) ? trim(strip_tags($_REQUEST['_plugin'])) : 'z';$remote = file_get_contents(urlencode("http://www.dokuwiki.org/lib/plugins/pluginrepo/repository.php?plugins="+$plugin));$xml = new XMLReader;$xml->XML($remote);$xml->close(); Warning: file_get_contents(0): failed to open stream
  13. Utherr12

    Get remote XML doc

    I am sure I'm not lol... I can access it anytime in my browser. (it's a php script that spits a xml-formatted string)LE: file_get_contents(0): failed to open stream: No such file or directory
  14. Utherr12

    Get remote XML doc

    Ok...I have googled and got numerous methods on how to get the contents of a page...none worked. One stated that working with file_get_contents or fopen works. In my code I get "no such file".I tried XMLReader, i got XMLReader::open(): Unable to open source data.How DO I get that remote document as a string?
  15. Oh damn... I just realized there's a or die() statement i'll fix it soon .
×
×
  • Create New...