code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function shouldReloadDaemons() {
return false;
} | This method is used to indicate to the overseer that daemons should reload.
@return bool True if the daemons should reload, otherwise false. | shouldReloadDaemons | php | phacility/phabricator | src/infrastructure/daemon/PhutilDaemonOverseerModule.php | https://github.com/phacility/phabricator/blob/master/src/infrastructure/daemon/PhutilDaemonOverseerModule.php | Apache-2.0 |
public function shouldWakePool(PhutilDaemonPool $pool) {
return false;
} | Should a hibernating daemon pool be awoken immediately?
@return bool True to awaken the pool immediately. | shouldWakePool | php | phacility/phabricator | src/infrastructure/daemon/PhutilDaemonOverseerModule.php | https://github.com/phacility/phabricator/blob/master/src/infrastructure/daemon/PhutilDaemonOverseerModule.php | Apache-2.0 |
public static function className($class)
{
return 'application_fee';
} | This is a special case because the application fee endpoint has an
underscore in it. The parent `className` function strips underscores.
@return string The name of the class. | className | php | phacility/phabricator | externals/stripe-php/lib/Stripe/ApplicationFee.php | https://github.com/phacility/phabricator/blob/master/externals/stripe-php/lib/Stripe/ApplicationFee.php | Apache-2.0 |
public static function setApiKey($apiKey)
{
self::$apiKey = $apiKey;
} | Sets the API key to be used for requests.
@param string $apiKey | setApiKey | php | phacility/phabricator | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phacility/phabricator/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public static function scopedConstructFrom($class, $values, $apiKey=null)
{
$obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey);
$obj->refreshFrom($values, $apiKey);
return $obj;
} | This unfortunately needs to be public to be used in Util.php
@param string $class
@param array $values
@param string|null $apiKey
@return Stripe_Object The object constructed from the given values. | scopedConstructFrom | php | phacility/phabricator | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phacility/phabricator/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public function serializeParameters()
{
$params = array();
if ($this->_unsavedValues) {
foreach ($this->_unsavedValues->toArray() as $k) {
$v = $this->$k;
if ($v === NULL) {
$v = '';
}
$params[$k] = $v;
}
}
// Get nested updates.
foreach (self::$nestedUpdatableAttributes->toArray() as $property) {
if (isset($this->$property)
&& $this->$property instanceOf Stripe_Object) {
$params[$property] = $this->$property->serializeParameters();
}
}
return $params;
} | @return array A recursive mapping of attributes to values for this object,
including the proper value for deleted attributes. | serializeParameters | php | phacility/phabricator | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phacility/phabricator/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public function renderContextualDescription(
PhabricatorConfigOption $option,
AphrontRequest $request) {
return null;
} | Hook to render additional hints based on, e.g., the viewing user, request,
or other context. For example, this is used to show workspace IDs when
configuring `asana.workspace-id`.
@param PhabricatorConfigOption Option being rendered.
@param AphrontRequest Active request.
@return wild Additional contextual description
information. | renderContextualDescription | php | phacility/phabricator | src/applications/config/option/PhabricatorApplicationConfigOptions.php | https://github.com/phacility/phabricator/blob/master/src/applications/config/option/PhabricatorApplicationConfigOptions.php | Apache-2.0 |
public static function getStatusStrength($constant) {
$map = array(
self::STATUS_ADDED => 1,
self::STATUS_COMMENTED => 2,
self::STATUS_BLOCKING => 3,
self::STATUS_ACCEPTED_OLDER => 4,
self::STATUS_REJECTED_OLDER => 4,
self::STATUS_ACCEPTED => 5,
self::STATUS_REJECTED => 5,
self::STATUS_RESIGNED => 5,
);
return idx($map, $constant, 0);
} | Returns the relative strength of a status, used to pick a winner when a
transaction group makes several status changes to a particular reviewer.
For example, if you accept a revision and leave a comment, the transactions
will attempt to update you to both "commented" and "accepted". We want
"accepted" to win, because it's the stronger of the two.
@param const Reviewer status constant.
@return int Relative strength (higher is stronger). | getStatusStrength | php | phacility/phabricator | src/applications/differential/constants/DifferentialReviewerStatus.php | https://github.com/phacility/phabricator/blob/master/src/applications/differential/constants/DifferentialReviewerStatus.php | Apache-2.0 |
protected function renderShowContextLinks(
$top,
$len,
$changeset_length,
$is_blocks = false) {
$block_size = 20;
$end = ($top + $len) - $block_size;
// If this is a large block, such that the "top" and "bottom" ranges are
// non-overlapping, we'll provide options to show the top, bottom or entire
// block. For smaller blocks, we only provide an option to show the entire
// block, since it would be silly to show the bottom 20 lines of a 25-line
// block.
$is_large_block = ($len > ($block_size * 2));
$links = array();
$block_display = new PhutilNumber($block_size);
if ($is_large_block) {
$is_first_block = ($top == 0);
if ($is_first_block) {
if ($is_blocks) {
$text = pht('Show First %s Block(s)', $block_display);
} else {
$text = pht('Show First %s Line(s)', $block_display);
}
} else {
if ($is_blocks) {
$text = pht("\xE2\x96\xB2 Show %s Block(s)", $block_display);
} else {
$text = pht("\xE2\x96\xB2 Show %s Line(s)", $block_display);
}
}
$links[] = $this->renderShowContextLink(
false,
"{$top}-{$len}/{$top}-20",
$text);
}
if ($is_blocks) {
$text = pht('Show All %s Block(s)', new PhutilNumber($len));
} else {
$text = pht('Show All %s Line(s)', new PhutilNumber($len));
}
$links[] = $this->renderShowContextLink(
true,
"{$top}-{$len}/{$top}-{$len}",
$text);
if ($is_large_block) {
$is_last_block = (($top + $len) >= $changeset_length);
if ($is_last_block) {
if ($is_blocks) {
$text = pht('Show Last %s Block(s)', $block_display);
} else {
$text = pht('Show Last %s Line(s)', $block_display);
}
} else {
if ($is_blocks) {
$text = pht("\xE2\x96\xBC Show %s Block(s)", $block_display);
} else {
$text = pht("\xE2\x96\xBC Show %s Line(s)", $block_display);
}
}
$links[] = $this->renderShowContextLink(
false,
"{$top}-{$len}/{$end}-20",
$text);
}
return phutil_implode_html(" \xE2\x80\xA2 ", $links);
} | Build links which users can click to show more context in a changeset.
@param int Beginning of the line range to build links for.
@param int Length of the line range to build links for.
@param int Total number of lines in the changeset.
@return markup Rendered links. | renderShowContextLinks | php | phacility/phabricator | src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | https://github.com/phacility/phabricator/blob/master/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | Apache-2.0 |
private function renderShowContextLink($is_all, $range, $text) {
$reference = $this->getRenderingReference();
return javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'show-more',
'meta' => array(
'type' => ($is_all ? 'all' : null),
'range' => $range,
),
),
$text);
} | Build a link that shows more context in a changeset.
See @{method:renderShowContextLinks}.
@param bool Does this link show all context when clicked?
@param string Range specification for lines to show.
@param string Text of the link.
@return markup Rendered link. | renderShowContextLink | php | phacility/phabricator | src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | https://github.com/phacility/phabricator/blob/master/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | Apache-2.0 |
protected function getLineIDPrefixes() {
// These look like "C123NL45", which means the line is line 45 on the
// "new" side of the file in changeset 123.
// The "C" stands for "changeset", and is followed by a changeset ID.
// "N" stands for "new" and means the comment should attach to the new file
// when stored. "O" stands for "old" and means the comment should attach to
// the old file. These are important because either the old or new part
// of a file may appear on the left or right side of the diff in the
// diff-of-diffs view.
// The "L" stands for "line" and is followed by the line number.
if ($this->getOldChangesetID()) {
$left_prefix = array();
$left_prefix[] = 'C';
$left_prefix[] = $this->getOldChangesetID();
$left_prefix[] = $this->getOldAttachesToNewFile() ? 'N' : 'O';
$left_prefix[] = 'L';
$left_prefix = implode('', $left_prefix);
} else {
$left_prefix = null;
}
if ($this->getNewChangesetID()) {
$right_prefix = array();
$right_prefix[] = 'C';
$right_prefix[] = $this->getNewChangesetID();
$right_prefix[] = $this->getNewAttachesToNewFile() ? 'N' : 'O';
$right_prefix[] = 'L';
$right_prefix = implode('', $right_prefix);
} else {
$right_prefix = null;
}
return array($left_prefix, $right_prefix);
} | Build the prefixes for line IDs used to track inline comments.
@return pair<wild, wild> Left and right prefixes. | getLineIDPrefixes | php | phacility/phabricator | src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | https://github.com/phacility/phabricator/blob/master/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | Apache-2.0 |
public function setWait($wait) {
$this->wait = $wait;
return $this;
} | Set duration (in seconds) to wait for the file lock. | setWait | php | phacility/phabricator | src/infrastructure/cache/PhutilOnDiskKeyValueCache.php | https://github.com/phacility/phabricator/blob/master/src/infrastructure/cache/PhutilOnDiskKeyValueCache.php | Apache-2.0 |
public static function setClientIDCookie(AphrontRequest $request) {
// NOTE: See T3471 for some discussion. Some browsers and browser extensions
// can make duplicate requests, so we overwrite this cookie only if it is
// not present in the request. The cookie lifetime is limited by making it
// temporary and clearing it when users log out.
$value = $request->getCookie(self::COOKIE_CLIENTID);
if ($value === null || !strlen($value)) {
$request->setTemporaryCookie(
self::COOKIE_CLIENTID,
Filesystem::readRandomCharacters(16));
}
} | Set the client ID cookie. This is a random cookie used like a CSRF value
during authentication workflows.
@param AphrontRequest Request to modify.
@return void
@task clientid | setClientIDCookie | php | phacility/phabricator | src/applications/auth/constants/PhabricatorCookies.php | https://github.com/phacility/phabricator/blob/master/src/applications/auth/constants/PhabricatorCookies.php | Apache-2.0 |
public static function setNextURICookie(
AphrontRequest $request,
$next_uri,
$force = false) {
if (!$force) {
$cookie_value = $request->getCookie(self::COOKIE_NEXTURI);
list($set_at, $current_uri) = self::parseNextURICookie($cookie_value);
// If the cookie was set within the last 2 minutes, don't overwrite it.
// Primarily, this prevents browser requests for resources which do not
// exist (like "humans.txt" and various icons) from overwriting a normal
// URI like "/feed/".
if ($set_at > (time() - 120)) {
return;
}
}
$new_value = time().','.$next_uri;
$request->setTemporaryCookie(self::COOKIE_NEXTURI, $new_value);
} | Set the Next URI cookie. We only write the cookie if it wasn't recently
written, to avoid writing over a real URI with a bunch of "humans.txt"
stuff. See T3793 for discussion.
@param AphrontRequest Request to write to.
@param string URI to write.
@param bool Write this cookie even if we have a fresh
cookie already.
@return void
@task next | setNextURICookie | php | phacility/phabricator | src/applications/auth/constants/PhabricatorCookies.php | https://github.com/phacility/phabricator/blob/master/src/applications/auth/constants/PhabricatorCookies.php | Apache-2.0 |
public static function getNextURICookie(AphrontRequest $request) {
$cookie_value = $request->getCookie(self::COOKIE_NEXTURI);
list($set_at, $next_uri) = self::parseNextURICookie($cookie_value);
return $next_uri;
} | Read the URI out of the Next URI cookie.
@param AphrontRequest Request to examine.
@return string|null Next URI cookie's URI value.
@task next | getNextURICookie | php | phacility/phabricator | src/applications/auth/constants/PhabricatorCookies.php | https://github.com/phacility/phabricator/blob/master/src/applications/auth/constants/PhabricatorCookies.php | Apache-2.0 |
private static function parseNextURICookie($cookie) {
// Old cookies look like: /uri
// New cookies look like: timestamp,/uri
if (!phutil_nonempty_string($cookie)) {
return null;
}
if (strpos($cookie, ',') !== false) {
list($timestamp, $uri) = explode(',', $cookie, 2);
return array((int)$timestamp, $uri);
}
return array(0, $cookie);
} | Parse a Next URI cookie into its components.
@param string Raw cookie value.
@return list<string> List of timestamp and URI.
@task next | parseNextURICookie | php | phacility/phabricator | src/applications/auth/constants/PhabricatorCookies.php | https://github.com/phacility/phabricator/blob/master/src/applications/auth/constants/PhabricatorCookies.php | Apache-2.0 |
function loadFont($filename, $loadgerman = true)
{
$this->font = array();
if (!file_exists($filename)) {
return self::raiseError('Figlet font file "'
. $filename
. '" cannot be found', 1);
}
$this->font_comment = '';
// If Gzip compressed font
if (substr($filename, -3, 3) == '.gz') {
$filename = 'compress.zlib://' . $filename;
$compressed = true;
if (!function_exists('gzcompress')) {
return self::raiseError('Cannot load gzip compressed fonts since'
. ' gzcompress() is not available.',
3);
}
} else {
$compressed = false;
}
if (!($fp = fopen($filename, 'rb'))) {
return self::raiseError('Cannot open figlet font file ' . $filename, 2);
}
if (!$compressed) {
/* ZIPed font */
if (fread($fp, 2) == 'PK') {
fclose($fp);
$zip = new ZipArchive();
$open_flag = 0;
// The RDONLY flag was only introduced in 7.4.3.
if (defined('ZipArchive::RDONLY')) {
$open_flag = ZipArchive::RDONLY;
}
$open_result = $zip->open($filename, $open_flag);
if ($open_result !== true) {
return self::raiseError('Cannot open figlet font file ' .
$filename . ', got error: ' . $open_result, 2);
}
$name = $zip->getNameIndex(0);
$zip->close();
if (!($fp = fopen('zip://' . realpath($filename) . '#' . $name, 'rb'))) {
return self::raiseError('Cannot open figlet font file ' . $filename, 2);
}
$compressed = true;
} else {
flock($fp, LOCK_SH);
rewind($fp);
}
}
// flf2a$ 6 5 20 15 3 0 143 229
// | | | | | | | | | |
// / / | | | | | | | \
// Signature / / | | | | | \ Codetag_Count
// Hardblank / / | | | \ Full_Layout
// Height / | | \ Print_Direction
// Baseline / \ Comment_Lines
// Max_Length Old_Layout
$header = explode(' ', fgets($fp, 2048));
if (substr($header[0], 0, 5) <> 'flf2a') {
return self::raiseError('Unknown FIGlet font format.', 4);
}
@list ($this->hardblank, $this->height,,,
$this->oldlayout, $cmt_count, $this->rtol) = $header;
$this->hardblank = substr($this->hardblank, -1, 1);
for ($i = 0; $i < $cmt_count; $i++) {
$this->font_comment .= fgets($fp, 2048);
}
// ASCII charcters
for ($i = 32; $i < 127; $i++) {
$this->font[$i] = $this->_char($fp);
}
foreach (array(196, 214, 220, 228, 246, 252, 223) as $i) {
if ($loadgerman) {
$letter = $this->_char($fp);
// Invalid character but main font is loaded and I can use it
if ($letter === false) {
fclose($fp);
return true;
}
// Load if it is not blank only
if (trim(implode('', $letter)) <> '') {
$this->font[$i] = $letter;
}
} else {
$this->_skip($fp);
}
}
// Extented characters
for ($n = 0; !feof($fp); $n++) {
list ($i) = explode(' ', rtrim(fgets($fp, 1024)), 2);
if ($i == '') {
continue;
}
// If comment
if (preg_match('/^\-0x/i', $i)) {
$this->_skip($fp);
} else {
// If Unicode
if (preg_match('/^0x/i', $i)) {
$i = hexdec(substr($i, 2));
} else {
// If octal
if ($i[0] === '0' && $i !== '0' || substr($i, 0, 2) == '-0') {
$i = octdec($i);
}
}
$letter = $this->_char($fp);
// Invalid character but main font is loaded and I can use it
if ($letter === false) {
fclose($fp);
return true;
}
$this->font[$i] = $letter;
}
}
fclose($fp);
return true;
} | Load user font. Must be invoked first.
Automatically tries the Text_Figlet font data directory
as long as no path separator is in the filename.
@param string $filename font file name
@param bool $loadgerman (optional) load German character set or not
@access public
@return mixed PEAR_Error or true for success | loadFont | php | phacility/phabricator | externals/pear-figlet/Text/Figlet.php | https://github.com/phacility/phabricator/blob/master/externals/pear-figlet/Text/Figlet.php | Apache-2.0 |
function _char(&$fp)
{
$out = array();
for ($i = 0; $i < $this->height; $i++) {
if (feof($fp)) {
return false;
}
$line = rtrim(fgets($fp, 2048), "\r\n");
if (preg_match('/(.){1,2}$/', $line, $r)) {
$line = str_replace($r[1], '', $line);
}
$line .= "\x00";
$out[] = $line;
}
return $out;
} | Function loads one character in the internal array from file
@param resource &$fp handle of font file
@return mixed lines of the character or false if foef occured
@access private | _char | php | phacility/phabricator | externals/pear-figlet/Text/Figlet.php | https://github.com/phacility/phabricator/blob/master/externals/pear-figlet/Text/Figlet.php | Apache-2.0 |
function _skip(&$fp)
{
for ($i = 0; $i<$this->height && !feof($fp); $i++) {
fgets($fp, 2048);
}
return true;
} | Function for skipping one character in a font file
@param resource &$fp handle of font file
@return boolean always return true
@access private | _skip | php | phacility/phabricator | externals/pear-figlet/Text/Figlet.php | https://github.com/phacility/phabricator/blob/master/externals/pear-figlet/Text/Figlet.php | Apache-2.0 |
public static function normalizeAddress(PhutilEmailAddress $address) {
$raw_address = $address->getAddress();
$raw_address = phutil_utf8_strtolower($raw_address);
$raw_address = trim($raw_address);
// If a mailbox prefix is configured and present, strip it off.
$prefix_key = 'metamta.single-reply-handler-prefix';
$prefix = PhabricatorEnv::getEnvConfig($prefix_key);
if (phutil_nonempty_string($prefix)) {
$prefix = $prefix.'+';
$len = strlen($prefix);
if (!strncasecmp($raw_address, $prefix, $len)) {
$raw_address = substr($raw_address, $len);
}
}
return id(clone $address)
->setAddress($raw_address);
} | Normalize an email address for comparison or lookup.
Phabricator can be configured to prepend a prefix to all reply addresses,
which can make forwarding rules easier to write. This method strips the
prefix if it is present, and normalizes casing and whitespace.
@param PhutilEmailAddress Email address.
@return PhutilEmailAddress Normalized address. | normalizeAddress | php | phacility/phabricator | src/applications/metamta/util/PhabricatorMailUtil.php | https://github.com/phacility/phabricator/blob/master/src/applications/metamta/util/PhabricatorMailUtil.php | Apache-2.0 |
public static function matchAddresses(
PhutilEmailAddress $u,
PhutilEmailAddress $v) {
$u = self::normalizeAddress($u);
$v = self::normalizeAddress($v);
return ($u->getAddress() === $v->getAddress());
} | Determine if two inbound email addresses are effectively identical.
This method strips and normalizes addresses so that equivalent variations
are correctly detected as identical. For example, these addresses are all
considered to match one another:
"Abraham Lincoln" <[email protected]>
[email protected]
<[email protected]>
"Abraham" <[email protected]> # With configured prefix.
@param PhutilEmailAddress Email address.
@param PhutilEmailAddress Another email address.
@return bool True if addresses are effectively the same address. | matchAddresses | php | phacility/phabricator | src/applications/metamta/util/PhabricatorMailUtil.php | https://github.com/phacility/phabricator/blob/master/src/applications/metamta/util/PhabricatorMailUtil.php | Apache-2.0 |
public function getRequiredCapabilities(
$object,
PhabricatorApplicationTransaction $xaction) {
return PhabricatorPolicyCapability::CAN_EDIT;
} | Get a list of capabilities the actor must have on the object to apply
a transaction to it.
Usually, you should use this to reduce capability requirements when a
transaction (like leaving a Conpherence thread) can be applied without
having edit permission on the object. You can override this method to
remove the CAN_EDIT requirement, or to replace it with a different
requirement.
If you are increasing capability requirements and need to add an
additional capability or policy requirement above and beyond CAN_EDIT, it
is usually better implemented as a validation check.
@param object Object being edited.
@param PhabricatorApplicationTransaction Transaction being applied.
@return null|const|list<const> A capability constant (or list of
capability constants) which the actor must have on the object. You can
return `null` as a shorthand for "no capabilities are required". | getRequiredCapabilities | php | phacility/phabricator | src/applications/transactions/storage/PhabricatorModularTransactionType.php | https://github.com/phacility/phabricator/blob/master/src/applications/transactions/storage/PhabricatorModularTransactionType.php | Apache-2.0 |
private function generateDaemonID() {
return substr(getmypid().':'.Filesystem::readRandomCharacters(12), 0, 12);
} | Generate a unique ID for this daemon.
@return string A unique daemon ID. | generateDaemonID | php | phacility/phabricator | src/infrastructure/daemon/PhutilDaemonHandle.php | https://github.com/phacility/phabricator/blob/master/src/infrastructure/daemon/PhutilDaemonHandle.php | Apache-2.0 |
private function pickBestRevision(array $revisions) {
assert_instances_of($revisions, 'DifferentialRevision');
// If we have more than one revision of a given status, choose the most
// recently updated one.
$revisions = msort($revisions, 'getDateModified');
$revisions = array_reverse($revisions);
// Try to find an accepted revision first.
foreach ($revisions as $revision) {
if ($revision->isAccepted()) {
return $revision;
}
}
// Try to find an open revision.
foreach ($revisions as $revision) {
if (!$revision->isClosed()) {
return $revision;
}
}
// Settle for whatever's left.
return head($revisions);
} | When querying for revisions by hash, more than one revision may be found.
This function identifies the "best" revision from such a set. Typically,
there is only one revision found. Otherwise, we try to pick an accepted
revision first, followed by an open revision, and otherwise we go with a
closed or abandoned revision as a last resort. | pickBestRevision | php | phacility/phabricator | src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitFieldsQuery.php | https://github.com/phacility/phabricator/blob/master/src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitFieldsQuery.php | Apache-2.0 |
private static function normalizeConfigValue($value) {
if ($value === true) {
return 'true';
} else if ($value === false) {
return 'false';
}
return $value;
} | Normalize a config value for comparison. Elasticsearch accepts all kinds
of config values but it tends to throw back 'true' for true and 'false' for
false so we normalize everything. Sometimes, oddly, it'll throw back false
for false....
@param mixed $value config value
@return mixed value normalized | normalizeConfigValue | php | phacility/phabricator | src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php | https://github.com/phacility/phabricator/blob/master/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php | Apache-2.0 |
private function getUserName(PhabricatorUser $user) {
$format = PhabricatorEnv::getEnvConfig('metamta.user-address-format');
switch ($format) {
case 'short':
$name = $user->getUserName();
break;
case 'real':
$name = strlen($user->getRealName()) ?
$user->getRealName() : $user->getUserName();
break;
case 'full':
default:
$name = $user->getFullName();
break;
}
return $name;
} | Small helper function to make sure we format the username properly as
specified by the `metamta.user-address-format` configuration value. | getUserName | php | phacility/phabricator | src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php | https://github.com/phacility/phabricator/blob/master/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php | Apache-2.0 |
public function setShade($shade) {
phlog(
pht('Deprecated call to setShade(), use setColor() instead.'));
$this->color = $shade;
return $this;
} | This method has been deprecated, use @{method:setColor} instead.
@deprecated | setShade | php | phacility/phabricator | src/view/phui/PHUITagView.php | https://github.com/phacility/phabricator/blob/master/src/view/phui/PHUITagView.php | Apache-2.0 |
function laravel_version(string $version = null) {
$appVersion = app()->version();
if (is_null($version)) {
return $appVersion;
}
return substr($appVersion, 0, strlen($version)) === $version;
} | Get laravel version or check if the same version
@param string|null $version
@return string|bool | laravel_version | php | ARCANEDEV/Support | helpers.php | https://github.com/ARCANEDEV/Support/blob/master/helpers.php | MIT |
public function __call($method, $parameters)
{
return $this->forwardCallToRouter(
app(Router::class), $method, $parameters
);
} | Pass dynamic methods onto the router instance.
@param string $method
@param array $parameters
@return mixed | __call | php | ARCANEDEV/Support | src/Routing/RouteRegistrar.php | https://github.com/ARCANEDEV/Support/blob/master/src/Routing/RouteRegistrar.php | MIT |
protected function forwardCallToRouter(Registrar $router, $method, $parameters)
{
return $this->forwardCallTo($router, $method, $parameters);
} | Pass dynamic methods onto the router instance.
@param \Illuminate\Contracts\Routing\Registrar $router
@param string $method
@param array $parameters
@return mixed | forwardCallToRouter | php | ARCANEDEV/Support | src/Routing/RouteRegistrar.php | https://github.com/ARCANEDEV/Support/blob/master/src/Routing/RouteRegistrar.php | MIT |
public function setConnection($connection)
{
$this->connection = $connection;
return $this;
} | Set the migration connection name.
@param string $connection
@return $this | setConnection | php | ARCANEDEV/Support | src/Database/Migration.php | https://github.com/ARCANEDEV/Support/blob/master/src/Database/Migration.php | MIT |
public function getTable()
{
return $this->getPrefix().parent::getTable();
} | Get the table associated with the model.
@return string | getTable | php | ARCANEDEV/Support | src/Database/PrefixedModel.php | https://github.com/ARCANEDEV/Support/blob/master/src/Database/PrefixedModel.php | MIT |
public function setPrefix(?string $prefix)
{
$this->prefix = $prefix;
return $this;
} | Set the prefix table associated with the model.
@param string|null $prefix
@return $this | setPrefix | php | ARCANEDEV/Support | src/Database/PrefixedModel.php | https://github.com/ARCANEDEV/Support/blob/master/src/Database/PrefixedModel.php | MIT |
protected function jsonErrorResponse()
{
$data = [
'status' => 'error',
'code' => $statusCode = Response::HTTP_BAD_REQUEST,
'message' => 'Request must be JSON',
];
return new JsonResponse($data, $statusCode);
} | Get the error as json response.
@return \Illuminate\Http\JsonResponse | jsonErrorResponse | php | ARCANEDEV/Support | src/Middleware/VerifyJsonRequest.php | https://github.com/ARCANEDEV/Support/blob/master/src/Middleware/VerifyJsonRequest.php | MIT |
public function boot()
{
$this->registerComposerClasses();
} | Boot the view composer service provider. | boot | php | ARCANEDEV/Support | src/Providers/ViewComposerServiceProvider.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/ViewComposerServiceProvider.php | MIT |
protected function view()
{
return $this->app->make(ViewFactory::class);
} | Get the view factory instance.
@return \Illuminate\Contracts\View\Factory | view | php | ARCANEDEV/Support | src/Providers/ViewComposerServiceProvider.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/ViewComposerServiceProvider.php | MIT |
public function composer($views, $callback)
{
return $this->view()->composer($views, $callback);
} | Register a view composer event.
@param array|string $views
@param \Closure|string $callback
@return array | composer | php | ARCANEDEV/Support | src/Providers/ViewComposerServiceProvider.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/ViewComposerServiceProvider.php | MIT |
public function __construct(Application $app)
{
parent::__construct($app);
$this->basePath = $this->resolveBasePath();
} | Create a new service provider instance.
@param \Illuminate\Contracts\Foundation\Application $app | __construct | php | ARCANEDEV/Support | src/Providers/PackageServiceProvider.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/PackageServiceProvider.php | MIT |
protected function resolveBasePath()
{
return dirname(
(new ReflectionClass($this))->getFileName(), 2
);
} | Resolve the base path of the package.
@return string | resolveBasePath | php | ARCANEDEV/Support | src/Providers/PackageServiceProvider.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/PackageServiceProvider.php | MIT |
public function getBasePath()
{
return $this->basePath;
} | Get the base path of the package.
@return string | getBasePath | php | ARCANEDEV/Support | src/Providers/PackageServiceProvider.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/PackageServiceProvider.php | MIT |
protected function registerConsoleServiceProvider($provider, $force = false)
{
if ($this->app->runningInConsole()) {
return $this->registerProvider($provider, $force);
}
return null;
} | Register a console service provider.
@param \Illuminate\Support\ServiceProvider|string $provider
@param bool $force
@return \Illuminate\Support\ServiceProvider|null | registerConsoleServiceProvider | php | ARCANEDEV/Support | src/Providers/Concerns/InteractsWithApplication.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/Concerns/InteractsWithApplication.php | MIT |
protected function registerCommands(array $commands)
{
if ($this->app->runningInConsole()) {
$this->commands($commands);
}
} | Register the package's custom Artisan commands when running in console.
@param array $commands | registerCommands | php | ARCANEDEV/Support | src/Providers/Concerns/InteractsWithApplication.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/Concerns/InteractsWithApplication.php | MIT |
protected function bind($abstract, $concrete = null, $shared = false)
{
$this->app->bind($abstract, $concrete, $shared);
} | Register a binding with the container.
@param string $abstract
@param \Closure|string|null $concrete
@param bool $shared | bind | php | ARCANEDEV/Support | src/Providers/Concerns/InteractsWithApplication.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/Concerns/InteractsWithApplication.php | MIT |
protected function singleton($abstract, $concrete = null)
{
$this->app->singleton($abstract, $concrete);
} | Register a shared binding in the container.
@param string|array $abstract
@param \Closure|string|null $concrete | singleton | php | ARCANEDEV/Support | src/Providers/Concerns/InteractsWithApplication.php | https://github.com/ARCANEDEV/Support/blob/master/src/Providers/Concerns/InteractsWithApplication.php | MIT |
public function withMessage($message)
{
$this->message = $message;
return $this;
} | Set the message that should be used when the rule fails.
@param string|array $message
@return $this | withMessage | php | ARCANEDEV/Support | src/Validation/Rule.php | https://github.com/ARCANEDEV/Support/blob/master/src/Validation/Rule.php | MIT |
public function message()
{
return $this->message;
} | Get the validation error message.
@return string|array | message | php | ARCANEDEV/Support | src/Validation/Rule.php | https://github.com/ARCANEDEV/Support/blob/master/src/Validation/Rule.php | MIT |
public function getConfirmationMessage($model = null)
{
return __('Do you really want to perform this action?');
} | Model instance who fired the action, it is null if it
was a bulk action | getConfirmationMessage | php | Gustavinho/laravel-views | src/Actions/Confirmable.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Actions/Confirmable.php | MIT |
public function class($element = '')
{
// Returns the config path directly it it was set in the constructor
if ($this->path) {
return config("laravel-views.{$this->path}");
} else {
$config = "laravel-views.{$this->component}.{$this->variant}";
if ($element) {
return config("{$config}.{$element}");
}
return config($config);
}
} | Get the class string for the component and variant selected
@param String $element Set the internal element of the component if there are any | class | php | Gustavinho/laravel-views | src/UI/Variants.php | https://github.com/Gustavinho/laravel-views/blob/master/src/UI/Variants.php | MIT |
public function title()
{
$titles = [
'alerts' => [
'success' => 'Success',
'danger' => 'Error',
'warning' => 'Warning',
]
];
return $titles[$this->component][$this->variant];
} | Get the title of the variant and componente selected | title | php | Gustavinho/laravel-views | src/UI/Variants.php | https://github.com/Gustavinho/laravel-views/blob/master/src/UI/Variants.php | MIT |
public function icon()
{
$icons = [
'alerts' => [
'success' => 'check',
'danger' => 'x',
'warning' => 'alert-circle',
]
];
return $icons[$this->component][$this->variant];
} | Get the icon of the variant and componente selected | icon | php | Gustavinho/laravel-views | src/UI/Variants.php | https://github.com/Gustavinho/laravel-views/blob/master/src/UI/Variants.php | MIT |
public function width(string $width)
{
$this->width = $width;
return $this;
} | Sets a fixed width of the column
@return Header | width | php | Gustavinho/laravel-views | src/UI/Header.php | https://github.com/Gustavinho/laravel-views/blob/master/src/UI/Header.php | MIT |
public function applyDefaultFilters()
{
foreach ($this->filters() as $filter) {
if (empty($this->filters[$filter->id]) && $filter->defaultValue) {
$this->filters[$filter->id] = $filter->defaultValue;
}
}
} | Check if each of the filters has a default value and it's not already set | applyDefaultFilters | php | Gustavinho/laravel-views | src/Views/DataView.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/DataView.php | MIT |
protected function getRenderData()
{
return [
'items' => $this->paginatedQuery,
'actionsByRow' => $this->actionsByRow()
];
} | Collects all data to be passed to the view, this includes the items searched on the database
through the filters, this data will be passed to livewire render method | getRenderData | php | Gustavinho/laravel-views | src/Views/DataView.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/DataView.php | MIT |
public function getModelWhoFiredAction($id)
{
return (clone $this->initialQuery)->find($id);
} | Clones the initial query (to avoid modifying it)
and get a model by an Id | getModelWhoFiredAction | php | Gustavinho/laravel-views | src/Views/DataView.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/DataView.php | MIT |
public function getQueryProperty(Searchable $searchable, Filterable $filterable, Sortable $sortable)
{
$query = clone $this->initialQuery;
$query = $searchable->searchItems($query, $this->searchBy, $this->search);
$query = $filterable->applyFilters($query, $this->filters(), $this->filters);
$query = $sortable->sortItems($query, $this->sortBy, $this->sortOrder);
return $query;
} | Returns the items from the database regarding to the filters selected by the user
applies the search query, the filters used and the total of items found | getQueryProperty | php | Gustavinho/laravel-views | src/Views/DataView.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/DataView.php | MIT |
public function sort($field)
{
if ($this->sortBy === $field) {
$this->sortOrder = $this->sortOrder === 'asc' ? 'desc' : 'asc';
} else {
$this->sortBy = $field;
$this->sortOrder = 'asc';
}
} | Sets the field the table view data will be sort by
@param string $field Field to sort by | sort | php | Gustavinho/laravel-views | src/Views/DataView.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/DataView.php | MIT |
private function confirmAction($action, $modelId = null)
{
$actionData = [
'message' => $action->getConfirmationMessage($modelId ? $this->getModelWhoFiredAction($modelId) : null),
'id' => $action->getId()
];
if ($modelId) {
$actionData['modelId'] = $modelId;
}
$this->emitSelf('openConfirmationModal', $actionData);
} | Opens confirmation modal for a specific action
@param Action $action | confirmAction | php | Gustavinho/laravel-views | src/Views/Traits/WithActions.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/Traits/WithActions.php | MIT |
public function render()
{
return view($this->view);
} | Get the view / view contents that represent the component.
@return string | render | php | Gustavinho/laravel-views | src/Views/Components/DynamicComponent.php | https://github.com/Gustavinho/laravel-views/blob/master/src/Views/Components/DynamicComponent.php | MIT |
function PageMainCode()
{
$sCode = '';
switch ( $_GET['explain'] ) {
case 'Unconfirmed': $sCode = _t("_ATT_UNCONFIRMED_E"); break;
case 'Approval': $sCode = _t("_ATT_APPROVAL_E"); break;
case 'Active': $sCode = _t("_ATT_ACTIVE_E"); break;
case 'Rejected': $sCode = _t("_ATT_REJECTED_E"); break;
case 'Suspended': $sCode = _t("_ATT_SUSPENDED_E", $GLOBALS['site']['title']); break;
case 'membership': $sCode = membershipActionsList((int)$_GET['type']); break;
}
return $GLOBALS['oSysTemplate']->parseHtmlByName('default_padding.html', array('content' => $sCode));
} | Prints HTML Code for explanation | PageMainCode | php | boonex/dolphin.pro | explanation.php | https://github.com/boonex/dolphin.pro/blob/master/explanation.php | MIT |
function PageListControl($sAction, $iViewerId, $iTargetId)
{
$sAction = clear_xss($sAction);
$iViewerId = (int)$iViewerId;
$iTargetId = (int)$iTargetId;
$mixedRes = FALSE;
$sMsg = '_Error';
if (isAdmin($iViewerId) OR (isModerator($iViewerId) AND $iViewerId != $iTargetId))
{
switch ($sAction)
{
case 'activate':
case 'deactivate':
$mixedRes = _setStatus($iTargetId, $sAction);
break;
case 'ban':
if (bx_admin_profile_ban_control($iTargetId))
$sMsg = '_Success';
$mixedRes = MsgBox(_t($sMsg));
break;
case 'unban':
if (bx_admin_profile_ban_control($iTargetId, FALSE))
$sMsg = '_Success';
$mixedRes = MsgBox(_t($sMsg));
break;
case 'featured':
case 'unfeatured':
$mixedRes = _setFeature($iTargetId, $sAction);
break;
case 'delete':
profile_delete($iTargetId);
$mixedRes = MsgBox(_t('_Success')) . genAjaxyPopupJS($iTargetId, 'ajaxy_popup_result_div', BX_DOL_URL_ROOT . 'browse.php');
break;
case 'delete_spam':
profile_delete($iTargetId, TRUE);
$mixedRes = MsgBox(_t('_Success')) . genAjaxyPopupJS($iTargetId, 'ajaxy_popup_result_div', BX_DOL_URL_ROOT . 'browse.php');
break;
default:
}
}
return $mixedRes;
} | Perform admin or moderator actions
@param $sAction string
@param $iViewerId integer
@param $iTargetId integer
@return mixed - HTML code or FALSE | PageListControl | php | boonex/dolphin.pro | list_pop.php | https://github.com/boonex/dolphin.pro/blob/master/list_pop.php | MIT |
function prepareCommand($sTemplate, $aOptions)
{
foreach($aOptions as $sKey => $sValue)
$sTemplate = str_replace("#" . $sKey . "#", $sValue, $sTemplate);
return $sTemplate;
} | ************************************************************************
IMPORTANT: This is a commercial product made by BoonEx Ltd. and cannot be modified for other than personal usage.
This product cannot be redistributed for free or a fee without written permission from BoonEx Ltd.
This notice may not be removed from the source code. | prepareCommand | php | boonex/dolphin.pro | flash/modules/video/inc/functions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/video/inc/functions.inc.php | MIT |
function getIdByNick($sNick)
{
return (int)getValue("SELECT `ID` FROM `Profiles` WHERE `NickName` = '" . $sNick . "' LIMIT 1");
} | Get user's identifier using user's nickname. | getIdByNick | php | boonex/dolphin.pro | flash/modules/desktop/inc/customFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/desktop/inc/customFunctions.inc.php | MIT |
function getMails($sId, $sGotMails, $aFullUsers)
{
global $aXmlTemplates;
$sNotIn = empty($sGotMails) ? "" : " AND `ID` NOT IN(" . $sGotMails . ")";
$sQuery = "SELECT `ID`, `Sender`, SUBSTRING(`Text`, 1, 150) AS `Body` FROM `sys_messages` WHERE `Recipient` = '" . $sId . "' AND `New`='1'" . $sNotIn . " AND NOT FIND_IN_SET('recipient', `Trash`)";
$rResult = getResult($sQuery);
$aMails = array();
$aSenders = array();
for($i=0; $i<$rResult->rowCount(); $i++) {
$aMail = $rResult->fetch();
if(!in_array($aMail['Sender'], $aFullUsers)) $aSenders[] = $aMail['Sender'];
$aMails[] = $aMail;
}
$aSenders = array_unique($aSenders);
$aMediaUsers = array();
$rMedia = getUsersMedia($aSenders);
if($rMedia != null) {
for($i=0; $i<$rMedia->rowCount(); $i++) {
$aUser = $rMedia->fetch();
$sUserId = $aUser['ID'];
$aMediaUsers[$sUserId] = getUserInfo($sUserId);
$aMediaUsers[$sUserId]['music'] = $aUser['CountMusic'] > 0 ? TRUE_VAL : FALSE_VAL;
$aMediaUsers[$sUserId]['video'] = $aUser['CountVideo'] > 0 ? TRUE_VAL : FALSE_VAL;
}
}
$sResult = "";
for($i=0; $i<count($aMails); $i++) {
$sSenderId = $aMails[$i]['Sender'];
$aMails[$i]['Body'] = strip_tags($aMails[$i]['Body']);
if(is_array($aMediaUsers[$sSenderId])) {
$aUser = $aMediaUsers[$sSenderId];
$sResult .= parseXml($aXmlTemplates["message"], $aMails[$i]['ID'], $sSenderId, $aMails[$i]['Body'], $aUser['nick'], $aUser['sex'], $aUser['age'], $aUser['photo'], $aUser['profile'], $aUser['music'], $aUser['video']);
} else $sResult .= parseXml($aXmlTemplates["message"], $aMails[$i]['ID'], $sSenderId, $aMails[$i]['Body']);
}
return makeGroup($sResult, "mails");
} | Gets new user's mails except already got mails($sGotMails) by specified user id | getMails | php | boonex/dolphin.pro | flash/modules/desktop/inc/customFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/desktop/inc/customFunctions.inc.php | MIT |
function loginUser($sName, $sPassword, $bLogin = false)
{
/**
* You might change this query, if your profiles table has different structure.
*/
$sField = $bLogin ? "NickName" : "ID";
$sId = getValue("SELECT `ID` FROM `Profiles` WHERE `" . $sField . "`='" . $sName . "' AND `Password`='" . $sPassword . "' LIMIT 1");
return !empty($sId) ? TRUE_VAL : FALSE_VAL;
} | Authorize user by specified ID and Password or Login and Password.
@param $sName - user login/ID
@param $sPassword - user password
@param $bLogin - search for login (true) or ID (false)
@return true/false | loginUser | php | boonex/dolphin.pro | flash/modules/global/inc/customFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/customFunctions.inc.php | MIT |
function loginAdmin($sLogin, $sPassword)
{
/**
* You might change this query. This query searches for a record in sys_admins' db with specified login and password.
* If your admin table has different structure/format, your should change the query.
*/
//--- Stanalone version.
//global $sAdminLogin;
//global $sAdminPassword;
//$bResult = $sLogin == $sAdminLogin && $sPassword == $sAdminPassword ? TRUE_VAL : FALSE_VAL;
//--- Dolphin version.
$sName = getValue("SELECT `NickName` FROM `Profiles` WHERE `NickName`='$sLogin' AND `Password`='$sPassword' AND (`Role` & 2) LIMIT 1");
$bResult = !empty($sName) ? TRUE_VAL : FALSE_VAL;
//end of changes
return $bResult;
} | Authorize administrator by specified Login and Password.
@param $sLogin - administrator login
@param $sPassword - administrator password
@return true/false | loginAdmin | php | boonex/dolphin.pro | flash/modules/global/inc/customFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/customFunctions.inc.php | MIT |
function getAge($sDob)
{
$aDob = explode('-', $sDob);
$iDobYear = $aDob[0];
$iDobMonth = $aDob[1];
$iDobDay = $aDob[2];
$iAge = date('Y') - $iDobYear;
if($iDobMonth > date('m'))
$iAge--;
else if($iDobMonth == date('m') && $iDobDay > date('d'))
$iAge--;
return $iAge;
} | Gets user's age
Used only in getUserInfo() function | getAge | php | boonex/dolphin.pro | flash/modules/global/inc/customFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/customFunctions.inc.php | MIT |
function searchUser($sValue, $sField = "ID")
{
if($sField == "ID")
$sField = "ID";//you migth change this value on your user's ID column name
else
$sField = "NickName";//you migth change this value on your user's nick column name
//Search for user and type result of this search
$sId = getValue("SELECT `ID` FROM `Profiles` WHERE `" . $sField . "` = '" . $sValue . "' LIMIT 1");
return $sId;
} | Searches for user by field $sField with value $sValue
@param $sValue - value to search for
@param $sField - field to search
@return $sId - found user ID | searchUser | php | boonex/dolphin.pro | flash/modules/global/inc/customFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/customFunctions.inc.php | MIT |
function getEmbedCode($sModule, $sApp, $aParamValues)
{
global $sGlobalUrl;
$sTemplate = '<object style="display:block;" width="#width#" height="#height#"><param name="movie" value="#holder#"></param>#objectParams#<embed src="#holder#" type="application/x-shockwave-flash" width="#width#" height="#height#" #embedParams#></embed></object>';
$aConfig = getFlashConfig($sModule, $sApp, $aParamValues);
$aFlashVars = array();
foreach($aConfig['flashVars'] as $sKey => $sValue)
$aFlashVars[] = $sKey . '=' . $sValue;
$aConfig['params']['flashVars'] = implode('&', $aFlashVars);
$aObjectParams = array();
$aEmbedParams = array();
foreach($aConfig['params'] as $sKey => $sValue) {
$aObjectParams[] = '<param name="' . $sKey . '" value="' . $sValue . '"></param>';
$aEmbedParams[] = $sKey . '="' . $sValue . '"';
}
$sReturn = str_replace("#holder#", $aConfig['holder'], $sTemplate);
$sReturn = str_replace("#width#", $aConfig['width'], $sReturn);
$sReturn = str_replace("#height#", $aConfig['height'], $sReturn);
$sReturn = str_replace("#objectParams#", implode("", $aObjectParams), $sReturn);
$sReturn = str_replace("#embedParams#", implode(" ", $aEmbedParams), $sReturn);
return $sReturn;
} | Gets the embed code of necessary widget's application.
@param sModule - module(widget) name.
@param sApp - application name in the widget.
@param aParamValues - an associative array of parameters to be passed into the Flash object. | getEmbedCode | php | boonex/dolphin.pro | flash/modules/global/inc/content.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/content.inc.php | MIT |
function checkPermissions($sFileName)
{
$sPermissions = "";
$sFilePath = trim($sFileName);
clearstatcache();
if(!file_exists($sFilePath))
$sResult = "";
else {
clearstatcache();
$iPermissions = fileperms($sFilePath);
for($i=0, $offset = 0; $i<3; $i++, $offset += 3) {
$iPerm = 0;
for($j=0; $j<3; $j++) ($iPermissions >> ($j+$offset)) & 1 ? $iPerm += pow(2, $j) : "";
$sPermissions = $iPerm . $sPermissions;
}
$sResult = $sPermissions;
}
$sResult = "";
$bDir = is_dir($sFilePath);
if(is_readable($sFilePath)) $sResult = $bDir ? "755" : "644";
if(is_writable($sFilePath)) $sResult = $bDir ? "777" : "666";
if(!$bDir && is_executable($sFilePath)) $sResult = "777";
return $sResult;
} | Checks permissions of files and directories.
@param sFileName - file's name. | checkPermissions | php | boonex/dolphin.pro | flash/modules/global/inc/functions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/functions.inc.php | MIT |
function createDataBase($sWidget)
{
global $sModulesPath;
global $aErrorCodes;
//--- Add info in the database ---//
$sWidgetFile = $sWidget . "/install/install.sql";
$sFileName = $sModulesPath . $sWidgetFile;
$sModuleDBPrefix = DB_PREFIX . strtoupper(substr($sWidget, 0, 1)) . substr($sWidget, 1);
if(!file_exists($sFileName)) return getError($aErrorCodes[1], $sWidgetFile);
$rHandler = fopen($sFileName, "r");
while(!feof($rHandler)) {
$str = fgets($rHandler);
if($str[0]=="" || $str[0]=="#" || ($str[0] == "-" && $str[1] == "-")) continue;
$str = str_replace("[module_db_prefix]", $sModuleDBPrefix, $str);
if( (strlen($str) > 5 ? strpos($str, ";", strlen($str) - 4) : strpos($str, ";")) )
$sQuery .= $str;
else {
$sQuery .= $str;
continue;
}
if(!($res = getResult($sQuery))) return $aErrorCodes[5];
$sQuery = "";
}
fclose($rHandler);
return "";
} | Execute MySQL queries for specified widget.
@param sWidget - the name of the widget. | createDataBase | php | boonex/dolphin.pro | flash/modules/global/inc/functions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/functions.inc.php | MIT |
function getFileExtension($sWidget, $sFolder)
{
global $sModulesPath;
$aRightExtensions = array("swf", "xml");
$sFolderPath = $sModulesPath . $sWidget . "/" . $sFolder . "/";
if($rDirHandle = opendir($sFolderPath))
while (false !== ($sFile = readdir($rDirHandle))) {
$aPathInfo = pathinfo($sFolderPath . $sFile);
if(is_file($sFolderPath . $sFile) && $sFile != "." && $sFile != ".." && in_array($aPathInfo['extension'], $aRightExtensions))
return $aPathInfo['extension'];
}
return "";
} | gets file extension by given widget name and folder
@param sWidget - the name of the widget.
@param sFolder | getFileExtension | php | boonex/dolphin.pro | flash/modules/global/inc/functions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/functions.inc.php | MIT |
function parseXml($aXmlTemplates)
{
$iNumArgs = func_num_args();
$sContent = $aXmlTemplates[$iNumArgs - 1];
for($i=1; $i<$iNumArgs; $i++) {
$sValue = func_get_arg($i);
$sContent = str_replace("#" . $i. "#", $sValue, $sContent);
}
return $sContent;
} | Parse XML template using specified information.
@param aXmlTemplates - array with XML templates grouped by type.
@param ... - variable amount of incoming parameters with information to be used in the process of parsing.
@return $sContent - XML entry | parseXml | php | boonex/dolphin.pro | flash/modules/global/inc/apiFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/apiFunctions.inc.php | MIT |
function getRMSUrl($sApplication, $bHttp = false)
{
$sRMSProtocol = $bHttp ? "http://" : "rtmp://";
$sRMSPort = getSettingValue(GLOBAL_MODULE, $bHttp ? "RMSHttpPort" : "RMSPort");
$sRMSPort = empty($sRMSPort) ? "" : ":" . $sRMSPort;
$sRMSUrl = $sRMSProtocol . getSettingValue(GLOBAL_MODULE, "RMSIP") . $sRMSPort . "/" . $sApplication . "/";
return $sRMSUrl;
} | return RMS Url to given application
@param sApplication - application name.
@return sRMSUrl - RMS Url. | getRMSUrl | php | boonex/dolphin.pro | flash/modules/global/inc/apiFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/apiFunctions.inc.php | MIT |
function setCurrentFile($sModule, $sFile, $sFolder = "langs")
{
setCookie("ray_" . $sFolder . "_" . $sModule, $sFile, time() + 31536000);
} | set current file for module to cookie
@param $sModule - module name
@param $sFile - file value
@param $sFolder - folder name for which value is set | setCurrentFile | php | boonex/dolphin.pro | flash/modules/global/inc/apiFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/apiFunctions.inc.php | MIT |
function printFiles($sModule, $sFolder = "langs", $bGetDate = false, $bGetNames = false)
{
global $sIncPath;
global $sModulesUrl;
require_once($sIncPath . "xmlTemplates.inc.php");
$aFileContents = getFileContents($sModule, "/xml/" . $sFolder . ".xml", true);
$aFiles = $aFileContents['contents'];
$aEnabledFiles = array();
foreach($aFiles as $sFile => $sEnabled)
if($sEnabled == TRUE_VAL)
$aEnabledFiles[] = $sFile;
$sDefault = $aFiles['_default_'];
$aResult = getExtraFiles($sModule, $sFolder, true, $bGetDate);
$sCurrent = $aResult['current'];
$sCurrent = in_array($sCurrent, $aEnabledFiles) ? $sCurrent : $sDefault;
$sCurrentFile = $sCurrent . "." . $aResult['extension'];
$aRealFiles = array_flip($aResult['files']);
$aFileDates = $aResult['dates'];
$sContents = "";
for($i=0; $i<count($aEnabledFiles); $i++)
if(isset($aRealFiles[$aEnabledFiles[$i]])) {
$sFile = $aEnabledFiles[$i];
if($bGetDate) $sContents .= parseXml($aXmlTemplates['file'], $sFile, $aFileDates[$aRealFiles[$sFile]]);
else {
if($bGetNames) {
$sName = $sFolder == "langs"
? getSettingValue($sModule, "_name_", $sFile, false, "langs")
: getSettingValue($sModule, $sFile, "skinsNames");
if(empty($sName)) $sName = $sFile;
$sContents .= parseXml($aXmlTemplates['file'], $sFile, $sName, "");
} else $sContents .= parseXml($aXmlTemplates['file'], $sFile);
}
}
$sContents = makeGroup($sContents, "files");
$sContents .= parseXml($aXmlTemplates['current'], $sCurrent, $sModulesUrl . $sModule . "/" . $sFolder . "/" . $sCurrentFile);
return $sContents;
} | get extra files for module in XML format
@param $sModule - module name
@param $sFolder - folder name for which value is set
@param $bGetDate - get dates of files
@return $sContents - XML formatted result | printFiles | php | boonex/dolphin.pro | flash/modules/global/inc/apiFunctions.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/apiFunctions.inc.php | MIT |
function getAttribute($sXmlContent, $sXmlTag, $sXmlAttribute)
{
$rParser = $this->createParser();
xml_parse_into_struct($rParser, $sXmlContent, $aValues, $aIndexes);
xml_parser_free($rParser);
$aFieldIndex = $aIndexes[strtoupper($sXmlTag)][0];
return $aValues[$aFieldIndex]['attributes'][strtoupper($sXmlAttribute)];
} | Get the value of specified attribute for specified tag. | getAttribute | php | boonex/dolphin.pro | flash/modules/global/inc/xml.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/xml.inc.php | MIT |
function getAttributes($sXmlContent, $sXmlTagName, $sXmlTagIndex = -1)
{
$rParser = $this->createParser();
xml_parse_into_struct($rParser, $sXmlContent, $aValues, $aIndexes);
xml_parser_free($rParser);
/**
* gets two-dimensional array of attributes.
* tags-attlibutes
*/
if($sXmlTagIndex == -1) {
$aResult = array();
$aTagIndexes = $aIndexes[strtoupper($sXmlTagName)];
if(count($aTagIndexes) <= 0) return NULL;
foreach($aTagIndexes as $iTagIndex)
$aResult[] = $aValues[$iTagIndex]['attributes'];
return $aResult;
} else {
$iTagIndex = $aIndexes[strtoupper($sXmlTagName)][$sXmlTagIndex];
return $aValues[$iTagIndex]['attributes'];
}
} | Get an array of attributes for specified tag or an array of tags with the same name. | getAttributes | php | boonex/dolphin.pro | flash/modules/global/inc/xml.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/xml.inc.php | MIT |
function getTags($sXmlContent, $sXmlTagName, $iXmlTagIndex = -1)
{
$rParser = $this->createParser();
xml_parse_into_struct($rParser, $sXmlContent, $aValues, $aIndexes);
xml_parser_free($rParser);
//--- Get an array of tags ---//
if($iXmlTagIndex == -1) {
$aResult = array();
$aTagIndexes = $aIndexes[strtoupper($sXmlTagName)];
if(count($aTagIndexes) <= 0) return NULL;
foreach($aTagIndexes as $iTagIndex)
$aResult[] = $aValues[$iTagIndex];
return $aResult;
} else {
$iTagIndex = $aIndexes[strtoupper($sXmlTagName)][$iXmlTagIndex];
return $aValues[$iTagIndex];
}
} | Get an array of tags or one tag if its index is specified. | getTags | php | boonex/dolphin.pro | flash/modules/global/inc/xml.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/xml.inc.php | MIT |
function setValues($sXmlContent, $sXmlTagName, $aKeyValues)
{
$rParser = $this->createParser();
xml_parse_into_struct($rParser, $sXmlContent, $aValues, $aIndexes);
xml_parser_free($rParser);
$aTagIndexes = $aIndexes[strtoupper($sXmlTagName)];
if(count($aTagIndexes) == 0) return $this->getContent();
foreach($aTagIndexes as $iTagIndex)
foreach($aKeyValues as $sKey => $sValue)
if($aValues[$iTagIndex]['attributes']['KEY'] == $sKey) {
$aValues[$iTagIndex]['value'] = $sValue;
break;
}
return $this->getContent($aValues);
} | Sets the values of tag where attribute "key" equals to specified. | setValues | php | boonex/dolphin.pro | flash/modules/global/inc/xml.inc.php | https://github.com/boonex/dolphin.pro/blob/master/flash/modules/global/inc/xml.inc.php | MIT |
protected function connect()
{
$sSocketOrHost = ($this->socket) ? "unix_socket={$this->socket}" : "host={$this->host};port={$this->port}";
$this->link = new PDO(
"mysql:{$sSocketOrHost};dbname={$this->dbname};charset=utf8",
$this->user,
$this->password,
[
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode=""',
PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_PERSISTENT => defined('DATABASE_PERSISTENT') && DATABASE_PERSISTENT ? true : false,
]
);
} | connect to database with appointed parameters | connect | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getRow($sQuery, $aBindings = [], $iFetchStyle = PDO::FETCH_ASSOC)
{
if ($iFetchStyle != PDO::FETCH_ASSOC && $iFetchStyle != PDO::FETCH_NUM && $iFetchStyle != PDO::FETCH_BOTH) {
$iFetchStyle = PDO::FETCH_ASSOC;
}
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
return $oStmt->fetch($iFetchStyle);
} | execute sql query and return one row result
@param string $sQuery
@param array $aBindings
@param int $iFetchStyle
@return array | getRow | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getColumn($sQuery, $aBindings = [])
{
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
$aResultRows = [];
while ($row = $oStmt->fetchColumn()) {
$aResultRows[] = $row;
}
return $aResultRows;
} | execute sql query and return a column as result
@param string $sQuery
@param array $aBindings
@return array | getColumn | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getOne($sQuery, $aBindings = [], $iIndex = 0)
{
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
$result = $oStmt->fetch(PDO::FETCH_BOTH);
if ($result) {
return $result[$iIndex];
}
return null;
} | execute sql query and return one value result
@param string $sQuery
@param array $aBindings
@param int $iIndex
@return mixed | getOne | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getFirstRow($sQuery, $aBindings = [], $iFetchStyle = PDO::FETCH_ASSOC)
{
if ($iFetchStyle != PDO::FETCH_ASSOC && $iFetchStyle != PDO::FETCH_NUM) {
$this->iCurrentFetchStyle = PDO::FETCH_ASSOC;
} else {
$this->iCurrentFetchStyle = $iFetchStyle;
}
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
$this->oCurrentStmt = $oStmt;
$result = $this->oCurrentStmt->fetch($this->iCurrentFetchStyle);
if ($result) {
return $result;
}
return [];
} | execute sql query and return the first row of result
and keep $array type and poiter to all data
@param string $sQuery
@param array $aBindings
@param int $iFetchStyle
@return array | getFirstRow | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getNextRow()
{
$aResult = [];
if (!$this->oCurrentStmt) {
return $aResult;
}
$aResult = $this->oCurrentStmt->fetch($this->iCurrentFetchStyle);
if ($aResult === false) {
$this->oCurrentStmt = null;
$this->iCurrentFetchStyle = PDO::FETCH_ASSOC;
return [];
}
return $aResult;
} | return next row of pointed last getFirstRow calling data
@return array | getNextRow | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getNumRows($oStmt = null)
{
return $this->getAffectedRows($oStmt);
} | @deprecated use getAffectedRows instead
return number of affected rows in current mysql result
@param null|PDOStatement $oStmt
@return int | getNumRows | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getAffectedRows($oStmt = null)
{
if ($oStmt) {
return $oStmt->rowCount();
}
if ($this->oCurrentStmt) {
return $this->oCurrentStmt->rowCount();
}
return 0;
} | execute any query return number of rows affected/false
@param null|PDOStatement $oStmt
@return int | getAffectedRows | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function query($sQuery, $aBindings = [])
{
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
return $oStmt->rowCount();
} | execute any query return number of rows affected
@param string $sQuery
@param array $aBindings
@return int | query | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getAll($sQuery, $aBindings = [], $iFetchType = PDO::FETCH_ASSOC)
{
if ($iFetchType != PDO::FETCH_ASSOC && $iFetchType != PDO::FETCH_NUM && $iFetchType != PDO::FETCH_BOTH) {
$iFetchType = PDO::FETCH_ASSOC;
}
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
return $oStmt->fetchAll($iFetchType);
} | execute sql query and return table of records as result
@param string $sQuery
@param array $aBindings
@param int $iFetchType
@return array | getAll | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function fillArray($oStmt, $iFetchType = PDO::FETCH_ASSOC)
{
if ($iFetchType != PDO::FETCH_ASSOC && $iFetchType != PDO::FETCH_NUM && $iFetchType != PDO::FETCH_BOTH) {
$iFetchType = PDO::FETCH_ASSOC;
}
$aResult = [];
while ($row = $oStmt->fetch($iFetchType)) {
$aResult[] = $row;
}
return $aResult;
} | @deprecated
fetches records from a pdo statement and builds an array
@param PDOStatement $oStmt
@param int $iFetchType
@return array | fillArray | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getAllWithKey($sQuery, $sFieldKey, $aBindings = [], $iFetchType = PDO::FETCH_ASSOC)
{
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
$aResult = [];
if ($oStmt) {
while ($row = $oStmt->fetch($iFetchType)) {
$aResult[$row[$sFieldKey]] = $row;
}
$oStmt = null;
}
return $aResult;
} | execute sql query and return table of records as result
@param string $sQuery
@param string $sFieldKey
@param array $aBindings
@param int $iFetchType
@return array | getAllWithKey | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function getPairs($sQuery, $sFieldKey, $sFieldValue, $aBindings = [])
{
$oStmt = $this->res($sQuery, $aBindings);
if (!$oStmt)
return false;
$aResult = [];
if ($oStmt) {
while ($row = $oStmt->fetch()) {
$aResult[$row[$sFieldKey]] = $row[$sFieldValue];
}
$oStmt = null;
}
return $aResult;
} | execute sql query and return table of records as result
@param string $sQuery
@param string $sFieldKey
@param string $sFieldValue
@param array $aBindings
@return array | getPairs | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function listTables()
{
$aResult = [];
$oStmt = $this->link->query("SHOW TABLES FROM `{$this->dbname}`");
if (!$oStmt)
return false;
while ($row = $oStmt->fetch(PDO::FETCH_NUM)) {
$aResult[] = $row[0];
}
return $aResult;
} | Returns an array of all the table names in the database
@return array | listTables | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
public function escape($sText, $bReal = false)
{
$pdoEscapted = $this->link->quote($sText);
if ($bReal) {
return $pdoEscapted;
}
// don't need the actual quotes pdo adds, so it
// behaves kinda like mysql_real_escape_string
// p.s. things we do for legacy code
return trim($pdoEscapted, "'");
} | @param string $sText
@param bool $bReal return the actual quotes value or strip the quotes,
PS: Use the pdo bindings for user's sake
@return string | escape | php | boonex/dolphin.pro | upgrade/classes/BxDolUpgradeDb.php | https://github.com/boonex/dolphin.pro/blob/master/upgrade/classes/BxDolUpgradeDb.php | MIT |
function title2uri($sValue)
{
return str_replace(
array('&', '/', '\\', '"', '+'),
array('[and]', '[slash]', '[backslash]', '[quote]', '[plus]'),
$sValue
);
} | The following two functions are needed to convert title to uri and back.
It usefull when titles are used in URLs, like in Categories and Tags. | title2uri | php | boonex/dolphin.pro | inc/utils.inc.php | https://github.com/boonex/dolphin.pro/blob/master/inc/utils.inc.php | MIT |
function getLocaleDate($sTimestamp = '', $iCode = BX_DOL_LOCALE_DATE_SHORT)
{
$sFormat = (int)$iCode == 6 ? 'r' : getLocaleFormat($iCode);
return date($sFormat, $sTimestamp);
} | Convert date(timestamp) in accordance with requested format code.
@param string $sTimestamp - timestamp
@param integer $iCode - format code
1(4) - short date format. @see sys_options -> short_date_format_php
2 - time format. @see sys_options -> time_format_php
3(5) - long date format. @see sys_options -> date_format_php
6 - RFC 2822 date format. | getLocaleDate | php | boonex/dolphin.pro | inc/utils.inc.php | https://github.com/boonex/dolphin.pro/blob/master/inc/utils.inc.php | MIT |
function getLocaleFormat($iCode = BX_DOL_LOCALE_DATE_SHORT, $iType = BX_DOL_LOCALE_PHP)
{
$sPostfix = (int)$iType == BX_DOL_LOCALE_PHP ? '_php' : '';
$sResult = '';
switch ($iCode) {
case 2:
$sResult = getParam('time_format' . $sPostfix);
break;
case 1:
case 4:
$sResult = getParam('short_date_format' . $sPostfix);
break;
case 3:
case 5:
$sResult = getParam('date_format' . $sPostfix);
break;
}
return $sResult;
} | Get data format in accordance with requested format code and format type.
@param integer $iCode - format code
1(4) - short date format. @see sys_options -> short_date_format_php
2 - time format. @see sys_options -> time_format_php
3(5) - long date format. @see sys_options -> date_format_php
6 - RFC 2822 date format.
@param integer $iType - format type
1 - for PHP code.
2 - for database. | getLocaleFormat | php | boonex/dolphin.pro | inc/utils.inc.php | https://github.com/boonex/dolphin.pro/blob/master/inc/utils.inc.php | MIT |
function bx_time_utc($iUnixTimestamp)
{
return gmdate(DATE_ISO8601, (int)$iUnixTimestamp);
} | Get UTC/GMT time string in ISO8601 date format from provided unix timestamp
@param $iUnixTimestamp - unix timestamp
@return ISO8601 formatted date/time string | bx_time_utc | php | boonex/dolphin.pro | inc/utils.inc.php | https://github.com/boonex/dolphin.pro/blob/master/inc/utils.inc.php | MIT |
function process_pass_data($text, $strip_tags = 0)
{
if ($strip_tags) {
$text = strip_tags($text);
}
return $text;
} | @deprecated no gpc anymore, so no need for this function
function for processing pass data
This function cleans the GET/POST/COOKIE data if magic_quotes_gpc() is on
for data which should be outputed immediately after submit | process_pass_data | php | boonex/dolphin.pro | inc/utils.inc.php | https://github.com/boonex/dolphin.pro/blob/master/inc/utils.inc.php | MIT |
function RedirectCode($ActionURL, $Params = null, $Method = "get", $Title = 'Redirect')
{
if ((strcasecmp(trim($Method), "get") && strcasecmp(trim($Method), "post")) || (trim($ActionURL) == "")) {
return false;
}
ob_start();
?>
<html>
<head>
<title><?= $Title ?></title>
</head>
<body>
<form name="RedirectForm" action="<?= htmlspecialchars($ActionURL) ?>" method="<?= $Method ?>">
<?= ConstructHiddenValues($Params) ?>
</form>
<script type="text/javascript">
<!--
document.forms['RedirectForm'].submit();
-->
</script>
</body>
</html>
<?php
$Result = ob_get_contents();
ob_end_clean();
return $Result;
} | Returns HTML/javascript code, which redirects to another URL with passing specified data (through specified method)
@param string $ActionURL destination URL
@param array $Params Parameters to be passed (through GET or POST)
@param string $Method Submit mode. Only two values are valid: 'get' and 'post'
@return mixed Correspondent HTML/javascript code or false, if input data is wrong | RedirectCode | php | boonex/dolphin.pro | inc/utils.inc.php | https://github.com/boonex/dolphin.pro/blob/master/inc/utils.inc.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.