Auctions display closed but, they're not fully closed

Discussion in 'General Support' started by david62311, Aug 30, 2018.

  1. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I had installed the latest script from Github last June. It was on a back page of mine. I didn't pay much attention to it but, noticed today that they was some auctions that displayed closed on the index.php page in the hot items but, not in the Latest Auctions. When I go into my user's control panel there is nothing in the closed auctions. My items show in the active items. When I look at the item on the item page it says closed. So, there seems to be a bug there in the newer Webid Script that wasn't there before.

    Here's some photos...gotta show the photos. The only update I did to the home page was made the login on the right. It may look different to you all because of that.

    capture-20180829-222944.png capture-20180829-223240.png capture-20180829-223940.png

    Does anybody else see this issue with the latest Webid script from Github? It should be a simple fix.

    It's 911 in the Language for the word Closed. It's not even in the home,tpl page so, the code issue should be in the index.php page.
     
    Last edited: Aug 30, 2018
  2. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    It doesn't even display closed in the classic theme on the home page but, it does when you look at the item.

    capture-20180829-225420.png

    capture-20180829-225648.png
     
  3. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    Here's the query code for the Hot Items on the index.php page. I will use Hot Items since that where my own issue is showing.

    PHP:
    // get hot items
    $query "SELECT a.id, a.title, a.current_bid, a.pict_url, a.ends, a.num_bids, a.minimum_bid
            FROM " 
    $DBPrefix "auctions a
            LEFT JOIN " 
    $DBPrefix "auccounter c ON (a.id = c.auction_id)
            WHERE closed = 0 AND suspended = 0 AND starts <= CURRENT_TIMESTAMP
            ORDER BY c.counter DESC LIMIT :limit"
    ;
    $params = array();
    $params[] = array(':limit'$system->SETTINGS['hotitemsnumber'], 'int');
    $db->query($query$params);
    $i 0;
    while (
    $row $db->fetch()) {
        
    $i++;
        if (
    strtotime($row['ends']) - time() > 0) {
            
    $current_time = new DateTime('now'$dt->UTCtimezone);
            
    $end_time = new DateTime($row['ends'], $dt->UTCtimezone);
            
    $difference $current_time->diff($end_time);
            
    $ends_string $dt->formatTimeLeft($difference);
        } else {
            
    $ends_string $MSG['911'];
        }
        
    $high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid'];
        
    $template->assign_block_vars('hotitems', array(
                
    'ENDS' => $ends_string,
                
    'ID' => $row['id'],
                
    'BID' => $system->print_money($high_bid),
                
    'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' $system->SETTINGS['thumb_show'] . '&amp;fromfile=' UPLOAD_FOLDER $row['id'] . '/' $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
                
    'TITLE' => htmlspecialchars($row['title'])
                ));
    }
    $hot_items = ($i 0) ? true false;
     
  4. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    Why do I feel like I have fixed this issue before? I think I have and it had to do with time issues!

    When I am here in it the Active Auctions or yourauctions.php page and try to close the item, it doesn't close. However, after I took this snapshot and added Test item #4, the item on the index.php showed the 24 hour countdown timer but, when I came here and closed it n the Active Auctions, it said closed on the index.php page.

    capture-20180829-223240.png

    The database looks right. It's showing a 0 for closed.

    capture-20180829-235029.png

    Once I added test item #4 I didn't see any changes in the database except for the end time was current but, I after tried to close Test item #4, there was still no database changes.

    capture-20180830-000751.png
     
  5. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I went to the index.php page and changed all of these:
    CURRENT_TIMESTAMP

    to:
    :time

    and that took care of the problems on that page. I will try to trace down the CURRENT_TIMESTAMPs and see where the code is messed up.
     
  6. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I don't know if it's related to the time issue but, when I try to close an active auction that is already closed but, still in the active auctions page, it generates these error:

    I did see the /cache/lock.txt file and I don't know if it's supposed to be a tmp file or if there is supposed to be a file there all of the time. It wasn't there when I looked.

    @pani100 I believe you know more about the time coding on the Webid Script than almost everyone here. Can you please help with this issue? I will keep looking at it but, I think I am stuck. I do think I am close and the issue is probably going to be on the cron.php page somewhere or the includes/functions_cron.php page or maybe even the common.php page.
     
  7. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I think I got it. From the error log it showed:

    This was what I believed caused all of the problems because it was never finding that file in the cache folder. On around line 19 in the cron.php I changed:

    PHP:
    $fp fopen("/cache/lock.txt""w+");
    To:

    PHP:
    $fp fopen("lock.txt""w+");
    This fixed my problem. Database is checking out good too. When I close an item manually it shows a 1 under the closed for that item in the database.
     
  8. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I ran further tests and it seems that forward slash most likely cause the problem.

    I changed this:
    PHP:
    $fp fopen("/cache/lock.txt""w+");
    To this:
    PHP:
    $fp fopen("cache/lock.txt""w+");
    And now it creates the lock.txt file in the cache folder.

    I tested it again and put the forward slash back in front and it stopped working and the errors in the error log got generated again. It's very odd that the forward slash would cause a problem but, it seems like it does. Maybe it has something to do with being on the back end of another site. My main website is supposed to be https:// but, on the Webid site, it shows it's http:// .

    If someone can confirm they have a closing issue using the latest Github Webid Script then that would be Great and much appreciated!

    Note: To anybody that changed the code like I mentioned that I did in the index.php at post #5, change it back to the way it was. That was just to help me trace the issue I was having.
     
    Last edited: Aug 30, 2018
  9. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    The code on the common.php page is written like CACHE_PATH could of been used there:

    PHP:
    //define the paths
    define('MAIN_PATH'$main_path);
    define('CACHE_PATH'MAIN_PATH 'cache/');
    define('INCLUDE_PATH'MAIN_PATH 'includes/');
    define('PACKAGE_PATH'MAIN_PATH 'includes/packages/');
    define('UPLOAD_FOLDER''uploaded/');
    define('UPLOAD_PATH'MAIN_PATH UPLOAD_FOLDER);
    define('IMAGE_CACHE_PATH'UPLOAD_PATH 'cache/');
    I like this new cpanel feature. I had just started to update the code there and a 'x' appeared on the left and when I hovered over it it explained what the 'x' was for and what needed to be corrected.

    New cpanel.jpg

    I made the code like this and it works the same:

    PHP:
    $fp fopen(CACHE_PATH 'lock.txt''w+');
    Just a note: There are 3 pages that the CACHE_PATH could of been used.
    admin/index.php, admin/clearcache.php, includes/template/Template.php
    One page had the code twice like this: (MAIN_PATH . 'cache')
     
    Last edited: Aug 30, 2018
  10. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Hi David,
    Yes I think this is an error I have come across. Auctions closed but still showing because the cron would not close them due to the error of the cache file not found.
    I have looked and found I had replaced line 19 in the cron.php
    PHP:
    $fp fopen("/cache/lock.txt""w+");
    with
    PHP:
    $fp fopen(MAIN_PATH "/cache/lock.txt""w+");
    I wasn't aware the cache path had already been declared in common.php and the best way to do is exactly like you worked out:
    PHP:
    $fp fopen(CACHE_PATH 'lock.txt''w+');
    :)
     
  11. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    Thanks @pani100 for confirming my code was right! I appreciate that! Even though I have improved a lot in my coding skills, I still can use reassurance on my corrections sometimes. I went ahead and added it to Github now that you confirm it was good to go.

    My error log report led me right to that issue when I tried to manually close the auction items. It saved me a lot of time searching for that issue.
     
  12. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    So @pani100 how about with these codes on these page below? Same code and function for each page but, parts of the codes above it are written differently. One is written with $_POST and one is written with $_GET and uses a switch. These lines of code below are the same code on both pages. It's just the codes above them that are different.
    Line 22 of the admin/index.php
    Line 25 of the admin/clearcache.php

    I'm a little confused why CACHE_PATH was used at the bottom part of the code but, not at the top.

    PHP:
    if (is_dir(MAIN_PATH 'cache')) {
                    
    $dir opendir(MAIN_PATH 'cache');
                    while ((
    $myfile readdir($dir)) !== false) {
                        if (
    $myfile != '.' && $myfile != '..' && $myfile != 'index.php') {
                            
    unlink(CACHE_PATH $myfile);
    I changed the code on my page and tested it and it works like this:

    PHP:
        if (is_dir(CACHE_PATH)) {
            
    $dir opendir(CACHE_PATH);
            while ((
    $myfile readdir($dir)) !== false) {
                if (
    $myfile != '.' && $myfile != '..' && $myfile != 'index.php') {
                    
    unlink(CACHE_PATH $myfile);
    I tested both of the updates and no errors or issues reported.

    Then the /includes/template/Template.php page has this:

    I changed:

    PHP:
    if (file_exists(MAIN_PATH 'themes/' $theme)) {
                
    $this->root MAIN_PATH 'themes/' $theme;
                
    $this->cachepath MAIN_PATH 'cache/tpl_' str_replace('_''-'$theme) . '_';
                
    $this->default_root MAIN_PATH 'themes/default';
                
    $this->default_cachepath MAIN_PATH 'cache/tpl_default' '_';
    To This:

    PHP:
    if (file_exists(MAIN_PATH 'themes/' $theme)) {
                
    $this->root MAIN_PATH 'themes/' $theme;
                
    $this->cachepath CACHE_PATH 'tpl_' str_replace('_''-'$theme) . '_';
                
    $this->default_root MAIN_PATH 'themes/default';
                
    $this->default_cachepath CACHE_PATH 'tpl_default' '_';
    And changed the code towards the bottom from:

    PHP:
    $this->cachepath MAIN_PATH 'cache/ctpl_' str_replace('_''-'$template_name) . '_';
    PHP:
    $this->cachepath CACHE_PATH 'ctpl_' str_replace('_''-'$template_name) . '_';
    Should I make a new proposal to have these changed on Github or just leave them as they were? Either way they work.
     
  13. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I love coming back and finding fixed that I already did because another code caused me to revert a whole page of code back for something that comes up like it did recently with me and caused my Website not to show anymore. I was getting a 500 page. When I finally got the site to come up all of my coded fixed that I did got changed, I guess. I came back to find this and I had to retrace my steps.

    I was wondering if I had made a proposal on Github to fix the issue but, I think at the time I was still using Windows XP and Vista and Github won't allow PCs with old Operating System to edit anything on there. I have finally upgraded to Windows 10 hoping it doesn't become obsolete in a few months. I have made the proposal now as the way I put the code at the bottom here.

    The error:
    Unknown error type: [2] fopen(/cache/lock.txt): failed to open stream: No such file or directory on /.../cron.php line 19

    The main fix is in the quote for the cron.php page around line 19.

    The code in the quotation reply above makes it so, a lock.txt file is written in the cache folder. The code can also be like this and it really should be:

    PHP:
    $fp fopen(CACHE_PATH 'lock.txt''w+');
     
  14. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    The fix I just posted in post #13 also stops these other errors from popping up. I just tested that. I saw some work in these areas on Github. It's amazing how much problems a silly forward slash can cause.

    Unknown error type: [2] fopen(/cache/lock.txt): failed to open stream: No such file or directory on /.../cron.php line 19
    Unknown error type: [2] flock() expects parameter 1 to be resource, boolean given on /.../cron.php line 22
    Unknown error type: [2] fclose() expects parameter 1 to be resource, boolean given on /.../cron.php line 627
     
  15. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    Stop Sign.jpg

    Before even messing with the lock coding stuff on the cron.php page please back up your database. Mainly the webid_auctions. Something in the coding is wiping out the existing auctions!

    All of my Auctions were still there until I removed the /Forward slash before the lock.txt. All removing the forward slash did was stop the errors and create the lock.txt file in the cache folder which it didn't do before.

    PHP:
    $fp fopen("/cache/lock.txt""w+");
    @renlok We need your attention on this one please! Nobody wants to lose their auctions in their database like that. I was very lucky my cpanel automatically backed up my database.
     
  16. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    It's not the just the forward slash on lock.txt code that causing my items to empty out my auctions table in my database, it's something else. Because the lock was not working properly, it was preventing the auctions to be cleared out of the auctions table. I tested this out by removing all of the lock coding that was added here. https://github.com/renlok/WeBid/com...22a1d20#diff-b182cca99e981dd636d04129c2da7a03 Once I reverted that code back to how it was, my auctions disappeared.

    I will look to try to figure out what happened but, there is a lot of coding involved. I could use some help here please. There is also includes/functions_cron.php included to look at too.
     
  17. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I want to clear something up on what I am seeing. This does not happen when I look at the auctions in the Webid Admin Panel.
    • All of my auctions delete after I go Webid page.
    • Once my auctions table goes empty, I have to delete the auctions table.
    • Then I import my backup.
    • I can see the auctions again in the admin panel and refresh the page and they are still there. It's when I go on to the site with my user that all of my auctions get deleted.
    I guess what I can do is start removing the query codes that are connected to the auctions table until i find it. It should sput up an error once I find it or not work.
     
  18. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    What a freaky thing and nightmare this has been for me! I feel like my head is running a fever from looking at it too much. No I have been working 24 hours each day on this if you were going to ask. I look at it at night.

    I had restored my site completely back to the way it was. It was working half way decent minus the auction number issue I was having. It still was doing that. I decided to add the flock feature that was added and dropping the the forward slash to an older cron.php page that I had on my site. It doesn't matter if I tried the latest cron.php page or a newer one. I still lose all of my auctions in my database every time I load the index.php page. The index.php page has a include code like this at the top for the cron.php page:

    PHP:
    // Run cron according to SETTINGS
    if ($system->SETTINGS['cron'] == 2)
    {
        include_once 
    'cron.php';
    }
    I've ran more test and and reverted my old cron.php page back to the old code that I was using when it was working fine. This older code got rid of the flock codes. You would think reverted to the cron.php page back to the way it was when it was working would solve this issue. NOPE! It still was deleting all of my auctions every time I went to the index.php page. It serious is a cron.php page related issue because if I go to my control and go direct to the my active auctions, I can see the auctions until I go to the home page and poof, all of the auctions disappear from the home page and the auctions table in the database.

    I am thinking wtf? I reverted my code back to when the page was loading okay and it would not go back to working right. It still was deleting the auctions every time I went to the home index.php page. I tried to clearing my history in my browser and I switched the browser and clear the cache and all and it still was deleting all of my auctions. I removed the code that I shared two paragraphs up with the cron include from the index.php page and of course when I loaded the index.php page, the auctions were still there. What surprised me was after I ran that include removal test for the cron.php and I saw my items were still there, I then put the code back to include the cron.php page and now it's keeping my auctions showing minus the pictures. The pictures most likely got deleted. At least my auctions are still showing.

    @pani100 or anybody, what the heck can cause this? I am thinking it started with the added flock code to the cron.php page but, something stored somewhere kept deleting my auctions even after I removed the flock coding from the cron.php page. I deleted everything in the cache folder manually too to test that out. When I went to the home index.php page, it didn't matter if I was logged off or on. It still deleted them. Now that I removed the include cron.php code and replaced it on the index.php it's no longer deleting the auctions in the database.

    I'm stumped and I am worn out. I really need help on this please!
     
    Last edited: Nov 1, 2018
  19. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I am testing this problem out in my Summer of 2018 Webid Github version and I can't add new auctions to even get started. It is however updating the ID number so, at least that is good and I am getting a new error in the Webid Admin Error log:

    Line 215 is the line that starts trigger_error.

    PHP:
        protected function error_handler($error)
        {
            
    trigger_error($errorE_USER_WARNING);
            if (!
    $this->error_supress) {
                
    debug_print_backtrace();
            }
        }
     
  20. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    Thanks to the help @pani100 was giving here http://www.webidsupport.com/forums/...length-no-error-if-too-long.14972/#post-59934, it got me to realize that the error reported was the character length added was too long for the 'starts' for the column.

    What I am about to tell you fixes the issue I mentioned at post #19...and it fixed the issue to allow me to add new auctions...at least for my newer Webid 2018 script. I kept trying to add new test auctions and nothing was getting inserts into the auctions table in the database or on the website. The fix for the SQLSTATE start length error is below.

    Go to your actual database and find the table for webid_auctions and drop it down and find starts and change the length value from 14.

    start 14.png

    To something higher like 20.

    start at 20.png

    Once that is fixed then you most like have to the same for the ends. Change the 14 on the ends:

    ends.png

    To 20 or something larger than 14.

    end at 20.png

    That's it for the that!
     

Share This Page