Exemplo n.º 1
0
 public function music($alias)
 {
     if (empty($alias)) {
         echo 'redirection somewhere';
     } else {
         $query = $this->music->find_user_list_by_alias($alias);
         if (!$query) {
             echo 'you are the loser';
         } else {
             $this->load->helper('create_xml');
             $user = $this->user->find($this->get_user_id());
             create_xml($query, $user->alias);
             $this->load->view('play/music');
         }
     }
 }
Exemplo n.º 2
0
function get_data($table, $format, $mysql)
{
    //получаем данные из выбранной таблицы
    $query = "SELECT * FROM {$table}";
    $result = $mysql->query($query);
    $data = $result->fetch_all(MYSQL_ASSOC);
    //проверка формата для вызова соответствующей функции генерирования файла
    switch ($format) {
        case "CSV":
            create_csv($table, $data, $mysql);
            break;
        case "JSON":
            create_json($table, $data, $mysql);
            break;
        case "XML":
            create_xml($table, $data, $mysql);
            break;
        default:
            echo "<h3>Выберите нужный формат из списка!</h3>";
    }
}
Exemplo n.º 3
0
// Проверка корректности таблицы
if (in_array($table, $allow_tables)) {
    try {
        $stmt = $pdo->query("SELECT * FROM {$table}");
        // Получаем имена столбцов
        $keys_stmt = $pdo->query("SHOW COLUMNS FROM {$table}");
    } catch (PDOException $e) {
        die("Ошибка выполенения запроса: " . $e->getMessage());
    }
} else {
    die("Неверно указана таблица");
}
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$keys = $keys_stmt->fetchAll(PDO::FETCH_ASSOC);
unset($pdo);
$keys_array = array();
foreach ($keys as $key) {
    $keys_array[] = $key['Field'];
}
switch ($format) {
    case 'csv':
        $filename = create_csv($data, $keys_array, $filepath);
        break;
    case 'json':
        $filename = create_json($data, $filepath);
        break;
    case 'xml':
        $filename = create_xml($data, $keys_array, $filepath, $table);
        break;
}
file_download($filepath);
Exemplo n.º 4
0
function do_addform($object, $class, $dttype = null, $notitleflag = false)
{
    global $gbl, $sgbl, $login, $ghtml;
    $gbl->setSessionV("lx_add_return_url", "/display.php?" . $ghtml->get_get_from_current_post(null));
    $cdesc = get_description($class);
    $cdesc = $dttype ? $dttype['val'] : $cdesc;
    if ($notitleflag) {
        $title = null;
    } else {
        $title = "Add {$cdesc}";
    }
    $string[] = $ghtml->object_variable_startblock($object, $class, $title);
    $string[] = $ghtml->object_inherit_classpath();
    $string[] = $ghtml->object_variable_hidden("frm_o_cname", $class);
    $string[] = $ghtml->object_variable_hidden("frm_dttype", $dttype);
    $ret = exec_class_method($class, 'addform', $object, $class, $dttype);
    if ($dttype) {
        $ret['variable'][$dttype['var']] = array('h', $dttype['val']);
    }
    $string[] = create_xml($object, $class, $ret);
    $vlist = $ret['variable'];
    $pre = $post = null;
    if (isset($vlist['__m_message_pre'])) {
        $pre = $vlist['__m_message_pre'];
    }
    if (isset($vlist['__m_message_post'])) {
        $post = $vlist['__m_message_post'];
    }
    $ghtml->print_information('pre', 'addform', $class, $dttype['val'], $pre);
    $ghtml->xml_print_page($string);
    $ghtml->print_information('post', 'addform', $class, $dttype['val'], $post);
}
Exemplo n.º 5
0
/**
 * get_company_search
 *
 * @return string XML representation of the search results (list of companies ids that match the query)
 */
function get_company_search() {
  // the obm var nams and the search parameters names may be different
  $replacement = array('name' => 'name',
    'number'=>'number',
    'phone'=>'phone',
    'zip'=>'zip',
    'town'=>'town',
    'country'=>'country',
    'type'=>'type',
    'activity'=>'activity',
    'naf'=>'naf',
    'datasource'=>'datasource',
    'market'=>'market',
    'date_after'=>'date_after',
    'date_before'=>'date_before'
  );

  $field_list = array('company_id' => 'company_id', 
  		 'company_name' => 'company_name',
		 'company_number' => 'company_number', 
		 'company_nafcode_id' => 'company_isin',
		 'company_address1' => 'company_address1',
		 'company_address2' => 'company_address2',
		 'company_address3' => 'company_address3',
		 'company_town' => 'company_town',
		 'company_zipcode' => 'company_zipcode',
		 'country_name' =>  'company_country',
		 'company_phone' => 'company_phone',
		 'company_fax' => 'company_fax',
		 'company_email' => 'company_email',
		 'company_web' => 'company_web'
   );

  $get=array();
  $root_node='listing';

  $multi_search = false;
  $require_fields = array();
  //permet de récupérer les champs qu'il faut affiché 
  $field_list = prepare_field_list($_GET,$field_list);

  foreach($replacement as $key => $value){
    if(isset($_GET[$value])){
      $get[$key]=$_GET[$value];
    }
  }
  
  //recupère tous les critères pour le recherche multiple
  $multi_search = search_multicritere($get,&$multicritere,&$champ);


  $datas = array();
  //Si c'est une recherche multicritere on recupere les informations
  //pour chaque critère
  if($multi_search){
    $root_node='multisearch';
    foreach($multicritere as $val){
      //a chaque critère on modifie le champ
      $get[$champ]=$val;
      $data = get_company_mono_search($get,$field_list);
      if(!empty($data)){
        //on fusionne les information que l'on as déjà avec les 
        //nouvelles pour evité les doublons
        $datas=array_merge($datas,$data);
      }
    }
  } else {
    $field_list=array('company_id' => 'company_id');
    $datas=get_company_mono_search($get,$field_list);
  }
  
  // if no datas, return
  if (count($datas) == 0) {
    return ;
  }
  return create_xml($datas,$root_node,'company',$multi_search);
}
Exemplo n.º 6
0
//получаем список таблиц из БД для выпадающего меню
$tables = get_tables($conn);
if ($_POST) {
    $name = $_POST['tables'];
    $format = $_POST['formats'];
    $m_format = strtolower($format);
    if (in_array($name, $tables)) {
        switch ($format) {
            case "CSV":
                create_csv($name, $conn);
                break;
            case "JSON":
                create_json($name, $conn);
                break;
            case "XML":
                create_xml($name, $conn);
                break;
            default:
                echo "<h3>Выберите формат файла!</h3>";
                break;
        }
        //проверяем существование файла
        $file = DIR . $m_format . "/" . $name . "." . $m_format;
        if (file_exists($file)) {
            download_file($file);
        }
    } else {
        echo "<h3>Выберите таблицу из списка!</h3>";
    }
}
?>
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $user = md5($_SERVER['REMOTE_ADDR']);
} else {
    $user = md5($_SERVER['HTTP_X_FORWARDED_FOR']);
}
if (isset($_POST['song']) && isset($_POST['name']) && isset($_POST['set'])) {
    $song = $_POST['song'];
    $name = $_POST['name'];
    $set = $_POST['set'];
    if (file_exists($settings)) {
        if (validate_values($song, $name, $set, $settings)) {
            if (file_exists($xmlFile)) {
                update_xml($user, $song, $name, $set, $xmlFile);
                echo "update";
            } else {
                create_xml($user, $song, $name, $set, $xmlFile);
                echo "create";
            }
        } else {
            echo "not valid";
        }
    } else {
        echo "settings not found";
    }
}
function validate_values($song, $name, $set, $settings)
{
    $found = false;
    $xml = new DOMDocument('1.0', 'utf-8');
    $xml->preserveWhiteSpace = true;
    $xml->load($settings);
Exemplo n.º 8
0
/**
 * get_contact_search
 *
 * @return string XML representation of the search results (list of contact ids that match the query)
 */
function get_contact_search() {
  // the obm var nams and the search parameters names may be different
  $replacement = array('fname' => 'firstname',
    'lname' => 'lastname',
    'privacy' => 'privacy',
    'number'=>'number',
    'phone'=>'phone',
    'email'=>'email',
    'company'=>'company',
    'zip'=>'zip',
    'town'=>'town',
    'country'=>'country',
    'datasource'=>'datasource',
    'function'=>'function',
    'title'=>'title',
    'market'=>'market',
    'date_field'=>'date_type',
    'date_after'=>'date_after',
    'date_before'=>'date_before',
  );

   $field_list = array('contact_id' => 'contact_id', 
  	 'contactfunction_label' => 'contact_function',
		 'contact_firstname' => 'contact_firstname',
		 'contact_lastname' => 'contact_lastname',
		 'kind_minilabel' => 'contact_genre',
		 'contact_title' => 'contact_title',
		 'contact_service' => 'contact_office',
		 'contact_address1' => 'contact_address1',
		 'contact_address2' => 'contact_address2',
		 'contact_address3' => 'contact_address3',
		 'company_town' => 'company_town',
		 'company_zipcode' => 'company_zipcode',
		 'company_country_name' => 'company_country',
		 'company_phone' => 'company_phone',
		 'company_fax' => 'company_fax',
     'contact_email' => 'contact_email'
   );

  $get=array();
  $root_node='listing';
  
  $multi_search = false;
  $require_fields = array();

  $field_list = prepare_field_list($_GET,$field_list);
  
  foreach($replacement as $key => $value){
    if(isset($_GET[$value])){
      $get[$key]=$_GET[$value];
    }
  }

  $multi_search = search_multicritere($get,&$multicritere,&$champ);


  $datas = array();
  if($multi_search){
    $root_node='multisearch';
    foreach($multicritere as $val){
      $get[$champ]=$val;
      $data = get_contact_mono_search($get,$field_list);
      if(!empty($data)){
        $datas=array_merge($datas,$data);
      }
    }
  } else {
    $field_list=array('contact_id' => 'contact_id');
    $datas=get_contact_mono_search($get,$field_list);
  }
  
  // if no datas, return
  if (count($datas) == 0) {
    return ;
  }
  return create_xml($datas,$root_node,'contact',$multi_search);
}