Jump to content

alin19

Members
  • Posts

    334
  • Joined

  • Last visited

    Never

Posts posted by alin19

  1. hello, i'm trying to find a tutorial where i can view how to integrate doctrine into the zend framework.

     

    i have found only for codeigniter.

     

    or at least a tutorial about doctrine and i will try to came up with something to integrate it into zend framework because i have learn a little about it.

     

    thanks in advance

  2. i was at a job interview for a php development job and i have to learn about php delegate( or something like this) in two weeks until i start the work.

     

    I didn't ask to many questions, they said that they don't use simple queries for mysql, they have some kind of delegate system, but i don't find to many info about it on the web or i'm searching in a wrong way. Can you please help me to understand where to look ? Because i don't want to ask them from where to learn.

     

     

    Thanks.

  3. C is indeed the correct answer.

     

    __FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.

     

    of couse it is also a magic constant , but why is my answer not right?

  4. A

     

    why is that?

     

    i have this code

     

    <?php

     

    var_dump($_POST);

     

    ?>

     

    i make a GET request to that page , it will show : array(0) { }

     

    if it was not initialized it would have been NULL ,

     

    please explain

  5. C is indeed the correct answer.

     

    thanks

     

    this one?

     

    if i make a get, delete, head request, $_POST var is still initialized with an empty array in my opinion

     

    Question:

     

    The $_POST[] superglobal is initialized ONLY when the user agent is

    making a request using the _________ method.

     

     

    A.

     

    POST

     

    B.

     

    TRACE

     

    C.

     

    DELETE

     

    D.

     

    HEAD

     

    E.

     

    OPTIONS

     

    Correct Answer: A

    User Answer: A ; C ; D

    Explanation: $_POST[] superglobal is initialized by the web server only when it receives an HTTP request via the POST method.

  6. i have took a test that i think it has some errors:

     

    can you please confirm or infirm that A is the right answer?

     

     

     

    Question:

     

    The default value for __FILE__ is _______________________________.

     

     

     

    A.

     

    the complete path of the currently executing script

     

    B.

     

    the relative path of the currently executing script

     

    C.

     

    a magical constant; it does not have a default value

     

    D.

     

    the complete path of the previous executed script

     

    E.

     

    the relative path of the previous executed script

     

    Correct Answer: C

    User Answer: A

    Explanation: The PHP engine stores the full path and filename of the currently executing script within the __FILE__ constant.

  7. i have fixed it, the problem was not in the code:

     

    looks like with mssql you have to define in : /etc/freetds/freetds.conf

     

    the server like this:

     

    # A typical Microsoft server

    [MyServer7]

    host = **** ;

    port = 1433

    tds version = 8.0

     

    and then connect like this

     

    cu mssql_connect("MyServer7",username,parola);

     

     

  8. I have this code:

     

    it connects to the database, start the statement but i get an error at mssql_execute :

    PHP Warning:  mssql_execute(): stored procedure execution failed in /home/alin/NetBeansProjects/MailScanner/index.php on line 30

     

    the procedure in the db looks like this:

     

    GetUsernames (@resultsCount Int=1);  resultsCount indicates the number of usernames to return. SELECT STMT Returns Username, ServerList

     

     

    i can't figure it out, need some help please,

    $ParameterOne=1;
    $Parameterdoi="";
    $ParameterTrei="";
    
    $conn = mssql_connect("***","***","***");
    if ($conn===false)
    
    {
    }
    
    if (mssql_select_db("***",$conn) === false)
    {
    }
    
    $proc = mssql_init('GetUsernames',$conn);
    mssql_bind($proc,'@resultsCount',$ParameterOne,SQLINT1,true, false, 10);
    mssql_bind($proc,'Username',$Parameterdoi,SQLVARCHAR);
    mssql_bind($proc,'ServerList',$ParameterTrei,SQLVARCHAR);
    
    if ($result = mssql_execute($proc))
    {
    if ($row = mssql_fetch_row($result))
    {
    
    }
    
    }
    

  9. i have a bash script that i was running with cron jobs:

     

    #! /bin/bash
    start=1000
    homedir="/home/alin/NetBeansProjects/Fragger2"
    
    numberofprocess=`expr $start + $2`
    
    i=$start
    
    currentnumber=`ps ax |  grep index | grep -c php`
    
    case "$1" in
      start)
    
            while [ $i -lt $numberofprocess ]
                    do
                       if [ `ps axo cmd | grep  index | grep php | grep -c $i` -lt 1 ] ; then
    
                       
                       /server/php/bin/php $homedir/index.php $i &
                       
                       fi;
                       
                       i=`expr $i + 1`
                       
            done
           ;;
       stop)
            while [ $currentnumber -ne 0 ]
            do
                    kill -9 `ps ax | grep php | grep index | awk {'print $1'} | head -n 1`;
    
                    currentnumber=`ps ax |  grep index | grep -c php`
            done
            
          ;;
    
      *)
    echo "Usage : " $0 "start|stop"
            ;;
    
    esac
    exit 0
    
    

     

    and it was working fine,

     

    now i'm tring to make it run from a page .

     

    if(isset ($_POST['stop'])){
        $conn->update("update `links` set `proccess`=0 ");
        exec("/home/alin/NetBeansProjects/Fragger2/Trans stop 0");
    }
    
    
    if(isset ($_POST['start'])){
        if(!preg_match("/^[0-9]+$/", $_POST['proccess']))
                echo "proccess should be only a number!";
        
        exec("/home/alin/NetBeansProjects/Fragger2/Trans start ".$_POST['proccess']);
    }
    

     

    and i don't know why it is not working,

     

    i have set for this folder all the permision for this folder  "chmod -R 777 /home/alin"

     

    it doesn't stop running and i can't figure out why

     

    i have to kill the procces from the comand line to stop

  10. I work on translating about 1200 k of phrases from japanese to english

     

     

    After about 150 requested translations it stops throwing the error i showed in the title, the requests are done under 60 seconds (the whole 150);

     

    I run this php scrip as cli script

     

    i use this method from a class

    public function TranslateDetails(){
            $get=$this->conn->select("select `details`.*,`summary`.`id` 'sum_id' from `summary`,`details` where `summary`.`id`=`details`.`summary_id` and `summary`.`details_translated`=0");
    
            if(sizeof($get)>0)
            foreach($get as $each) {
                
                if($each['text']=="")
                    continue;
    
                try {
                $text=$this->Translate($each['text']);
                } catch (GTranslateException $e){
                    echo $e;
                    die("Stoped");
                }
    
    
                $this->conn->update("update `details` set `text`='".$text."' where `id`=".$each['id']);
                $this->conn->update("update `summary` set `details_translated`=1 where `id`=".$each['sum_id']);
                echo  date("H:i:s"),"\t","Translated Details: ",$each['id'],PHP_EOL;
            }
        }
    

     

    The problem is that after about 150 translation per minute it throws an exception.

     

    Has anybody used this class? How can i have access to translate unlimited words?

    Thanks.

  11.  

    i have this class:

    i have a sand box account :

     

    but it seams that the payment isn't completed because the log file looks like this:

    called
    
    IPN PAYPAL TRANSACTION ID: 93797056AB281154A
    SUCCESS
    DATE: 07/28/2010 10:59 PM
    PAYER EMAIL: porpag_1280151493_per@yahoo.com
    NAME: User Test
    LINK ID: 1
    QUANTITY: 1
    TOTAL: 33.00
    Failed By Alin
    

    and this is the code that is called:

    <?php
    $fp=fopen("text.txt","a");
    include_once('paypal.inc.php');
    $paypal=new paypal();
    
    // optionally enable logging
    // $paypal->log=1;
    // $paypal->logfile='/absolute/path/to/logfile.txt';
    
    //if you are dealing with subscriptions this must be called first
    $paypal->ignore_type=array('subscr_signup');
    fwrite($fp,"called".PHP_EOL);
    $paypal->log=1;
    $paypal->logfile='/server/apache/htdocs/Paypal/text.txt';
    
    if($paypal->validate_ipn())
    {
    //280346602
        if($paypal->payment_success==1)
        {
            //payment is successfull
            //use the item id to identify for which product the payment was made
            $id=intval($paypal->posted_data['item_number']);
            fwrite($fp, "id=>".$id.PHP_EOL);
            foreach($paypal->posted_data as $key=>$each){
                fwrite($fp, $key."=>".$each.PHP_EOL);
            }
        }
        else
        {
            fwrite($fp, "Failed By Alin");
            
            //payment not successful and/or subcsription cancelled
        }
    }
    else
    {
        
            foreach($paypal->posted_data as $key=>$each){
                fwrite($fp, $key."=>".$each.PHP_EOL);
            }
    
    }
    ?>
    

    <?php
    /*********************************************************
    
    * DO NOT REMOVE *
    
    Project: PHP PayPal Class 1.0
    Url: http://phpweby.com
    Copyright: (C) 2009 Blagoj Janevski - bl@blagoj.com
    Project Manager: Blagoj Janevski
    
    For help, comments, feedback, discussion ... please join our
    Webmaster forums - http://forums.phpweby.com
    
    License------------------------------------------------:
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    End License----------------------------------------------
    
    *********************************************************/
    
    class paypal
    {
    var $logfile='ipnlog.txt';
    var $form=array();
    var $log=0;
    //var $form_action='https://www.paypal.com/cgi-bin/webscr';
    var $form_action='https://www.sandbox.paypal.com/cgi-bin/webscr';
            var $paypalurl='www.sandbox.paypal.com';
            // var $paypalurl='www.paypal.com';
    var $type='payment';
    var $posted_data=array();
    var $action='';
    var $error='';
    var $ipn='';
    var $price=0;
    var $payment_success=0;
    var $ignore_type=array();
    
    
    function paypal($price_item=0)
    {
    	$this->price=$price_item;
    }
    
    function validate_ipn()
    {
    	if(!empty($_POST))
    	{
    		$postvars='';
    		$this->price=0;
    
    		foreach($_POST as $key=>$value)
    		{
    			$postvars.=$key. '=' . urlencode($value) . '&';
    			$this->posted_data[$key]=$value;
    		}
    
    		$postvars.="cmd=_notify-validate";
    
    		$errstr=$errno='';
    		$fp= @ fsockopen($this->paypalurl,80,$errno,$errstr,30);
    
    		if(!$fp)
    		{
    			$this->error="fsockopen error no. $errno: $errstr";
    			return 0;
    		}
    
    		@ fputs($fp, "POST /cgi-bin/webscr HTTP/1.1\r\n");
    		@ fputs($fp, "Host: ".$this->paypalurl."\r\n");
    		@ fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
    		@ fputs($fp, "Content-length: ".strlen($postvars)."\r\n");
    		@ fputs($fp, "Connection: close\r\n\r\n");
    		@ fputs($fp, $postvars . "\r\n\r\n");
    
    		$str='';
    
    		while(!feof($fp))
    		$str.=@ fgets($fp,1024);
    
    		@ fclose($fp);
    
    		if(preg_match('/VERIFIED/i',$str))
    		{
    			if($this->log)
    			$this->log_results(1);
    
    			if(preg_match('/subscr/',$this->posted_data['txn_type']))
    			{
    				$this->type='subscription';
    
    				if(in_array($this->posted_data['txn_type'],$this->ignore_type))
    				return 0;
    
    				if($this->posted_data['txn_type']=='subscr_payment')
    				{
    					if($this->posted_data['payment_status']=='Completed')
    					{
    						$this->price=$this->posted_data['mc_amount3'];
    						$this->payment_success=1;
    					}
    				}
    
    			}
    			else
    			{
    				if($this->posted_data['payment_status']=='Completed')
    				{
    					$this->type='payment';
    					$this->price=$this->posted_data['mc_gross'];
    					$this->payment_success=1;
    				}
    			}
    
    			return 1;
    		}
    		else
    		{
    			if($this->log)
    			$this->log_results(0);
    
    			$this->error='IPN verification failed.';
    			return 0;
    		}
    	}
    	else
    	return 0;
    }
    
    function add($name,$value)
    {
    	$this->form[$name]=$value;
    }
    
    function remove($name)
    {
    	unset($this->form[$name]);
    }
    
    function enable_recurring()
    {
    	$this->type='subscription';
    	$this->add('src','1');
    	$this->add('sra','1');
    	$this->add('cmd','_xclick-subscriptions');
    	$this->remove('amount');
    	$this->add('no_note',1);
    	$this->add('no_shipping',1);
    	$this->add('currency_code','USD');
    	$this->add('a3',$this->price);
    	$this->add('notify_url',$this->ipn);
    
    }
    
    function recurring_year($num)
    {
    	$this->enable_recurring();
    	$this->add('t3','Y');
    	$this->add('p3',$num);
    }
    
    function recurring_month($num)
    {
    	$this->enable_recurring();
    	$this->add('t3','M');
    	$this->add('p3',$num);
    }
    
    function recurring_day($num)
    {
    	$this->enable_recurring();
    	$this->add('t3','D');
    	$this->add('p3',$num);
    }
    
    
    function enable_payment()
    {
    	$this->type='payment';
    	$this->remove('t3');
    	$this->remove('p3');
    	$this->remove('a3');
    	$this->remove('src');
    	$this->remove('sra');
    	$this->add('amount',$this->price);
    	$this->add('cmd','_xclick');
    	$this->add('no_note',1);
    	$this->add('no_shipping',1);
    	$this->add('currency_code','USD');
    	$this->add('notify_url',$this->ipn);
    }
    function output_form()
    {
    
    	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
    	. '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Redirecting to PayPal...</title></head>'
    	.'<body onload="document.f.submit();"><h3>Redirecting to PayPal...</h3>'
    	. '<form name="f" action="'.$this->form_action.'" method="post">';
    
    	foreach($this->form as $k=>$v)
    	{
    		echo '<input type="hidden" name="' . $k . '" value="' . $v . '" />';
    	}
    
    	echo '<input type="submit" value="Click here if you are not redirected within 10 seconds" /></form></body></html>';
    
    
    }
    
    function reset_form()
    {
    	$this->form=array();
    }
    
    function log_results($var)
    {
    	$fp=@ fopen($this->logfile,'a');
    	$data=date('m/d/Y g:i A');
    	if($var==1)
    	{
    		$str="\nIPN PAYPAL TRANSACTION ID: " . $this->posted_data['txn_id'] ."\n";
    		$str.="SUCCESS\n";
    		$str.="DATE: ". $data . "\n";
    		$str.="PAYER EMAIL: " . $this->posted_data['payer_email']. "\n";
    		$str.="NAME: " . $this->posted_data['last_name']." ".$this->posted_data['first_name']. "\n";
    		$str.="LINK ID: ". $this->posted_data['item_number']. "\n";
    		$str.="QUANTITY: ". $this->posted_data['quantity']. "\n";
    		$str.="TOTAL: "   . $this->posted_data['mc_gross']. "\n\n\n";
    	}
    	else
    	{
    		$str="\nIPN PAYPAL TRANSACTION ID:\n";
    		$str.="INVALID\n";
    		$str.="REMOTE IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
    		$str.="ERROR: ". $this->posted_data['error'] . "\n";
    		$str.="DATE: ". $data . "\n";
    		$str.="PAYER EMAIL: " . $this->posted_data['payer_email']. "\n";
    		$str.="NAME: " . $this->posted_data['last_name']." ".$this->posted_data['first_name']. "\n";
    		$str.="LINK ID: ". $this->posted_data['item_number']. "\n";
    		$str.="QUANTITY: ". $this->posted_data['quantity']. "\n";
    		$str.="TOTAL: "   . $this->posted_data['mc_gross']. "\n\n\n";
    	}
    	if($fp)
    	@ fputs($fp,$str);
    
    	@ fclose($fp);
    }
    
    function headers_nocache()
    {
    	header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
    	header('Cache-Control: no-store, no-cache, must-revalidate');
    	header('Cache-Control: pre-check=0, post-check=0, max-age=0');
    	header('Pragma: no-cache');
    }
    
    
    }
    

     

     

  12. i have made some progress :

     

    $input=utf8_decode(quoted_printable_decode (file_get_contents("php://stdin")));

     

    will get me the string into: ISO-8859-1 (this is the format that i need);

     

    but  still there is a problem : "€" is shown as "?"

     

    any ideea?

     

    Later edit:

     

    $input=utf8_decode ("€");

     

    $input=quoted_printable_encode($input);

     

    echo bin2hex(utf8_decode(quoted_printable_decode($input)));

     

    this script

    outputs 3F that is the hex for "?";

     

    for  € should be "80"

     

    any idea ?

  13. i get this text from an email:

    "STARTSMS ££££ ENDSMS"

    and the write it into a file, but i get:

    "STARTSMS =A3=A3=A3=A3 ENDSMS"

     

    this is actually a larger part of the email that i get from the server:

    Content-Type: text/plain; charset=iso-8859-1
    Content-Transfer-Encoding: quoted-printable
    
    STARTSMS =A3=A3=A3=A3 ENDSMS
    =0A=0A=0A      
    --0-1766339983-1270731703=:14998
    Content-Type: text/html; charset=iso-8859-1
    Content-Transfer-Encoding: quoted-printable

     

    i tryed like this:

    $input = file_get_contents("php://stdin");
    
    mb_convert_encoding($input, "UTF-8", "ASCII");
    
    $fp=fopen("test.txt","w");
    
    fwrite($fp,mb_detect_encoding($input));
    fwrite($fp,"\n\n".$input);
    
    fclose($fp);

    but in the file i still file ASCII

     

    and the wrong text.

     

    Need some help

     

    Thanks

  14. hello.

    I run a script that reads an email and sends forward some dates.

     

    But there is a problem:

     

    if i receive the sign:  £ with the encoding:  iso-8859-1

    it doesn't handles alright the dates:

     

    instead of "£" he sees : "=?"

     

    how can i change the default encoding to a php script to utf-8?

     

    i remember that there was a function that did this;

    can you help me?

     

    Thanks.

  15. Uhmmm.....  And what would be the purpose of that?  First thought is a spam bot.

     

     

    Anyway, you'll want to use preg_match_all once you get the content in a variable.

     

    i can't prove to you but is not a spam boot,

     

    i have that  but i needed to crawl throw all the website not just the homepage

  16. does anybody know a class that i can use to search an entire website for the most likely contact email?

     

    i mean to get the homepage and crawl throw the website and find the email, i have started to create one but i think that i might be one already.

     

    thanks

  17. hello

    i'm trying to mimic that i'm a browser to a website using http_request but i have some problems.

     

    can you give me some help?

    i can't keep the session alive.

     

    $req =& new HTTP_Request($firstReq);
    $req->setMethod(HTTP_REQUEST_METHOD_GET);
    $req->addHeader("Keep-Alive", 1000);
    $req->sendRequest();
    var_dump($cookie=$req->getResponseCookies());
    
    $req->addCookie($cookie['name'],$cookie['value']);
    
    $req->setURL($phoneLink);
    
    $req->sendRequest();
    var_dump($cookie=$req->getResponseCookies());
    
    var_dump($req->getResponseHeader());
    

  18. preg_match_all("/<a\sclass=\"BoldLightBlue\".+>(.+)<\/a>/",$match[1],$tables);

     

    i have this code but it gets me the data ntill the last <\/a> in the text ;

    how can i tell him to search until the first <\/a> is found ?

     

     

  19. if i would have to fixed id from head to tail i will delete everyting and code it from scratch,

     

    but i just need to fix something that he is not comfortable with ; i will make him aware of the problems,

    uncoded psw for users, deprecated functions , and much more, it will be his choise if he will invest money in it or leave it like this.

     

    thanks for your answer

     

    L.E:  i have found it, thanks  for your post; i know it is good intended

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