utils.inc.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @package Dolphin Core
  4. * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  5. * @license CC-BY - http://creativecommons.org/licenses/by/3.0/
  6. */
  7. defined('BX_DOL') or die('hack attempt');
  8. /*
  9. * Returns unique SID for communication with BoonEx Unity.
  10. * @see BxDolStudioStore -> checkoutCart and BxDolStudioOAuth -> authorize
  11. */
  12. function generateSid() {
  13. return md5(BX_DOL_URL_ROOT . '_' . BX_DOL_VERSION . '.' . BX_DOL_BUILD);
  14. }
  15. function bx_array_insert_before($aInsert, $aSource, $sKey) {
  16. return bx_array_insert($aInsert, $aSource, $sKey, 0);
  17. }
  18. function bx_array_insert_after($aInsert, $aSource, $sKey) {
  19. return bx_array_insert($aInsert, $aSource, $sKey, 1);
  20. }
  21. function bx_array_insert($aInsert, $aSource, $sKey, $iDirection = 1) {
  22. $iPosition = array_search($sKey, array_keys($aSource)) + $iDirection;
  23. if($iPosition == 0)
  24. return $aInsert + $aSource;
  25. if($iPosition == count($aSource))
  26. return $aSource + $aInsert;
  27. return array_slice($aSource, 0, $iPosition, true) + $aInsert + array_slice($aSource, $iPosition, NULL, true);
  28. }
  29. /** @} */