HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/FlashOnlineDao.php
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// WebSite:  http://www.rvglobalsoft.com
// Unauthorized copying is strictly forbidden and may result in severe legal action.
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
// 
// =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
// This Agreement is a legal contract, which specifies the terms of the license
// and warranty limitation between you and RV Global Soft Co.,Ltd. and RV Site Builder.
// You should carefully read the following terms and conditions before
// installing or using this software.  Unless you have a different license
// agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
// indicates your acceptance of the license and warranty limitation terms
// contained in this Agreement. If you do not agree to the terms of this
// Agreement, promptly delete and destroy all copies of the Software.
//
// =====  Grant of License =======
// The Software may only be installed and used on a single host machine.
//
// =====  Disclaimer of Warranty =======
// THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
// WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
// WARRANTIES WHETHER EXPRESSED OR IMPLIED.   BECAUSE OF THE VARIOUS HARDWARE
// AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
// FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.  THE USER MUST ASSUME THE
// ENTIRE RISK OF USING THIS PROGRAM.  ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
// LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
// IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
// CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
// OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
// BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
// NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
// RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
// RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
// BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
// +---------------------------------------------------------------------------+
// $Id$
// +---------------------------------------------------------------------------+

/**
 *  Data access methods for the online flash of RVSiteBuilder  
 *
 * @package sitebuilder
 * @author  Pairote Manunphol <pairote@rvglobalsoft.com>
 * @author  Parinya <parinya@rvglobalsoft.com>
 * @version $Revision$
 * @since   PHP 5.1
 */

class FlashOnlineDao extends DbWrapper implements SitebuilderInf
{
	function FlashOnlineDao()
	{
		parent::DbWrapper();
	}
	
	/**
	 * Returns a singleton FlashOnlineDao instance.
	 *
	 * @param bool $autoload
	 * @return obj
	 */
	public static function singleton($autoload=false)
    {
        static $instance;
        // If the instance is not there, create one
        if (!isset($instance) || $autoload) {
            $class = __CLASS__;
            $instance = new $class();
        }
        return $instance;
    }

    /**
     * Find flash_folder, flash_type_width , flash_type_height from table rvs_flash_online , rvs_flash_type and rvs_flash_item
     * @author duangdao.k 
     * @param string $rvsFlashId
     * 
     * @return array
     */
    public function findFlashdataByRvsflashId($rvsFlashId = null, $fetchMode='getrow')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oFlashType = DB_DataObject::factory($this->aConf['table']['rvs_flash_type']);
        if (!is_null($rvsFlashId)) {
            $query = sprintf('
                SELECT
                    ft.flash_folder 
                    , t.flash_type_width
                    , t.flash_type_height
                FROM 
                    %s o
                    , %s t
                    , %s  ft
                WHERE 
                    o.rvs_flash_id = %s
                    AND t.flash_type_id = o.flash_type_id
                    AND ft.rvs_flash_id = o.rvs_flash_id
                '
                , $this->aConf['table']['rvs_flash_online']
                , $this->aConf['table']['rvs_flash_type']
                , $this->aConf['table']['rvs_flash_item']
                , RvsLibs_String::quoteSmart($rvsFlashId)
            );
            $oFlashType->query($query);
        }
        $aCloneData = array();
        while ($oFlashType->fetch()) {
            $aCloneData[] = clone($oFlashType);
        }
        return DbWrapper::fetchDatas($oFlashType->_resultFields, $aCloneData, $fetchMode);
    }
    
    /**
     * Find rvs_flash_item_id from table rvs_flash_item
     *
     * @author duangdao.k 
     * @param string $rvsFlashId
     * @param string $fetchMode
     * @return array
     */
    public function findRvsFlashItemIdByRvsFlashId($rvsFlashId = null, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oFlashItem = DB_DataObject::factory($this->aConf['table']['rvs_flash_item']);
        if (!is_null($rvsFlashId)) {
             $query = sprintf('
                SELECT 
                    rvs_flash_item_id
                FROM 
                    %s
                WHERE 
                    rvs_flash_id = %s
                '
                , $this->aConf['table']['rvs_flash_item']
                , RvsLibs_String::quoteSmart($rvsFlashId)
            );
            $oFlashItem->query($query);
        }
        $aCloneData = array();
        while ($oFlashItem->fetch()) {
            $aCloneData[] = clone($oFlashItem);
        }
        return DbWrapper::fetchDatas($oFlashItem->_resultFields, $aCloneData, $fetchMode);
    }
    
    /**
     * Find rvs_flash_item_id and color_name from table rvs_flash_item and rvs_color
     *
     * @author duangdao.k 
     * @param string $rvsFlashId
     * @param string $fetchMode
     * @return array
     */
    public function findRvsFlashItemIdAndcolorNameByRvsFlashId($rvsFlashId = null , $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oFlashItem = DB_DataObject::factory($this->aConf['table']['rvs_flash_item']);
        if (!is_null($rvsFlashId)) {
             $query = sprintf('    
                        SELECT 
                                    i.rvs_flash_item_id
                                    , c.color_name
                        FROM 
                                    %s i
                                    , %s c
                        WHERE 
                                    i.rvs_flash_id = %s
                                    AND c.color_id = i.color_id
                                    '
                                    , $this->aConf['table']['rvs_flash_item']
                                    , $this->aConf['table']['rvs_color']
                                    , RvsLibs_String::quoteSmart($rvsFlashId)
                                    );
             $oFlashItem->query($query);       
        }
        $aCloneData = array();
        while ($oFlashItem->fetch()) {
            $aCloneData[] = clone($oFlashItem);
        }
        return DbWrapper::fetchDatas($oFlashItem->_resultFields, $aCloneData, $fetchMode);
    }
    
    /**
     * Find flash_folder, flash_type_width and flash_type_height by $rvsFlashId and $rvsFlashItemId from table rvs_flash_online,  rvs_flash_type and rvs_flash_item 
     *
     * @author duangdao.k
     * @param string $rvsFlashId
     * @param string $rvsFlashItemId
     * @param string $fetchMode
     * @return array
     */
   public function findFlashdataByRvsFlashIdAndRvsFlashItemId($rvsFlashId = null, $rvsFlashItemId = null, $fetchMode = 'getassoc')
   {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oFlashType = DB_DataObject::factory($this->aConf['table']['rvs_flash_type']);
        if (!is_null($rvsFlashId) && !is_null($rvsFlashItemId)) {
             $query = sprintf('    
                SELECT
                    ft.flash_folder 
                    , t.flash_type_width
                    , t.flash_type_height
                FROM 
                    %s o
                    , %s t
                    , %s ft
                WHERE 
                    o.rvs_flash_id = %s
                    AND ft.rvs_flash_item_id = %s
                    AND t.flash_type_id = o.flash_type_id
                    AND ft.rvs_flash_id = o.rvs_flash_id
                '
                , $this->aConf['table']['rvs_flash_online']
                , $this->aConf['table']['rvs_flash_type']
                , $this->aConf['table']['rvs_flash_item']
                , RvsLibs_String::quoteSmart($rvsFlashId)
                , RvsLibs_String::quoteSmart($rvsFlashItemId)
            );
            $oFlashType->query($query);                   
        }
        $aCloneData = array();
        while ($oFlashType->fetch()) {
            $aCloneData[] = clone($oFlashType);
        }
        return DbWrapper::fetchDatas($oFlashType->_resultFields, $aCloneData, $fetchMode);
   }
   
   /**
    * Find data table rvs_flash_online by rvs_flash_id
    *
    * @author duangdao.k
    * @param string $rvsFlashId
    * @param string $fetchMode
    * @return array
    */
   public function findRvsflashOnlineDataByRvsFlashId($rvsFlashId = null, $fetchMode = 'getassoc', $aResultFields=array())
   {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oFlashOnline = DB_DataObject::factory($this->aConf['table']['rvs_flash_online']);
        if (!is_null($rvsFlashId)) {
             $query = sprintf('    
                        SELECT 
                                    *
                        FROM 
                                    %s
                        WHERE 
                                    rvs_flash_id = %s
                    '
                    , $this->aConf['table']['rvs_flash_online']
                    , RvsLibs_String::quoteSmart($rvsFlashId)
                     );
          $oFlashOnline->query($query); 
        }
        $aCloneData = array();
        while ($oFlashOnline->fetch()) {
            $aCloneData[] = clone($oFlashOnline);
        }
       $_aResultFields = DbWrapper::buildResultFields($oFlashOnline, $aResultFields);
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
   }
   
   /**
    * Find data from table rvs_flash_item by rvs_flash_item_id
    *
    * @author duangdao.k
    * @param string $rvsFlashItemId
    * @param string $fetchMode
    * @return array
   /*$query = "    
                        SELECT 
                                    *
                        FROM 
                                    {$this->conf['table']['rvs_flash_item']}
                        WHERE 
                                    rvs_flash_item_id = '$output->rvs_flash_item_id'
    ";*/
   public function findRvsFlashItemDataByrvsFlashItemId($rvsFlashItemId = null, $fetchMode = 'getassoc')
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashItem = DB_DataObject::factory($this->aConf['table']['rvs_flash_item']);
        if (!is_null($rvsFlashItemId)) {
            $query = sprintf('    
                SELECT 
                    *
                FROM 
                    %s
                WHERE 
                    rvs_flash_item_id = %s
                '
                , $this->aConf['table']['rvs_flash_item']
                , RvsLibs_String::quoteSmart($rvsFlashItemId)
            );
            $oFlashItem->query($query);            
        }
        $aCloneData = array();
        while ($oFlashItem->fetch()) {
            $aCloneData[] = clone($oFlashItem);
        }
        return DbWrapper::fetchDatas($oFlashItem->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * Find Data from table rvs_flash_online
    *
    * @author duangdao.k
    * @param string $flashTypeId
    * @param string $fetchMode
    * @return string
    */
   public function findFlashIdByFlashTypeId($flashTypeId = null, $fetchMode = 'getassoc', $aResultFields=array('rvs_flash_id'))
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashItem = DB_DataObject::factory($this->aConf['table']['rvs_flash_item']);
       
       if (!is_null($flashTypeId)) {
            $query = sprintf('    
                 SELECT 
                       * 
                  FROM 
                       %s
                  WHERE 
                       flash_type_id = %s
                 '
                 , $this->aConf['table']['rvs_flash_online']
                 , RvsLibs_String::quoteSmart($flashTypeId)
             );
            $oFlashItem->query($query);            
       }
        $aCloneData = array();
        while ($oFlashItem->fetch()) {
            $aCloneData[] = clone($oFlashItem);
        }
        $_aResultFields = DbWrapper::buildResultFields($oFlashItem, $aResultFields);
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
   }
   
   /**
    * Find Data from table rvs_flash_type
    * @author duangdao.k
    * @param $string $fetchMode
    * @return arrayobj
    */
   public function findfFashTypeData($fetchMode = 'getassoc', $aResultFields=array())
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashType = DB_DataObject::factory($this->aConf['table']['rvs_flash_type']);
       $query = sprintf('    
             SELECT 
                    *
             FROM 
                    %s
             '
            , $this->aConf['table']['rvs_flash_type']
        );
       $oFlashType->query($query);    
       $aCloneData = array();
        while ($oFlashType->fetch()) {
            $aCloneData[] = clone($oFlashType);
        }
        $_aResultFields = DbWrapper::buildResultFields($oFlashType, $aResultFields);
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
   }
   
   /**
    * Find FlashTypeData By FlashTypeId
    *
    * @author duangdao.k
    * @param $string $flashTypeId
    * @param $string $fetchMode
    * @param $array $aResultFields
    * @return array
    */
   public function findFlashTypeDataByFlashTypeId($flashTypeId = null, $fetchMode = 'getassoc', $aResultFields=array())
   {
      SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashType = DB_DataObject::factory($this->aConf['table']['rvs_flash_type']);
       if (!is_null($flashTypeId)) {
            $query = sprintf('    
                 SELECT 
                        *
                 FROM 
                        %s
                 WHERE 
                         flash_type_id = %s
                 '
                 , $this->aConf['table']['rvs_flash_type']
                 , RvsLibs_String::quoteSmart($flashTypeId)
            );
            $oFlashType->query($query); 
       }
		 $aCloneData = array();      
         while ($oFlashType->fetch()) {
            $aCloneData[] = clone($oFlashType);
        }
        $_aResultFields = DbWrapper::buildResultFields($oFlashType, $aResultFields);
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
   }
   
   /**
    * Find FlashId And FlashItemId from table rvs_flash_online and rvs_flash_item by flash_type_id and rvs_flash_id
    * 
    * @author duangdao.k
    * @param $string $flashTypeId
    * @param $string $fetchMode
    * @return array
    */
   public function findFlashIdAndFlashItemIdByFlashTypeIdAndFlashId($flashTypeId = null, $fetchMode = 'getassoc')
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashOnline = DB_DataObject::factory($this->aConf['table']['rvs_flash_online']);
       if (!is_null($flashTypeId)) {
            $query = sprintf('    
                SELECT 
                       o.rvs_flash_id
                        , i.rvs_flash_item_id
                 FROM 
                        %s o
                        , %s i
                 WHERE 
                         o.flash_type_id = %s
                         AND i.rvs_flash_id = o.rvs_flash_id
                '
               , $this->aConf['table']['rvs_flash_online']
               , $this->aConf['table']['rvs_flash_item']
               , RvsLibs_String::quoteSmart($flashTypeId)
            );
            $oFlashOnline->query($query);   
       }
        $aCloneData = array();
        while ($oFlashOnline->fetch()) {
            $aCloneData[] = clone($oFlashOnline);
        }
        return DbWrapper::fetchDatas($oFlashOnline->_resultFields, $aCloneData, $fetchMode);
   }
   private function getFlashFolderFromPageData($pageData)
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       RvsLibs_String::preg_match_all('/flash_(.*?)[\|](.*?)[\.]/', $pageData, $aMatches);
       return array_unique($aMatches[2]);
   }
   
   public function findFlashItemByFlashFolder($flashFolder, $fetchMode = 'getassoc')
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashItem = DB_DataObject::factory($this->aConf['table']['rvs_flash_item']);
       if (!is_null($flashFolder)) {
           $oFlashItem->flash_folder = $flashFolder;
       }
       $oFlashItem->find();
       $aCloneData = array();
        while ($oFlashItem->fetch()) {
            $aCloneData[] = clone($oFlashItem);
        }
        return DbWrapper::fetchDatas($oFlashItem->_resultFields, $aCloneData, $fetchMode);
   }
   
    public function findFlashOnlineByFlashId($flashId, $fetchMode = 'getassoc')
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashOnline = DB_DataObject::factory($this->aConf['table']['rvs_flash_online']);
       if (!is_null($flashId)) {
           $oFlashOnline->rvs_flash_id = $flashId;
       }
       $oFlashOnline->find();
       $aCloneData = array();
        while ($oFlashOnline->fetch()) {
            $aCloneData[] = clone($oFlashOnline);
        }
        return DbWrapper::fetchDatas($oFlashOnline->_resultFields, $aCloneData, $fetchMode);
   }
   
    public function findFlashTypeByFlashTypeId($flashTypeId, $fetchMode = 'getassoc')
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oFlashType = DB_DataObject::factory($this->aConf['table']['rvs_flash_type']);
       if (!is_null($flashTypeId)) {
           $oFlashType->flash_type_id = $flashTypeId;
       }
       $oFlashType->find();
       $aCloneData = array();
        while ($oFlashType->fetch()) {
            $aCloneData[] = clone($oFlashType);
        }
        return DbWrapper::fetchDatas($oFlashType->_resultFields, $aCloneData, $fetchMode);
   }
    
   public function backupsql($projectId, $usrId)
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       $aSQLData = array();
       $aFlashId = array();
       $aFlashTypeId = array();
       $aFlashItemInProject = array();
       /// Get $aProjectPageId From rvs_project_layout_page by project_id
       $aProjectPageId = DaoFactory::ProjectLayoutPage()->findProjectLayoutPage($projectId, 'getassoc');
       /// Get $aProjectPageId From internal page
       $aInternalPage = DaoFactory::InternalPage()->findInternalProjectPageIdByProjectId($projectId, 'getassoc', $aResultFields = array('project_page_id'));
       $aProjectPageId = array_merge($aProjectPageId, $aInternalPage);
       foreach ($aProjectPageId as $key => $val) {
           /// Get PageData
           $aProjectPageData = DaoFactory::ProjectPage()->findProjectPageDataByProjectPageId($key, 'getDataObject', $aResultFields = array());
           if (count($aProjectPageData) > 0) {
               $aFlashFolder = $this->getFlashFolderFromPageData($aProjectPageData[0]->page_data);
               foreach ($aFlashFolder as $flashFolder) {
                   $aFlashItem = $this->findFlashItemByFlashFolder($flashFolder, 'getDataObject');
                   if(isset($aFlashItem[0])) {
                      $aFlashItemInProject[] =  $aFlashItem[0];
                   }
               }
           }
       }
       /// Backup table rvs_flash_item
       foreach ($aFlashItemInProject as $val) {
       	if (isset($val->rvs_flash_id)) {
       		$aFlashId[] = $val->rvs_flash_id;
       		$aSQLData[] = DbWrapper::buildSQLFormat($val);
       	}
       }
       foreach ($aFlashId as $flashId) {
       	///Backup table rvs_flash_online by $flashId
       	$oFlashOnline = $this->findFlashOnlineByFlashId($flashId, 'getDataObject');
       	foreach ($oFlashOnline as $k => $v) {
       		if (isset($v->flash_type_id)) {
       			$aFlashTypeId[] = $v->flash_type_id;
       			$aSQLData[] = DbWrapper::buildSQLFormat($v);
       		}
       	}
       }
       foreach ($aFlashTypeId as $flashTypeId) {
       	///Backup table rvs_flash_type by $flashTypeId
       	$oFlashType = $this->findFlashTypeByFlashTypeId($flashTypeId, 'getDataObject');
       	foreach ($oFlashType as $k => $v) {
			$aSQLData[] = DbWrapper::buildSQLFormat($v);
       	}
       }
       return $aSQLData;
   }
    
   public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array()) 
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
        ///@TODO : delete flash online
   }
}
?>