[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two in one :)



SS>> 1) I am looking for a php function that makes hebrew flip to
SS>> data retrieved from a mysql database. Some idea? Somebody have
SS>> something ready?

See attachment for a primitive implementation. It should work in most
cases. hrev is reversing (in fact, BiDi rendering) algorithm, and rev_div
divides it by lines. Note that this should be plain text, effects of HTML
might be far from what is expected. I don't thinks it's possible to render
BiDi HTML without help from the browser.

SS>> 2) I'm trying to install a merchant system.
SS>> The system is telling me during installation that the user root cannot run
SS>> the scripts, therefore I need to create a new user who's own the script
SS>> directory...... How can I do this??

useradd newuser
chown newuser /script/directory

what's the problem? Or you mean something else?

-- 
frodo@sharat.co.il	\/  There shall be counsels taken
Stanislav Malyshev	/\  Stronger than Morgul-spells
phone +972-3-9316425	/\  		JRRT LotR.
http://sharat.co.il/frodo/	whois:!SM8333


<?
Function rev_div($str,$string_len,$lang="heb") {
	if($lang != "heb") {
	  return $str;
        }
	$rstr=hrev($str);
	$out = "";
      while(strlen($rstr) > $string_len) { # we need to divide
	    $n_sp=strcspn(substr($rstr,-$string_len)," \t\n.,!?");
	    $sp_str=substr($rstr,-$string_len+$n_sp);
            if($sp_str == "") {
		break;
	    }
	    $out = $out . ($out != ""?"<br>":"") . $sp_str;
	    $rstr=substr($rstr,0,-strlen($sp_str));
        } 
	return $out == ""?$rstr:$out."<br>".$rstr;
    }


  Function hrev($str) {
    $result=""; $cursor=0; $rtl=0;
   while($i<strlen($str)):
     $l=substr($str,$i,1);

     if($l >= "à" && $l <= "ú"):
       if($rtl==0 && substr($result,strlen($result)-1,1)==" "):
         $result=" ".substr($result,0,strlen($result)-1);
       endif;
       $rtl=1;
       $cursor=0;
     endif;

     if(ereg("[a-zA-Z]",$l)!=0 && $rtl==1):
       $cursor=strlen($result);
       $rtl=0;
     endif;

     if($l >= "0" && $l <= "9"):
      if($push==0):
         $pushc=$cursor;
       endif;
       $push=1;
     else:
       $push=0;
     endif;

     if($push==1):
       $oldc=$cursor;
       $cursor=$pushc;
     endif;  

     $result=substr($result,0,$cursor) . $l . substr($result,$cursor,strlen($result)-$cursor+1);

     if($push==1):
       $cursor=$oldc;
       $pushc++;
     endif;

     if($rtl==0):
       $cursor++;
     endif;

     $i++;
   endwhile;
   return $result;
  }

?>