Jump to content

jonndoe45

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.thaiwife.org

Profile Information

  • Gender
    Not Telling

jonndoe45's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You best bet is to get firefox installed, install firebug for it and run through what is happening in the debugger can you post the actual code for the submit button, is it done via an onclick or just standard button activation ?
  2. Ok you're thinking about this all wrong the for loop will be in a php file that is NOT the main php file that generates the page, it is called by JS/Ajax the for loop will not produce any other output apart from either xml/json data the xml/json data is passed back to the js the js then updates the div with what is passed back
  3. I found this one the hard way if you have call a url in js something like www.test.com/test.php?id=5 the above is fine, no problem www.test.com/test.php/?id=5 this is also works (not good though and a typo), it works but with your next httprequest what happens is it doesn't get what you expect but you get the last page not the xml docco you expected yuck
  4. put an error_log statement in your script to dump out the query, then run the query in mysql query browser
  5. I have developed a intranet php app. I need to create nice looking printouts - reports and invoices. Yes I know that you can't print for the clients machine, it won't be done like that. The server will do the printouts. What I am going to do is create the printable files in a set directory. The invoices need a graphic image to be printed as the logo then the invoice, probably done on a thermal printer. The reports will be a bog standard printer. So, I need to know if there are print libraries out there to get my formatting set out and how do I test these files easily without having to print them out every time I make a minor change - is there some sort of print preview viewer in Ubuntu ? If anyone can help, greatly appreciated Thanks JD
  6. System: Ubuntu 9.10, lates php, latest apache all x64 Problem: mounting external hard disk formatted under ntfs, using directory commands like is_dir have "no results" i.e when I test if i do something like is_dir('/media/offline1/files/a/') it returns false, although it is a directory. The same would work on mountex ext3 external hd. So, any way around it ? Why does it not work ???? Anyone can help me please. Thanks JD
  7. Here are some functions to access gracenotes via curl, to compare album/track names , just some functions i have been playing with, critique or suggestions most welcome, JD TIA <?php define('NEWLINE', "\n"); define('CACHE_PATH' , "C:\\webserver\\cache\\") ; define('SPLIT_VARIABLENAME', 0); define('SPLIT_TAG_PRESENT', 1); define('SPLIT_TAG_BEGIN', 2); define('SPLIT_TAG_END', 3); # var, present tag, begin tag, end tag $split1 = array(); $split2 = array(); $album = array(); $artist = array(); $tracks = array(); $id = array(); $split1[] = array('album', '<div class="album-name large"><strong>Album:</strong>','>','</a></div>'); $split1[] = array('artist', '<div class="artist-name"><strong>Artist:</strong>', '>', '</div>'); $split1[] = array('id', '?tui_id=', '=', '&tui_tag=">'); $split2[] = array('trackno', '<div class="track_num">', '>', '</div>'); $split2[] = array('trackname', '<div class="track_name">', '>', '</div>'); $pathname = "E:\\music\\artists, single\\athlete, tourist"; getnameinfo($pathname, $hierarchy, $hd_artist, $hd_album); $search = str_replace(' ', '+', $hd_album); $method = "album"; getalbumids($search, $method, true, $split1, $id, $album, $artist); $hdtracks = hd_gettracks($pathname, true, $hd_artist, $hd_album ); echo "ids " . count($id) . "<br>"; echo "album " . count($album) . "<br>"; echo "artist " . count($artist) . "<br>"; $compare=array(); compare_albumnames($hd_album, false, $compare, $id, $album, $artist); gettracks($id[0], true, $split2, $tracks); compare_tracks($hdtracks, $tracks, true); ################################################################################ function getalbumids($search, $method, $show, $split1, &$id, &$album, &$artist){ ################################################################################ $url= "http://www.gracenote.com/search/?query=$search\&search_type=$method"; $filename = CACHE_PATH . "search_" . $method . "_" . $search ; if ( file_exists($filename) ) { $store = file_get_contents($filename);} else { $ch = curl_init( ($url) ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); curl_close ($ch); file_put_contents($filename, $store);} $split = explode(chr(10), $store); $max = count($split); $max2 = count($split1); if ($show){ echo "searching for album by $method called $search<br>"; } for ($n=0; $n < $max; $n++){ for ( $n2=0; $n2 < $max2; $n2++){ if ( is_numeric( stripos($split[$n], $split1[$n2][sPLIT_TAG_PRESENT])) ){ $temp = split3($split[$n], $split1[$n2][sPLIT_TAG_BEGIN], $split1[$n2][sPLIT_TAG_END]); $name = $split1[$n2][sPLIT_VARIABLENAME]; ${$name}[] = $temp; if ($show){ echo "found " . $name . "=$temp<br>"; }} } } return ;} ################################################################################ function gettracks($id, $show, $split2, &$tracks){ ################################################################################ $trackno = array(); $trackname = array(); $url= "http://www.gracenote.com/search/album_details.php?tui_id=$id&tui_tag="; if ($show){ echo "<br><br>looking up tracks for album id ".$id."<br>";} $filename = CACHE_PATH . "album_" . $id ; if ( file_exists($filename) ) { $store = file_get_contents($filename);} else { $ch = curl_init( ($url) ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); curl_close ($ch); file_put_contents($filename, $store);} $split = explode(chr(10), $store); $max = count($split); $max2 = count($split2); for ($n=0; $n < $max; $n++){ for ( $n2=0; $n2 < $max2; $n2++){ if ( is_numeric( stripos($split[$n], $split2[$n2][sPLIT_TAG_PRESENT])) ){ $temp = split3($split[$n], $split2[$n2][sPLIT_TAG_BEGIN], $split2[$n2][sPLIT_TAG_END]); $name = $split2[$n2][sPLIT_VARIABLENAME]; ${$name}[] = $temp; if ($show){ echo "found " . $name . "=$temp<br>"; }} } } $tracks = array_merge2($trackno, $trackname); return ;} ################################################################################ function hd_gettracks($dir, $show, $hd_artist, $hd_album){ ################################################################################ $dir = @$_GET["directory"] ? realpath($_GET["directory"]) : $dir; if ($show){ echo "<br><br>reading tracks from directorty $dir<br><br>";} $last_author = ""; $last_series = ""; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $full_name = "$dir/$file"; if (is_file($full_name) AND is_numeric(stripos($full_name, ".mp3"))) { if ($show){ echo "track $file<br>"; } tidyname($file); $tracks[] = array($file); } } } } tracknofix($tracks); tracknamefix($tracks, $hd_artist, $hd_album); return $tracks;} ################################################################################ function tidyname(&$name){ ################################################################################ $search1 = array( ".mp3", "\"", "\'", "." , "!", "[", "]"); $search2 = array( "_", "=", "-", ","); $name = strtolower($name); $name = str_replace($search1, "", $name); $name = str_replace($search2, " ", $name); #get rid of double spaces $name = str_replace(" ", " ", $name); $name = str_replace(" ", " ", $name); $name = trim($name); return ;} ################################################################################ function compare_name2($name1, $name2, $show){ ################################################################################ $return = 0; $hits = 0; tidyname($name1); tidyname($name2); $split_name1 = explode(" ", $name1); $split_name2 = explode(" ", $name2); if (count($split_name2) > count($split_name1)){ swap($split_name1, $split_name2); swap($name1, $name2);} if ($show){ echo "compare: $name1 to: $name2<br>";} $max = count($split_name1); if ( $max == 1 ) { $pos = array_search($split_name1[0],$split_name2, true); if (is_numeric($pos) AND $pos == 0) { $return = 100; $hits = 1;}} else { $per = 100/($max); $hits = 0; if ($show){ echo "max is : " . ($max) . " per is : " . $per ;} for ($n = 0; $n < $max ; $n++){ $pos = array_search($split_name1[$n],$split_name2, true); if (!is_numeric($pos)){ $pos = array_search2($split_name1[$n],$split_name2);} if (is_numeric($pos)){ if ($show){ echo "pos $pos value " . $split_name2[$pos] . " n $n value " . $split_name1[$n] . "<br>";} $hits++; $return += $per;} } } if ($show){ echo "hits : " . $hits . "<br>" ;} if ($show){ echo "return is : " . $return . "<br>" ;} return $return;} ################################################################################ function compare_albumnames($hd_album, $show, &$compare, &$id, &$album, &$artist){ ################################################################################ if (!empty($id)){ $max = count($id); if ($show){ echo "<br><br>album name on HD is: " . $hd_album . "<br><br>";} for ($n=0; $n < $max; $n++){ $compare[] = round(compare_name2($hd_album, $album[$n], false));} array_multisort($compare, SORT_DESC, SORT_NUMERIC, $album, $id, $artist); if ($show){ for ($n=0; $n < $max; $n++){ echo "$n id " . $id[$n] . " artist " . $artist[$n] . " name " . $album[$n] . " % " . $compare[$n]."<br>"; }} } return ;} ################################################################################ function compare_tracks(&$hdtracks, $tracks, $show){ ################################################################################ if (!empty($hdtracks)){ $max = count($hdtracks); $max2 = count($tracks); for ($n=0; $n < $max; $n++){ $compare = array(); for ($n2 = 0; $n2 < $max2; $n2++){ $compare[] = round(compare_name2($hdtracks[$n][0], $tracks[$n2][1], false) );} array_multisort($compare, SORT_DESC, SORT_NUMERIC, $tracks); $hdtracks[$n][] = $compare[0]; $hdtracks[$n][] = $tracks[0][0]; $hdtracks[$n][] = $tracks[0][1];} if ($show){ echo "<br><br>";} for ($n=0; $n < $max; $n++){ if ($show){ echo " track " . $hdtracks[$n][0] . " original track no " . $hdtracks[$n][1] . " compare % " . $hdtracks[$n][2] . " track no " . $hdtracks[$n][3] . " track name " . $hdtracks[$n][4] . "<br>"; }} } return ;} ################################################################################ function split2($string, $begin, $beginlength, $end){ ################################################################################ $middle = false; $start = stripos($string, $begin); $stop = stripos($string, $end); if (is_numeric($start) AND is_numeric($stop)) { $length = $stop - ($start + $beginlength); $middle = substr( $string, ($start + $beginlength), $length);} return $middle;} ################################################################################ function split3($string, $begin, $end){ ################################################################################ $middle = false; $start = false; $stop = stripos($string, $end); if (is_numeric($stop)) { $start = backsearch($string, $begin, $stop);} if (is_numeric($start) AND is_numeric($stop)) { $length = $stop - ($start + 1); $middle = substr( $string, ($start + 1), $length); } return $middle;} ################################################################################ function backsearch($str, $begin, $p){ ################################################################################ while($p > -1 and $str{$p} <> $begin) $p--; if ($p == -1){ $return = false;} else { $return = $p;} return $return; } ################################################################################ function array_merge2($array1, $array2){ ################################################################################ $return = array(); $max1 = count($array1); $max2 = count($array2); if ( $max1 == $max2 and !empty($array1) ){ for ($n=0; $n < $max1; $n++){ $return[] = array($array1[$n], $array2[$n]);}} return $return;} ################################################################################ function getnameinfo($pathname, &$hierarchy, &$hd_artist, &$hd_album){ ################################################################################ $hierarchy = explode("\\", $pathname); $temp = $hierarchy[(count($hierarchy)-1)]; $count = substr_count($temp, ","); if ($count == 1){ list($hd_artist, $hd_album) = explode(",", $temp);} else { $hd_album = $temp; $hd_artist = "";} return ;} ################################################################################ function swap(&$var1, &$var2){ ################################################################################ $temp = $var1; $var1 = $var2; $var2 = $temp; return ;} ################################################################################ function array_search2($needle, $haystack){ ################################################################################ $count = count($haystack); for ($n=1;$n<$count;$n++){ if ( soundex($haystack[$n]) == soundex($needle) ){ return $n;} } return false;} ################################################################################ function tracknofix(&$tracks){ ################################################################################ $pos = array(); $poshits = array(); $poslast = array(); $count = count($tracks); for ($n=0; $n<$count; $n++){ $split = explode(' ', $tracks[$n][0]); $splits[] = $split; $count2 = count($split); for ($n2 = 0; $n2 < $count2; $n2++){ if (is_numeric($splits[$n][$n2]) AND array_search($n2, $pos) === false ) { $poshits[] = 0; $poslast[] = 0; $pos[] = $n2;} } } $count2 = count($pos); # first find all numeric columns that are ascending for ($n=0; $n<$count; $n++){ for ($n2 = 0; $n2<$count2;$n2++){ if ( isset($splits[$n][$pos[$n2]]) AND is_numeric($splits[$n][$pos[$n2]]) AND $splits[$n][$pos[$n2]] > $poslast[$n2] ) { $poslast[$n2] = $splits[$n][$pos[$n2]]; $poshits[$n2]++ ;} } } # remove these columns from the exploded array for ($n=0; $n<$count; $n++){ $tracknoremoved = false; for ($n2 = 0; $n2<$count2;$n2++){ if ( $poshits[$n2] == $count ){ if ( !$tracknoremoved ){ $tracknoremoved = true; $tracks[$n][1] = $splits[$n][$pos[$n2]];} unset( $splits[$n][$pos[$n2]] );} } } # rejoin split for ($n=0; $n<$count; $n++){ $join = implode(' ', $splits[$n]); $tracks[$n][0] = $join;} return ;} ################################################################################ function tracknamefix(&$tracks, $hd_artist, $hd_album){ ################################################################################ $count = count($tracks); for ($n=0; $n < $count; $n++){ $tracks[$n] = str_ireplace($hd_artist, '', $tracks[$n]); } return ;} ?>
  8. i had to put in effect a javascrit workaround to a css problem (not sure if it is a bug), where the margin-left, margin-right auto thing doesn't seem to work, on either the ladies listing page or the profile page i have put the auto margin in the root div (called mainpix) , not worked, so tried it on a content div witj just the auto margin and a width and still not worked so gave up and just used javascript to do a margin-left shift of the content my web site is www.thaiwife.org, mydefs.css is the stylesheet JD
  9. being a newbie to javascript, the screen.width is an object so how do i store the numeric value in a var ? thanks JD
  10. thanks for the feedback, i will imprement the css bit asap but at the moment stuck in an internet cafe and no net connection at home thats thailand for you lol. one thing that is bugging me is i had to put in effect a javascrit workaround to a css problem (not sure if it is a bug), where the margin-left, margin-right auto thing doesn't seem to work, on either the ladies listing page or the profile page i have put the auto margin in the root div (called mainpix) , not worked, so tried it on a content div witj just the auto margin and a width and still not worked so gave up and just used javascript to do a margin-left shift of the content another question - sorry if wrong place, but being a newbie to javascript, the screen.width is an object so how do i store the numeric value in a var ? thanks JD
  11. Hi, I am new on here, so if I make a faux pas, please forgive me! Can some kind person have a look at my web site: http://www.thaiwife.org I have just launched this web site, it's a non profit web site and this is my first attempt at not using tables in layout, and yes it gave me a headache. Written in PHP with a little bit of javascript in places. One thing I would like to ask is for SEO is the use of numeric urls for the profiles ok or will it downgrade the site in the rankings, thanks. I have tested the web site in Opera v9, IE 6, IE7 and Firefox (latest) I have a slight problem with the CSS for the profile layout, in hi res there is a gap between the profile pictures and the profile information. (if anyone has a solution to this I really would appreciate it) Sorry, no test profile available. The website is all my own work - EXCEPT for the menu system, which is pure CSS and is sourced from www.grc.com and is free , obviously the menu is generated in php :-), no templates where used in the website construction. JD
×
×
  • 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.