Exemplo n.º 1
0
 /**
  * Will return sticky articles by the given category name, page and sorting;
  *
  * This method will return all articles in the given combination of category name and page limits. It can be used to display
  * articles in a category like manner by just giving two parameters obligatory. It can be used for article pages, where a
  * string of articles is needed to be displayed;
  *
  * @param S $objCategoryURL The category URL;
  * @param S $objPageInt The page to limit to;
  * @param S $objOrdering What kind of ordering;
  * @return array The result array;
  */
 public function getStickyArticlesByCategoryURLAndPage(S $objCategoryURL, S $objPageInt, S $objOrdering = NULL)
 {
     // Do return ...
     return $this->getArticlesByCategoryURL($objCategoryURL, _S('AND %objArticleTableFState = "%Sd"
     ORDER BY %objArticleTableFDatePublished %TypeOfOrdering LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', ((int) $objPageInt->toString() - 1) * (int) self::$objItemsPerPage->toString())->doToken('%UpperLimit', (int) self::$objItemsPerPage->toString())->doToken('%TypeOfOrdering', $objOrdering == NULL ? new S('DESC') : $objOrdering)->doToken('%Sd', self::STATE_STICKY));
 }
Exemplo n.º 2
0
 /**
  * Writes the .htaccess file only if there is a difference between the current imploded string and the file source. This method is
  * a private method used to write the .htaccess file only if there is a difference between the imploded string (from the internal
  * htArray variable) and the file source. If the two strings differ, then we rewrite the .htaccess file.
  *
  * @param S $htString The string, parsed from file array to be written
  * @return B Will return true if the file was written
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 07_APC.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access private
  * @static
  */
 private static function writeHTFile(S $htString)
 {
     // Do a quick .htaccess write;
     if ($htFile = fopen(DOCUMENT_ROOT . '.htaccess', 'w')) {
         fwrite($htFile, $htString->toString());
         fclose($htFile);
         // Do return ...
         return new B(TRUE);
     } else {
         // Error me proudly;
         self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_WRITE_HTACCESS), new S(CANNOT_WRITE_HTACCESS_FIX));
     }
 }
Exemplo n.º 3
0
 /**
  * Will parse the URL into an associative array. This method will get the current URL string and parse it in an associative array
  * that we can then insert in the _GET superglobal to work with. It's an internal private method not used by non-core developers.
  *
  * @param I $segmentNumber The number of the segment to get from;
  * @return A The associative array, parsed from the URL, as key/var pairs;
  * @author Elena Ramona <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 09_URL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access private
  * @static
  * @final
  */
 private static final function associativeFromURL(I $segmentNumber)
 {
     $getURLSegments = new A(array_slice(self::$objGETURLSegment->toArray(), $segmentNumber->toInt() - 1));
     $i = new I(0);
     $lastURLVar = new S(_NONE);
     $returnedArray = new A();
     foreach ($getURLSegments as $v) {
         if ($i->toInt() % 2) {
             $returnedArray[$lastURLVar->toString()] = $v;
         } else {
             $returnedArray[$v] = new B(FALSE);
             $lastURLVar->setString($v);
         }
         // Increment;
         $i->doInc();
     }
     // Do return ...
     return $returnedArray;
 }
Exemplo n.º 4
0
 public function getProductsByPage(S $objPageInt, S $objOrdering = NULL)
 {
     // Do return ...
     return $this->getProducts(_S('ORDER BY %objProductsTableFId %TypeOfOrdering LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', ((int) $objPageInt->toString() - 1) * (int) self::$objItemsPerPage->toString())->doToken('%UpperLimit', (int) self::$objItemsPerPage->toString())->doToken('%TypeOfOrdering', $objOrdering == NULL ? new S('DESC') : $objOrdering));
 }
Exemplo n.º 5
0
 /**
  * Will unset a _SESSION variable, checking that it has been set first. To actually unset a _SESSION variable you need to make sure
  * that the variable was set at first, or this function would just execute and return FALSE. We provide it as an OOP way to manage
  * the _SESSION superglobal in a way that gives the developer more control over the data stored in the _SESSION;
  *
  * @param S $theKey The key to be set in the _SESSION
  * @return B Will return true if the key/var pair are set
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 06_SES.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access protected
  * @static
  * @final
  */
 protected static final function unsetSessionVar(S $theKey)
 {
     if (isset($_SESSION[PROJECT_NAME . _U . $theKey->toString()])) {
         $_SESSION[PROJECT_NAME . _U . $theKey->toString()] = _NONE;
         unset($_SESSION[PROJECT_NAME . _U . $theKey->toString()]);
         // Do return ...
         return new B(TRUE);
     } else {
         // Do return ...
         return new B(FALSE);
     }
 }
Exemplo n.º 6
0
 /**
  * Will set an object variable in the .php file to be extracted in the .tp file, and used there. This method, similar to the
  * popular Smarty->assign, is the method that will assign variables to the template file to be executed. You need to specify
  * the name of the variable inside the execution loop;
  *
  * @param M $tpVar The variable to be set for the current .tp
  * @param S $tpVarString The name of the variable that will be set
  * @param S $tpFileName Path to the .tp file where to set the requested variables
  * @param S $tpAction What action to take on the variable
  * @return M Will return a mixed result (either false/true or string, depends)
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 10_TPL.php 315 2009-10-11 07:11:31Z catalin.zamfir $
  * @since Version 1.0
  * @access public
  * @static
  * @final
  */
 public static final function tpSet(M $tpVar, S $tpVarString, FilePath $tpFileName, S $tpAction = NULL)
 {
     // Set .tp vars;
     if ($tpFileName->checkPathExists()) {
         // Set the variable, taking tpAction in consideration;
         if ($tpAction != NULL) {
             switch ($tpAction->toString()) {
                 case 'capitalize':
                     // Make it an S, so we can be sure it's a string;
                     $tpVar = new S($tpVar);
                     // Capitalize it, with strtoupper ();
                     self::$objFilePathArray[$tpFileName][$tpVarString] = $tpVar->toUpper();
                     break;
                 case 'explode':
                     if ($tpVar instanceof A) {
                         foreach ($tpVar as $k => $v) {
                             // Parse every array key as a .tp variable;
                             self::$objFilePathArray[$tpFileName][$k] = $v;
                         }
                     } else {
                         self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_WORK_ON_NON_ARRAY), new S(CANNOT_WORK_ON_NON_ARRAY_FIX));
                     }
                     break;
                     #################################################################
                     # Define other actions here!
             }
         } else {
             // Set an unmodified var, as-is;
             self::$objFilePathArray[$tpFileName][$tpVarString] = $tpVar;
         }
     } else {
         self::renderScreenOfDeath(new S(__CLASS__), new S(FILE_DOESNT_EXIST), new S(FILE_DOESNT_EXIST_FIX));
     }
 }
Exemplo n.º 7
0
    /**
     * Will render a requested widget;
     *
     * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this
     * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some
     * configuration options that control the way the widget functions or showns;
     *
     * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets
     * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place
     * the developer needs them;
     *
     * @param $objW The widget to render;
     * @return mixed Depends on the widget;
     */
    public function renderWidget(S $objW, A $objWA = NULL)
    {
        // Make an empty array if NULL ...
        if ($objWA == NULL) {
            $objWA = new A();
        }
        // XML & RSS: Do a switch ...
        switch ($objW) {
            case 'widgetXML':
                // Yo man ... woohoooooo ...
                foreach ($this->getApprovedAudioFiles(new S('ORDER
                BY %objAudioTableFUploadedDate DESC')) as $k => $v) {
                    // Set some requirements ...
                    $objDTE = date('Y-m-d', (int) $v[self::$objAudioTableFUploadedDate]->toString());
                    $objLOC = URL::staticURL(new A(array(AUDIO_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objAudioTableFSEO], FRONTEND_AUDIO_URL)));
                    // Get the (INNER) CHILD of every young SEO freak ...
                    $objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL);
                    // Set the XML Sitemap kids ...
                    $objURL->addCHILD(Frontend::XML_LOCATION, $objLOC);
                    $objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE);
                    $objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY);
                    $objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY);
                }
                // BK;
                break;
            case 'widgetRSS':
                // Yo man ... woohoooooo ...
                if ($_GET[FRONTEND_FEED_URL] == __CLASS__) {
                    // Get'em 30 ...
                    foreach ($this->getApprovedAudioFiles(new S('ORDER BY %objAudioTableFUploadedDate
                    DESC LIMIT 0, 30')) as $k => $v) {
                        // Set some requirements ...
                        $objDTE = date(DATE_RFC822, (int) $v[self::$objAudioTableFUploadedDate]->toString());
                        $objLOC = URL::staticURL(new A(array(AUDIO_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objAudioTableFSEO], FRONTEND_AUDIO_URL)));
                        $objTTL = $v[self::$objAudioTableFTitle]->appendString(_DCSP)->appendString($v[self::$objAudioTableFArtist])->appendString(_DCSP)->appendString($v[self::$objAudioTableFAlbum]);
                        $objDSC = $v[self::$objAudioTableFDescription]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags();
                        // Get the (INNER) CHILD of every young SEO freak ...
                        $objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM);
                        // Set the RSS kids ...
                        $objURL->addCHILD(Frontend::RSS_TITLE, $objTTL);
                        $objURL->addCHILD(Frontend::RSS_LINK, $objLOC);
                        $objURL->addCHILD(Frontend::RSS_GUID, $objLOC);
                        $objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE);
                        $objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC);
                    }
                }
                // BK;
                break;
        }
        // HTML: Do a switch ...
        switch ($objW) {
            case 'widgetCategoryList':
                // Set some requirements ...
                if (isset($objWA['cache_file'])) {
                    // Take the input;
                    $objCacheFile = $objWA['cache_file'];
                } else {
                    // Do cache me ...
                    $objCacheFile = new B(TRUE);
                }
                if (isset($objWA['cache_time'])) {
                    // Get the cache time from me;
                    $objCacheTime = $objWA['cache_time'];
                } else {
                    // Do a cache for: 6 hours;
                    $objCacheTime = new I(60 * 60 * 6);
                }
                // Set the template file ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), $objCacheTime, $objCacheFile)) {
                    // Get the category to start from ...
                    if (isset($objWA['start_from_category'])) {
                        // Get the category LIST;
                        $objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']);
                    } else {
                        // Get the category LIST;
                        $objCategoryList = $this->getCategories(NULL, NULL);
                    }
                    // Set the template file ...
                    TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetList':
                // Check some needed requirements ...
                if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_AUDIO_URL) {
                    // Set some requirements ...
                    $objPag = isset($_GET[AUDIO_PAGE_URL]) ? $_GET[AUDIO_PAGE_URL] : new S((string) 1);
                    $objPag = new I((int) $objPag->toString());
                    // Fixes for a bugged user ...
                    if ($objPag->toInt() == 0) {
                        // Make the proper header, at first ...
                        $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND));
                        // Give me back my free hardcore, Quoth the server, '404' ...
                        $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
                    } else {
                        // Make it a string again ...
                        $objPag = new S((string) $objPag->toInt());
                    }
                    // Get your switches on ...
                    if (isset($_GET[AUDIO_ITEM_URL])) {
                        // Check that the article exists, before doing anything stupid ...
                        if ($this->checkAudioFileURLIsUnique($objURL = $_GET[AUDIO_ITEM_URL])->toBoolean() == TRUE) {
                            // Make the proper header, at first ...
                            $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND));
                            // Give me back my free hardcore, Quoth the server, '404' ...
                            $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
                        } else {
                            // Make me SEO ... yah!
                            TPL::manageTTL($objTTL = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFTitle));
                            TPL::manageTTL($objART = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFArtist));
                            TPL::manageTTL($objALB = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFAlbum));
                            // SEO my category, little one ...
                            TPL::manageTTL($objCAT = MPTT::mpttRemoveUnique($this->getCategoryInfoById($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFCategoryId), self::$objCategoryTableFName)));
                            // Get the published date ... we need it;
                            $objPBL = new S(date(self::$objFrontend->STG->getConfigKey(new S('settings_default_date_format')), (int) $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFUploadedDate)->toString()));
                            // Get the keywords ...
                            $objKEY = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFDescription)->entityDecode(ENT_QUOTES)->stripTags();
                            // Get the description ...
                            $objDSC = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFDescription)->entityDecode(ENT_QUOTES)->stripTags();
                            // Cut it down to size ...
                            if ($objDSC->toLength()->toInt() > META_DESCRIPTION_MAX) {
                                $objDSC->doSubStr(0, META_DESCRIPTION_MAX)->appendString(_SP)->appendString(_DTE);
                            }
                            if ($objKEY->toLength()->toInt() > META_DESCRIPTION_MAX) {
                                $objKEY->doSubStr(0, META_DESCRIPTION_MAX)->appendString(_SP)->appendString(_DTE);
                            }
                            // Only description if it's bigger ...
                            if ($objDSC->toLength()->toInt() != 0) {
                                $objDSC = $objDSC->prependString($objWA['audio_description'])->prependString(', ');
                            }
                            // Get the description ... but prepend it with the Title, Artist, Album ...
                            $objDSC->prependString($objPBL)->prependString($objWA['audio_uploaded_at'])->prependString(', ')->prependString($objCAT)->prependString($objWA['audio_genre'])->prependString(', ')->prependString($objALB)->prependString($objWA['audio_album'])->prependString(', ')->prependString($objART)->prependString($objWA['audio_artist'])->prependString(', ')->prependString($objTTL)->prependString($objWA['audio_title']);
                            // Add them LYRICS ...
                            if ($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFLyrics)->toLength()->toInt() != 0) {
                                // Yes ...
                                $objHasLrc = new S('Da');
                            } else {
                                // Nop ...
                                $objHasLrc = new S('Nu');
                            }
                            // Add them DESCRIPTIONS ...
                            if ($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFDescription)->toLength()->toInt() != 0) {
                                // Yes ...
                                $objHasDsc = new S('Da');
                            } else {
                                // Nop ...
                                $objHasDsc = new S('Nu');
                            }
                            // Modify the DESCRIPTION ...
                            $objDSC->appendString(', ')->appendString($objWA['audio_lyrics'])->appendString($objHasLrc);
                            $objDSC->appendString(', ')->appendString($objWA['audio_description'])->appendString($objHasDsc);
                            // Add the TAG, as we have description ...
                            TPL::manageTAG(new S('description'), $objDSC->entityEncode(ENT_QUOTES));
                            // Add the TAG, as we have keywords ...
                            if ($objKEY->toLength()->toInt() != 0) {
                                TPL::manageTAG(new S('keywords'), $objKEY->eregReplace('[^a-zA-Z0-9 -]', _NONE)->eregReplace(_SP, ', ')->eregReplace(', ,', ',')->entityEncode(ENT_QUOTES));
                            }
                            // Set some requirements ...
                            $objPathToItem = self::$objMPTT->mpttGetSinglePath($this->getCategoryInfoById($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFCategoryId), self::$objCategoryTableFName));
                            // Update them views ...
                            $this->_Q(_QS('doUPDATE')->doToken('%table', self::$objAudioTable)->doToken('%condition', new S('%objAudioTableFViews = %objAudioTableFViews + 1
							WHERE %objAudioTableFSEO = "%Id"'))->doToken('%Id', $objURL));
                            // Set the template file ...
                            $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item' . TPL_EXTENSION);
                            TPL::tpSet($objPathToItem, new S('objPathToItem'), $tpF);
                            TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                            TPL::tpSet($objURL, new S('objURL'), $tpF);
                            TPL::tpSet($this->ATH, new S('ATH'), $tpF);
                            TPL::tpSet($this->STG, new S('STG'), $tpF);
                            TPL::tpSet($this, new S('AUD'), $tpF);
                            TPL::tpExe($tpF);
                        }
                    } else {
                        if (isset($_GET[AUDIO_CATEGORY_URL])) {
                            // Check that the category exists, before doing anything stupid ...
                            if ($this->checkCategoryURLIsUnique($objCat = $_GET[AUDIO_CATEGORY_URL])->toBoolean() == TRUE) {
                                // Make the proper header, at first ...
                                $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND));
                                // Give me back my free hardcore, Quoth the server, '404' ...
                                $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
                            } else {
                                // Do me SEO, yah baby! ...
                                TPL::manageTTL(MPTT::mpttRemoveUnique($this->getCategoryInfoByURL($objCat, self::$objCategoryTableFName)));
                                // Make a condition to avoid dup. title tags on different pages ...
                                if ((int) $objPag->toString() >= 1 && isset($_GET[AUDIO_PAGE_URL])) {
                                    TPL::manageTTL(_S(AUDIO_PAGE_URL)->appendString(_SP)->appendString($objPag));
                                }
                                // Set some requirements ...
                                $objCnt = $this->getApprovedAudioFileCountForCategoryURL($objCat);
                                $objArt = $this->getApprovedAudioFilesByCategoryURLAndPage($objCat, $objPag);
                            }
                        } else {
                            if (isset($_GET[AUDIO_SEARCH_URL])) {
                                // Get audio by page ...
                                $objCnt = $this->getApprovedAudioFileCountForSearch($_GET[AUDIO_SEARCH_URL]);
                                $objArt = $this->getApprovedAudioFilesByPageAndSearch($objPag, $_GET[AUDIO_SEARCH_URL]);
                            } else {
                                // Do me SEO, yah baby! ...
                                TPL::manageTTL(_S(FRONTEND_AUDIO_URL));
                                // Make a condition to avoid dup. title tags on different pages ...
                                if ((int) $objPag->toString() >= 1 && isset($_GET[AUDIO_PAGE_URL])) {
                                    TPL::manageTTL(_S(AUDIO_PAGE_URL)->appendString(_SP)->appendString($objPag));
                                }
                                // Set some requirements ...
                                $objArt = $this->getApprovedAudioFilesByPage($objPag);
                                $objCnt = $this->getApprovedAudioFileCount();
                            }
                        }
                        // Set the template file ...
                        $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                        TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                        TPL::tpSet($objArt, new S('objAr'), $tpF);
                        TPL::tpExe($tpF);
                        // Set them paginations ...
                        if ($objCnt->toInt() > (int) self::$objItemsPerPage->toString()) {
                            self::$objFrontend->setPagination($objCnt, new I((int) self::$objItemsPerPage->toString()));
                        }
                    }
                } else {
                    // Do the biggest error on the PLANET ...
                    self::renderScreenOfDeath(new S(__CLASS__), new S(AUDIO_NEED_PROPER_SECTION), new S(AUDIO_NEED_PROPER_SECTION_FIX));
                }
                // BK;
                break;
            case 'widgetComments':
                // Check if we have the proper URL enabled ...
                if (isset($_GET[AUDIO_ITEM_URL])) {
                    // Check if the comments are enabled ...
                    if ($this->getAudioFileInfoByURL($objURL = $_GET[AUDIO_ITEM_URL], self::$objAudioTableFCanComment) == 'Y') {
                        // Set some requirements ...
                        $objCommentIsOk = new S();
                        $objComments = $this->getApprovedCommentsByAudioFileURL($_GET[AUDIO_ITEM_URL], new S('ORDER BY %objCommentsTableFDate DESC'));
                        // Check for status ...
                        if (isset($_GET[AUDIO_STATUS_URL])) {
                            if ($_GET[AUDIO_STATUS_URL] == AUDIO_STATUS_OK_URL) {
                                $objCommentIsOk = new S($objWA['comment_has_been_added']);
                            }
                        }
                        // Set the template file ...
                        $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                        TPL::tpSet($objCommentIsOk, new S('objCommentIsOk'), $tpF);
                        TPL::tpSet($objComments, new S('objComments'), $tpF);
                        TPL::tpSet($this->STG, new S('STG'), $tpF);
                        TPL::tpSet($this->ATH, new S('ATH'), $tpF);
                        TPL::tpExe($tpF);
                        // Set some requirements ...
                        $objShowFrm = new B(TRUE);
                        // Check if we're allowed to show the comment form ...
                        if ($this->getConfigKey(new S('audio_settings_audio_auth_to_comment')) == 'Y') {
                            if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) {
                                // To show ... or not ...
                                $objShowFrm = new B(TRUE);
                            } else {
                                // to show ... or not ...
                                $objShowFrm = new B(FALSE);
                            }
                        }
                        // Do some work ...
                        if ($objShowFrm->toBoolean() == TRUE) {
                            if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) {
                                if ($this->getPOST(self::$objCommentsTableFComment)->toLength()->toInt() == 0) {
                                    $this->setErrorOnInput(self::$objCommentsTableFComment, new S($objWA['error_no_comment']));
                                }
                            }
                            if ($this->checkPOST(self::$objCommentsTableFName)->toBoolean() == TRUE) {
                                if ($this->getPOST(self::$objCommentsTableFName)->toLength()->toInt() == 0) {
                                    $this->setErrorOnInput(self::$objCommentsTableFName, new S($objWA['error_no_name']));
                                }
                            }
                            if ($this->checkPOST(self::$objCommentsTableFEML)->toBoolean() == TRUE) {
                                if ($this->getPOST(self::$objCommentsTableFEML)->toLength()->toInt() == 0) {
                                    $this->setErrorOnInput(self::$objCommentsTableFEML, new S($objWA['error_no_email']));
                                }
                            }
                            // Make the form ... (ya, outside the box ...);
                            $this->setMethod(new S('POST'))->setFieldset(new S($objWA['comment_add']))->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objCommentsTableFId);
                            if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) {
                                $this->setRedirect(URL::rewriteURL(new A(array(AUDIO_STATUS_URL)), new A(array(AUDIO_STATUS_OK_URL))));
                            }
                            $this->setName(new S('commentForm'))->setExtraUpdateData(self::$objCommentsTableFDate, new S((string) time()))->setExtraUpdateData(self::$objCommentsTableFAudioFileId, $this->getAudioFileInfoByURL($_GET[AUDIO_ITEM_URL], self::$objAudioTableFId))->setInputType(new S('submit'))->setValue(new S($objWA['comment_submit']))->setName(new S('submit'))->setContainerDiv(new B(TRUE));
                            // Check if the user is authenticated ...
                            if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) {
                                // Set the RUId;
                                $this->setExtraUpdateData(self::$objCommentsTableFRUId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId));
                            } else {
                                // Set the other infos;
                                $this->setInputType(new S('text'))->setName(self::$objCommentsTableFName)->setLabel(new S($objWA['comment_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFEML)->setLabel(new S($objWA['comment_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFURL)->setLabel(new S($objWA['comment_website']))->setContainerDiv(new B(TRUE));
                            }
                            // Continue ...
                            $this->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S($objWA['comment_message']))->setRows(new S('10'))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE));
                            // Notify ...
                            if ($this->checkFormHasErrors()->toBoolean() == FALSE && $this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) {
                                if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) {
                                    // Query the authentication ...
                                    $objUSR = $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName);
                                } else {
                                    // Or trust the FORM ...
                                    $objUSR = $this->getPOST(self::$objCommentsTableFName);
                                }
                                // Go and SP ... MAIL me ...
                                $objMAIL = new MAIL();
                                $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsCommentPosted'))->doToken('%t', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFTitle))->doToken('%a', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFArtist))->doToken('%b', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFAlbum))->doToken('%u', $objUSR));
                                // Go deeper and notify them users ...
                                $objCommentsForItem = $this->getCommentsByAudioFileURL($objURL);
                                foreach ($objCommentsForItem as $k => $v) {
                                    $objMAIL = new MAIL();
                                    $objMAIL->doMAIL($this->ATH->getUserInfoById($v[self::$objCommentsTableFRUId], Authentication::$objAuthUsersTableFEML), new S(AUDIO_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsCommentPostedFrontend'))->doToken('%t', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFTitle))->doToken('%a', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFArtist))->doToken('%b', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFAlbum))->doToken('%u', $objUSR)->doToken('%k', URL::rewriteURL()));
                                }
                            }
                            // End form and execute ...
                            $this->setFormEndAndExecute(new B(TRUE));
                        }
                    }
                }
                // BK;
                break;
            case 'widgetUploadForm':
                // Ya, checking the STATUS ...
                if (isset($_GET[AUDIO_STATUS_URL])) {
                    // Get me going my dear one ...
                    $objConfKey = new S('audio_settings_audio_form_page_status_ok');
                    $objShowFrm = new B(FALSE);
                } else {
                    // Get me going my dear one ...
                    $objConfKey = new S('audio_settings_audio_form_page');
                    $objShowFrm = new B(TRUE);
                }
                // If we're NOT authenticated ... bang, you're DEAD ...
                if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == FALSE) {
                    // Get me going my dear one ...
                    $objConfKey = new S('audio_settings_audio_form_not_authenticated');
                    $objShowFrm = new B(FALSE);
                }
                // Set the template file ...
                $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                TPL::tpSet($this->getConfigKey($objConfKey), new S('objContent'), $tpF);
                TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                TPL::tpSet($objShowFrm, new S('objShowForm'), $tpF);
                TPL::tpSet($this, new S('AUD'), $tpF);
                TPL::tpExe($tpF);
                break;
            case 'widgetLastN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('ORDER BY %objAudioTableFUploadedDate DESC LIMIT 0, %UpperLimit')->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objLastN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetRandomN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('ORDER BY RAND() LIMIT 0, %UpperLimit')->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objRandomN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetRelatedN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('AND %objAudioTableFArtist LIKE "%Id" LIMIT 0, %UpperLimit')->doToken('%Id', $this->getAudioFileInfoByURL($objWA['audio_song_item'], self::$objAudioTableFArtist))->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objRandomN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetTopN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('ORDER BY %objAudioTableFViews DESC LIMIT 0, %UpperLimit')->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objRandomN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetRandomItem':
                // Do some work ...
                if ($this->checkPOST(new S('search_random_item'))->toBoolean() == TRUE) {
                    // Get me there ... quick ...
                    $this->setHeaderKey(URL::staticURL(new A(array(AUDIO_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($this->getApprovedAudioFiles(_S('ORDER BY RAND() LIMIT 1'))->offsetGet(0)->offsetGet(self::$objAudioTableFSEO), FRONTEND_AUDIO_URL))), new S('Location'));
                }
                // Do the form, make it happen ...
                $this->setMethod(new S('POST'))->setName(new S('audioRandomItem'))->setInputType(new S('submit'))->setName(new S('search_random_item'))->setValue(new S($objWA['audio_random']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
                break;
        }
    }
Exemplo n.º 8
0
 /**
  * Will unset the given key;
  *
  * This method, after we are done with our information will clear the cookie information stored at that key. This for example,
  * in the authentication module will deauthenticate the user. Other uses can be thought of in other modules;s
  *
  * @param S $objKey The key to unset;
  * @return boolean Will return true if it was able to unset the key;
  */
 public function unSetKey(S $objKey)
 {
     switch ($this->objObjectCookie->getConfigKey(new S('authentication_cookie_store_type'))) {
         case 'cookie':
             // Trigger the browser cookie cleaning mechanism;
             $expTme = new I($_SERVER['REQUEST_TIME'] - 31556926);
             // Re-set the cookie;
             setcookie($this->objProjectString . _U . $this->objObjectCookie->getObjectCLASS() . _U . $objKey, new S(), $expTme->toInt(), new S('/'));
             break;
         case 'session':
             // Do unset ...
             unset($_SESSION[$this->objProjectString->toString()][$this->objObjectCookie->getObjectCLASS()->toString()][$objKey->toString()]);
             break;
         default:
             // Make an error on it, cause yeah ...
             self::renderScreenOfDeath(new S(__CLASS__), new S(SESSION_TYPE_ERROR), new S(SESSION_TYPE_ERROR_FIX));
             break;
     }
     // Do return ...
     return new B(TRUE);
 }
Exemplo n.º 9
0
 /**
  * Will return a MySQL Resource, containing the result of the passed SQL. This method will query the database and return the
  * MySQL resource which will get processed and transformed into a specifc RA array (A) that you can then access for information
  * you actually need;
  *
  * @param S $queryString The query string to be queried
  * @param S $queryField The field name (unique) to index by
  * @return A The returned query resource
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 11_SQL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access public
  * @static
  */
 public static function getQuery(S $queryString, S $queryFieldId = NULL)
 {
     // Get the MySQL result, or go an echo an error screen if it failed ...
     $queryResource = new O(mysql_query($queryString->doToken(SQL_PREFIX, self::$objSQLR)));
     // Do another checking for FALSE, and return what's needed ...
     if ($queryResource->checkIs('res')->toBoolean()) {
         $queryResourceSet = new R($queryResource->toMix());
         $arrayResourceSet = new A();
         if ($queryFieldId == NULL) {
             // Set the indexer to minus 1, so we can ++i;
             $i = -1;
             // Do the looping ...
             while ($r = self::getQueryResultRow($queryResourceSet)) {
                 // MySQL: Numeric ...
                 $arrayResourceSet[++$i] = $r;
             }
             // Just do it;
             return $arrayResourceSet;
         } else {
             // Do the looping ...
             while ($r = self::getQueryResultRow($queryResourceSet)) {
                 // MySQL: Associative ...
                 $arrayResourceSet[$r[$queryFieldId->toString()]] = $r;
             }
             // Just return, we know what it is;
             return $arrayResourceSet;
         }
     } else {
         if ($queryResource->checkIs('bln')->toBoolean()) {
             if ($queryResource->toMix() == TRUE) {
                 // Return TRUE, is not a resource ...
                 return new B(TRUE);
             } else {
                 // Return FALSE, output error screen;
                 self::renderSQLScreenOfDeath();
             }
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Will set a key/var pair, like 'gzip', 'Content-encoding'. We use such a method so we can have a single point where we can globally
  * modify the way our headers are sent to the browser or the client, thus having control over what's done and in what circumstances,
  * as the HTTP protocol works by sending and receiving headers, mechanism that is the SOUL of our Web-enabled applications;
  * <code>
  * <?php
  *		// Ex: redirect the client ...
  *		HDR::setHeaderKey (new S ('http://google.ro'), new S ('Location'));
  * ?>
  * </code>
  *
  * @param S $headerContent The content to be set for the header key
  * @param S $headerType The header key to be set
  * @return B Will return true if the headers have been set
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @link http://php.net/header
  * @version $Id: 05_HDR.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access public
  * @static
  * @final
  */
 public static final function setHeaderKey(S $headerContent, S $headerType)
 {
     // Check if we've sent ANY headers;
     if (headers_sent()) {
         // Error me proudly;
         self::renderScreenOfDeath(new S(__CLASS__), new S(HEADERS_ALREADY_SENT), new S(HEADERS_ALREADY_SENT_FIX));
     } else {
         // Add the HEADER, to the current page;
         switch ($headerType) {
             case 'Location':
                 // CALL the PHP function & exit ...
                 header($headerType->toString() . _CL . $headerContent->toString());
                 // Empty the _SESSION
                 if (isset($_SESSION['POST'])) {
                     unset($_SESSION['POST']);
                 }
                 // Empty the __FILES
                 if (isset($_SESSION['FILES'])) {
                     unset($_SESSION['FILES']);
                 }
                 // Exit!;
                 exit(0);
                 // BK;
                 break;
             default:
                 // CALL the PHP function ...
                 header($headerType->toString() . _CL . $headerContent->toString());
                 // BK;
                 break;
         }
         // Do return ...
         return new B(TRUE);
     }
 }
Exemplo n.º 11
0
 /**
  * Will execute necessary SQL operations on the current form ...
  *
  * This method, setSQLOperationsOnForm, you don't need to know the internal workings of it. This is because, as you can see
  * it is a private method, and thus, it's used internally by the class, to achieve it's goals of execution. Just pass on
  * and read any other 'public' or 'protected' method out there ...
  *
  * @param array $inputAttributes The core attributes (found in every HTML element) that can be set;
  * @param string $tp The path to the .tp file where to set those variables;
  */
 private static function moveFILEUploads()
 {
     if (isset(self::$objFormDataContainer['upload_dir'])) {
         $uploadDirectory = DOCUMENT_ROOT . UPLOAD_DIR . _S . self::$objFormDataContainer['upload_dir'] . _S;
         if (!is_dir($uploadDirectory)) {
             // Issue a mkdir, to make the directory;
             if (!mkdir($uploadDirectory, 0777, TRUE)) {
                 self::renderScreenOfDeath(new S(__CLASS__), new S(UPLOAD_ERROR), new S(UPLOAD_ERROR_FIX));
             }
         }
         // We use the /tmp/php*****, generated by php, which has a slash;
         self::$objImageTimestampPrefix = $_SERVER['REQUEST_TIME'];
         foreach ($_SESSION['FILES'] as $k => $v) {
             // Process the K ...
             $k = new S($k);
             $_SESSION['FILES'][$k->toString()]['name'] = new S(self::$objImageTimestampPrefix . _U . $_SESSION['FILES'][$k->toString()]['name']);
             $_SESSION['FILES'][$k->toString()]['name'] = self::sanitizePATH($_SESSION['FILES'][$k->toString()]['name']);
             // Process uploaded files, so that they contain the prefix;
             $uploadInputFromPOST = new S(self::$objImageTimestampPrefix . _U . self::getPOST($k));
             $uploadInputFromPOST = self::sanitizePATH($uploadInputFromPOST);
             self::setPOST($k, $uploadInputFromPOST);
             $uploadedFileMovedToDirectory = $uploadDirectory . $_SESSION['FILES'][$k->toString()]['name'];
             // Do something specific for WIN ...
             if (WIN == TRUE) {
                 $_SESSION['FILES'][$k->toString()]['tmp_name'] = new S($_SESSION['FILES'][$k->toString()]['tmp_name']);
                 $_SESSION['FILES'][$k->toString()]['tmp_name']->doToken(DIRECTORY_SEPARATOR, _S);
                 $_SESSION['FILES'][$k->toString()]['tmp_name']->doToken(dirname(dirname(DOCUMENT_ROOT)), _NONE);
                 $temporaryDirectory = new S(DOCUMENT_ROOT . UPLOAD_DIR . $_SESSION['FILES'][$k->toString()]['tmp_name']);
                 rename($temporaryDirectory, $uploadedFileMovedToDirectory);
             } else {
                 // Rename, on Linux;
                 $temporaryDirectory = new S(DOCUMENT_ROOT . UPLOAD_DIR . $_SESSION['FILES'][$k->toString()]['tmp_name']);
                 rename($temporaryDirectory, $uploadedFileMovedToDirectory);
             }
         }
     } else {
         self::renderScreenOfDeath(new S(__CLASS__), new S(UPLOAD_DIR_NOT_SPECIFIED), new S(UPLOAD_DIR_NOT_SPECIFIED_FIX));
     }
 }
Exemplo n.º 12
0
 /**
  * Checks to see if whether a given method string is_callable, else outputs an error. In certain cases we are actually needed to
  * check that a method is callable before we actually even try to call it. In the case of our framework, due to interfaces taht
  * allow us to define a rigid architecture, this is going to rarelly be a case, but in the context of objects that are serialized
  * back and forward and retrieved from different sources, such a check my be adequate;
  * <code>
  * <?php
  * 		// Check a method ...
  *		if (EXE::checkMethodIsCallable (new S ('getExeTime'))) {
  *			// cause we're here, do something;
  *		}
  * ?>
  * </code>
  *
  * @param S $methodName The name of the method to check for callability
  * @return B Will return true if method is callable
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 02_EXE.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access protected
  * @static
  * @final
  */
 protected static final function checkMethodIsCallable(S $methodName)
 {
     // Check if the method is callable;
     if (is_callable($methodName->toString())) {
         // Do return ...
         return new B(TRUE);
     } else {
         // Make an error ...
         self::renderScreenOfDeath(new S(__CLASS__), new S(FATAL_ERROR), new S(FATAL_ERROR_CHECK_LOG), new S(METHOD_IS_NOT_CALLABLE));
     }
 }