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
private function login() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = array('accountType' => 'GOOGLE', 'Email' => $this->login, 'Passwd' => $this->password, 'source' => 'php_curl_analytics', 'service' => 'analytics'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $hasil = curl_exec($ch); curl_close($ch); // Get the login token // SID=DQA...oUE // LSID=DQA...bbo // Auth=DQA...Sxq if (preg_match('/Auth=(.*)$/', $hasil, $matches) > 0) { $this->loginToken = $matches[1]; } else { trigger_error('Authentication problem', E_USER_WARNING); return null; } }
Login to the google server See : http://google-data-api.blogspot.com/2008/05/clientlogin-with-php-curl.html @return void
login
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Analytics/GoogleAnalyticsAPI.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Analytics/GoogleAnalyticsAPI.class.php
MIT
public function checkIpBots() { $sIpBot = t('Unknown Search Engine Bot IP'); foreach (self::$aIpRobots as $sRegex => $sName) { if ($this->find($sRegex, $this->sUserAgent)) { $sIpBot = $sName; break; } } return $sIpBot; }
Check IP of search engine bots. @return string IP bot.
checkIpBots
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Analytics/Analytics.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Analytics/Analytics.class.php
MIT
private function find($sToFind, $sContents) { return preg_match('/' . $sToFind . '/i', $sContents); }
Find a word in contents using the RegEx pattern. @param string $sToFind @param string $sContents @return bool
find
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Analytics/Analytics.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Analytics/Analytics.class.php
MIT
public function __invoke() { return static::getInstance(); }
Directly call "static::getInstance()" method when the object is called as a function. @return static
__invoke
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Pattern/Singleton.trait.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Pattern/Singleton.trait.php
MIT
public static function dataUri($sFile, File $oFile) { // Switch to right MIME-type $sExt = $oFile->getFileExt($sFile); $sMimeType = $oFile->getMimeType($sExt); $sBase64 = base64_encode(file_get_contents($sFile)); return "data:$sMimeType;base64,$sBase64"; }
Data URI scheme - base64 encoding. @param string $sFile @param File $oFile @return string Returns format: data:[<MIME-type>][;base64],<data>
dataUri
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Optimization.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Optimization.class.php
MIT
public static function cssDataUriCleanup($sFile, $sDir) { // Scan any left file references & adjust their paths preg_match_all(self::REGEX_CSS_IMPORT_URL_PATTERN, $sFile, $aHit, PREG_PATTERN_ORDER); for ($i = 0, $iCountHit = count($aHit[0]); $i < $iCountHit; $i++) { $sProtocolContext = str_replace(['"', "'"], '', $aHit[2][$i]); if ( substr($sProtocolContext, 0, 5) !== 'http:' && substr($sProtocolContext, 0, 6) !== 'https:' && substr($sProtocolContext, 0, 5) !== 'data:' && substr($sProtocolContext, 0, 6) !== 'mhtml:' && substr($sProtocolContext, 0, 1) !== '/' && substr($sProtocolContext, strlen($sProtocolContext) - 4, 4) !== '.htc' ) { $sSearch = $aHit[1][$i] . $aHit[2][$i] . $aHit[3][$i]; $sReplace = $sDir . $aHit[1][$i]; $sReplace .= $aHit[2][$i] . $aHit[3][$i]; $sFile = str_replace($sSearch, $sReplace, $sFile); } } return $sFile; }
Scan the path ($sDir) of all file-references found. Note: This function is a slightly modified version from Christian Schepp Schaefer's function (CSS JS booster). @param string $sFile Contents to scan. @param string $sDir Folder name to prepend. @return string Content with adjusted paths.
cssDataUriCleanup
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Optimization.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Optimization.class.php
MIT
public function setDefaultTpl(string $sNewDefTpl) { $this->sDefaultTpl = $sNewDefTpl; return $this; }
Set the default template name. @param string $sNewDefTpl Template name. @return self
setDefaultTpl
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/LoadTemplate.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/LoadTemplate.class.php
MIT
public function subHeader() { return '<table> <tr><td> <div id="sub_container"> <h1 class="logo"><a href="' . Registry::getInstance()->site_url . '">' . Registry::getInstance()->site_name . '</a></h1>'; }
Sub Header HTML with the site logo. @return string HTML Contents.
subHeader
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Html/Mail.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Html/Mail.class.php
MIT
public function flashMsg() { $aFlashData = [ self::FLASH_MSG, self::FLASH_TYPE ]; if ($this->oSession->exists($aFlashData)) { echo '<div class="center bold alert alert-', $this->oSession->get(self::FLASH_TYPE), '" role="alert">', $this->oSession->get(self::FLASH_MSG), '</div>'; $this->oSession->remove($aFlashData); } }
Flash displays the message defined in the method setFlash. @return void The message text with CSS layout depending on the type of message.
flashMsg
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Html/Design.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Html/Design.class.php
MIT
public function ip($sIp = null, $bPrint = true) { $sIp = Ip::get($sIp); $sHtml = '<a href="' . Ip::api($sIp) . '" title="' . t('Get information about this IP address') . '" target="_blank" rel="noopener noreferrer">' . $this->oStr->extract($sIp, self::MAX_IP_LENGTH_SHOWN) . '</a>'; if (!$bPrint) { return $sHtml; } echo $sHtml; }
Show the user IP address with a link to get the IP information. @internal If it's an IPv6, show only the beginning, otherwise it would be too long in the template. @param string $sIp Allows to specify another IP address than the client one. @param bool $bPrint Print or Return the HTML code. Default TRUE @return void|string
ip
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Html/Design.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Html/Design.class.php
MIT
public function geoIp($bPrint = true) { $sCountry = Geo::getCountry(); $sCountryCode = Country::fixCode(Geo::getCountryCode()); $sCountryLang = t($sCountryCode); // Country name translated into the user language $sCity = Geo::getCity(); if (SysMod::isEnabled('map')) { $sHtml = '<a href="' . Uri::get('map', 'country', 'index', $sCountry . PH7_SH . $sCity) . '" title="' . t('Meet New People in %0%, %1% with %site_name%!', $sCountryLang, $sCity) . '">' . $sCity . '</a>'; } else { $sHtml = '<abbr title="' . t('Meet New People in %0%, %1% thanks to %site_name%!', $sCountryLang, $sCity) . '">' . $sCity . '</abbr>'; } if (!$bPrint) { return $sHtml; } echo $sHtml; }
Show the geolocation of the user (with link that points to the Country controller). @param bool $bPrint Print or Return the HTML code. Default TRUE @return void|string
geoIp
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Html/Design.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Html/Design.class.php
MIT
public function socialMediaWidgets() { if ((bool)DbConfig::getSetting('socialMediaWidgets')) { $sHtml = <<<HTML <div class="a2a_kit a2a_kit_size_32 a2a_default_style"> <a class="a2a_dd" href="https://www.addtoany.com/share" rel="nofollow"></a> <a class="a2a_button_facebook"></a> <a class="a2a_button_twitter"></a> <a class="a2a_button_pinterest"></a> <a class="a2a_button_facebook_messenger"></a> <a class="a2a_button_linkedin"></a> </div> HTML; echo $sHtml; } }
Add 'normal' size of the Social Media Widgets. @internal AddToAny JS file will be included through 'ph7_static_files' table. @return void HTML output.
socialMediaWidgets
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Html/Design.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Html/Design.class.php
MIT
public function littleSocialMediaWidgets() { if ((bool)DbConfig::getSetting('socialMediaWidgets')) { $sHtml = <<<HTML <div class="a2a_kit a2a_kit_size_32 a2a_default_style"> <a class="a2a_dd" href="https://www.addtoany.com/share" rel="nofollow"></a> <a class="a2a_button_facebook"></a> <a class="a2a_button_twitter"></a> <a class="a2a_button_pinterest"></a> </div> HTML; echo $sHtml; } }
Add 'small' size of the Social Media Widgets. @internal AddToAny JS file will be included through 'ph7_static_files' table. @return void HTML output.
littleSocialMediaWidgets
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Html/Design.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Html/Design.class.php
MIT
public function jQueryDocumentReady() { echo 'jQuery("#', $this->form->getId(), ' .pfbc-element:last").css({ "margin-bottom": "0", "padding-bottom": "0", "border-bottom": "none" });'; }
jQuery is used to apply css entries to the last element.
jQueryDocumentReady
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/View.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/View.php
MIT
protected function renderLabel(Element $element) { $label = $element->getLabel(); $id = $element->getID(); $description = $element->getDescription(); if (!empty($label) || !empty($description)) { echo '<div class="pfbc-label">'; if (!empty($label)) { echo '<label for="', $id, '">'; if ($element->isRequired()) { echo '<strong>*</strong> '; } echo $label, '</label>'; } if (!empty($description)) { echo '<em>', $description, '</em>'; } echo '</div>'; } }
This method encapsulates the various pieces that are included in an element's label. @param Element $element
renderLabel
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/View.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/View.php
MIT
public function __sleep() { return ['attributes', 'label', 'validation']; }
When an element is serialized and stored in the session, this method prevents any non-essential information from being included.
__sleep
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function getCSSFiles() { }
If an element requires external stylesheets, this method is used to return an array of entries that will be applied before the form is rendered.
getCSSFiles
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function isValid($value) { $valid = true; if (!empty($this->validation)) { if (!empty($this->label)) { $element = $this->label; if (substr($element, -1) === ':') { $element = substr($element, 0, -1); } } else { $element = $this->attributes['name']; } foreach ($this->validation as $validation) { if (!$validation->isValid($value)) { /*In the error message, %element% will be replaced by the element's label (or name if label is not provided).*/ $this->errors[] = str_replace('%element%', $element, $validation->getMessage()); $valid = false; } } } return $valid; }
The method ensures that the provided value satisfies each of the element's validation rules. @param string $value @return bool
isValid
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function jQueryDocumentReady() { }
If an element requires jQuery, this method is used to include a section of javascript that will be applied within the jQuery(document).ready(function() {}); section after the form has been rendered.
jQueryDocumentReady
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function jQueryOptions() { if (!empty($this->jQueryOptions)) { $options = ''; foreach ($this->jQueryOptions as $option => $value) { if (!empty($options)) { $options .= ', '; } $options .= $option . ': '; /*When javascript needs to be applied as a jQuery option's value, no quotes are needed.*/ if (is_string($value) && substr($value, 0, 3) === 'js:') { $options .= substr($value, 3); } else { $options .= var_export($value, true); } } echo '{ ', $options, ' }'; } }
Elements that have the jQueryOptions property included (Date, Sort, Checksort, and Color) can make use of this method to render out the element's appropriate jQuery options.
jQueryOptions
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function render() { if (isset($this->attributes['value']) && is_array($this->attributes['value'])) { $this->attributes['value'] = ''; } $sHtml = '<input' . $this->getAttributes(); $sHtml .= $this->getHtmlRequiredIfApplicable(); echo $sHtml, ' />'; }
Many of the included elements make use of the <input> tag for display. These include the Hidden, Textbox, Password, Date, Color, Button, Email, and File element classes. The project's other element classes will override this method with their own implementation.
render
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function isRequired() { if (!empty($this->validation)) { foreach ($this->validation as $validation) { if ($validation instanceof Validation\Required) { return true; } } } return false; }
This method provides a shortcut for checking if an element is required.
isRequired
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function renderCSS() { }
If an element requires inline stylesheet definitions, this method is used send them to the browser before the form is rendered.
renderCSS
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function renderJS() { }
If an element requires javascript to be loaded, this method is used send them to the browser after the form is rendered.
renderJS
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function setRequired($required) { if (!empty($required)) { $this->validation[] = new Validation\Required; } }
This method provides a shortcut for applying the Required validation class to an element.
setRequired
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public function setValidation($validation) { /*If a single validation class is provided, an array is created in order to reuse the same logic.*/ if (!is_array($validation)) { $validation = [$validation]; } foreach ($validation as $object) { /*Ensures $object contains a existing concrete validation class.*/ if ($object instanceof Validation) { $this->validation[] = $object; } } }
This method applies one or more validation rules to an element. If can accept a single concrete validation class or an array of entries. @param array|string $validation
setValidation
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element.php
MIT
public static function setError($id, $messages, $element = '') { if (!is_array($messages)) { $messages = [$messages]; } if (empty($_SESSION['pfbc'][$id]['errors'][$element])) { $_SESSION['pfbc'][$id]['errors'][$element] = []; } foreach ($messages as $message) { $_SESSION['pfbc'][$id]['errors'][$element][] = $message; } }
Validation errors are saved in the session after the form submission, and will be displayed to the user when redirected back to the form.
setError
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
MIT
public static function renderAjaxErrorResponse($id = 'pfbc') { $form = self::recover($id); if (!empty($form)) { $form->error->renderAjaxErrorResponse(); } }
When ajax is used to submit the form's data, validation errors need to be manually sent back to the form using json. @param string $id
renderAjaxErrorResponse
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
MIT
public function __sleep() { return ['attributes', 'elements', 'error']; }
When a form is serialized and stored in the session, this function prevents any non-essential information from being included.
__sleep
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
MIT
public function setValues(array $values) { $this->values = array_merge($this->values, $values); }
An associative array is used to pre-populate form elements. The keys of this array correspond with the element names. @param array $values
setValues
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
MIT
private function save() { $_SESSION['pfbc'][$this->attributes['id']]['form'] = serialize($this); }
The save method serialized the form's instance and saves it in the session.
save
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Form.class.php
MIT
public function debug() { echo '<pre>', print_r($this, true), '</pre>'; }
This method can be used to view a class' state.
debug
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Base.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Base.php
MIT
protected function filter($sText) { return htmlspecialchars($sText, ENT_QUOTES); }
This method converted special characters to entities in HTML attributes from breaking the markup. @param string $sText @return string
filter
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Base.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Base.php
MIT
public function __construct($sLabel, array $aProperties = null) { parent::__construct($sLabel, '', [], $aProperties); $this->iMinAge = (int)DbConfig::getSetting('minAgeRegistration'); $this->iMaxAge = (int)DbConfig::getSetting('maxAgeRegistration'); $this->generateHtmlElements(); }
Generate the select field for age search. @param string $sLabel @param array|null $aProperties
__construct
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Form/Engine/PFBC/Element/Age.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Form/Engine/PFBC/Element/Age.php
MIT
public function enablePhpFunctions($bEnable = true) { $this->bPhpFunc = (bool)$bEnable; return $this; }
Enable or disable the PHP functions in the XSTL template. @param bool $bEnable @return self
enablePhpFunctions
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Xsl/PH7Xsl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Xsl/PH7Xsl.class.php
MIT
public function getMainPage() { return static::MAIN_PAGE . static::TEMPLATE_FILE_EXT; }
Get the main page file of the template. @return string The main page file.
getMainPage
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function setTemplateDir($sDir) { if (!is_dir($sDir)) { throw new PH7InvalidArgumentException( sprintf('<strong>%s</strong> cannot find "%s" template directory.', self::NAME, $sDir) ); } $this->sTemplateDir = $this->file->checkExtDir($sDir); }
Set the directory for the template. @param string $sDir @return void @throws PH7InvalidArgumentException An explanatory message if the directory does not exist.
setTemplateDir
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function setCompileDir($sDir) { if (!is_dir($sDir)) { throw new PH7InvalidArgumentException( sprintf( '<strong>%s</strong> cannot find "%s" compile directory.', self::NAME, $sDir) ); } $this->sCompileDir = $this->file->checkExtDir($sDir); }
Set the directory for the compilation template. @param string $sDir @return void @throws PH7InvalidArgumentException An explanatory message if the directory does not exist.
setCompileDir
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function setCacheDir($sDir) { if (!is_dir($sDir)) { throw new PH7InvalidArgumentException( sprintf('<strong>%s</strong> cannot find "%s" cache directory.', self::NAME, $sDir) ); } $this->sCacheDir = $this->file->checkExtDir($sDir); }
Set the directory for the cache template. @param string $sDir @return void @throws PH7InvalidArgumentException An explanatory message if the directory does not exist.
setCacheDir
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function __get(string $sKey) { return $this->getVar($sKey); }
Retrieve an assigned variable (overload the magic __get method). @see pH7Tpl::getVar() @param string $sKey The variable name. @return mixed The variable value.
__get
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function __isset($sKey) { return isset($this->_aVars[$sKey]); }
Allows testing with empty() and isset() to work. @param string $sKey @return bool
__isset
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function getVar(string $sVarName) { return $this->_aVars[$sVarName] ?? ''; }
Get a variable we assigned with the assign() method. @see __get() @param $sVarName string Name of a variable that is to be retrieved. @return mixed Value of that variable.
getVar
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function clean() { unset($this->_aVars, $this->_oVars); }
Remove all variables from memory template. @return void
clean
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function __clone() { $this->_oVars = $this; }
Set self pointer on cloned object. @clone
__clone
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
protected function cache() { // Create cache folder $this->file->createDir($this->sCacheDir); $this->sCacheDir2 = $this->sCacheDir . PH7_TPL_NAME . PH7_DS . $this->registry->module . '_' . md5($this-> registry->path_module) . PH7_DS . PH7_TPL_MOD_NAME . PH7_DS . PH7_LANG_NAME . PH7_DS . $this->getCurrentController() . PH7_DS; $this->file->createDir($this->sCacheDir2); $this->sCacheDirFile = $this->sCacheDir2 . str_replace(PH7_DS, '_', $this->file->getFileWithoutExt($this->sTplFile)) . static::CACHE_FILE_EXT; if ($this->hasCacheExpired()) { ob_start(); // Extraction Variables extract($this->_aVars); require $this->sCompileDirFile; $sOutput = ob_get_contents(); ob_end_clean(); if ($this->bHtmlCompressor) { $sOutput = (new Compress)->parseHtml($sOutput); } if ($this->file->putFile($this->sCacheDirFile, $sOutput) === false) { throw new TplException( sprintf('Unable to write HTML cached file "%s"', $this->sCacheDirFile) ); } echo $sOutput; } else { readfile($this->sCacheDirFile); } }
Cache system for the static contents with support for different templates and languages! @return void @throws Exception @throws \PH7\Framework\File\Permission\PermissionException @throws TplException If the cache file could not be written.
cache
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/PH7Tpl.class.php
MIT
public function getParsedCode() { return $this->sCode; }
Get the converted PHP code from template engine's syntax. @return string
getParsedCode
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Layout/Tpl/Engine/PH7Tpl/Syntax/Syntax.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Layout/Tpl/Engine/PH7Tpl/Syntax/Syntax.class.php
MIT
private function launchNonRewritingRouters() { if (!$this->isRouterRewritten()) { if ($this->isSimpleModuleRequest()) { $this->simpleModuleRouter(); } else { $this->simpleRouter(); } } }
If the module action isn't rewriting, we launch the basic router.
launchNonRewritingRouters
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function launchRewritingRouter() { $oUrl = UriRoute::loadFile(new DomDocument); foreach ($oUrl->getElementsByTagName('route') as $oRoute) { if ($this->isRewrittenUrl($oRoute, $aMatches)) { $this->setRewritingRouter(); // Get the module path from routes/*.xml file (e.g., "system/modules" or just "modules") $sModulePath = $oRoute->getAttribute('path') . PH7_SH; // Get module, from the `routes/<LANG_CODE>.xml` file $this->oRegistry->module = $oRoute->getAttribute('module'); // Check if config module file exists if (!$this->oConfig->load(PH7_PATH_APP . $sModulePath . $this->oRegistry->module . PH7_DS . PH7_CONFIG . PH7_CONFIG_FILE)) { $this->notFound('The <b>' . $this->oRegistry->module . '</b> system module is not found.<br />File: <b>' . PH7_PATH_APP . $sModulePath . $this->oRegistry->module . PH7_DS . '</b><br /> or the <b>' . PH7_CONFIG_FILE . '</b> file is not found.<br />File: <b>' . PH7_PATH_APP . $sModulePath . $this->oRegistry->module . PH7_DS . PH7_CONFIG . PH7_CONFIG_FILE . '</b>'); } /***** PATH THE MODULE *****/ $this->oRegistry->path_module = PH7_PATH_APP . $sModulePath . $this->oRegistry->module . PH7_DS; /***** URL THE MODULE *****/ $this->oRegistry->url_module = PH7_URL_ROOT . $this->oRegistry->module . PH7_SH; /***** PATH THE TEMPLATE *****/ $this->oRegistry->path_themes_module = PH7_PATH_ROOT . PH7_LAYOUT . $sModulePath . $this->oRegistry->module . PH7_DS . PH7_TPL; /***** URL THE TEMPLATE *****/ $this->oRegistry->url_themes_module = PH7_RELATIVE . PH7_LAYOUT . $sModulePath . $this->oRegistry->module . PH7_SH . PH7_TPL; // Get the default controller $this->oRegistry->controller = ucfirst($oRoute->getAttribute('controller')) . self::CONTROLLER_SUFFIX; // Get the default action $this->oRegistry->action = $oRoute->getAttribute('action'); if ($oRoute->hasAttribute('vars')) { $this->generateRequestParameters($oRoute, $aMatches); } break; } } unset($oUrl); }
Router for the modules that are rewriting through the custom XML route file. @throws PH7Exception @throws \PH7\Framework\File\IOException If the XML route file is not found.
launchRewritingRouter
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
public function _unsetDatabaseInfo() { unset($this->oConfig->values['database']); }
Removing the sensitive database information in the config object. @return void
_unsetDatabaseInfo
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function initializeLanguage() { if (!defined('PH7_PREF_LANG')) { define('PH7_PREF_LANG', DbConfig::getSetting('defaultLanguage')); } if (!defined('PH7_LANG_NAME')) { // Set the default language of the site and load the default language path $sLangName = (new Lang) ->setDefaultLang(PH7_PREF_LANG) ->init() ->load(self::MAIN_GETTEXT_FILENAME, PH7_PATH_APP_LANG) ->getLocaleName(); define('PH7_LANG_NAME', $sLangName); } /*** Get the ISO language code (the two first letters) ***/ define('PH7_DEFAULT_LANG_CODE', Lang::getIsoCode(PH7_DEFAULT_LANG)); define('PH7_LANG_CODE', Lang::getIsoCode(PH7_LANG_NAME)); /*** Set locale environment variables for gettext ***/ putenv('LC_ALL=' . PH7_LANG_NAME); setlocale(LC_ALL, PH7_LANG_NAME); }
Internationalization with Gettext. @return void @throws \PH7\Framework\Translate\Exception
initializeLanguage
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function initializeAssets() { if ($this->isAssetRequest(0)) { switch ($this->oUri->fragment(1)) { case self::AJAX_REQUEST_PARAM_NAME: // Loading Asynchronous Ajax files $this->ajaxRouter(); break; case 'file': // Loading files $this->fileRouter(); break; case 'cron': // Loading Cron Jobs files $this->cronRouter(); break; case 'css': // Loading Style sheet files $this->cssRouter(); break; case 'js': // Loading JavaScript files $this->jsRouter(); break; default: $this->notFound( 'Asset file not found!', self::REDIRECT_ERROR_MOD ); } exit; } }
Initialize the resources of the assets folders. @return void @throws PH7Exception @throws \PH7\Framework\Http\Exception
initializeAssets
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function checkUriCacheStatus() { if (UriRoute::URI_CACHE_ENABLED && UriRoute::isCachedUrlOutdated()) { UriRoute::clearCache(); } }
Check if the URI cache needs to be regenerated when outdated. @return void
checkUriCacheStatus
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function isCronHashValid() { return strcmp( $this->oHttpRequest->get('secret_word'), DbConfig::getSetting('cronSecurityHash') ) === 0; }
Check if the cron's security string is valid or not. @return bool
isCronHashValid
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function isRouterRewritten() { return $this->bIsRouterRewritten; }
Check if the module's action is rewriting by the XML route file or not. @return bool
isRouterRewritten
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function setRewritingRouter() { $this->bIsRouterRewritten = true; }
If the action is rewriting by the XML route file, set the correct router to be used. @return void
setRewritingRouter
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function secureRequestParameter($sVar) { $sVar = escape($sVar, true); // Convert characters to entities and return them $aBadCharacters = [ '$', '(', ')', '%28', '%29' ]; $aGoodCharacters = [ '&#36;', '&#40;', '&#41;', '&#40;', '&#41;' ]; return str_replace( $aBadCharacters, $aGoodCharacters, $sVar ); }
Secures the Request Parameter. @param string $sVar @return string
secureRequestParameter
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function clearRequestParameter() { unset($this->aRequestParameter); }
Remove the Request Parameter variable. @return void
clearRequestParameter
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function indexFileRouter() { // The following code will be useless if pH7Builder will be able to work without mod_rewrite if ($this->oHttpRequest->currentUrl() === PH7_URL_ROOT . self::INDEX_FILE) { $this->notFound('In "production" mode, it simulates "404 page not found" if the index.php filename is called, to avoid disclosing the language index filename for security reasons.'); } }
We display an error page if someone requests "index.php" filename in order to avoid disclosing and explicitly request the PHP index filename for security reasons. Otherwise, if the URL rewrite extension is not enabled, we redirect the page to index.php file (then [URL]/index.php/[REQUEST]/ ). @see self::notFound() @return void @throws PH7Exception
indexFileRouter
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
private function notFound($sMsg = null, $iRedirect = null) { if ($sMsg !== null && isDebug()) { throw new PH7Exception($sMsg); } if ($iRedirect === null) { $this->oRegistry->module = 'error'; // Reload the config.ini file for the "error" module $this->oConfig->load(PH7_PATH_SYS . PH7_MOD . 'error' . PH7_DS . PH7_CONFIG . PH7_CONFIG_FILE); } else { Header::redirect( UriRoute::get( 'error', 'http', 'index' ) ); } }
This method has two different behaviors depending on the environment mode site. 1. In production mode: Displays the page not found using the system module "error". 2. In development mode: It throws an Exception with displaying an explanatory message that indicates why this page was not found. @param string $sMsg @param string $iRedirect 1 = redirect @return void @throws PH7Exception If the site is in development mode, displays an explanatory message that indicates why this page was not found.
notFound
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Router/FrontController.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Router/FrontController.class.php
MIT
public function getInfos($bOnlyActive = true) { $oCache = (new Cache)->start(self::CACHE_GROUP, 'list' . $bOnlyActive, 172800); if (!$aData = $oCache->get()) { $sSqlWhere = $bOnlyActive ? 'WHERE active = \'1\'' : ''; $sSqlQuery = 'SELECT * FROM ' . DB::prefix(DbTableName::LANGUAGE_INFO) . $sSqlWhere . ' ORDER BY name ASC'; $rStmt = Db::getInstance()->prepare($sSqlQuery); $rStmt->execute(); $aData = $rStmt->fetchAll(\PDO::FETCH_OBJ); Db::free($rStmt); $oCache->put($aData); } unset($oCache); return $aData; }
Get information about the language(s). @param bool $bOnlyActive Only active lang @return array Get the info of the available languages.
getInfos
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Lang.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Lang.class.php
MIT
public static function setClick($iAdsId) { $sSql = 'UPDATE' . Db::prefix(DbTableName::AD) . 'SET clicks = clicks+1 WHERE adsId = :id LIMIT 1'; $rStmt = Db::getInstance()->prepare($sSql); $rStmt->bindValue(':id', $iAdsId, \PDO::PARAM_INT); $rStmt->execute(); Db::free($rStmt); }
Adding an Advertisement Click. @param int $iAdsId @return void
setClick
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Ads.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Ads.class.php
MIT
public function get($sFolderName = null) { $this->cache->start( static::CACHE_GROUP, 'list' . $sFolderName, static::CACHE_TIME ); if (!$oData = $this->cache->get()) { $bIsFolderName = $sFolderName !== null; $sSelect = $bIsFolderName ? 'enabled' : '*'; $sSqlWhere = $bIsFolderName ? 'WHERE folderName = :modName LIMIT 1' : ''; $rStmt = Db::getInstance()->prepare( 'SELECT ' . $sSelect . ' FROM ' . DB::prefix(DbTableName::SYS_MOD_ENABLED) . $sSqlWhere ); if ($bIsFolderName) { $rStmt->bindValue(':modName', $sFolderName, \PDO::PARAM_STR); } $rStmt->execute(); $sFetchMethod = $bIsFolderName ? 'fetch' : 'fetchAll'; $oData = $rStmt->$sFetchMethod(\PDO::FETCH_OBJ); Db::free($rStmt); $this->cache->put($oData); } return $oData; }
Get all modules status (enabled and disabled). @param string|null $sFolderName Name of the module folder. @return \stdClass|array
get
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Module.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Module.class.php
MIT
public function update($iId, $sIsEnabled = self::YES) { return $this->orm->update( DbTableName::SYS_MOD_ENABLED, 'enabled', $sIsEnabled, 'moduleId', $iId ); }
Update the module status (enabled/disabled). @param string $iId Module ID @param string $sIsEnabled '1' = Enabled | '0' = Disabled. Need to be string because in DB it is an "enum" @return int|bool Returns the number of rows on success or FALSE on failure.
update
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Module.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Module.class.php
MIT
public static function clearCache() { (new Cache)->start( self::CACHE_GROUP, null, null )->clear(); }
Clean the entire DbConfig group Cache. @return void
clearCache
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/DbConfig.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/DbConfig.class.php
MIT
public static function getView($iId, $sTable) { $sWhere = Various::convertTableToId($sTable); $sSqlQuery = 'SELECT views FROM' . Db::prefix($sTable) . 'WHERE ' . $sWhere . ' = :id LIMIT 1'; $rStmt = Db::getInstance()->prepare($sSqlQuery); $rStmt->bindValue(':id', $iId, \PDO::PARAM_INT); $rStmt->execute(); $iViews = (int)$rStmt->fetchColumn(); Db::free($rStmt); return $iViews; }
This method was created to avoid retrieving the column "views" with the general Model of the module, since it uses the cache and therefore cannot retrieve the number of real-time views. @param int $iId @param string $sTable @return int Number of views.
getView
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Statistic.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Statistic.class.php
MIT
public function updateApi($sCode) { return Engine\Record::getInstance()->update( DbTableName::ANALYTIC_API, 'code', $sCode ); }
Update the analytics API code. @param string $sCode @return int|bool Returns the number of rows on success or FALSE on failure.
updateApi
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Analytics.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Analytics.class.php
MIT
public function ad($iWidth, $iHeight, $bOnlyActive = true) { $this->oCache->start(self::CACHE_STATIC_GROUP, 'ads' . $iWidth . $iHeight . $bOnlyActive, static::CACHE_TIME); if (!$oData = $this->oCache->get()) { $sSqlActive = $bOnlyActive ? ' AND (active = \'1\') ' : ' '; $rStmt = Db::getInstance()->prepare('SELECT * FROM ' . Db::prefix(DbTableName::AD) . 'WHERE (width=:width) AND (height=:height)' . $sSqlActive . 'ORDER BY RAND() LIMIT 1'); $rStmt->bindValue(':width', $iWidth, \PDO::PARAM_INT); $rStmt->bindValue(':height', $iHeight, \PDO::PARAM_INT); $rStmt->execute(); $oData = $rStmt->fetch(\PDO::FETCH_OBJ); Db::free($rStmt); $this->oCache->put($oData); } /** * Don't display ads on the admin panel. */ if ($oData && !AdminCore::isAdminPanel()) { echo '<div class="inline" onclick="$(\'#ad_' . $oData->adsId . '\').attr(\'src\',\'' . PH7_URL_ROOT . '?' . Banner::PARAM_URL . '=' . $oData->adsId . '\');return true;">'; echo Banner::output($oData, $this->oHttpRequest); echo '<img src="' . PH7_URL_STATIC . PH7_IMG . 'useful/blank.gif" style="border:0;width:0px;height:0px;" alt="" id="ad_' . $oData->adsId . '" /></div>'; } unset($oData); }
Gets Ads with ORDER BY RAND() SQL aggregate function. With caching, advertising changes every hour. @param int $iWidth @param int $iHeight @param bool $bOnlyActive @return bool|void
ad
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Design.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Design.class.php
MIT
public function errorCode() { return self::$oDb->errorCode(); }
Fetch the SQLSTATE associated with the last operation on the database handle. @return string
errorCode
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function exec($sStatement) { $fStartTime = microtime(true); $mReturn = self::$oDb->exec($sStatement); $this->increment(); $this->addTime($fStartTime, microtime(true)); return $mReturn; }
Execute an SQL statement and return the number of affected rows. @param string $sStatement @return bool|int
exec
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function getAttribute($iAttribute) { return self::$oDb->getAttribute($iAttribute); }
Retrieve a database connection attribute. @param int $iAttribute @return mixed
getAttribute
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function getAvailableDrivers() { return self::$oDb->getAvailableDrivers(); }
Return an array of available PDO drivers. @return array
getAvailableDrivers
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function lastInsertId($sName = null) { return (string)self::$oDb->lastInsertId($sName); }
Returns the ID of the last inserted row or sequence value. @param string $sName Name of the sequence object from which the ID should be returned. @return string
lastInsertId
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function prepare($sStatement) { $fStartTime = microtime(true); $bReturn = self::$oDb->prepare($sStatement); $this->increment(); $this->addTime($fStartTime, microtime(true)); return $bReturn; }
Prepares a statement for execution and returns a statement object. @param string $sStatement A valid SQL statement for the target database server. @return PDOStatement
prepare
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function execute($sStatement) { return self::$oDb->execute($sStatement); }
Execute an SQL prepared with prepare() method. @param string $sStatement @return bool
execute
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function query($sStatement) { $fStartTime = microtime(true); $mReturn = self::$oDb->query($sStatement); $this->increment(); $this->addTime($fStartTime, microtime(true)); return $mReturn; }
Executes an SQL statement, returning a result set as a PDOStatement object. @param string $sStatement @return PDOStatement|bool Returns PDOStatement object, or FALSE on failure.
query
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function queryFetchAllAssoc($sStatement) { return self::$oDb->query($sStatement)->fetchAll(PDO::FETCH_ASSOC); }
Execute query and return all rows in assoc array. @param string $sStatement @return array
queryFetchAllAssoc
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function queryFetchRowAssoc($sStatement) { return self::$oDb->query($sStatement)->fetch(PDO::FETCH_ASSOC); }
Execute query and return one row in assoc array. @param string $sStatement @return array
queryFetchRowAssoc
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function queryFetchColAssoc($sStatement) { return self::$oDb->query($sStatement)->fetchColumn(); }
Execute query and select one column only. @param string $sStatement @return mixed
queryFetchColAssoc
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function quote($sInput, $iParameterType = PDO::PARAM_NULL) { return self::$oDb->quote($sInput, $iParameterType); }
Quotes a string for use in a query. @param string $sInput @param int $iParameterType @return string
quote
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public static function prefix($sTable = '', $bSpace = true) { $sSpace = $bSpace ? ' ' : ''; return ($sTable !== '') ? $sSpace . self::$sPrefix . $sTable . $sSpace : self::$sPrefix; }
If table name is empty, only prefix will be returned otherwise the table name with its prefix will be returned. @param string $sTable Table name. Default '' @param bool $bSpace With or without a space before and after the table name. Default value is FALSE, so with space before and after table name. @return string prefixed table name, just prefix if table name is empty.
prefix
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Db.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Db.class.php
MIT
public function addValue($sKey, $sValue) { $this->aValues[$sKey] = $sValue; return $this; }
Add a value to the values array. @param string $sKey the array key @param string $sValue The value @return self
addValue
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Record.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Record.class.php
MIT
public function delete($sTable, $sField, $sId) { try { $oDb = Db::getInstance(); // We start the transaction $oDb->beginTransaction(); $this->sSql = 'DELETE FROM' . Db::prefix($sTable) . "WHERE $sField = :id"; $rStmt = $oDb->prepare($this->sSql); $rStmt->bindParam(':id', $sId); $bStatus = $rStmt->execute(); // If all goes well, we commit the transaction $oDb->commit(); Db::free($rStmt); return $bStatus; } catch (Exception $oE) { $this->aErrors[] = $oE->getMessage(); // We cancel the transaction if an error occurs $oDb->rollBack(); return false; } }
Delete a recored from a table. @param string $sTable The table name @param string $sField @param string $sId @return bool Returns TRUE on success or FALSE on failure.
delete
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Record.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Record.class.php
MIT
public function clean() { // Set to default values $this->sSql = ''; $this->aValues = []; }
Clean out the query variables. You can do this to build another query. @return void
clean
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Record.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Record.class.php
MIT
public function getOne($sTable, $sField = null, $sId = null, $sWhat = '*', $sOptions = null) { try { $bIsWhere = isset($sField, $sId); $this->sSql = 'SELECT ' . $sWhat . ' FROM' . Db::prefix($sTable); if ($bIsWhere) { $this->sSql .= "WHERE $sField = :id "; } if (!empty($sOptions)) { $this->sSql .= " $sOptions "; } $this->sSql .= 'LIMIT 0,1'; // Get only one column $rStmt = Db::getInstance()->prepare($this->sSql); if ($bIsWhere) { $rStmt->bindParam(':id', $sId); } $rStmt->execute(); $mRow = $rStmt->fetch(PDO::FETCH_OBJ); Db::free($rStmt); return $mRow; } catch (Exception $oE) { $this->aErrors[] = $oE->getMessage(); } }
Select query and return one value result. @param string $sTable @param string|null $sField Default: NULL @param string|null $sId Default: NULL @param string $sWhat Default: '*' @param string|null $sOptions Default: NULL @return string|stdClass|bool SQL query on success (returns string or stdClass values) or throw PDOException on failure (returns a false boolean).
getOne
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Record.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Record.class.php
MIT
public function find($sField, $sValue) { $this->where($sField, $sValue, '='); return $this; }
Find in SQL column(s) (with where clause). @see self::where() @param string $sField @param string $sValue @return self
find
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Record.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Record.class.php
MIT
protected function optClause($sClsName, $sField, $sVal, $sOpt) { $sVal = $this->escape($sVal); $this->sSql .= " $sClsName $sField $sOpt $sVal"; return $this; }
Add a clause with operator and escape the input value. @param string $sClsName Clause operator. @param string $sField Field @param string $sVal Value. @param string $sOpt Operator. @return self
optClause
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Record.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Record.class.php
MIT
public function restoreArchive() { $rArchive = gzopen($this->sPath, 'r'); $sSqlContent = ''; while (!feof($rArchive)) { $sSqlContent .= gzread($rArchive, filesize($this->sPath)); } gzclose($rArchive); $sSqlContent = str_replace(PH7_TABLE_PREFIX, Db::prefix(), $sSqlContent); $oDb = Db::getInstance(); $rStmt = $oDb->exec($sSqlContent); unset($sSqlContent); return $rStmt === false ? print_r($oDb->errorInfo(), true) : true; }
Restore the gzip compressed archive backup. @return bool|string Returns TRUE if there are no errors, otherwise returns "the error message".
restoreArchive
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Model/Engine/Util/Backup.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Model/Engine/Util/Backup.class.php
MIT
public function getMethod() { return $this->getRequestMethod(); }
Get method (alias of Http::getRequestMethod() ). @return string 'GET', 'POST', 'HEAD', 'PUT'
getMethod
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function getUri() { return $this->getRequestUri(); }
Get Request URI (alias of Http::getRequestUri() ). @return string
getUri
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function getExists($mKey, $sParam = null) { $bExists = false; // Default value if (is_array($mKey)) { foreach ($mKey as $sKey) { if (!$bExists = $this->getExists($sKey, $sParam)) { break; } } } else { if (!$this->validate($this->aGet, $mKey, $sParam)) { return false; } $bExists = isset($this->aGet[$mKey]); } return $bExists; }
Check is the request method GET exists. @param array|string $mKey The key of the request or an array with the list of key of the variables request. @param string $sParam Optional, check the type of the request variable | Value types are: str, int, float, bool @return bool
getExists
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function postExists($mKey, $sParam = null) { $bExists = false; // Default value if (is_array($mKey)) { foreach ($mKey as $sKey) { if (!$bExists = $this->postExists($sKey, $sParam)) { break; } } } else { if (!$this->validate($this->aPost, $mKey, $sParam)) { return false; } $bExists = isset($this->aPost[$mKey]); } return $bExists; }
Check is the POST request method exists. @param array|string $mKey The key of the request or an array with the list of key of the variables request. @param string $sParam Optional, check the type of the request variable | Value types are: str, int, float, bool @return bool
postExists
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function sets($sKey, $sValue) { $this->setGet($sKey, $sValue); $this->setPost($sKey, $sValue); }
Sets a variable in the GET and POST request. @param string $sKey @param string $sValue @return void
sets
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function setGet($sKey, $sValue) { $this->setRequestVar($this->aGet, $sKey, $sValue); }
Add a variable in the GET request. @param string $sKey @param string $sValue @return void
setGet
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function setPost($sKey, $sValue) { $_SERVER['REQUEST_METHOD'] = self::METHOD_POST; $this->setRequestVar($this->aPost, $sKey, $sValue); }
Add a variable in the POST request. @param string $sKey @param string $sValue @return void
setPost
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
public function gets($sKey, $sParam = null) { if ($this->getExists($sKey, $sParam)) { return $this->get($sKey, $sParam); } if ($this->postExists($sKey, $sParam)) { return $this->post($sKey, $sParam); } return ''; }
$_GET and $_POST request type. @param string $sKey @param string $sParam Optional, set a type of the request | Value types are: str, int, float, bool, self::ONLY_XSS_CLEAN, or self::NO_CLEAN @return string Uses Str::escape() method to secure the data display unless you specified the constant "self::ONLY_XSS_CLEAN" or "self::NO_CLEAN"
gets
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
protected function validate(&$aType, $sKey, $sParam) { if (!empty($sParam) && !Secty\Validate\Validate::type($aType[$sKey], $sParam)) { return false; } return true; }
Check is a request variable is valid. @param array $aType Request variable type ($_GET, $_POST, $_COOKIE, $_REQUEST). @param string $sKey @param string $sParam @return bool Returns TRUE if the type of the variable is valid, FALSE otherwise.
validate
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
protected function checkType(&$aType, $sKey, $sType) { if (!empty($sType) && $sType !== self::ONLY_XSS_CLEAN) { settype($aType[$sKey], $sType); } }
Set the type of a request variable of eligible. @param array $aType Request variable type ($_GET, $_POST, $_COOKIE, $_REQUEST). @param string $sKey @param string $sType A PHP Type: "bool", "int", "float", "string", "array", "object" or "null". @return void
checkType
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
private function clearCSRFToken(&$aType, $sKey) { return preg_replace( '#(\?|&)' . Secty\CSRF\Token::VAR_NAME . '\=[^/]+$#', '', $aType[$sKey] ); }
Clear the CSRF token in the request variable name. @param array $aType Request variable type ($_GET, $_POST, $_COOKIE, $_REQUEST). @param string $sKey The request variable to clean. @return string
clearCSRFToken
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Mvc/Request/Http.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Mvc/Request/Http.class.php
MIT
protected function setUrlData($sName, $sValue) { $this->sRequest .= '&' . $sName . '=' . Url::encode($sValue); return $this; }
Set data URL e.g., "&key=value" @param string $sName @param string $sValue @return self
setUrlData
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Payment/Gateway/Api/PayPal.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Payment/Gateway/Api/PayPal.class.php
MIT
private static function get() { $aSuggestions = file(PH7_PATH_APP_CONFIG . static::DIR . self::$sFile); // It removes all spaces, line breaks, ... $aSuggestions = array_map('trim', $aSuggestions); return implode('\',\'', $aSuggestions); }
Generic method to to pick and translate words. @return string The transform words.
get
php
pH7Software/pH7-Social-Dating-CMS
_protected/framework/Service/Suggestion.class.php
https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Service/Suggestion.class.php
MIT