veedeoo 474 Junior Poster Featured Poster

Hi,

Based on your script above, you should only get 1 image at a time.. The reason is that you are acessing the image file from your PHP tmp directory.

What you need to do is use

$new_location = 'yourDir/filename.extension';
move_uploaded_file($_FILES['image']['tmp_name'], $new_location);

## then you can bring it on the screen

echo '<img src="$new_location" />';

If you want to upload multiple-images, then you will have to add more file input. If you want to view all the images in the directory including the newly uploaded file, then you will need to write another php script for that..e.g. scan image directory and then iterate through its contents based on the extension you want to show..

veedeoo 474 Junior Poster Featured Poster

Do as suggested above, otherwise, it appears to me that you maybe using an ubuntu? or any linux derivs ? How did you install your server? conical or command line?

Let me know if it is Linux distros... that should be an easy fix...

sudo :)....

veedeoo 474 Junior Poster Featured Poster

Please allow me to just add these info., because I am sure you will be asking how to create a remote CSV file using the API..

I will be using this as example, the integer coding guideline is located in the last page of the documentation.. I believe this is an example of a CVS file 1 as indicated on the id.

{"method": "Project.importOrdersTripletexCSV", "params": [";2010-01-01;10010;Tripletex;Kronprinsensgt.17;;251;Oslo;post@tripletex.no;;;;;1111;2010-03-01;Leveranseveien14;\"'Dette er en kommentar;;;;;;;;;1000;;3;Ordrelinje (h\u00f8ysats);\r\n","ISO-8859-1",true, false], "id": 1}

First, you can initialize the cURL to

$ch = curl_init('https://tripletex.no/resources/examples/order_import_example.csv');

Then you define your CVS data... values can be from database or from any resources you may have. Here is the equivalent post request in PHP

 $csv_data = array('method'=>'Project.importOrdersTripletexCSV','params'=>array('put all the data here'),'id'=>1);

  $csv_data = jason_encode( $csv_data);
veedeoo 474 Junior Poster Featured Poster

thanks for bringing that up... I will look at throughly later..

For the time being you may want to experiment by sending the cURL post request to https://tripletex.no/JSON-RPC . The common response from tripletex if we send an empty data to this url will be

{"error":{"code":590,"msg":"couldn't parse request arguments"}}

That response will enable us to create a cURL function using the proper protocol as described in the documentation.

Without reading the documentation in its entirety, they want us to send request in this format as shown in their JAVA recommendation.. here is an excerpt of the JAVA code..

public static void main(String[] args) throws Exception {
HttpClient httpClient = new HttpClient();
PostMethod method = new PostMethod("https://tripletex.no/JSON-RPC");
String request1 = "{\"method\": \"Sync.login\", \"params\":
[7,\"test246\",\"test@test.no\",\"pwd\"], \"id\": 1}";

What the JAVA code above is requesting a method login, and sending the user password and id to the tripletex.no/JSON-RPC()..

Now, the challenge is how are we going to create the same functionality in PHP.. Keep in mind that tripletex requires us to have the cookies, and not only a cookie, but specifically they want the second cookie from the two outputted by the server.

here is the typical tripletex response along with two cookies and they want the second one..

RESPONSE:
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.0.2 (build: CVSTag=JBoss_4_0_2
date=200505022023)/Tomcat-5.5
Set-Cookie: JSESSIONID=09E2172BB69BA99F9CBA3AD9C0F2A025; Path=/; Secure
Set-Cookie: JSESSIONID=F81885A42D1CC3876039EAB8C441C5B3; Path=/; Secure
Content-Type: text/plain;charset=utf-8
Content-Length: 29
Date: Wed, 21 Jul 2010 06:59:38 GMT

Tripletex wants to validate on the second cookie from …

veedeoo 474 Junior Poster Featured Poster

Hi,

Sorry for late response... If will be difficult to parse html by converting them into array like that and then re-parse for the xml writter script.

What we need to do is use a dom html parser..download this file from sourceforge and test it with simple html first..,

follow this instruction here..

for example, if we have a simple html document like this

 <html>
 <head>
 <title>this is going to be parsed</title>
 </head>
 <body>
 <table>
 <tr>
 <td>address 1</td>
 <td>address 2</td>
 <td>address 3</td>
 </tr>
 </table>
 </body>

The sample PHP for the parser can be like this..

include_once 'lOCATION_OF_SIMPLE_HTML_DOM_CLASS';
$html = file_get_html('htmllocation');

function parse_this($html){
$td_data = array();
foreach($html->find('tr') as $row){
   foreach($row->find('td') as $item){
    $td_data[] = $item;

}
}
## address 1 to 3 are in this array

return $$td_data;

}

## test it
print_r (parse_this($html));

Let me know if you successfully print out the array as shown in my example... Once you got it working, it will be so easy to generate an xml file..

veedeoo 474 Junior Poster Featured Poster

try this first... put this before the closing bracket of the method listStats;;

    return $data;
    } // closing bracket of method listStats..

like this ..

    public function listStats($id) {
$sql = DB::inst()->query( "SELECT *
FROM ".
TP."tracking
WHERE
mID = '$id'
GROUP BY
mID"
);
$data = array();
if($sql->num_rows > 0) {
while($row = $sql->fetch_assoc()) {
$data[] = $row;
}

}

    return $data;
}
veedeoo 474 Junior Poster Featured Poster

Hi,

What framework are you using?

can you var_dump or print_r this ?

listStats($id);

and this

$this->listStats

what do you get?

I am assuming that $this->listStats is a method of the view class?

veedeoo 474 Junior Poster Featured Poster

Hi,

The pdf file link is dead..

To send a jason to the tripletex, the recieved response from paypal can be forwarded to the tripletex..

example...

 ## response from paypal..this may contain payment, item, amount, quantity, subscriptions.
 $this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));

 ## stablish a filtering mechanism to make sure response is true..
 if($this->response_status){

 ## use jason_encode the data recieved from paypal
 $paypal_data = json_encode($this->response_status);  

 ## stablish a new cURL connector for the tripletext
 ////////// put all cURL 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'Content-Type: application/json',                                                                                
'Content-Length: ' . strlen($paypal_data))                                                                       
);       

If the data from paypal does not match the API format of the TRIPLETEX, then you can either add data to the paypal response or reiterate through the response array and just remove what is not needed.

To add mor data into the array response from paypal, you can use array_push(). Something like this. For example paypal response is given like this

    ## example of paypal response, shown as an array

    $paypal_data = array('success'=>'true','item'=>'ipad','confirmation_id'=>'1235488','amount'=>'15.00','currency'=>'USD');

If you need to add more data as per tripletex requirements, you can do it like this.

array_push($paypal_data,'inventory'=>'100','sold'=>'50','receipt'=>'45597798','t_id'=>'1235488')
veedeoo 474 Junior Poster Featured Poster

sorry, for the double post..how did it happen??????

veedeoo 474 Junior Poster Featured Poster

I believe the penny gained at 40K was coming from 0.00026 . $factor minus the actual value used (0.065)..

veedeoo 474 Junior Poster Featured Poster

Hi,

First, you will have provide us with the tags for your xml files. What I meant by tags is your own mark up based on your needs or how do you want the xml file structured.

something like this,

<?xml version="1.0"?>
<mydata>
<item>
<title>my title</title>
<description>my description</description>
</item>
</mydata>

Second, you will have to provide us with your sample html document, so that we are able to see if it can be parsed using PHP, and then ultimately write the parsed data in xml format as file or directly to the browser.

example of possible HTML doc..

<html>
<head>
</head>
<body>
<h1> Title </h1>
<p> My description</p>
</body>
</html>
veedeoo 474 Junior Poster Featured Poster

Here are the wrappers I found One and two. You can either use them or use them as reference.

I wrote an extended version of ricocheting, but it will only work on frameworks and template engine queries.

If you will be following ricocheting's wrappers, this wrapper is written in Singleton pattern. If you will be using an instance manager instead of auto-loader, you must remove the singleton objects.

In an occasion where you still want to go ahead and write your own wrapper, here are my suggestions.

  1. wrapper should have a method that can work on all of PDO objects. For example, you may want to create an object within your class that will handle a requests from specific class of an application.

Example codes ..WARNING! NOT TESTED ... just giving you an idea.

public function bind_to_class($thisClass){
## this is an array output
return (self::fetchAll(PDO::FETCH_CLASS,$thisClass));
}

Alternatively, you can write the same method with query option something like this. Warning! This is an skeleton method and will not work until the proper external objects are implemented and defined.

public function bind_to_class($thisClass, $thisQuery){
## just like the first example this will return the result as array 
$fetchThis = self::query($thisQuery, PDO::FETCH_CLASS, $thisClass);

    while($row = $fetchThis->fetch()) {
     $out[] = $row;
    }
    ## this will deliver the output to the outside
    return $out;
    }
  1. Wrapper should be able to return affected row count.
  2. Wrapper should be able to return single item query result.
  3. Wrapper should have a …
veedeoo 474 Junior Poster Featured Poster

this will work also, even if the $element is not initialized

$andy = new ThisArray($nameArray);

because of the the =NULL in the constructor..

You can also access the object similar to what broj1 have suggested.. something like this

foreach($arrayres as $name){
echo $name.'<br/>';

}

If this one, looks odd to you.

public function __construct($array = array(),$element=null)

you can also change it to this to make it a lot nicer

public function __construct(array $array,$element=null)
veedeoo 474 Junior Poster Featured Poster

Hi,

here is a simple class pretty much similar to what you have above. $element is not mandatory during the instantiation. However, the $array is mandatory.

<?php

class ThisArray{

public $element, $array;

public function __construct($array=array(),$element=null){
$this->element = $element;
$this->array = $array;

}

public function load_Array(){

return $this->array;

}

public function get_element(){

return $this->element;
}
}


$element = 'Hello this is element';
$nameArray = array('bob','bill','rich','poorboy');

$andy = new ThisArray($nameArray,$element);

$arrayres = $andy->load_Array();
echo $arrayres[0];
echo '<br/>';
echo $arrayres[1];
echo '<br/>';
echo $arrayres[3];

echo '<br/>';
echo $andy->get_element();
veedeoo 474 Junior Poster Featured Poster

Hi,

You will need to add something like this

if(isset($_GET['param'])){

## rest of your codes here

}

else{

## code when $_GET is empty

}

The Theory!! Another trick I use outside the norms is this

if($_GET){


## codes here if $_GET is not empty
## make sure to check for empty values.

}
else{
## codes when $_GET is empty

}

Ok, ok,... I know people maybe wondering what the H.... is going on? why am I using it instead of (isset($_GET['param'].

Proof!

 if($_GET){

 var_dump($_GET); 

 ## codes above should return an array if $_GET is not empty

 }

Another way of doing this can be like this,

if($_SERVER['REQUEST_METHOD']=== $_GET){

## do things here

}
veedeoo 474 Junior Poster Featured Poster

Hi,

Can you please elaborate which table names?

Mysql? ==> show us your codes?
Something else? ==> show us your codes?

veedeoo 474 Junior Poster Featured Poster

you cannot embed html tags like that. You will have to close the PHP first and then add your html tags.

mysql_select_db('snack', $con);
?>
<form action="action.php" method="post">
<?php
mysql_query("INSERT INTO Produk VALUES ('Produk')");
mysql_query("INSERT INTO Jumlah VALUES ('Jumlah')");
mysql_query("INSERT INTO Tanggal_Masuk VALUES ('Tanggal_Masuk')");
?>
<input type="submit">
</form>

But then again, I have doubts if those codes will ever work though, because we don't have any clues about the rest of the codes.

veedeoo 474 Junior Poster Featured Poster

you can also add login failed counter and assign the count in session. Define how many failed login would you allow, before requiring an account reset or captcha.

Test your login script with the most common login hacks e.g. type OR'' on the password field, without typing any username... if the script shows the mysterious user as logged in, then you need to sanitize more..

veedeoo 474 Junior Poster Featured Poster

Hi,

Do you have the basic tripletex basic syntax recommendation? I mean , how to handle or port the data to their application?

On success, paypal would send an array of response of which you will be able to either add them to your database, or send it somewhere else. If you look at the ipn listener, the IPN response is stored in variable response.

IPN response..

     $this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));

     ## and response for the non-cURL
      $this->response .= $status = fgets($fp, 1024); 
      $this->response_status = trim(substr($status, 9, 4));
veedeoo 474 Junior Poster Featured Poster

Just to follow up.. If you will be using Micah's class, you will have to set your form like this

This will be on the storefront with the payment button or whatever settings you prefer.

First, open the ipn.php file and fill-in your paypal sandbox credentials. As shown by the lifted snippets from the ipn.php

     mail('YOUR EMAIL ADDRESS', 'Verified IPN', $listener->getTextReport());

} else {
    /*
    An Invalid IPN *may* be caused by a fraudulent transaction attempt. It's
    a good idea to have a developer or sys admin manually investigate any 
    invalid IPN.
    */
    mail('YOUR EMAIL ADDRESS', 'Invalid IPN', $listener->getTextReport());
}

Remember that the email address is the email address of the vendor you have created in the paypal sandbox, and the buyer must use the email address of the created buyer account.

Two, the storefront form can be as simple as this

    <?php

    ## define the location of the ipn.php
    $ipn = 'ipn.php';
    ## define the sandbox seller email addresss created from step one.
    $seller_email = "seller@yourDomain.com";
    ## define the item you are selling
    $item = 'ipad';
    $item_price = 600.00;
    $currency = 'USD'; // define your currency
    $return_url = 'YourSite.com';

    ?>
    <!-- show the form -->

    <form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" 
method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $seller_email;?>">
<input type="hidden" name="currency_code" value="<?php echo $currency;?>">
<input type="hidden" name="item_name" value="<?php echo $item;?>">
<input type="hidden" name="amount" value="<?php echo $item_price;?>">
<input type="hidden" name="return" value="<?php echo $return_url;?>">
<input type="hidden" name="notify_url" value="<?php echo $ipn;?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" …
veedeoo 474 Junior Poster Featured Poster

Hi,

Is that all your codes? No IPN listener or anything to grab the response from paypal?

If possible try practicing on this one . The sample script is in the example directory.

Let us know about your progress. If you find any problem with the script, let me know so that I can update my forked version.

!UPDATE! Here is a much detailed tutorial from Dan Dawson .

veedeoo 474 Junior Poster Featured Poster

Hi,

quickest way of doing this in wordpress without breaking this module is to send the full-image to a dynamic page.

There are many tutorials on the web about creating dynamic page in wordpress environment. I am not going to cover it here, but I will give you two links and show you the work around.

If you take a look at this approach posted on stackoverflow.. and another plugin here ..

Warning! Codes below is not tested. I don't have any locally installed wordpress at the moment.

I am more in favor of the first option than the plugin. That would be my reference.

Say we call our dynamic page as view.php.. and we will using the same codes as lifted from stackoverflow..

    <?php
    ## filename: view.php

    define('WP_USE_THEMES', false);
    require("/wp-path/wp-blog-header.php");
    get_header();

    if(isset($_GET['view'])){
    $image = $_GET['img'];
    $title = $_GET['title'];
    $alt = $_GET['alt'];
    $id = $_GET['view'];

    echo '<img src="'. $image .'" alt="'. $alt .'" /><br/>';
    echo  $title .'<br/>';

    ## do what you need to do with rest of the data..
    }
    else{

    ?>
    There is nothing here

    <?php
    }
    get_footer();
    ?>

Save this new page in the wordpress directory.. or in the same directory as your index.php

Now let's go back to our target codes.. we can modify it to this

  $gallery_content .= '<a data-type="'.$item_type.'" href="view.php?view='.$att_id.'"&title='. $att_title .'&img='. $att_img[1] .'&alt='. $alt_data_str .' title="'.$att_title.'" data-medium="'.$att_img_med[0].'" data-med-size="'.$att_img_med[1].'-'.$att_img_med[2].'" data-full-size="'.$att_img[1].'-'.$att_img[2].'" '.$alt_data_str.' class="list-item-pad image-content">'.$item_index.'</a>';   

Try experimenting witht he codes above..don't forget to set these values properly

    define('WP_USE_THEMES', …
veedeoo 474 Junior Poster Featured Poster

these codes right here..

 $gallery_content .= '<a data-type="'.$item_type.'" href="'.$att_img[0].'" title="'.$att_title.'" data-medium="'.$att_img_med[0].'" data-med-size="'.$att_img_med[1].'-'.$att_img_med[2].'" data-full-size="'.$att_img[1].'-'.$att_img[2].'" '.$alt_data_str.' class="list-item-pad image-content">'.$item_index.'</a>';   

should be the focus of modification.. we should be able to pass the unique id of the images so that wordpress engine be able to interpret it as post..

veedeoo 474 Junior Poster Featured Poster

IGNORE this response.. I came in little slower than your second response..

try looking at the plugins directory..

The default wordpress plugin included in the distribution is akismet. All others are either added by you or by the theme developer.

If you have netbeans for PHP ( this is a free PHP IDE), you can create a new project and then use the plugins directory as the source directory. You can then use the netbeans search function to search for the string "insert". The resulting queries are the file and the location where the word 'insert' were used. Click on any of these files, to view the source code.

veedeoo 474 Junior Poster Featured Poster

Hi,

You will need to look for the function or class responsible for inserting the items in the database, and the function responsible for sending it on the view.

these codes....

$module_item_option = new WPW_ModuleItemOption(
array(
"type" => "option-tab",
"title" => __("Item Type", $wpw_theme_lang),
"id" => $this->cfg['id']."_item_type",
"description" => __("Chose what type of item.", $wpw_theme_lang),
"option-group" => "item-type",
"br" => "1",
"css-class" => " main-item-setting",
"options" => array(
"image" => "Image",
"video" => "Video",
"audio" => "Audio",
"text" => "Text"
)
)
);

are for your tab menu or to show the setting options, on your administration page for the plugin.

veedeoo 474 Junior Poster Featured Poster

LastMitch is precisely correct, unlink is something you cannot reverse. For safety precaution, you need to test it on dummy files first, before allowing the script to work on real uploaded files. The use of unlink() with glob() is even dangerous than just using regular dir php function.

example of unlink codes you must avoid...I have seen this type of codes somewhere, but don't remember the site

## dangerous script and should not be used, unless it is certain that items within the directory must be deleted.

array_map('unlink', glob("/directoryName/*"));

The code above will delete everything in the directoryName .

One safe method of deleting file is to check if the file exist, and then execute unlink. For example

    $this_file = 'somefile.jpg';
    if (file_exists($this_file)) {
        unlink($this_file);
        echo $this_file .'   Has been deleted ';

    }
    else{

    echo 'This file: '. $this_file .' Does not exist. ';

    }

You can also use javascript to provide a confirmaton, before deleting the file.

veedeoo 474 Junior Poster Featured Poster

How did they set-up the indexes in the array? You might be able to add it there..

I believe CakePHP allows this type of data assignment.

$this_Data = array(

            'string_var1' => $value,
            'string_var2' => $value_two,
            'string_var3' => $value_three,
            'url'   => $this->request['param']
            );

   $this->set($this_data);

If you can add the url data in the array, you can easily follow the existing reiteration in the view side to display the url.

I understand your situation. Sometimes previous coders or "ADMIN and BOSS" would do a pretty lazy approach.. something like this.

$this->set($some_function_or_method_here());

## or a hard coded const from the model file
$this->set(model::var_string());

## common practice they don't even make a comment on where the method is coming from. 

I hate it when people do that, because it will be difficult to reference variable values on the view.

You can also try looking at your application model file.. look for something like this

class Name_Of_Your_Application extends AppModel{

 public $YourApplicationVar = array(
    'Something' => array(
        's_var1'  => 'SomethingHere',
        's_var2' => 'somethingHere_again',
        ## watch out for array like this
        's_array' = array('s_array1'=>'s_array1_value', 's_array2' => 's_array2_value' )
    )
);
}
veedeoo 474 Junior Poster Featured Poster

When sending data from logic side to the view side, we can safely assumed that pretty much all frameworks and templating engines have identical coding convention, .

Like smarty, dwoo, twig just to name a few, the data are passed in this convention

$this->FrameWork_method('string_variable', $value_of_string_variable_from_anywhere');

So, for our Cake it can be something like this in the controller

$this->set('url',$this->request['param']);

The 'set' method made the string variable available for view's disposal. To display the url on the view, it can be coded as simple as this

    <!-- Here is the code for the url -->

    Url: <?php echo $url ?> 
veedeoo 474 Junior Poster Featured Poster

did you try $this->request['param']; as suggested here?

I really don't understand why? cake php would deprecate such a useful function like the array access

$this->request['url']['param']
veedeoo 474 Junior Poster Featured Poster

Do you mean a mechanical printer, printing the form as shown on your webpage? If so, then you can read the tutorial here. The tutorial will teach you how to create a PDF file with forms in it. PDF format have a nicer output for the mechanical printer compared to direct printing of an actual webpage..

veedeoo 474 Junior Poster Featured Poster

make sure the javascript file is referenced by this page. Otherwise the MM_swapImgRestore and MM_swapImage functions will be undefined js functions. Make sure of that and please let us know.

veedeoo 474 Junior Poster Featured Poster

can you please mark this as solved.. I just landed on this page for the third time :).

veedeoo 474 Junior Poster Featured Poster

Here is a good example of validation and comparison. Pay attention to the commented part of the script. Most importantly on the id.

I am assuming that your script should give you a captcha "foo"? , and therefore the my_text should validate to foo and so as the $captcha_code = $captcha->generate() which is derived from the array of figlet. The validation and comparison of the two is the same as what is stated on the link I have provided above. Here is the snippet from the zend site.

if ($captcha->isValid($_POST['foo'], $_POST)) {
// Validated!
}

so, in your case it can be something like this

if ($captcha->isValid($_POST['my_text'], $_POST)) {
// Validated!
}
veedeoo 474 Junior Poster Featured Poster

Hi,

I was a big fan of all of these MVC frameworks in the past, but the more I tried to write something based on them, the more time I spent on learning how to get around their restrictions. Unlike CI, the CAKE is not that js friendly, while symfony allows ajax and js integration flawlessly.

Here is a link of a tutorial on how to pass data from the controller to javascript files, and I hope this will help you.

good luck to you.

veedeoo 474 Junior Poster Featured Poster

Hi,

Did you read the Zend API Documentation on figlet? The answer to your question is right on the page.

veedeoo 474 Junior Poster Featured Poster

The above is the quality scaler or reducer that will help you reduce the file size. Below is another class I wrote from early last year. This has already been posted here at daniweb, but I can't find it.

Class below will properly scale any images to your desired size

<?php
## filename Scaler.class.php
## simple demonstration on how the singleton pattern can be use in OO PHP..
## written by veedeoo or poorboy 2012 , from daniweb.com ,phpclasses.org, tutpages.com, and yahoo php expert community.
## this script will be available at http://www.phpclasses.org/ .

class Scaler{
   ## Singleton Pattern begins
   public static $instance = NULL;
   private function __construct(){
                ## if there will be another class needed by this class, you can create an instance here, else just leave this empty
            }
   public static function getInstance() {
                if(!isset(self::$instance)) {

                ## we create an instance of the class Scaler if there is no instance running
                  self::$instance = new Scaler();
                }
                return self::$instance;
              } 
    private function  __clone() {
      ## don't worry about this, just to make sure there is no clone going in the background.
    }

    ## end of singleton pattern
    ## class Scaler methods begins  
    public function createThumb($filename, $maxW, $maxH, $image_path, $thumb_path, $outname) {

    $ext = substr($filename, strrpos($filename, ".") + 1) ;
    switch (strtolower($ext)) {
        case "jpg":
        case "jpeg":
            $img = imagecreatefromjpeg($image_path.$filename) ;
            $size = self::ResizeMath($maxW, $maxH, $img) ;
            $size[0] = $maxW ;
            $size[1] = $maxH ;
            $img2 = imagecreatetruecolor($size[0], $size[1]) ;
            imagecopyresized($img2, $img, 0, 0, 0, 0, $size[0], $size[1], …
veedeoo 474 Junior Poster Featured Poster

Hi,

Here is an old image manipulator I wrote early last year . I have not tested it since then, but I still believe it will work..

<?  
## this image manipulator class was written by veedeoo or poorboy 2012
## feel free to modify, extend this clas as you wish.
## does not have any warranty of any kind

class ReduceImage{
    private $imageLoc = null;
    private $outImageLoc = null;
    private $imageResizePoint = null;


public function __construct($imageLoc,$outImageLoc,$imageQuality){
    $this->imgLoc = $imageLoc;
    $this->outLoc = $outImageLoc;
    $this->quality = $imageQuality;
}

protected function getImageInfo(){
 list($this->x,$this->y) = getimagesize($this->imgLoc);

 return array($this->x, $this->y);

}
public function createImage(){
    $this->imageX_Y = self::getImageInfo();
    $this->newImage = imagecreatetruecolor($this->imageX_Y[0],$this->imageX_Y[1]);

    ## in production server use code below
    //$this->newImage = @imagecreatetruecolor($imageX_Y[0],$imageX_Y[1])

  //$this->newX_Y = self::getImageInfo();
  $this->newfile = imagecreatefromjpeg($this->imgLoc);
  imagecopyresampled($this->newImage, $this->newfile, 0, 0, 0, 0, $this->imageX_Y[0], $this->imageX_Y[1], $this->imageX_Y[0], $this->imageX_Y[1]);


 imagejpeg($this->newImage,$this->outLoc,$this->quality);
 ## in production server use code below
 //@imagejpeg($this->newImage,$this->outLoc,$this->imageResize);

// return array($this->newImage,$this->outLoc,$this->newfile);

return $this->outLoc;
imagedestroy($this->newImage);
imagedestroy($this->newfile);

}




}

To use the class above, just provide the required parameters..

  ## quality of 50 is acceptable, but you may want to experiment from 60.
$quality = 60; 
$reducethis = new ReduceImage("images/sample.jpg","images/output1.jpg",$quality);
$image = $reducethis->createImage();

echo '<img src="'.$image.'">';

I hope this helps. If not, there should be someone else here that is a lot knowledgeable than me.. I am pretty sure of that..

veedeoo 474 Junior Poster Featured Poster

Are you sure it has value? Because AFAIK, error like that is related to the where clause when it is not wrapped with single quotes.

For example, lets use your query above
$query_recTenantID = "SELECT * FROM md_tenant WHERE tenantID = ".$tenantID;

Scenario 1: Table md_tenant don't exist : error -> Query failed: Table 'YourDatabaseName.md_tenant' doesn't exist

Scenario 2: Column tenantID don't exist: error -> Query failed: Unknown column 'tenantID' in 'where clause'

Scenarion 3: everything are fine and does exists, but tenantID have no value in where clause: error -> Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Quick solution for scenario 3 to prevent blank and no value to cause query error. Wrap your where clause value with single quotes like this. This will NOT create a line 1 error, because blank is a value that does not even exist and will NOT return anything, but without error.

    $query_recTenantID = "SELECT * FROM md_tenant WHERE tenantID = '". $tenantID ."'";
veedeoo 474 Junior Poster Featured Poster

Your codes looks ok. Make sure $tentID is defined or have value otherwise it will give you an undefined variable tenantID, and sql syntax error .

veedeoo 474 Junior Poster Featured Poster

Hi,

All you need to do is cascade your file input like this

<label>File One</label>
<input type="file" name="file[]" id="file[]">
<br/>
<label>File Two</label>
<input type="file" name="file[]" id="file[]">
<br/>
<label>File Three</label>
<input type="file" name="file[]" id="file[]">

<!-- add more as needed -->
veedeoo 474 Junior Poster Featured Poster

I would ask my hosting company first, for any changes they made on your server. It might be some major upgrades or changed of server appliance...e.g. apache to nginx or something similar.

veedeoo 474 Junior Poster Featured Poster

Hi,

Did you try changing this

$query = mysql_query('SELECT description FROM events WHERE date = "'. $deets .'"');

to this?

$query = mysql_query('SELECT description, date FROM events WHERE date = "'. $deets .'"');
veedeoo 474 Junior Poster Featured Poster

Not the best, but a nice place to start discovering what ajax could do. There are are books called ajax for dummies and javascript and ajax for dummies that are pretty good for learning the ajax language. I always read these books at my local library.

veedeoo 474 Junior Poster Featured Poster

Dude,

Your controlled page does not check for any existing session. YOu need to validate if the session exist, before letting them in.

I hope I am making sense here.

veedeoo 474 Junior Poster Featured Poster

Hi,

on your function login, you can try setting the session for that username.

for example,

    if(mysql_num_rows($query)== 1){

    ## this user exists
    ## set session for this user
    session_start(); 

    $_SESSION['thisUser'] = $username;

    }

    else{

    ## do what you want to do on failed login

    }

You protection function on top of every pages can be as simple as this

    session_start();
    if(!isset($_SESSION['thisUser']) )

    {
    ## this user is not login send them to the login page, or wherever you deemed appropriate.

    header("location:login.php");
    die();

    }
    else{

    ## this is user is authenticated at the very least :).

        $user_isLogin = true;

        $user = $_SESSION['thisUser'];



    }

Warning! There are broader topics in web security, validation, and sanitization of data you must take into consideration, before sending this script to production site.

veedeoo 474 Junior Poster Featured Poster

You mean change this

$sql="name, price from table1";
echo "<tr><td>Name</td><td>>Price</td></tr>";
if ($result=mysql_query($sql)) {
while ($row=mysql_fetch_assoc($result)) {
echo "<td>".$row['name']."</td>";
echo "<td>".$row['price']."</td></tr>";}}

to this, right ?

$sql="select name, price from table1";
echo "<tr><td>Name</td><td>>Price</td></tr>";
if ($result=mysql_query($sql)) {

while ($row=mysql_fetch_assoc($result)) {
echo "<tr><td colspan=2>".$row['name'].",".$row['price']."</td></tr>";
}

}
veedeoo 474 Junior Poster Featured Poster

ok, I tried them and other IP's I found on other sites with similar service, but for some reason cURL would fail most of the time.

For the random IPs above, I've got 2 dead ones and one 403 with redirection. Codes I used is the same as your code above except I added this..

    curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL, 1);

We can also check if the cURL is reading something by passing the fetched data to a PHP function called stripos or even better pregmatch.

    if (preg_match("/html/i", $data)) {
        echo 'IP is alive';
} else {
    echo 'IP is dead';
}

## I have seen some other guys do it like this

  $countX = stripos($data,'</html>');   
  if($countX > 0 ){

  echo 'It is alive';

  }

  else{

  echo 'Not available';

  }

There is a class written by Stanislav in PHPclass.org that looks pretty promising. Another one is written by Alexey , this may need minor work, but it is looking pretty good because of the Ping functions, instead of sending the cURL right away.

UPDATE: I forgot mention there is a PHP exec that can be very helpful in knowing if the IP is alive or not. If you run this code..

        function GetPing($ip=NULL) {
             if(empty($ip)) {$ip = $_SERVER['REMOTE_ADDR'];}
             if(getenv("OS")=="Windows_NT") {
              $exec = exec("ping -n 3 -l 64 ".$ip);
              return end(explode(" ", $exec ));
             }
             else {
              $exec = exec("ping -c 3 -s 64 -t 64 ".$ip);
              $array = explode("/", end(explode("=", $exec )) );
              return ceil($array[1]) …
Resentful commented: Awesome solution! +1
veedeoo 474 Junior Poster Featured Poster

ok, you need to provide us with a sample IP:PORT. AT least three of them ..please don't give me more than 5. I get lazy right away..

like this 00.00.00.00:126 where: 126 is port and the zeros before it are part of the IP.

veedeoo 474 Junior Poster Featured Poster

Hi,

Updated: check this proxy API. It looks pretty easy to use.

veedeoo 474 Junior Poster Featured Poster

I guess we are locked out :). There must be a really big party going on in there and we are not invited :). ( I am just kidding of course, it could be something is wrong with the controller file). They will fix it for sure.