home *** CD-ROM | disk | FTP | other *** search
/ 79.96.193.101 / 79.96.193.101.tar / 79.96.193.101 / www / getmenu.php < prev    next >
PHP Script  |  2014-10-20  |  999b  |  32 lines

  1. <?php
  2. Header("Content-type: text/plain; charset=UTF-8");
  3. require './inc/config.php';
  4.  
  5.  mysql_connect($dbhost, $dbuser, $dbpass) or die('unable to connect to mysql server');
  6.  mysql_select_db($dbname) or die('database not found');
  7.  
  8.  mysql_query("SET NAMES utf8");
  9.  
  10. function get_menu($parent, $navid=1, $area=1) {
  11.     global $dbprefix;
  12.     $res = mysql_query("SELECT * FROM {$dbprefix}_navi WHERE parent_id={$parent} AND nav_id={$navid} AND area={$area} AND active=1 ORDER BY posi");
  13.     $menu = array();
  14.     while ($row = mysql_fetch_array($res)) {
  15.         if (get_menu($row['id']) != false) $row['child'] = get_menu($row['id']);
  16.         array_push($menu, $row);
  17.     }
  18.     return (count($menu) > 0) ? $menu : false;
  19. }
  20.  
  21. function make_flashvars($array, $option='menu', $link='link', $link_replacer = '*') {
  22.     $str = ''; $i=1;
  23.     foreach ($array as $menu) {
  24.         $str .= $option.$i.'='.$menu['title'].'&'.$link.$i.'='.str_replace('&', $link_replacer, $menu['document']).'&';
  25.         $i++;
  26.     }
  27.     return $str;
  28. }
  29.  
  30. echo make_flashvars(get_menu(0));
  31.  
  32. ?>