Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Posts posted by etrader

  1. I want to perform a php process initiated by AJAX according to the method described in http://www.w3schools.com/PHP/php_ajax_database.asp

     

    with this line

    xmlhttp.open("GET","getuser.php?q="+str,true);
    

    the php process in getuser.php is initiated. But how I can restrict direct access to getuser.php?

     

    If someone visit getuser.php?q=something; the process will be started for "something". I want to run the getuser.php process only and only when it is initiated from my main page.

  2. Thanks Nightslyr! You are an excellent teacher and I learned a lot. However, it did not resolve my issue. In this case, I need to include $q in $arr() within the text. I try to keep the format of $arr('some words').

     

    I was looking for a trip to bring the string ($q) into the function; but it seems it is not possible. Maybe it is better to put three functions within the switch cases.

  3. I use $word. Actually, the array file has a structure of

    $term = array(
    "word1" => "modern1",
    "word2" => "modern2"
    );

     

    and function will be

    function arr($word) {
    switch($q) {
      case 'modern':
       include('modern.php');
      break;
      case 'classic':
       include('classic.php');
      break;
    }
    echo $term[$word];
    }

     

    I want to use arra('something') in the text by reading corresponding array file depending on the value of $q.

  4. Let me clarify what I need

     

    <?php
    $q = $_GET['q'];
    
    function arr($word) {
    switch($q) {
      case 'modern':
       include('modern.php');
      break;
      case 'classic':
       include('classic.php');
      break;
    }
    }
    
    arr($word);
    ?>

     

    My problem is how to make switch for $q inside a function for $word.

  5. Sorry, but it did not resolve the issue. You defined the case by "something", but I want to define it by $q. For example, $q can be "modern" or "classic"; I want to include modern.php or classic.php

     

    Indeed, my problem is how to bring $q into the function.

  6. Thanks, but I do not want to add the second variable into the function, since the function is widely used in the text. I get the string from url as

     

    $q=$_GET[[$q];

     

    now I want to include a given file for each value of $q. The text frequently contains $arr('something'). I want to display different message by $arr('something') depending on the value of $q.

  7. I have a simple function reading a two-component array as

    function arr($word) {
    include 'array1.php";
    echo $something[$word];
    }

     

    How I can make a condition for this function to load different array files as array1.php or array2.php or array3.php. The name of file comes from a string.

  8. Sounds great. I thought that __() only works for mo files as php has a function to get it. However, I did not get your solution

    echo __('en.welcome_text');
    

     

    How it can recognize to look into $lang array ?

  9. Thanks, it seems to be a perfect solution. I can call the translations by $lang['word']

     

    BUT how I can write a function to return (or echo) based on this scheme. I mean

     

    function language($word) {
    echo $lang[$word];
    }

     

    then using language('word') for displaying the translation.

  10. I want to introduce some variable into Wordpress functions, but it does not work when defining the string outside the function. Consider this example function:

     

    	function bbp_get_topic_edit_link( $args = '' ) {
    	$defaults = array (
    		'id'           => 0,
    		'link_before'  => '',
    		'link_after'   => '',
    		'edit_text'    => __( 'Edit', 'bbpress' )
    	);

     

    This does not work when I introduce a string as (when string to replace "edit" with "something")

     

    	
    $str="SOMETHING";
                   function bbp_get_topic_edit_link( $args = '' ) {
    	$defaults = array (
    		'id'           => 0,
    		'link_before'  => '',
    		'link_after'   => '',
    		'edit_text'    => $str
    	);

     

    But it works when introducing the string within the function as

                   function bbp_get_topic_edit_link( $args = '' ) {
    $str="SOMETHING";
    	$defaults = array (
    		'id'           => 0,
    		'link_before'  => '',
    		'link_after'   => '',
    		'edit_text'    => $str
    	);

     

    How I can make my strings active within functions? I want to store all strings within a reference file and the include it in each page (or through header).

  11. I want to create a multi-language website. For translating the terms, I have two options. For using define() for each sentence; e.g.

    DEFINE('WORD1', 'word1 in German');

    DEFINE('WORD2', 'word2 in German');

    ......

     

    and include this php language file.

     

    Another option which is more standard is to create a mo file and call it by php. I prefer the first method as everything is just based on php; but I doubt if it is the best way for a website with 1000+ sentences. Any idea?

     

  12. There are some indirect download links (e.g. in download.cnet.com), as when clickingon domain.com/download?startdownload; it will start to download a file from domain.com/files/something.zip

     

    How to get the actuall download link (the second one) with php and curl? I think it is part of main features of cURL, but I have no idea how to do so.

     

    Thanks  :D

  13. No, I cannot run rar_open(), but I can unrar in php by this command

    $string='unrar e -y /path/to/file';
    exec($string);

     

    My issue is that I am looking for a way to put the name of rar file in the unrared files. For example: file.rar containing ebooks; I want to unrar it to

    file-ebook1.pdf

    file-ebook2.pdf

    ....

     

  14. I am on Ubuntu server and have installed unrar-free. In SSH I can successfully unrar with commands like

    $ unrar e file.rar

    but how I can unrar in php? DO need to install unrar for php? because I was not able to run commands introduce in php.net  :shrug:

×
×
  • 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.