Ejemplo n.º 1
0
 /**
  * Will parse the URL into an associative array. This method will get the current URL string and parse it in an associative array
  * that we can then insert in the _GET superglobal to work with. It's an internal private method not used by non-core developers.
  *
  * @param I $segmentNumber The number of the segment to get from;
  * @return A The associative array, parsed from the URL, as key/var pairs;
  * @author Elena Ramona <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 09_URL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access private
  * @static
  * @final
  */
 private static final function associativeFromURL(I $segmentNumber)
 {
     $getURLSegments = new A(array_slice(self::$objGETURLSegment->toArray(), $segmentNumber->toInt() - 1));
     $i = new I(0);
     $lastURLVar = new S(_NONE);
     $returnedArray = new A();
     foreach ($getURLSegments as $v) {
         if ($i->toInt() % 2) {
             $returnedArray[$lastURLVar->toString()] = $v;
         } else {
             $returnedArray[$v] = new B(FALSE);
             $lastURLVar->setString($v);
         }
         // Increment;
         $i->doInc();
     }
     // Do return ...
     return $returnedArray;
 }
Ejemplo n.º 2
0
 /**
  * Will check ACL for the specific user and zone;
  *
  * This method will query the database, user, group, zone and zone mapping tables to see if the current user that is mapped
  * to a group or is in a hierarchy of groups has access to the specified zone. Access is giving by mapping permissions in
  * a zone like manner, with either allow or deny type of access;
  *
  * @param S $objUserName The user to check ACL for;
  * @param S $objZoneName The zone to check ACL for;
  * @return boolean Will return true if the current user has access to zone;
  */
 private function checkZoneACL(S $objUserName, S $objZoneName)
 {
     // Get some requirements;
     $objUserId = $this->getUserInfoByName($objUserName, self::$objAuthUsersTableFId);
     $objZoneId = $this->getZoneInfoByName($objZoneName, self::$objAuthZonesTableFId);
     // Make a new query container;
     $objQ = $this->_Q(_QS('doSELECT')->doToken('%what', self::$objAuthZoneMTableFAorD)->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFZId = "%z" AND %objAuthZoneMTableFUGId = "%u"
     AND %objAuthZoneMTableFIUG = "N" LIMIT 1'))->doToken('%z', $objZoneId)->doToken('%u', $objUserId));
     // Get the zone access for user groups/subgroup;
     if ($objQ->doCount()->toInt() != 0) {
         // Determine if specific zone access have been enabled;
         switch ($objQ->offsetGet(0)->offsetGet(self::$objAuthZoneMTableFAorD)) {
             case 'A':
                 return new B(TRUE);
                 break;
             default:
                 return new B(FALSE);
                 break;
         }
     } else {
         // Determine the path from the users sub-group, to the top root group;
         $objCurrentUserHierarchy = self::$objMPTT->mpttGetSinglePath($this->getGroupInfoByUserId($this->getUserInfoByName($objUserName, self::$objAuthUsersTableFId), self::$objAuthGroupTableFName));
         // Foreach LVL, get respective zone-mappings;
         foreach ($objCurrentUserHierarchy as $k => $v) {
             $objGroupId = $this->getGroupInfoByName($v[self::$objAuthGroupTableFName], self::$objAuthGroupTableFId);
             $objQueryACL[] = $this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFZId = "%z" AND %objAuthZoneMTableFUGId = "%g"
             AND %objAuthZoneMTableFIUG = "Y"'))->doToken('%z', $objZoneId)->doToken('%g', $objGroupId))->offsetGet(0);
         }
         // Go down the tree, pass through every mapped group/subgroup and memorize, the LAST Access/Denied flag;
         $objACLMemorized = new S('D');
         foreach ($objQueryACL as $k => $v) {
             if ($v->doCount()->toInt() != 0) {
                 $objACLMemorized->setString($v[self::$objAuthZoneMTableFAorD]);
             }
         }
         // Switch between A/D/OR ELSE;
         switch ($objACLMemorized) {
             case 'A':
                 return new B(TRUE);
                 break;
             case 'D':
                 return new B(FALSE);
                 break;
             default:
                 return new B(FALSE);
                 break;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Will return a string containing three lines from the PHP file that was in a debug_backtrace, by parsing the previous, current and
  * next line from the debugged file. It's an easy way to get the content of a file in many circumstances. Also, for EVAL'ed code,
  * where we actually don't have a file, we issue a default NULL string back to the calling method so execution can go on;
  *
  * @param S $codeFile The path to the file to be GeSHi'ed
  * @param S $codeLine The number of line (+/-1) that should be GeSHi'ed
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access private
  * @static
  */
 private static function getDebugCodeLine(S $codeFile, I $codeLine)
 {
     // S make;
     $theString = new S();
     // Get the file array from the passed argument;
     if (WIN == TRUE) {
         // Get the contents;
         if (file_exists($codeFile)) {
             // PHP Code: FILE;
             $theFileArray = file($codeFile->doToken(DOCUMENT_ROOT, _NONE)->toString(), FILE_SKIP_EMPTY_LINES);
         } else {
             // PHP Code: EVAL;
             return new S(_NONE);
         }
     } else {
         // Get the contents;
         if (file_exists($codeFile)) {
             // PHP Code: FILE;
             $theFileArray = file($codeFile->toString(), FILE_SKIP_EMPTY_LINES);
         } else {
             // PHP Code: EVAL;
             return new S(_NONE);
         }
     }
     // Files that are bellow 3 LINES have problems, so here's the fix;
     if (count($theFileArray) >= 3) {
         if (isset($theFileArray[$codeLine->toInt() - 2])) {
             $theString->setString($theFileArray[$codeLine->toInt() - 2] . $theFileArray[$codeLine->toInt() - 1] . $theFileArray[$codeLine->toInt()]);
         }
     } else {
         if (count($theFileArray) == 1) {
             $theString->setString($theFileArray[$codeLine->toInt() - 1]);
         } else {
             if (count($theFileArray) == 2) {
                 $theString->setString($theFileArray[$codeLine->toInt() - 1] . $theFileArray[$codeLine->toInt()]);
             }
         }
     }
     // We should empty theFileArray straight away, and return the string;
     unset($theFileArray);
     return $theString;
 }
Ejemplo n.º 4
0
 /**
  * Will replace module tokens (also named table fields) that can be used independent of the table structure. This provides the
  * basics of our ORM (Object Relationship Mapping) as we can easily separate table fields from the SQL string and have an
  * independent way to query the database freely of the structure or the table/field names;
  *
  * @param S $objSQLParam The SQL string to be processed
  * @return S Will return the current SQL string with modified tokens
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 11_SQL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access protected
  */
 protected function doModuleTokens(A $objTokens, A $objReplac, S $objSQLParam)
 {
     // Modify tokens;
     foreach ($objTokens as $k => $v) {
         // Replace %[theToken] with the corresponding field in the table;
         $objSQLParam->setString(preg_replace('/%\\b' . $v . '\\b/i', $objReplac[$k], $objSQLParam));
     }
     // Do return ...
     return $objSQLParam->doToken($objTokens->toArray(), $objReplac->toArray());
 }