Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Questions related to functions

    Ok So I was trying to understand this function:
    zen_parse_search_string
    which parses search string into indivual objects
    It accepts two parameters
    zen_parse_search_string($search_str = '', &$objects)
    I am not able to understand what second parameter is

    When it is getting called in header_php.php, it is getting called as:
    zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords))
    although I can understand how first parameter is coming, but I am not able to understand from where the value of $search_keywords is coming from

    I tried the search and got this url:
    http://localhost/zencart/index.php?m...word=microsoft

    So value of $_GET['keyword']='microsoft' but what is &$objects?
    Please explain with an example
    Thanks

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Questions related to functions

    The & indicates that the stated object is being passed by reference.
    It's an OOP technique.
    This article may help: http://www.zend.com/php5/articles/engine2-php-oo.php
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Questions related to functions

    Thanks
    I cannot get where $search_keywords is getting the value from
    Is it empty?
    San

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Questions related to functions

    $search_keywords is set within the function, and its contents are available to the script after the function returns from execution

    PHP Code:
      if (zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords)) { 
    1. run the function, passing the $_GET info for 'keyword' param, also passing the variable into which calculated search keywords will be placed
    2. when the function is completed, it returns a boolean true/false, and at the same time, $search_keywords has the contents of the stated object in the function ... in this case, the $objects array, which is the prepared search wordslist.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Questions related to functions

    Is there any documentation as to which file do what etc?

    Let us say, for instance
    I want to make changes in the search functionality
    How can I do this?
    This and lot more questions keep going on my mind as to how zen cart works
    I know it will come with experience and I am reading and trying to understand the functions/classes of zen cart but again just wanted to ask the people here if there is any documentation which can make my task easier
    Thanks

  6. #6
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Questions related to functions

    Can somenoe tell me how the new version works
    just a small example would do
    I dont see main_page calling advanced_search_result in application_top
    What changes have happened in the latest version?
    Thanks
    San
    Tutorials on Zen Cart
    http://tutorials.zen-cart.com/index.php
    ---------------
    advanced.programmer at gmail dot com
    In love with Zen Cart!!

  7. #7
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Questions related to functions

    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Questions related to functions

    Thanks

    Just to capture the variables, I added this piece of code in

    includes\templates\template_default\sideboxes\tpl_search_header.php

    $myFile = "testFile.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = $content;
    fwrite($fh, $stringData);
    fclose($fh);

    It works seperately(file gets created with values written in it)
    But not when I am trying to run it here inside tpl_search_header.php
    Any idea why?

    updates: Its working I was not seeing the file in the correct path!
    Last edited by superprg; 17 Aug 2006 at 02:59 AM.
    Tutorials on Zen Cart
    http://tutorials.zen-cart.com/index.php
    ---------------
    advanced.programmer at gmail dot com
    In love with Zen Cart!!

  9. #9
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Questions related to functions

    In the file functions\general.php

    function zen_validate_password($plain, $encrypted) {
    if (zen_not_null($plain) && zen_not_null($encrypted)) {
    $stack = explode(':', $encrypted);
    if (sizeof($stack) != 2) return false;
    if (md5($stack[1] . $plain) == $stack[0]) {
    return true;
    }
    }
    return false;
    }

    When I passed the password string as 'zencart123' and I did

    echo (md5($stack[1]).$plain);

    I dont get my output as zencart123 although it gets validated and function is returning true
    Tutorials on Zen Cart
    http://tutorials.zen-cart.com/index.php
    ---------------
    advanced.programmer at gmail dot com
    In love with Zen Cart!!

  10. #10
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Questions related to functions

    Quote Originally Posted by DrByte View Post
    The & indicates that the stated object is being passed by reference.
    It's an OOP technique.
    This article may help: http://www.zend.com/php5/articles/engine2-php-oo.php
    Very interesting article DrByte, thanks for posting the link :-)

 

 

Similar Threads

  1. Replies: 4
    Last Post: 12 Sep 2013, 04:09 PM
  2. Custom Functions
    By solo_400 in forum Code Collaboration
    Replies: 2
    Last Post: 25 Feb 2013, 02:50 PM
  3. A few tax-related questions
    By silverbitz in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 5
    Last Post: 6 Feb 2007, 05:54 PM
  4. Questions related to database tables
    By superprg in forum General Questions
    Replies: 25
    Last Post: 15 Aug 2006, 10:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg