veedeoo 474 Junior Poster Featured Poster

Hi,

Please allow me to clarify things about paypal API. Before implementing any payment processors that utilizes an IPN class or script, script should be tested in paypal sandbox environment.

Suggested steps to take.
1. Create a paypal sandbox account.
2. Login to your sandbox account and create a seller and buyer accounts. This is extremely important. Your test transactions will be made between these two.
3. Select which IPN script you will be using. For example, this one.

  1. Follow the IPN script installation instructions. Most of them have some kind of database to record the payment made and payment received.

  2. Write a php script that will check the subscription renewal date. You can set up a cron job for this script to run once a day. If the script finds any account due for renewal of billing, the script will trigger the IPN script to send payment request to paypal. The IPN listener will then email you for confirmations and errors.

Example of integrated form using an IPN class

<form action=”https://www.paypal.com/cgi-bin/webscr” method=”post”>
<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”business” value=” seller@yourDomain.com “>
<input type=”hidden” name=”item_name” value=”ipad”>
<! -- the rest of the form here --->

Convert the above for subscription form

<form action=”https://www.paypal.com/cgi-bin/webscr” method=”post”>
<input type=”hidden” name=”cmd” value=”_xclick-subscriptions”>
<input type=”hidden” name=”business” value=” seller@yourDomain.com “>
<input type=”hidden” name=”item_name” value=”Your service yearly subscription”>
<input type=”hidden” name=”return” value=”yourDomain.com/ipnlistener.php “>

Notice the return value? yourDomain.com/ipnlistener.php. This is the file …

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,

Although I am not a master NOR I am close to becoming one and I have not seen codeIgniter for a while, I am still familiar with the basic syntax of this framework..

Before getting into this question, please allow me to ask you this..

on your controller file, did you add the load view method? example

$this->load->view('this_form', $data);

If so, on your view file called 'this_form.php', you must loop through the $data array, because it is defined as an array in your controller file..

** WARNING! codes are not tested. Please use as guidelines only if applicable.** For example,

<!-- filename: this_form.php -->
<form>
<?php 
foreach($data as $item){

   echo '<input type="checkbox" value="'.$item.'">'. $item ;
   }

   ?>
  <!-- add more form items here -->
 </form> 

In CI, you can also do this. If you can modify your codes above to something similar to this, it will be a lot easier for you to assign the values for skill as demonstraed by item1 array.

    $data = array(

            'item1' => array('item1a'=>'item1a1','item1b'=>'item1b1'),
            ## let me use data from your codes above.
            'item2' => $this->session->userdata('user_id')
            )

It is highly recommended to pass the data in this manner. By adhering to this recommendation, it will be so much easier to implement templating engine in the near future.

I think ??? CI also allows you to do this..

    public function your_function(){

    $data = array();

    return $data;
    }

    $this->load->view('this_form',self::your_function());

or

     $this->load->view('this_form', $this->your_function());

if it does, then my sample …

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

Hi,

this

if (!$search)

does not return a boolean response. To force it to return a boolean response then we can do something like this.. actually, we need to add a simple function like this.

    function is_null_empty($input){
    ## true is empty or null
    ## false go ahead

    return(strlen($input)== 0 ? true: false );        
}

we can then use the function in your code like this

 if(is_null_empty($search)){
  echo 'You have not entered search details. Please go back and try again.';
  exit;

  }
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

ok.. hold on let me run your codes in my debugger........

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

Here is an example of an oracle connector with persistent connection and with query included .

veedeoo 474 Junior Poster Featured Poster

Hi,

This class is a DB connector class.. you still have to provide the query for it to work..

I just want to let you know that OCIPlogon alias has been deprecated. Use oci_pconnect instead.

veedeoo 474 Junior Poster Featured Poster

Hi,

Like any other responses I've posted for all framework based questions..e.g. cake, CI, Zend, symfony, and others.. All of these frameworks shares a pretty similar coding convention. So, for the Code Igniter, the syntax will be as simple as this

General syntax for the CI database library

$your_query = "SELECT * FROM everywhere WHERE something = '$something'";
## use the CI query method
$this_query = $this->db->query($your_query);

Now, you decide what are you going to do with the query result.. example one

## put them in some row variable and echo them
foreach ($this_query->result() as $row)
{
   echo $row->col1;
   echo $row->col2;
   echo $row->col3;
}

example two, Send the result to the template engine e.g. smarty, twig, dwoo, tinybutstrong. It does not matter, they are all the same in nature.

## this query result is a CI built in method included in the library and it will return an array  if not false
## using the same query above send the result to the template engine

$smarty->assign('data_from_db',$this_query->result());

If you are new to CI and PHP, I strongly suggest for you to learn the ins and outs of the OOP . Otherwise, I don't see any reason to rush in using a framework at this level. It is not that hard, it just requires patience. I mean lots and lots of them...

Update! Here is a nice tutorial on building grids with jquery. The concept is the same as I have already mentioned above, with the exception …

LastMitch commented: Nice example & tutorial! +9
veedeoo 474 Junior Poster Featured Poster

here is a simple function that will generate a random integers based on the number of digits you defined. This will be a lot easier on your mysql server.

    function generate_id($range_a, $range_b, $digits)
            {
            return rand($range_a, pow($range_b, $digits));
            }

Usage sample, say we want a 8 digits random number between 1 and 100, we can call the function above like this

        echo generate_id( 1 , 100 , 8 );

The function above demonstrate the flexibility and control of the output. You can define any combination of min. and max (range_a and range_b), and the number of digits

php reference pow function.

UPDATE! stackoverflow has a better solution in controlling the number of digits. My function does not work all the time. I missed it by few more codes.. :)

veedeoo 474 Junior Poster Featured Poster

Hi,

You cannot use the random integers from 1200 to 9600 and expect a result from it. The probability on getting a match is (Xb - Xa) to the power of (xb-xa) times the number of digits combination.

Of course, script is not going to return something that it is not there. Unless, you want to manually testing it by allowing the script to run and choose a random integer and then create a new query ONLY based on the random integer choosen.

I strongly suggest to use the random integer only for the purpose of generating a unique id, instead of using it to find a match on what is already on the database. The problem is that you are pushing your database server too hard just to find one entry from multitude of probable integer combination.

This is acceptable of course ( code wise ), if you are building some kind of md5 decoder that will penetrate a high-end website, but for the purpose of student enrollment system, I believe you need to re-write your codes to something simple e.g. 10 random student id out of 100 random integer. The approximate probabilty of getting the exact sequence is about 1 for almost every 3.5 million refresh of the script.

veedeoo 474 Junior Poster Featured Poster

There is a php class called simple html DOM parser that can also help you achieved this task. For google, they have a custom search API, however this have a limit of 100 quieries per day and they want a fee of $5 per 1000 queries, for up to 10,000 queries per day.

diafol commented: nice parser - thanks for sharing +14
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

you can easily get the filename of the items $entry, by modifying the downlink link code like this

echo '<a href="'. $dir . $entry .'">'.preg_replace('/\.[^.]*$/', '', $entry) .'</a><br/>';

there are many ways of getting the filename without extension, but the above codes is the only one I come up of right now. e.g. basename, substr, str_replace will work also..

veedeoo 474 Junior Poster Featured Poster

what I meant by this

Did you try to initiate and instance of the db_session in the controller?

is

Did you try to initiate an instance of the db_session in the constructor?

the MVC question got stucked in my head..

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

Hi,

Did you try to initiate and instance of the db_session in the controller? Then just close the connection within the method that uses it.

!WARNING! These are just examples, others may have a different ways of doing things. However, If I am in your shoes, this is what I am going to do.

public function __construct(){

$this->db = DB_sessions::get_instance();

## add other stuffs here

}

You can also close the db connection within the methods, example for closing the connection within method.

public function _read($id) {

## all of your stuffs here



## just after the return or before it, add

self::_close();

## alternatively we can also use
$this->_close();

}

that's pretty much it from me...................................

veedeoo 474 Junior Poster Featured Poster

Can you show us your php responsible for generating your form? Normally, php does not refresh page. The only time the page will reload the page, when the form is submitted.

Most form processors are either written in PHP , ASP , and CGI . Although CGI was the most common form processors in the past, today PHP and ASP are the most common form processors.

If you don't want any page reload on submit, then you can use either or both ajax and jquery, but still jquery and ajax needs either PHP or ASP as form processor.

veedeoo 474 Junior Poster Featured Poster

Hi,

There are two php functions called "opendir" and "readdir". By using these functions, you can easily create a simple php script to generate download links for the files located in the directory you assigned.

For example, WARNING! script below is not tested, but I am confident this will work in the absensce of the any syntax errors.

<?php

function this_download($dir,$extension){
## use opendir please see referenced link above
if ($handle = opendir($dir)) {

## cycle items in the directory
 while (false !== ($entry = readdir($handle))) {
    ## get show only the file extension you want downloaded
    ## otherwise just remove this
    if(substr(strrchr($entry, '.'), 1) === $extension){

    ## generate the download link
    echo '<a href="'. $entry .'">Download This file</a>';
    }
}

}

to use the function above just supply the dir and the file extension you want the download link generated.

 ## sample usage
 $createDownloadLink = this_download('downloadDir', 'flv');

please read opendir and readdir as referenced above.

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

!Correction !

I just found a syntax error... change the above to this

    echo (($this_sheet->addRow($this_values)) ? 'Data Successfully Added to your Google spreadsheets' : 'The attempted operation FAILED' ) ;

My keyboard battery charged is getting low, so it is not catching up on me pretty well... :)

veedeoo 474 Junior Poster Featured Poster

Hi,

To use the google doc API, you will need the following.

  1. Zend_Gdata- Only this file. Unzipped this file in the root directory of your site.

  2. Download this file Google_Spreadsheet.php. Place this file in the same directory as your site's index.php

  3. You must have a google gmail account...

If we are going to port my example script above to the zend_Gdata, we can add the following codes . ( please refer to the line numbers of my example codes above ).

add codes on line 2

    ## this is the common Zend coding convention when including any Zend libraries.
    ## if you have not used Zend libraries in the past, this can get a bit tricky.

    set_include_path(get_include_path() . PATH_SEPARATOR . "$_SERVER[DOCUMENT_ROOT]/ZendGdata-1.12.1/library");

    ## include the google spreadsheet class you downloaded from github
    require_once('Google_Spreadsheet.php');

add codes on line 36

    ## define your google email account ! make sure you are allowed to access google doc.. normally, this is included by default.

    $gmail_user = 'yourEmail@gmail.com';
    $gmail_pass = 'your_gmail_password';
    ## define the name of your spreadsheet's file name 
    $sheet_name = 'txcpsh';
    ## If you have an existing spreadsheets, you must change the above filename.

    ## define the columns of your spreadsheets. I will be using what we already have right now as shown on my example codes.
    ## again, if you have an existing spreadsheet, make sure the column name matched that of the exsiting column names.
    $col_1 = 'Name';
    $col_2 = 'Email';
    $col_3 = 'Language'; …
veedeoo 474 Junior Poster Featured Poster

@robin 2,

Diafol is precisely correct, a features like this requires a database. Is your organization have a mysql installed in their server? If you can manage to set up a msyql server this should be an easy task for you. Here is a tutorial on how to create spreadsheets from database. Always remember google can make things a lot easier.

Another thoughts: If you don't have mysql server, will you be willing to use flat file? I don't recommend this because of the security issues, but there are always some methods in protecting flat files.

As far as readily available script is concern, that one is a little tricky to find. However, you can practice on simple example shown below. I just pulled them out from the top of my head. It's been a while, since the last time I wrote in pure procedural. So, my coding techniques may not look good as others. Make sure to sanitize the form data, before sending them to your database insert query.

Looking at my example script below, you will noticed two files english.pdf and spanish.pdf. Change this to your requirements. The mail() function I used in this example is the most basic. For more php mail function, please read here.

<?php

## define your form
    $this_form = '<form method="post" action="">
        <label>Name</label>
        <input type="text" name="name" placeholder="enter your name">
        <br/>
        <label>Email </label>
        <input type="text" name="email" placeholder="enter your email">
        <br/>
        <label>Select your language</label>
        <select name="lang">
        <option>English</option>
        <option>Spanish</option>
        </select>
        <br/>
        <input …
veedeoo 474 Junior Poster Featured Poster

can you try $server_name="localhost", if it does not work for you, read more about it here.

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

Hi,

I think $HTTP_GET_VARS has been deprecated. Just use $_GET[].

The new implementation we are currently using in the last 2 years is this

if(($_SERVER["REQUEST_METHOD"] == "POST")|| ($_SERVER["REQUEST_METHOD"] == "GET")){

## deal with the GET method
function process_get(){

}
## deal with the POST method{

function process_post(){


}

}

By using the above processing method, you can pretty much process any form data coming from all points of your website.. Yes, that includes pagination. YOu will just have to write a simple function for it, or a simple processor class.

veedeoo 474 Junior Poster Featured Poster

do as adviced, and if you have the chance, join the github and look for projects that interests you. If you found one that interests you, fork it.. if you don't know where to start, fork these. It is a simple commentator script and youtube video for CodeIgniter for you to practice on. If you don't feel comfortable with forking, contribute to any of the repositories that you like. Most applications grew this way, even some of the google's API originated as community build.

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

:) It looks like an order to me.

@siddharth.dixit.5243 WELCOME TO DANIWEB. You will have to learn how to write your questions properly. All people here are volunteers. We don't expect people to give us back those favors, but we do NOT expect people to give us orders. We give response solely under our own prerogative.

properly written question,

I am new to PHP language and I really need an expert guidance on how to write a foreign currency  converter script ASAP.

You can post the same question in this forum and you will be surprised how many people will even write it for you.

poorly written question,

Write me a foreign currency converter script ASAP.

If someone helped you, the most positive response is

Thank you very much for taking your time in responding to my questions.

The more negative response that can get you strangulated at times.

Well, after reading much about the topic online, I found out that your proposed sulution is not the right way.

I have seen this type of feedback from many posters. If they don't like the proposed sulutions, they must keep it for themselves. The right thing to do is always be thankful for any suggested solutions. Besides, it is free while the time spent by the experts is their own free time.

In response to your order ( or whatever you intended it to be), there is a google API for this. If you don't have any …

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

@unikorndesigns,

Mitch is right, you will have to give us the codes for the upload.php as defined in your javascript function url:this.config.uploadUrl

On this upload.php, you will need to make it to check if the file already exist in the upload directory. It must return a response like 'file already exist'.

! Additional Information ONLY, without any commitment for further discussion on my part !
About the codeIgniter issues, although I was always tempted to respond, I don't normally respond to this type of questions because most of the time, the discussion is much bigger than what the poster thought it would be. We can probably help you, but it is not guarantee because it is pretty big of a topic that you must put a lot of efforts into it. You need to be extremely familiar how the MVC frameworks operate. Most frameworks are almost the same.

For example to create a new page or full application, the first step is to add your application file in the controller dir,in the model dir, and finally its own directory in the view directory.

So for example, if we want to create an uploader application, then the uploader.php in the controller file can be something like this..

class Uploader extends CI_Controller {

public function __construct()
{
    parent::__construct();
    ## tell the controller which file to call for this application. In this case it is the model/upload_model.php
    $this->load->model('upload_model');
}
## the method telling the application about the template files to be loaded …
veedeoo 474 Junior Poster Featured Poster

Hi,

Can you provide me a link where I can browse the source code? I just need to see the jquery part of it..

if it is the jquery conflicting with other libraries, it's possble to fix it as suggested in jquery site.

veedeoo 474 Junior Poster Featured Poster

Here is my suggestion. Please examine how the tables are constructed and their relationships. They are related on two things course section and studentID.

table for the members , can accept students or proffessors

table name: members
columns:
id = auto-incremented
username
password
type = student->001, professors->007
studentID = unique for student ONLy.
year = school year
terms = semesters .e.g. fall, spring, winter, summer etc.
status = true or false .. this to filter if the student is enrolled or not
courses= This is should be the integer of number of courses the student is enrolled on current term. You must increment this by the number of courses, when the student confirmed enrollment.

Table name: courses
columns:
c_id = auto incremented
c_name = course name
c_desc = course description
c_section = course section
c_term = course semester offerings
c_max = maximum number of students this course allows to be enrolled at any given time

Table name: current_enrollement
columns:
e_id = NOT auto-incremented must be equal to the c_id in the courses table
e_section = course section where students are enrolled
e_studentID = student id of the student enrolled in this class
e_coursetitle = title of the course equal to the c_name in the courses table

Table name: grades
columns:
g_id = auto incremented
g_courseId = equal to the c_section in the courses table

LastMitch commented: Very Detailed Explanation! +9
veedeoo 474 Junior Poster Featured Poster

I don't see any query sorting the grades based on the studentID or student subject grade based on the studentID. It has to be the unique, and not the subject. Otherwise, your database will just output anything that is true eventhough it does not belong to particular studentID.

YOu will need to show how is your database table constructed.

veedeoo 474 Junior Poster Featured Poster

Hi,

You can echo them in single line. Use single quotes to eliminate the extra efforts on escaping the double quotes.

Something like this

echo '<img src="'. $row['ImagePath'] .'" alt = "Country Music Nightclub Orlando" title="'. $row['ArtistDate'] .'" /> </a>';
veedeoo 474 Junior Poster Featured Poster

There are PHP predefined variables called $_SERVER. This may help you.

I would look into the following variables

    HTTP_HOST
    HTTP_REFERER

There are plenty of resources online on how to implement this. I just don't have the time today to test it, but if ever you will not be able to find something, please let me know and I will write you the codes if needed.

The second option is making a minor changes on your API specifically on the GET request. So the remote site will have to add piece of codes to their requesting script.. for example, if your API accepts request like this

yourSiteDotCom/api/search?q=something

you can ask them to add something like this

$theirDomain = $_SERVER["HTTP_HOST"]; 

## the new query for sending an API request to your site

yourSiteDotCom/api/search?q=something&rsite=<?php echo $theirDomain;?>

On your API application, you can add simple codes like this

    if(isset($_GET['rsite'])){
    ## this is the domain name of the requesting remote site
    $remotSite = $_GET['rsite'];
    ## we need to clean this up and validate, and make sure it is a valid url
    if(filter_var($remoteSite, FILTER_VALIDATE_URL)){

    ## do what you need to do e.g. like adding it to your database

    }

    }
    ## allow other request from other site to get process.
    ## or you can use the PHP variables I have suggested above.
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

may I know how domains access your API? Is it through GET request or something else?

Example: yourSiteDotCom/api/search?q=something