Switch to English?
Yes
Переключитись на українську?
Так
Переключиться на русскую?
Да
Przełączyć się na polską?
Tak
Post your project for free and start receiving proposals from freelancers within minutes after publication!

Rewrite the code to PHP 7.0 and above.

Translated11 USD
PHP

Client's review of cooperation with Anatoly Demchenko

Quality
Professionalism
Cost
Contactability
Deadlines

thank you. very quickly. I will be contacting again.

Freelancer's review of cooperation with Aleksey Mitroshin

Payment
Task setting
Clarity of requirements
Contactability

It is a pleasure to have a deal with Alexey - he has provided everything he needs. I checked and paid quickly. I recommend !

    Another 4 proposals concealed
  • Aleksey Mitroshin
    9 February 2022, 13:42 |

    <?


    class DBI


    {


        ## Class properties description


        var $dbh,      # database link handler


            $sth,      # resource handler


            $errno,    # database error number


            $errmsg,   # database error message


            $host,     # host


            $user,     # user name


            $pass,     # password


            $database, # database name


            $q,        # query text


            $log_file = '',  # Log FileName, if empty - no loging mysqlog.txt


            $time_limit = 1.5;       # Log only querys above this time





        #@@@ PUBLIC METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@



        ### Connect to server and select database



        function connect($host="",$user="",$pass="", $database="")


        {



          error_reporting(!E_WARNING);



          $this->dbh=mysql_connect($host,$user,$pass);# or $this->GetError("Connection failed");


          if (!$this->dbh){


            echo "На сервере ведутся технические работы. Извините за доставленное неудобство.";


            exit;

            return false;


          }else{


              error_reporting(E_ALL & ~E_NOTICE);

        

              mysql_select_db($database) or $this->GetError("Database selection failed");


              $this->database = $database;

              return true;

          }




        }




        ## set auto_recoding from cp1251 to koi8ukr


        function cp1251_koi8(){


         $this->query("set option character set cp1251_koi8");


        }



        ## set auto_recoding to default

        function to_default(){

         $this->query("set option character set DEFAULT");

        }

        ### Send query


        function query($query="", $debug_query = 0){

            global $debug_query;

            if(!$query){


              echo "DB class error: [No query parameter]";


              $this->close();


              exit;

            }


            if($debug_query){


              //echo "<pre>".$query."</pre>";

              echo $query."<br>---<br>";


            }


            $this->q = $query;


            $page_parse_time_start = microtime();


            if($query)

             $this->sth =  mysql_query($query, $this->dbh) or $this->GetError("Query error");




            if ($_SERVER['REQUEST_URI'] and $this->log_file)

               $tmp = explode('.',$_SERVER['REQUEST_URI']);


            if($this->log_file && !in_array(strtolower($tmp[count($tmp)-1]),array('jpg', 'png', 'gif'))){

              $time_start = explode(' ', $page_parse_time_start);

              $time_end = explode(' ', microtime());

              $time_int = $time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]);

              if($time_int > $this->time_limit){

                $parse_time = number_format($time_int, 3);


                ###### лог запросов в файл #########

                $query = ereg_replace("\r", "", $query);

                $query = ereg_replace("\n", " ", $query);

                global $ROOT_DIRECTORY, $HTTP_AFTER, $domain;

                $fp = fopen($ROOT_DIRECTORY.$this->log_file, "a+");

                fwrite($fp, date(" H:i:s")." ".$parse_time." ".$_SERVER['REMOTE_ADDR']." ".($domain ? $domain.'.'.$HTTP_AFTER : $_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI']." ".session_id()." ".$query."\n");

                fclose($fp);

                ####################################

              }

            }

            return $this->sth;

        }



        ### Return number of result rows of last SELECT QUERY


        function num_rows($linkno=0)




         //$linkno - number of link resource (default = 0)


        {


            if (!$this->sth && !$linkno){  ## IF NO RESOURCE


                echo "No performed SELECT query: [Invalid resource link]";


                exit;


            }


            $num=mysql_num_rows($linkno ? $linkno : $this->sth);


            return $num;


        }




        ### Return number of affected rows of performed query


        function affected_rows()


         //$linkno - number of link resource (default = 0)


        {


            $num=mysql_affected_rows();


            return $num;


        }






        ### Fetch row as array


        function fetch_row($linkno=0)

             //$linkno - number of link resource (default = 0)


        {

          //echo $linkno;

          return mysql_fetch_row($linkno ? $linkno : $this->sth);


        }


        ### Fetch row as ac array


        function fetch_array($linkno=0)

             //$linkno - number of link resource (default = 0)


        {

          return mysql_fetch_array($linkno ? $linkno : $this->sth);


        }




        ### Fetch row as hash


        function fetch_hash($linkno=0)


             //$linkno - number of link resource (default = 0)


        {


          return mysql_fetch_assoc($linkno ? $linkno : $this->sth);


        }








        ### Data seek; Move result pointer to the row $row, by default 0


        function seek($row=0, $linkno=0)


         //$linkno - number of link resource (default = 0)


        {


          return mysql_data_seek($linkno ? $linkno : $this->sth,$row);


        }






        ### Fetch field


        function fetch_field($row=0,$field=0, $linkno=0){


         //$linkno - number of link resource (default = 0)


          $flag=true;


            if ($row<0 || $row>=$this->num_rows()){


                //echo "Data seek error: [Invalid row offset ($row)]";


                return false;


               }




            if ( (!is_int($field)) || $field<0 || $field>=$this->num_fields()){


                echo "Field seek error: [Invalid field offset ($field)]";


             exit;


            }


            return mysql_result($linkno ? $linkno : $this->sth,$row,$field);


        }


        


        function last_id(){


         return mysql_insert_id($this->dbh);


        }




        function num_fields($linkno=0){


         //$linkno - number of link resource (default = 0)


          if (!$this->sth && !$linkno){


            echo "Fetch length error: [Invalid resource link]";


            exit;


          }


          return mysql_num_fields($linkno ? $linkno : $this->sth);


        }






        ### Close connection


        function close(){

          @mysql_close($this->dbh);

        }








        #@@@ PRIVATE METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


        ##  Get database error parameters. Print error, close database connection and terminate


        function GetError($hint="")


        {


          $this->errno=mysql_errno($this->dbh);


          $this->errmsg=mysql_error($this->dbh);


          $this->close();


          $this->q = eregi_replace("select ", "<b>SELECT</b> ", $this->q);

          $this->q = eregi_replace("update ", "<b>UPDATE</b> ", $this->q);

          $this->q = eregi_replace("insert ", "<b>INSERT</b> ", $this->q);

          $this->q = eregi_replace(" from ", "\n<b>FROM</b> ", $this->q);

          $this->q = eregi_replace(" left ", "\n<b>LEFT</b> ", $this->q);

          $this->q = eregi_replace(" right ", "\n<b>RIGHT</b> ", $this->q);

          $this->q = eregi_replace(" join ", " <b>JOIN</b> ", $this->q);

          $this->q = eregi_replace(" where ", "\n<b>WHERE</b> ", $this->q);

          $this->q = eregi_replace(" order ", "\n<b>ORDER</b> ", $this->q);

          $this->q = eregi_replace(" group ", "\n<b>GROUP</b> ", $this->q);

          $this->q = eregi_replace(" limit ", "\n<b>LIMIT</b> ", $this->q);


          $e = debug_backtrace();

          echo '<b>Error</b> in line: <b>'.$e[1]['line'].'</b> [<font color="green">'.$e[1]['file'].'</font>]';



          echo '<pre>';

          echo $this->q;

          echo '</pre>';


          echo "<b>$hint.</b> Error #",$this->errno,"<blockquote>",$this->errmsg,"</blockquote>";


          exit;


        }




    }


    ?>

  • Sergey H.
    9 February 2022, 13:46 |

    Здравствуйте. Пришлите сам класс.

Current freelance projects in the category PHP

Modules for a website on Laravel

90 USD

Delivery and payment module for the site https://novabook.top/ (Botble CMS / Laravel) Add convenient delivery and payment methods (including installment plans) in the checkout, similar in style and convenience to the mirson ua site.Delivery (mandatory) Nova Poshta Branch…

Javascript and TypescriptPHP ∙ 4 hours 18 minutes back ∙ 15 proposals

Integration needed: KeyCRM → Cash Register Kashalot

It is necessary to set up integration between KeyCRM and the Cash Register Kahalot. When placing an order in KeyCRM, the data must be automatically transmitted to Kahalot: • order information • products, nomenclature • prices • quantity More details in private.

Content Management SystemsPHP ∙ 2 days 3 hours back ∙ 28 proposals

Development of 2 SEO-oriented websites for selling spare parts (ATVs and special equipment)

Development of Two Specialized Websites for Selling Spare PartsGeneral Information It is necessary to develop two specialized websites: Spare parts for ATVs, UTVs, SSVs, and other similar equipment. Spare parts for special equipment. Existing company website:…

PHPWeb Programming ∙ 4 days 10 hours back ∙ 77 proposals

Development of a WordPress website

23 USD

We are looking for a contractor to develop a custom website on WordPress for a jewelry store. The first stage will be a consultation.

Content Management SystemsPHP ∙ 7 days 2 hours back ∙ 75 proposals

Parser expireddomains.net

112 USD

A parser is needed for expireddomains.net. You need to log in to the site first; the problem is that it blocks the IP when trying to parse data. You need to parse thematic domains based on a list of keywords. If you are not confident in your abilities, please do not write.

PHPWeb Programming ∙ 9 days 10 hours back ∙ 53 proposals

Client
Aleksey Mitroshin
Ukraine Kyiv  7  0
Project published
4 years back
55 views