Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Products Image Verify


ce7

Recommended Posts

Hi,

Using Phoenix, installed Products Image Verify and has some issue, this addon has been tested on BS and was working. Image as below:
https://www.oscommerce.com/forums/forum/11-general-support/?do=add#

however it doesn't show up the list with CE version
image.thumb.png.edd66ac5df7e78470f21327785e28c36.png

here is the original file:

<?php
	require('includes/application_top.php');
require('includes/template_top.php');
	if(!function_exists('file_put_contents')) {
        function file_put_contents($filename, $data, $file_append = false) {
        $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
                        if(!$fp) {
                                trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
                return;
            }
        fputs($fp, $data);
        fclose($fp);
        }
}
?>
	<!-- body_text //-->
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
	      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
                <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_IMAGE_SIZE; ?></td>
                                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
    <?php
                                           
                                        
        
        if($sID !="" && file_exists(DIR_FS_ADMIN . 'image_verify_cache.php'))
        {
                                        $fd = fopen (DIR_FS_ADMIN . 'image_verify_cache.php', "r");
                                        $iv_cache_contents = fread ($fd,filesize (DIR_FS_ADMIN . 'image_verify_cache.php'));
                                        fclose ($fd);
        $verify_query_raw = "select p.products_id, p.products_image, pd.products_name  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and (" . $iv_cache_contents .") order by pd.products_name";
        }else{
                if(file_exists(DIR_FS_ADMIN . 'image_verify_cache.php'))
                {
                        unlink(DIR_FS_ADMIN . 'image_verify_cache.php');
                }
        $verify_query_raw = "select p.products_id, p.products_image, pd.products_name  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id order by pd.products_name";
        }
    $verify_query = tep_db_query($verify_query_raw);
                while ($verify = tep_db_fetch_array($verify_query)) {
                
                        if ( ((!$HTTP_GET_VARS['sID']) || ($HTTP_GET_VARS['sID'] == $verify['products_id'])) && (!$sInfo) ) {
                                $sInfo = new objectInfo($verify);
                        }
	//Checks Status of all 3 image sizes to make sure it is not blank, null or if file exists so we only print out products with missing images only.                        
                                $image_status = 0;
                                if ($verify['products_image'] != "" && $verify['products_image'] != "NULL")
                                {
                                        if (file_exists(DIR_FS_CATALOG_IMAGES . $verify['products_image']))
                                        {
                                                $image_status = 1;
                                        }else{
                                                $image_status = 0;
                                        }
                                }else{
                                        $image_status = 2;
                                }
	                                if ($image_status != 1)
                                {
                                        if (file_exists(DIR_FS_ADMIN . 'image_verify_cache.php'))
                                        {
                                                file_put_contents(DIR_FS_ADMIN . 'image_verify_cache.php'," or pd.products_id = " . $verify['products_id'],'append.php');
                                        }else{
                                                file_put_contents(DIR_FS_ADMIN . 'image_verify_cache.php',"pd.products_id = " . $verify['products_id']);
                                        }
                                }
                                
                                if ( (is_object($sInfo)) && ($verify['products_id'] == $sInfo->products_id)  && ($image_status != 1)) {
                                echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link('image_verify.php', '&sID=' . $sInfo->products_id) . '\'">' . "\n";
                                
                        } else {
                                echo '                  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link('image_verify.php', '&sID=' . $verify['products_id']) . '\'">' . "\n";
                        }
	 
	                        if ($image_status != 1)
                        {
                        ?>
                <td  class="dataTableContent"><?php echo $verify['products_name']; ?></td>
                <td  class="dataTableContent" align="left"><?php
	                        }
        
                        switch ($image_status)
                        {
                                case 0:
                                        echo tep_image('images/icons/' . 'ms_error.png', KEY_OK, 20, 20);
                                        break;
                                case 2:
                                        echo tep_image('images/icons/' . 'ms_warning.png', KEY_ERROR, 20, 20);
                                        break;
                        }
                                                        
                        
        
                
                        
        
	        if ($image_status != 1)
        {
        ?>
        </td>
                <td class="dataTableContent" align="right">
                <?php if ( (is_object($sInfo)) && ($verify['products_id'] == $sInfo->products_id) ) {
                echo tep_image('images/' . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link('image_verify.php', 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $verify['products_id']) . '">' . tep_image('images/' . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'
                ; } ?>&nbsp;</td>
      </tr>
<?php
        }
                }
?>
              
            </table></td>
<?php
 
$heading = array();
  $contents = array();
 
                if($sID =="")
                {
                $heading[] = array('text' => '<b><center>PLEASE CLICK ON PRODUCT ROW<BR>FOR MORE OPTIONS</center></b>');
                }else{
                $heading[] = array('text' => '<b><center>' . $sInfo->products_name. '</center></b>');
                }
                $contents[] = array('text' => '' . tep_image('images/' . 'pixel_black.gif', '', '100%', 3));                        
                if($sID !="")
                {
	                }
                $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link('categories.php', '&pID=' . $sInfo->products_id . '&action=new_product') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link('categories.php', '&pID=' . $sInfo->products_id . '&action=delete_product') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
                $contents[] = array('text' => '' . tep_image('images/' . 'pixel_black.gif', '', '100%', 3));
                $contents[] = array('text' => '' . tep_image('images/icons/' . 'ms_error.png', '', 20, 20) . KEY_ERROR);
                $contents[] = array('text' => '' . tep_image('images/icons/' . 'ms_warning.png', '', 20, 20) . KEY_NOT_USED);
                $contents[] = array('text' => '' . tep_image('images/' . 'pixel_black.gif', '', '100%', 3));
                $contents[] = array('text' =>   DELETE_WARNING);
                $contents[] = array('text' => '' . tep_image('images/' . 'pixel_black.gif', '', '100%', 3));
                $contents[] = array('text' =>   EDIT_WARNING);
                $contents[] = array('text' => '' . tep_image('images/' . 'pixel_black.gif', '', '100%', 3));
                
	
      
                if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
                        echo '            <td width="25%" valign="top">' . "\n";
                        $box = new box;
                        echo $box->infoBox($heading, $contents);
                        echo '            </td>' . "\n";
                }
	?>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
	
</body>
</html>
<?php require('includes/template_bottom.php'); ?>
<?php require('includes/application_bottom.php'); ?>  


 

When tested with BS, the PHP was version 5, with CE now the PHP is version 7.

Any suggestion of how to fix it? Many thanks!   Lyn

Link to comment
Share on other sites

I would turn on error reporting to see what messages are shown.  Once you know what the problem is you can then fix them or ask for additional help.

Dan

Link to comment
Share on other sites

Try replacing every instance of

$HTTP_GET_VARS

with

$_GET

I.e.

<?php
  require 'includes/application_top.php';

  if (!function_exists('file_put_contents')) {
    function file_put_contents($filename, $data, $file_append = false) {
      $fp = fopen($filename, ($file_append ? 'a+' : 'w+'));
      if (!$fp) {
        trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
        return;
      }
      
      fputs($fp, $data);
      fclose($fp);
    }
  }

  require 'includes/template_top.php';
?>
  <!-- body_text //-->
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
        <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
                <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_IMAGE_SIZE; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php
  if ($sID !="" && file_exists(DIR_FS_CACHE . 'image_verify.cache')) {
    $fd = fopen (DIR_FS_CACHE . 'image_verify.cache', "r");
    $iv_cache_contents = fread ($fd,filesize (DIR_FS_CACHE . 'image_verify.cache'));
    fclose ($fd);
    $verify_query_raw = "select p.products_id, p.products_image, pd.products_name from products p, products_description pd where p.products_id = pd.products_id and (" . $iv_cache_contents .") order by pd.products_name";
  } else {
    if (file_exists(DIR_FS_CACHE . 'image_verify.cache')) {
      unlink(DIR_FS_CACHE . 'image_verify.cache');
    }

    $verify_query_raw = "select p.products_id, p.products_image, pd.products_name  from products p, products_description pd where p.products_id = pd.products_id order by pd.products_name";
  }

  $verify_query = tep_db_query($verify_query_raw);
  while ($verify = tep_db_fetch_array($verify_query)) {
    if ( !isset($sInfo) && (!isset($_GET['sID']) || ($_GET['sID'] == $verify['products_id'])) ) {
      $sInfo = new objectInfo($verify);
    }

//Checks Status of all 3 image sizes to make sure it is not blank, null or if file exists so we only print out products with missing images only.
    $image_status = 0;
    if ($verify['products_image'] != "" && $verify['products_image'] != "NULL") {
      if (file_exists(DIR_FS_CATALOG . 'images/' . $verify['products_image'])) {
        $image_status = 1;
      } else {
        $image_status = 0;
      }
    } else {
      $image_status = 2;
    }

    if ($image_status != 1) {
      if (file_exists(DIR_FS_CACHE . 'image_verify.cache')) {
        file_put_contents(DIR_FS_CACHE . 'image_verify.cache', " or pd.products_id = " . $verify['products_id'], 'append.php');
      } else {
        file_put_contents(DIR_FS_CACHE . 'image_verify.cache', "pd.products_id = " . $verify['products_id']);
      }
    }

    if ( (is_object($sInfo ?? null)) && ($verify['products_id'] == $sInfo->products_id) && ($image_status != 1)) {
      echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link('image_verify.php', '&sID=' . $sInfo->products_id) . '\'">' . "\n";
    } else {
      echo '                  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link('image_verify.php', '&sID=' . $verify['products_id']) . '\'">' . "\n";
    }

    if ($image_status != 1) {
?>
                <td  class="dataTableContent"><?php echo $verify['products_name']; ?></td>
                <td  class="dataTableContent" align="left"><?php
    }

    switch ($image_status) {
      case 0:
        echo tep_image('images/icons/ms_error.png', KEY_OK, 20, 20);
        break;
      case 2:
        echo tep_image('images/icons/ms_warning.png', KEY_ERROR, 20, 20);
        break;
    }

    if ($image_status != 1) {
?></td>
                <td class="dataTableContent" align="right">
<?php
      if ( (is_object($sInfo)) && ($verify['products_id'] == $sInfo->products_id) ) {
        echo tep_image('images/icon_arrow_right.gif', '');
      } else {
        echo '<a href="' . tep_href_link('image_verify.php', 'page=' . $_GET['page'] . '&sID=' . $verify['products_id']) . '">' . tep_image('images/icon_info.gif', IMAGE_ICON_INFO) . '</a>';
      }
?>&nbsp;</td>
      </tr>
<?php
    }
  }
?>

            </table></td>
<?php
  $heading = [];
  $contents = [];

  if ($sID =="") {
    $heading[] = ['text' => '<b><center>PLEASE CLICK ON PRODUCT ROW<BR>FOR MORE OPTIONS</center></b>'];
  } else {
    $heading[] = ['text' => '<b><center>' . $sInfo->products_name. '</center></b>'];
  }

  $contents[] = ['text' => '' . tep_image('images/pixel_black.gif', '', '100%', 3)];
  $contents[] = [
    'align' => 'center',
    'text' => '<a href="' . tep_href_link('categories.php', '&pID=' . $sInfo->products_id . '&action=new_product') . '">'
            . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link('categories.php', '&pID=' . $sInfo->products_id . '&action=delete_product') . '">'
            . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>',
  ];
  $contents[] = ['text' => '' . tep_image('images/pixel_black.gif', '', '100%', 3)];
  $contents[] = ['text' => '' . tep_image('images/icons/ms_error.png', '', 20, 20) . KEY_ERROR];
  $contents[] = ['text' => '' . tep_image('images/icons/ms_warning.png', '', 20, 20) . KEY_NOT_USED];
  $contents[] = ['text' => '' . tep_image('images/pixel_black.gif', '', '100%', 3)];
  $contents[] = ['text' =>   DELETE_WARNING];
  $contents[] = ['text' => '' . tep_image('images/pixel_black.gif', '', '100%', 3)];
  $contents[] = ['text' =>   EDIT_WARNING];
  $contents[] = ['text' => '' . tep_image('images/pixel_black.gif', '', '100%', 3)];

  if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
    echo '            <td width="25%" valign="top">' . "\n";
    $box = new box();
    echo $box->infoBox($heading, $contents);
    echo '            </td>' . "\n";
  }
?>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

</body>
</html>
<?php require 'includes/template_bottom.php'; ?>
<?php require 'includes/application_bottom.php'; ?>

Also changed the location of the cache file.  The previous version required the admin directory to be writable, which should not be necessary. 

Always back up before making changes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...