Example #1
0
 private function CreateObjects($mysql_result, $objectClass, $lazyLoad = true)
 {
     $objectList = array();
     if ($mysql_result != null) {
         while ($row = Database::Read($mysql_result)) {
             $pog_object = new $objectClass();
             $this->PopulateObjectAttributes($row, $pog_object);
             $objectList[] = $pog_object;
         }
     }
     return $objectList;
 }
 function Execute()
 {
     $objectName = get_class($this->sourceObject);
     $fcv_array = $this->argv[0];
     $sql = 'select count(*) as mycount from `' . strtolower($objectName) . '`';
     if (sizeof($fcv_array) > 0) {
         $sql .= " where ";
         for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) {
             if (sizeof($fcv_array[$i]) == 1) {
                 $sql .= " " . $fcv_array[$i][0] . " ";
                 continue;
             } else {
                 if ($i > 0 && sizeof($fcv_array[$i - 1]) != 1) {
                     $sql .= " AND ";
                 }
                 $fieldAttributes = $this->sourceObject->GetFieldAttribute($fcv_array[$i][0], 'db_attributes');
                 if ($fieldAttributes != null && $fieldAttributes[0] != 'NUMERIC' && $fieldAttributes[0] != 'SET') {
                     if ($GLOBALS['configuration']['db_encoding'] == 1) {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(" . $fcv_array[$i][2] . ")" : "'" . $fcv_array[$i][2] . "'";
                         $sql .= "BASE64_DECODE(`" . $fcv_array[$i][0] . "`) " . $fcv_array[$i][1] . " " . $value;
                     } else {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $this->Escape($fcv_array[$i][2]) . "'";
                         $sql .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                     }
                 } else {
                     $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $fcv_array[$i][2] . "'";
                     $sql .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                 }
             }
         }
     }
     $connection = Database::Connect();
     $cursor = Database::Reader($sql, $connection);
     while ($row = Database::Read($cursor)) {
         $count = $row['mycount'];
     }
     return $count;
 }
 /**
  * Returns a sorted array of objects that match given conditions
  * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
  * @param string $sortBy 
  * @param boolean $ascending 
  * @param int limit 
  * @return array $parent_List
  */
 function GetList($fcv_array = array(), $sortBy = '', $ascending = true, $limit = '')
 {
     $connection = Database::Connect();
     $sqlLimit = $limit != '' ? "LIMIT {$limit}" : '';
     $this->pog_query = "select * from `parent_` ";
     $parent_List = array();
     if (sizeof($fcv_array) > 0) {
         $this->pog_query .= " where ";
         for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) {
             if (sizeof($fcv_array[$i]) == 1) {
                 $this->pog_query .= " " . $fcv_array[$i][0] . " ";
                 continue;
             } else {
                 if ($i > 0 && sizeof($fcv_array[$i - 1]) != 1) {
                     $this->pog_query .= " AND ";
                 }
                 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') {
                     if ($GLOBALS['configuration']['db_encoding'] == 1) {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(" . $fcv_array[$i][2] . ")" : "'" . $fcv_array[$i][2] . "'";
                         $this->pog_query .= "BASE64_DECODE(`" . $fcv_array[$i][0] . "`) " . $fcv_array[$i][1] . " " . $value;
                     } else {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $this->Escape($fcv_array[$i][2]) . "'";
                         $this->pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                     }
                 } else {
                     $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $fcv_array[$i][2] . "'";
                     $this->pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                 }
             }
         }
     }
     if ($sortBy != '') {
         if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') {
             if ($GLOBALS['configuration']['db_encoding'] == 1) {
                 $sortBy = "BASE64_DECODE({$sortBy}) ";
             } else {
                 $sortBy = "{$sortBy} ";
             }
         } else {
             $sortBy = "{$sortBy} ";
         }
     } else {
         $sortBy = "parent_id";
     }
     $this->pog_query .= " order by " . $sortBy . " " . ($ascending ? "asc" : "desc") . " {$sqlLimit}";
     $thisObjectName = get_class($this);
     $cursor = Database::Reader($this->pog_query, $connection);
     while ($row = Database::Read($cursor)) {
         $parent_ = new $thisObjectName();
         $parent_->parent_Id = $row['parent_id'];
         $parent_->attribute = $this->Unescape($row['attribute']);
         $parent_List[] = $parent_;
     }
     return $parent_List;
 }
 /**
  * Returns a sorted array of objects that match given conditions
  * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ..}
  * @param string $sortBy
  * @param boolean $ascending
  * @param int limit
  * @return array $pluginList
  */
 function GetList($fcv_array = array(), $sortBy = '', $ascending = true, $limit = '')
 {
     $connection = Database::Connect();
     $sqlLimit = $limit != '' ? "LIMIT {$limit}" : '';
     $this->pog_query = "select * from `plugin` ";
     $pluginList = array();
     if (sizeof($fcv_array) > 0) {
         $this->pog_query = $this->pog_query . " where ";
         for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) {
             if (sizeof($fcv_array[$i]) == 1) {
                 $this->pog_query = $this->pog_query . " " . $fcv_array[$i][0] . " ";
                 continue;
             } else {
                 if ($i > 0 && sizeof($fcv_array[$i - 1]) != 1) {
                     $this->pog_query = $this->pog_query . " AND ";
                 }
                 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') {
                     if ($GLOBALS['configuration']['db_encoding'] == 1) {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(" . $fcv_array[$i][2] . ")" : "'" . $fcv_array[$i][2] . "'";
                         $this->pog_query = $this->pog_query . "BASE64_DECODE(`" . $fcv_array[$i][0] . "`) " . $fcv_array[$i][1] . " " . $value;
                     } else {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $this->Escape($fcv_array[$i][2]) . "'";
                         $this->pog_query = $this->pog_query . "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                     }
                 } else {
                     $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $fcv_array[$i][2] . "'";
                     $this->pog_query = $this->pog_query . "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                 }
             }
         }
     }
     if ($sortBy != '') {
         if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') {
             if ($GLOBALS['configuration']['db_encoding'] == 1) {
                 $sortBy = "BASE64_DECODE({$sortBy}) ";
             } else {
                 $sortBy = "{$sortBy} ";
             }
         } else {
             $sortBy = "{$sortBy} ";
         }
     } else {
         $sortBy = "pluginid";
     }
     $this->pog_query = $this->pog_query . " order by " . $sortBy . " " . ($ascending ? "asc" : "desc") . " {$sqlLimit}";
     $thisObjectName = get_class($this);
     $cursor = Database::Reader($this->pog_query, $connection);
     while ($row = Database::Read($cursor)) {
         $plugin = new $thisObjectName();
         $plugin->pluginId = $row['pluginid'];
         $plugin->name = $this->Unescape($row['name']);
         $plugin->author = $this->Unescape($row['author']);
         $plugin->description = $this->Unescape($row['description']);
         $plugin->code = $this->Unescape($row['code']);
         $plugin->version = $this->Unescape($row['version']);
         $plugin->emailAddress = $this->Unescape($row['emailaddress']);
         $plugin->password = $this->Unescape($row['password']);
         $plugin->active = $this->Unescape($row['active']);
         $plugin->mysql = $this->Unescape($row['mysql']);
         $plugin->php = $this->Unescape($row['php']);
         $pluginList[] = $plugin;
     }
     return $pluginList;
 }
Example #5
0
        if (!isset($_SESSION['objectName'])) {
            $_SESSION['objectName'] = $objectNameList[0];
        }
        for ($i = 0; $i < count($objectNameList); $i++) {
            $name = $objectNameList[$i];
            eval('$instance = new ' . $name . '();');
            if (!TestIsMapping($instance)) {
                echo "<li " . ($_SESSION['objectName'] == $objectNameList[$i] ? "id='current'" : '') . "><a href='./index.php?objectName=" . $objectNameList[$i] . "'>" . $objectNameList[$i] . "</a></li>";
                //echo "<a href='./index.php?objectName=".$objectNameList[$i]."'".(isset($_SESSION['objectName']) && $_SESSION['objectName']==$objectNameList[$i]?"class='activetab'":(!isset($_SESSION['objectName'])&&$i==0?"class='activetab'":"inactivetab")).">".$objectNameList[$i]."</a> ";
            }
        }
        $connection = Database::Connect();
        $count = 0;
        $sql = 'show index from `' . strtolower($_SESSION['objectName']) . '` where Key_name = "searching"';
        $cursor = Database::Reader($sql, $connection);
        while ($row = Database::Read($cursor)) {
            $count++;
        }
        ?>
	</ul>
	</div><!--header-->
	</div><!--subtabs-->
	<div class="toolbar"><div style="float:left;"><a href="<?php 
        echo $_SESSION['links'][$_SESSION['objectName']];
        ?>
" target="_blank" title="modify and regenerate object"><img src="./setup_images/setup_regenerate.jpg" border="0"/></a><a href="#" title="Delete all objects" onclick="if (confirm('Are you sure you want to delete all objects in this table? TPress OK to Delete.')){window.location='./?thrashall=true';}else{alert('Phew, nothing was deleted ;)');}"><img src='./setup_images/setup_deleteall.jpg' alt='delete all' border="0"/></a><a href="#" onclick="javascript:expandAll();return false;" title="expand all nodes"><img src='./setup_images/setup_expandall.jpg' alt='expand all' border="0"/></a><a href="#" onclick="javascript:collapseAll();return false;" title="collapse all nodes"><img src='./setup_images/setup_collapseall.jpg' alt='collapse all' border="0"/></a><a href="#" title="update all objects to newest POG version" onclick="if (confirm('Setup will now attempt to upgrade your objects by contacting the POG SOAP server. Would you like to continue?')){window.location='./setup_library/upgrade.php';}else{alert('Upgrade aborted');}"><img src='./setup_images/setup_updateall.jpg' alt='update all objects' border='0'/></a></div><?php 
        if ($count > 0) {
            ?>
<div style="position:relative;float:left;height:20px;padding-top:10px;padding-left:15px;width:100px;"><input id='search_objects' type="text" name="Search" value="Search <?php 
            echo ucfirst($_SESSION['objectName']);
            ?>
 /**
  * Returns a sorted array of objects that match given conditions
  * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ..} 
  * @param string $sortBy 
  * @param boolean $ascending 
  * @param int limit 
  * @return array $siblingList
  */
 function GetObjectList($fcv_array = array(), $sortBy = '', $ascending = true, $limit = '')
 {
     $sqlLimit = $limit != '' ? "LIMIT {$limit}" : '';
     $connection = Database::Connect();
     $object = new object();
     $objectList = array();
     $this->pog_query = "select distinct * from `object` a INNER JOIN `objectsiblingmap` m ON m.objectid = a.objectid where m.siblingid = '{$this->siblingId}' ";
     if (sizeof($fcv_array) > 0) {
         $this->pog_query = $this->pog_query . " AND ";
         for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) {
             if (sizeof($fcv_array[$i]) == 1) {
                 $this->pog_query = $this->pog_query . " " . $fcv_array[$i][0] . " ";
                 continue;
             } else {
                 if ($i > 0 && sizeof($fcv_array[$i - 1]) != 1) {
                     $this->pog_query = $this->pog_query . " AND ";
                 }
                 if (isset($object->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $object->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $object->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') {
                     if ($GLOBALS['configuration']['db_encoding'] == 1) {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(" . $fcv_array[$i][2] . ")" : "'" . $fcv_array[$i][2] . "'";
                         $this->pog_query = $this->pog_query . "BASE64_DECODE(`" . $fcv_array[$i][0] . "`) " . $fcv_array[$i][1] . " " . $value;
                     } else {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $this->Escape($fcv_array[$i][2]) . "'";
                         $this->pog_query = $this->pog_query . "a.`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                     }
                 } else {
                     $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $fcv_array[$i][2] . "'";
                     $this->pog_query = $this->pog_query . "a.`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                 }
             }
         }
     }
     if ($sortBy != '') {
         if (isset($object->pog_attribute_type[$sortBy]['db_attributes']) && $object->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $object->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') {
             if ($GLOBALS['configuration']['db_encoding'] == 1) {
                 $sortBy = "BASE64_DECODE(a.{$sortBy}) ";
             } else {
                 $sortBy = "a.{$sortBy} ";
             }
         } else {
             $sortBy = "a.{$sortBy} ";
         }
     } else {
         $sortBy = "a.objectid";
     }
     $this->pog_query = $this->pog_query . " order by " . $sortBy . " " . ($ascending ? "asc" : "desc") . " {$sqlLimit}";
     $cursor = Database::Reader($this->pog_query, $connection);
     while ($row = Database::Read($cursor)) {
         $object = new object();
         foreach ($object->pog_attribute_type as $attribute_name => $attrubute_type) {
             if ($attrubute_type['db_attributes'][1] != "HASMANY" && $attrubute_type['db_attributes'][1] != "JOIN") {
                 if ($attrubute_type['db_attributes'][1] == "BELONGSTO") {
                     $object->{strtolower($attribute_name) . 'Id'} = $row[strtolower($attribute_name) . 'id'];
                     continue;
                 }
                 $object->{$attribute_name} = $this->Unescape($row[strtolower($attribute_name)]);
             }
         }
         $objectList[] = $object;
     }
     return $objectList;
 }
 /**
  * Returns a sorted array of objects that match given conditions
  * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
  * @param string $sortBy 
  * @param boolean $ascending 
  * @param int limit 
  * @return array $onetimepasswordList
  */
 function GetList($fcv_array = array(), $sortBy = '', $ascending = true, $limit = '')
 {
     $connection = Database::Connect();
     $sqlLimit = $limit != '' ? "LIMIT {$limit}" : '';
     $this->pog_query = "select * from `onetimepassword` ";
     $onetimepasswordList = array();
     if (sizeof($fcv_array) > 0) {
         $this->pog_query .= " where ";
         for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) {
             if (sizeof($fcv_array[$i]) == 1) {
                 $this->pog_query .= " " . $fcv_array[$i][0] . " ";
                 continue;
             } else {
                 if ($i > 0 && sizeof($fcv_array[$i - 1]) != 1) {
                     $this->pog_query .= " AND ";
                 }
                 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') {
                     if ($GLOBALS['configuration']['db_encoding'] == 1) {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(" . $fcv_array[$i][2] . ")" : "'" . $fcv_array[$i][2] . "'";
                         $this->pog_query .= "BASE64_DECODE(`" . $fcv_array[$i][0] . "`) " . $fcv_array[$i][1] . " " . $value;
                     } else {
                         $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $this->Escape($fcv_array[$i][2]) . "'";
                         $this->pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                     }
                 } else {
                     $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'" . $fcv_array[$i][2] . "'";
                     $this->pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " " . $value;
                 }
             }
         }
     }
     if ($sortBy != '') {
         if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') {
             if ($GLOBALS['configuration']['db_encoding'] == 1) {
                 $sortBy = "BASE64_DECODE({$sortBy}) ";
             } else {
                 $sortBy = "{$sortBy} ";
             }
         } else {
             $sortBy = "{$sortBy} ";
         }
     } else {
         $sortBy = "onetimepasswordid";
     }
     $this->pog_query .= " order by " . $sortBy . " " . ($ascending ? "asc" : "desc") . " {$sqlLimit}";
     $thisObjectName = get_class($this);
     $cursor = Database::Reader($this->pog_query, $connection);
     while ($row = Database::Read($cursor)) {
         $onetimepassword = new $thisObjectName();
         $onetimepassword->onetimepasswordId = $row['onetimepasswordid'];
         $onetimepassword->userId = $row['userid'];
         $onetimepassword->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
         $onetimepassword->reference = $this->Unescape($row['reference']);
         $onetimepassword->key = $this->Unescape($row['key']);
         $onetimepassword->key_checksum = $this->Unescape($row['key_checksum']);
         $onetimepassword->data = $this->Unescape($row['data']);
         $onetimepassword->version = $this->Unescape($row['version']);
         $onetimepassword->creation_date = $row['creation_date'];
         $onetimepassword->request_date = $row['request_date'];
         $onetimepassword->usage_date = $row['usage_date'];
         $onetimepasswordList[] = $onetimepassword;
     }
     return $onetimepasswordList;
 }
/**
 * Gets total no. of records;
 */
function GetNumberOfRecords($objectName)
{
    $sql = 'select count(*) from `' . strtolower($objectName) . "`";
    $connection = Database::Connect();
    $cursor = Database::Reader($sql, $connection);
    if ($cursor !== false) {
        while ($row = Database::Read($cursor)) {
            return $row['count(*)'];
        }
    }
    return 0;
}
 function PerformUnitTest()
 {
     //test w/o arguments
     //any object
     $objectNames = unserialize($_SESSION['objectNameList']);
     //try getting a count
     if (sizeof($objectNames) > 0) {
         $anyObject = $objectNames[0];
         include_once "../objects/class." . strtolower($anyObject) . ".php";
         $anyObjectInstance = new $anyObject();
         $count = $anyObjectInstance->GetCount();
         $count2 = 0;
         $sql = 'select count(*) from `' . strtolower($anyObject) . '`;';
         $connection = Database::Connect();
         $cursor = Database::Reader($sql, $connection);
         if ($cursor !== false) {
             while ($row = Database::Read($cursor)) {
                 $count2 = $row['count(*)'];
             }
         }
         if ($count == $count2) {
             return true;
         }
         return false;
     }
     //test w/ arguments
 }