Beispiel #1
0
 function test_clear()
 {
     $s1 = new QString("hello");
     $s1->clear();
     $this->assertEquals($s1->__toString(), "", "Could not clear()!");
     echo "\ntesting QString::clear() passed";
 }
 /**
  * Given a string, this will create a sanitized token for it
  * @param string $strTokenCandidate
  * @return string
  */
 public static function SanitizeForToken($strTokenCandidate)
 {
     $strTokenCandidate = trim(strtolower($strTokenCandidate));
     $intLength = strlen($strTokenCandidate);
     $strToReturn = '';
     for ($intChar = 0; $intChar < $intLength; $intChar++) {
         $strChar = $strTokenCandidate[$intChar];
         $intOrd = ord($strChar);
         if ($intOrd >= ord('a') && $intOrd <= ord('z')) {
             $strToReturn .= $strChar;
         } else {
             if ($intOrd >= ord('0') && $intOrd <= ord('9')) {
                 $strToReturn .= $strChar;
             } else {
                 if ($strChar == ' ' || $strChar == '.' || $strChar == ':' || $strChar == '-' || $strChar == '/' || $strChar == '(' || $strChar == ')' || $strChar == '_') {
                     $strToReturn .= '_';
                 }
             }
         }
     }
     // Cleanup leading and trailing underscores
     while (QString::FirstCharacter($strToReturn) == '_') {
         $strToReturn = substr($strToReturn, 1);
     }
     while (QString::LastCharacter($strToReturn) == '_') {
         $strToReturn = substr($strToReturn, 0, strlen($strToReturn) - 1);
     }
     // Cleanup Dupe Underscores
     while (strpos($strToReturn, '__') !== false) {
         $strToReturn = str_replace('__', '_', $strToReturn);
     }
     return $strToReturn;
 }
 public static function DisplayAsHtml($strContent)
 {
     // Let's get started
     $strResult = null;
     // Normalize all linebreaks and tabs
     $strContent = str_replace("\r\n", "\n", $strContent);
     $strContent = str_replace("\t", "    ", $strContent);
     while ($strContent) {
         // See if we are declaring a special block
         $strMatches = array();
         // Any Blank Lines get processed as such
         if (QString::FirstCharacter($strContent) == "\n") {
             $strContent = substr($strContent, 1);
             $strResult .= "<br/>\n";
             // Any Blocks matched by the PatternBlock regexp should be processed as a block
         } else {
             if (preg_match(self::PatternBlock, $strContent, $strMatches) && count($strMatches) >= 3 && ($strProcessorResult = QTextStyleBlock::Process($strMatches, $strContent)) !== false) {
                 $strResult .= $strProcessorResult;
                 // Any ListBlocks matched by the PatternListBlock regexp should be processed as a listblock (uses the same QTSBP::Process method)
             } else {
                 if (preg_match(self::PatternListBlock, $strContent, $strMatches) && count($strMatches) >= 3 && ($strProcessorResult = QTextStyleBlock::Process($strMatches, $strContent)) !== false) {
                     $strResult .= $strProcessorResult;
                     // Finally, anything that doesn't match any of the above will be processed as "Default"
                 } else {
                     $strContent = QTextStyle::KeyDefault . '. ' . $strContent;
                 }
             }
         }
     }
     // Return the resulting HTML
     return $strResult;
 }
Beispiel #4
0
 public function setupUi($Dialog)
 {
     if ($Dialog->objectName()->isEmpty()) {
         $Dialog->setObjectName(QString::fromUtf8("Dialog"));
     }
     $size = new QSize(394, 311);
     $size = $size->expandedTo($Dialog->minimumSizeHint());
     $Dialog->resize($size);
     $this->buttonBox = new QDialogButtonBox($Dialog);
     $buttonBox = $this->buttonBox;
     // scope
     $buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
     $buttonBox->setGeometry(new QRect(40, 270, 341, 32));
     $buttonBox->setOrientation(Qt::Horizontal);
     $buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
     $this->textBrowser = new QTextBrowser($Dialog);
     $textBrowser = $this->textBrowser;
     // scope
     $textBrowser->setObjectName(QString::fromUtf8("textBrowser"));
     $textBrowser->setGeometry(new QRect(10, 10, 371, 211));
     $this->lineEdit = new QLineEdit($Dialog);
     $lineEdit = $this->lineEdit;
     // scope
     $lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
     $lineEdit->setGeometry(new QRect(10, 230, 371, 25));
     $this->retranslateUi($Dialog);
     QObject::connect($buttonBox, SIGNAL('accepted()'), $Dialog, SLOT('accept()'));
     QObject::connect($buttonBox, SIGNAL('rejected()'), $Dialog, SLOT('reject()'));
     QMetaObject::connectSlotsByName($Dialog);
 }
Beispiel #5
0
 public function Validate()
 {
     if (parent::Validate()) {
         if (trim($this->strText) != "") {
             $this->strText = trim($this->strText);
             $strOriginal = $this->strText;
             $strFinal = '';
             while (strlen($strOriginal)) {
                 if (is_numeric(QString::FirstCharacter($strOriginal))) {
                     $strFinal .= QString::FirstCharacter($strOriginal);
                 }
                 if (strtolower(QString::FirstCharacter($strOriginal)) == 'x') {
                     $strFinal .= 'x';
                 }
                 $strOriginal = substr($strOriginal, 1);
             }
             if (strlen($strFinal) == 10 && strpos($strFinal, 'x') === false) {
                 $this->strText = substr($strFinal, 0, 3) . '-' . substr($strFinal, 3, 3) . '-' . substr($strFinal, 6);
                 $this->strValidationError = null;
                 return true;
             }
             if (strlen($strFinal) > 11 && strpos($strFinal, 'x') == 10 && strpos($strFinal, 'x', 11) === false && strlen($strFinal) <= 17) {
                 $this->strText = substr($strFinal, 0, 3) . '-' . substr($strFinal, 3, 3) . '-' . substr($strFinal, 6, 4) . ' ' . substr($strFinal, 10);
                 $this->strValidationError = null;
                 return true;
             }
             $this->strValidationError = 'For example "213-555-1212" or "213-555-1212 x123"';
             return false;
         }
     } else {
         return false;
     }
     $this->strValidationError = null;
     return true;
 }
Beispiel #6
0
 /**
  * Get the HTML for this Control.
  * @return string
  */
 public function GetControlHtml()
 {
     // Pull any Attributes
     $strAttributes = $this->GetAttributes();
     // Pull any styles
     if ($strStyle = $this->GetStyleAttributes()) {
         $strStyle = 'style="' . $strStyle . '"';
     }
     // Return the HTML
     $strHtml = null;
     if (!$this->strFilePath) {
         $strHtml .= sprintf('<input type="button" class="button" id="%s_button" value="Browse"/>', $this->strControlId);
         $strHtml .= sprintf('<span id="%s_ospan"><iframe id="%s_iframe" scrolling="no" style="display: none;"></iframe></span>', $this->strControlId, $this->strControlId);
         $strHtml .= sprintf('<div class="progress" id="%s_progress" style="display: none;">', $this->strControlId);
         $strHtml .= sprintf('<div class="size" id="%s_size">n/a</div>', $this->strControlId);
         $strHtml .= '<div class="bar">';
         $strHtml .= sprintf('<div class="status" id="%s_status">Uploading...</div>', $this->strControlId);
         $strHtml .= sprintf('<div class="fill" id="%s_fill"></div>', $this->strControlId);
         $strHtml .= '</div>';
         $strHtml .= '<div class="cancel"><a href="#">Cancel</a></div>';
         $strHtml .= '</div>';
     } else {
         $strHtml .= sprintf('<strong>%s</strong> (%s) &nbsp; <a href="#" %s>Remove</a>', $this->strFileName, QString::GetByteSize($this->intFileSize), $this->pxyRemoveFile->RenderAsEvents(null, false));
     }
     return sprintf('<div id="%s" %s%s>%s</div>', $this->strControlId, $strAttributes, $strStyle, $strHtml);
 }
Beispiel #7
0
 protected function btnFirstSubmit_Click($strFormId, $strControlId, $strParameter)
 {
     if ($objPublicLogin = PublicLogin::LoadByUsername(trim(strtolower($this->txtUsername->Text)))) {
     } else {
         $this->txtUsername->Warning = 'Username does not exist';
         $this->txtUsername->Blink();
         $this->txtUsername->Focus();
         return;
     }
     $this->txtUsername->Visible = false;
     $this->btnFirstSubmit->Visible = false;
     $this->lblFirstMessage->Visible = true;
     $this->lblFirstMessage->HtmlEntities = false;
     $this->lblFirstMessage->Text = '<p>Before we can proceed, please answer the following security question that you specified when you registered for <strong>my.alcf</strong>.</p>';
     $this->lblQuestion->Visible = true;
     $this->lblQuestion->Name = 'Security Question';
     $this->lblQuestion->Text = $objPublicLogin->LostPasswordQuestion;
     if (QString::LastCharacter($objPublicLogin->LostPasswordQuestion) != '?') {
         $this->lblQuestion->Text .= '?';
     }
     $this->txtAnswer->Visible = true;
     $this->txtAnswer->Name = 'Your Answer';
     $this->txtAnswer->Required = true;
     $this->txtAnswer->CausesValidation = $this->txtAnswer;
     $this->txtAnswer->Focus();
     $this->btnFinalSubmit->Visible = true;
     $this->btnFinalSubmit->Text = 'Reset My Password';
     $this->btnFinalSubmit->CausesValidation = $this->txtAnswer;
     $this->txtAnswer->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnFinalSubmit_Click'));
     $this->txtAnswer->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->btnFinalSubmit->AddAction(new QClickEvent(), new QAjaxAction('btnFinalSubmit_Click'));
     $this->objPublicLogin = $objPublicLogin;
 }
Beispiel #8
0
 public static function StripDollar($strText)
 {
     if (QString::FirstCharacter($strText) == '$') {
         return substr($strText, 1);
     } else {
         return $strText;
     }
 }
 public static function UnderscoreFromCamelCase($strName)
 {
     if (strlen($strName) == 0) {
         return '';
     }
     $strToReturn = QString::FirstCharacter($strName);
     for ($intIndex = 1; $intIndex < strlen($strName); $intIndex++) {
         $strChar = substr($strName, $intIndex, 1);
         if (strtoupper($strChar) == $strChar) {
             $strToReturn .= '_' . $strChar;
         } else {
             $strToReturn .= $strChar;
         }
     }
     return strtolower($strToReturn);
 }
 public function Render($blnPrint = true, $blnRenderAsAjax = false)
 {
     //Render Actions first if applicable
     $strRendered = parent::Render();
     if (!$blnRenderAsAjax) {
         $strText = $this->strText;
     } else {
         $strText = QString::XmlEscape(trim($this->strText));
     }
     $strRendered .= sprintf("<a id='%s' name='%s' %s>%s</a>", $this->strControlId, $this->strControlId, $this->GetAttrString(), $strText);
     if ($blnPrint) {
         _p($strRendered, false);
     } else {
         return $strRendered;
     }
 }
Beispiel #11
0
 public function Render($blnPrint = true, $blnRenderAsAjax = false)
 {
     if ($blnRenderAsAjax) {
         $strElementOverride = 'control';
         $this->Attr('transition', $this->strTransition);
     } else {
         $strElementOverride = 'div';
     }
     $strRendered = parent::Render();
     $strHeader = sprintf("<%s id='%s' name='%s' %s>\n", $strElementOverride, $this->strControlId, $this->strControlId, $this->GetAttrString());
     //If template is set render template
     if (!is_null($this->strTemplate)) {
         if (!file_exists($this->strTemplate)) {
             throw new QCallerException("Template file (" . $this->strTemplate . ") does not exist");
         }
         global $_CONTROL;
         $objPrevControl = $_CONTROL;
         $_CONTROL = $this;
         $_FORM = $this->objForm;
         $strRendered .= $this->objForm->EvaluateTemplate($this->strTemplate);
         $_CONTROL = $objPrevControl;
     }
     //Render Text
     $strRendered .= $this->strText;
     //Check/Do autorender children
     if ($this->blnAutoRenderChildren) {
         foreach ($this->arrChildControls as $objChildControl) {
             $strRendered .= $objChildControl->Render(false);
         }
     }
     $strFooter = sprintf("</%s>", $strElementOverride);
     if (!$blnRenderAsAjax) {
         $strRendered = $strHeader . $strRendered . $strFooter;
     } else {
         $strRendered = $strHeader . QString::XmlEscape(trim($strRendered)) . $strFooter;
     }
     $this->blnModified = false;
     if ($blnPrint) {
         _p($strRendered, false);
     } else {
         return $strRendered;
     }
 }
Beispiel #12
0
 public function __construct()
 {
     parent::__construct();
     $this->layout = new QVBoxLayout($this);
     // Load the test xml
     $unicodeXml = new DOMDocument();
     $unicodeXml->load("unicode.xml");
     $xpath = new DOMXPath($unicodeXml);
     $dataNodes = $xpath->query("/test/data");
     // Loop on all data node and create buttons
     foreach ($dataNodes as $data) {
         $this->buttons[] = new QLineEdit(QString::fromUtf8($data->nodeValue, -1), $this);
         foreach ($data->attributes as $attribute) {
             $this->layout->addWidget(new QLabel($attribute->name . ": " . $attribute->value));
         }
         $this->layout->addWidget($this->buttons[count($this->buttons) - 1]);
     }
     $this->buttons[] = new QLineEdit("Test", $this);
     $this->layout->addWidget($this->buttons[count($this->buttons) - 1]);
     $this->buttons[] = new QLineEdit("second Test", $this);
     $this->layout->addWidget($this->buttons[count($this->buttons) - 1]);
 }
Beispiel #13
0
 public function SetProperty($strName, $intState)
 {
     if (QString::FirstCharacter($strName) == '"' && QString::LastCharacter($strName) == '"') {
         $strName = substr($strName, 1, strlen($strName) - 2);
     } else {
         if (QString::FirstCharacter($strName) == "'" && QString::LastCharacter($strName) == "'") {
             $strName = substr($strName, 1, strlen($strName) - 2);
         }
     }
     if (array_key_exists($strName, $this->PropertyArray)) {
         $objProperty = $this->PropertyArray[$strName];
     } else {
         $objProperty = new QScriptParserProperty();
         $objProperty->Name = $strName;
         $this->PropertyArray[$strName] = $objProperty;
     }
     if ($intState == STATE_GET) {
         $objProperty->Read = true;
     } else {
         if ($intState == STATE_SET) {
             $objProperty->Write = true;
         }
     }
 }
Beispiel #14
0
 /**
  * This function displays helpful development info like queries sent to database and memory usage.
  * By default it shows only if database profiling is enabled in any configured database connections.
  * 
  * If forced to show when profiling is disabled you can monitor qcodo memory usage more accurately,
  * as collecting database profiling information tends to noticeable bigger memory consumption.
  * 
  * @param boolean $blnForceDisplay optional parameter, set true to always display info even if DB profiling is disabled
  * @return void
  */
 public static function DisplayProfilingInfo($blnForceDisplay = false)
 {
     if (QDatabaseBase::IsAnyDatabaseProfilingEnabled() || $blnForceDisplay) {
         print '<br clear="all"/><div style="padding: 5px; text-align: left; margin: 1em auto; border: 1px solid #888888; width: 800px;">';
         // Output DB Profiling Data
         foreach (QApplication::$Database as $objDb) {
             if ($objDb->EnableProfiling == true) {
                 $objDb->OutputProfiling();
             }
         }
         // Output runtime statistics
         if (function_exists('memory_get_peak_usage')) {
             print 'memory_get_peak_usage: ' . QString::GetByteSize(memory_get_peak_usage(true)) . ' / ' . ini_get('memory_limit') . '<br/>';
         }
         print 'max_execution_time: ' . ini_get('max_execution_time') . '&nbsp;s<br/>';
         print 'max_input_time: ' . ini_get('max_input_time') . '&nbsp;s<br/>';
         print 'upload_max_filesize: ' . ini_get('upload_max_filesize') . '<br/>';
         // Output any other PHPINI issues
         if (ini_get('safe_mode')) {
             print '<font color="red">safe_mode need to be disabled</font><br/>';
         }
         if (ini_get('magic_quotes_gpc')) {
             print '<font color="red">magic_quotes_gpc need to be disabled</font><br/>';
         }
         if (ini_get('magic_quotes_runtime')) {
             print '<font color="red">magic_quotes_runtime need to be disabled</font><br/>';
         }
         print '</div>';
     }
 }
Beispiel #15
0
 protected function RenderOutput($strOutput, $blnDisplayOutput, $blnForceAsBlockElement = false)
 {
     // First, let's mark this control as being rendered and is ON the Page
     $this->blnRendering = false;
     $this->blnRendered = true;
     $this->blnOnPage = true;
     // Determine whether or not $strOutput is considered a XHTML "Block" Element
     if ($blnForceAsBlockElement || $this->blnIsBlockElement) {
         $blnIsBlockElement = true;
     } else {
         $blnIsBlockElement = false;
     }
     // Check for Visibility
     if (!$this->blnVisible) {
         $strOutput = '';
     }
     $strStyle = '';
     if ($this->strPosition && $this->strPosition != QPosition::NotSet) {
         $strStyle .= sprintf('position:%s;', $this->strPosition);
     }
     if (!$this->blnDisplay) {
         $strStyle .= 'display:none;';
     } else {
         if ($blnIsBlockElement) {
             $strStyle .= 'display:inline;';
         }
     }
     if (strlen(trim($this->strLeft)) > 0) {
         $strLeft = null;
         try {
             $strLeft = QType::Cast($this->strLeft, QType::Integer);
         } catch (QInvalidCastException $objExc) {
         }
         if (is_null($strLeft)) {
             $strStyle .= sprintf('left:%s;', $this->strLeft);
         } else {
             $strStyle .= sprintf('left:%spx;', $this->strLeft);
         }
     }
     if (strlen(trim($this->strTop)) > 0) {
         $strTop = null;
         try {
             $strTop = QType::Cast($this->strTop, QType::Integer);
         } catch (QInvalidCastException $objExc) {
         }
         if (is_null($strTop)) {
             $strStyle .= sprintf('top:%s;', $this->strTop);
         } else {
             $strStyle .= sprintf('top:%spx;', $this->strTop);
         }
     }
     switch ($this->objForm->CallType) {
         case QCallType::Ajax:
             // If we have a ParentControl and the ParentControl has NOT been rendered, then output
             // as standard HTML
             if ($this->objParentControl && ($this->objParentControl->Rendered || $this->objParentControl->Rendering)) {
                 if ($strStyle) {
                     $strStyle = sprintf('style="%s"', $strStyle);
                 }
                 if ($blnIsBlockElement) {
                     $strOutput = sprintf('<div id="%s_ctl" %s>%s</div>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
                 } else {
                     $strOutput = sprintf('<span id="%s_ctl" %s>%s</span>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
                 }
                 //						$strOutput = sprintf('<ins id="%s_ctl" style="%stext-decoration:inherit;">%s</ins>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
                 //						$strOutput = sprintf('<q id="%s_ctl" style="%s">%s</q>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
             } else {
                 // Otherwise, we are rendering as a top-level AJAX response
                 // Surround Output HTML around CDATA tags
                 $strOutput = QString::XmlEscape($strOutput);
                 $strOutput = sprintf('<control id="%s">%s</control>', $this->strControlId, $strOutput);
                 //					QApplication::ExecuteJavaScript(sprintf('qcodo.registerControl("%s"); ', $this->strControlId), true);
                 //					QApplication::ExecuteJavaScript(sprintf('qc.regC("%s"); ', $this->strControlId), true);
                 //					$strScript = $this->GetEndScript();
                 //					if ($strScript)
                 //						QApplication::ExecuteJavaScript($strScript);
                 if ($this->blnWrapperModified && $this->blnVisible) {
                     //							QApplication::ExecuteJavaScript(sprintf('qcodo.getWrapper("%s").style.cssText = "%s"; ', $this->strControlId, $strStyle));
                     QApplication::ExecuteJavaScript(sprintf('qc.getW("%s").style.cssText = "%stext-decoration:inherit;"; ', $this->strControlId, $strStyle));
                 }
             }
             break;
         default:
             if ($strStyle) {
                 $strStyle = sprintf('style="%s"', $strStyle);
             }
             //					$strOutput = sprintf('<div id="%s_ctl" style="%s">%s</div>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
             //					$strOutput = sprintf('<ins id="%s_ctl" style="%stext-decoration:inherit;">%s</ins>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
             if ($blnIsBlockElement) {
                 $strOutput = sprintf('<div id="%s_ctl" %s>%s</div>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
             } else {
                 $strOutput = sprintf('<span id="%s_ctl" %s>%s</span>%s', $this->strControlId, $strStyle, $strOutput, $this->GetNonWrappedHtml());
             }
             break;
     }
     // Output or Return
     if ($blnDisplayOutput) {
         print $strOutput;
     } else {
         return $strOutput;
     }
 }
 public function RenderControlRegisterJS($blnPrint = true, $blnAjaxFormating = false)
 {
     $strRendered = '';
     if (!$blnAjaxFormating) {
         $strRendered .= "<script language='javascript'>\n\t";
     }
     $strRendered .= "\$(document).ready(function(){\n\t";
     $strRendered .= "MJax.ClearRegisteredControls();\n\t";
     foreach ($this->arrControls as $objControl) {
         $strRendered .= sprintf("MJax.RegisterControl('%s');\n\t", $objControl->ControlId);
     }
     $strRendered .= "});\n\t";
     if (!$blnAjaxFormating) {
         $strRendered .= "</script>";
     }
     if ($blnAjaxFormating) {
         $strRendered = QString::XmlEscape(trim($strRendered));
     }
     if ($blnPrint) {
         _p($strRendered, false);
     } else {
         return $strRendered;
     }
 }
 /**
  * Uses regular expression matching to return an array of valid e-mail addresses
  *
  * @param string $strAddresses Single string containing e-mail addresses and anything else
  * @return string[] An array of e-mail addresses only, or NULL if none
  */
 public static function GetEmailAddresses($strAddresses)
 {
     $strAddressArray = null;
     // Define the ATEXT-based DOT-ATOM pattern which defines the LOCAL-PART of
     // an ADDRESS-SPEC in RFC 2822
     $strDotAtomPattern = "[a-zA-Z0-9\\!\\#\\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~\\.]+";
     // Define the Domain pattern, defined by the allowable domain names in the DNS Root Zone of the internet
     // Note that this is stricter than what RFC 2822 allows in DCONTENT, because we assume developers are
     // wanting to send email over the internet, and not using it for a completely closed intranet with a
     // non-DNS Root Zone compliant domain name infrastructure.
     $strDomainPattern = '(?:[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?\\.)*[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?';
     // The RegExp Pattern to Use
     $strPattern = sprintf('/%s@%s/', $strDotAtomPattern, $strDomainPattern);
     // See how many address candidates we have
     $strCandidates = explode(',', $strAddresses);
     foreach ($strCandidates as $strCandidate) {
         if (preg_match($strPattern, $strCandidate, $strCandidateArray) && count($strCandidateArray) == 1) {
             $strCandidate = $strCandidateArray[0];
             $strParts = explode('@', $strCandidate);
             // Validate String Lengths, and add to AddressArray if Valid
             if (QString::IsLengthBeetween($strCandidate, 3, 256) && QString::IsLengthBeetween($strParts[0], 1, 64) && QString::IsLengthBeetween($strParts[1], 1, 255)) {
                 $strAddressArray[] = $strCandidate;
             }
         }
     }
     if (count($strAddressArray)) {
         return $strAddressArray;
     } else {
         return null;
     }
 }
 /**
  * Given the path of a directory, process all the directories and files in it that have NOT been seen in SeenRealPath.
  * Assumes: the path is a valid directory that exists and has NOT been SeenRealPath
  * @param string $strPath
  * @return void
  */
 protected function ProcessDirectory($strPath, QDirectoryToken $objDirectoryToken)
 {
     $strRealPath = realpath($strPath);
     $this->strSeenRealPath[$strRealPath] = true;
     $objDirectory = opendir($strPath);
     while ($strName = readdir($objDirectory)) {
         // Only Process Files/Folders that do NOT start with a single "."
         if (QString::FirstCharacter($strName) != '.') {
             // Put Together the Entire Full Path of the File in Question
             $strFullPath = $strPath . '/' . $strName;
             // Process if it's a file
             if (is_file($strFullPath)) {
                 $this->ProcessFile($strFullPath, $objDirectoryToken);
                 // Process if it's a directory
             } else {
                 if (is_dir($strFullPath)) {
                     // Only continue if we haven't visited it and it's not a folder that we are ignoring
                     $strRealPath = realpath($strFullPath);
                     if (!array_key_exists($strRealPath, $this->strSeenRealPath) && !array_key_exists(strtolower($strName), $this->blnIgnoreFolderArray)) {
                         $this->ProcessDirectory($strFullPath, $objDirectoryToken);
                     }
                     // It's neither a file nor a directory?!
                 } else {
                     throw new Exception('Not a valid file or folder: ' . $strFullPath);
                 }
             }
         }
     }
 }
 protected function TypeTokenFromTypeName($strName)
 {
     $strToReturn = '';
     for ($intIndex = 0; $intIndex < strlen($strName); $intIndex++) {
         if (ord($strName[$intIndex]) >= ord('a') && ord($strName[$intIndex]) <= ord('z') || ord($strName[$intIndex]) >= ord('A') && ord($strName[$intIndex]) <= ord('Z') || ord($strName[$intIndex]) >= ord('0') && ord($strName[$intIndex]) <= ord('9') || $strName[$intIndex] == '_') {
             $strToReturn .= $strName[$intIndex];
         }
     }
     if (is_numeric(QString::FirstCharacter($strToReturn))) {
         $strToReturn = '_' . $strToReturn;
     }
     return $strToReturn;
 }
Beispiel #20
0
 public static function Run($strClassName, $strNamespace = null)
 {
     QApplication::$EncodingType = 'UTF-8';
     $objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
     $objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
     $objClassWrapperCache = new QCache('soap', QApplication::$ScriptName, 'class.php', QApplication::$ScriptFilename);
     // Reflect through this QSoapService
     $strDisco = $objDiscoCache->GetData();
     if ($strDisco === false || !$strNamespace) {
         $objReflection = new ReflectionClass($strClassName);
     }
     // Figure Out Namespace
     if (!$strNamespace) {
         $objReflectionProperties = $objReflection->getStaticProperties();
         $strNamespace = $objReflectionProperties['DefaultNamespace'];
     }
     $strNamespace = trim($strNamespace);
     if (QString::LastCharacter($strNamespace) == '/') {
         $strNamespace = substr($strNamespace, 0, strlen($strNamespace) - 1);
     }
     // Check for Cached Disco
     if ($strDisco === false) {
         // Instantiate Service and Setup new Soap Methods
         $objService = new $strClassName($strClassName, $strNamespace);
         // Setup SOAP Methods
         try {
             $objService->SetupSoapMethods($objReflection);
         } catch (QCallerException $objExc) {
             $objExc->IncrementOffset();
             throw $objExc;
         }
         // Get Disco, Wsdl and Wrapper, and cache them!
         $objWsdlCache->SaveData($objService->GetWsdl());
         $objDiscoCache->SaveData($objService->GetDisco());
         $objClassWrapperCache->SaveData($objService->GetClassWrapper());
     }
     // Process Service Browse (e.g. if accessed via GET)
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         if (array_key_exists('QUERY_STRING', $_SERVER)) {
             switch (strtolower($_SERVER['QUERY_STRING'])) {
                 case 'disco':
                     header('Content-Type: text/xml');
                     _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false);
                     _p($objDiscoCache->GetData(), false);
                     return;
                 case 'wsdl':
                     header('Content-Type: text/xml');
                     _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false);
                     _p($objWsdlCache->GetData(), false);
                     return;
             }
         }
         printf('<link rel="alternate" type="text/xml" href="%s?disco"/><a href="%s?disco">Web Service Discovery File</a> &nbsp;|&nbsp; <a href="%s?wsdl">Web Service Description File (WSDL)</a>', QApplication::$ScriptName, QApplication::$ScriptName, QApplication::$ScriptName);
         return;
     }
     // Process Service Execution (e.g. accessed via a POST)
     $objService = new $strClassName($strClassName, $strNamespace);
     // Get the Request
     $strRequest = file_get_contents("php://input");
     // Create the Service Class Wrapper
     require $objClassWrapperCache->GetFilePath();
     // Use PHP 5.1+'s SoapServer class to handle the actual work
     $objService->objSoapServer = new SoapServer($objWsdlCache->GetFilePath());
     $objService->objSoapServer->setClass($strClassName . 'Wrapper', $strClassName, $strNamespace);
     $objService->objSoapServer->handle($strRequest);
 }
 /**
  * Function renders Javascript on the client browser.
  * @static
  * @param bool $blnOutput if true print the result, otherwise return it
  * @return null|string
  */
 public static function RenderJavaScript($blnOutput = true)
 {
     $strScript = '';
     foreach (QApplication::$AlertMessageArray as $strAlert) {
         $strAlert = addslashes($strAlert);
         $strScript .= sprintf('alert("%s"); ', $strAlert);
     }
     foreach (QApplication::$JavaScriptArrayHighPriority as $strJavaScript) {
         $strJavaScript = trim($strJavaScript);
         if (QString::LastCharacter($strJavaScript) != ';') {
             $strScript .= sprintf('%s; ', $strJavaScript);
         } else {
             $strScript .= sprintf('%s ', $strJavaScript);
         }
     }
     foreach (QApplication::$JavaScriptArray as $strJavaScript) {
         $strJavaScript = trim($strJavaScript);
         if (QString::LastCharacter($strJavaScript) != ';') {
             $strScript .= sprintf('%s; ', $strJavaScript);
         } else {
             $strScript .= sprintf('%s ', $strJavaScript);
         }
     }
     foreach (QApplication::$JavaScriptArrayLowPriority as $strJavaScript) {
         $strJavaScript = trim($strJavaScript);
         if (QString::LastCharacter($strJavaScript) != ';') {
             $strScript .= sprintf('%s; ', $strJavaScript);
         } else {
             $strScript .= sprintf('%s ', $strJavaScript);
         }
     }
     QApplication::$AlertMessageArray = array();
     QApplication::$JavaScriptArrayHighPriority = array();
     QApplication::$JavaScriptArray = array();
     QApplication::$JavaScriptArrayLowPriority = array();
     if ($strScript) {
         if ($blnOutput) {
             _p($strScript, false);
         } else {
             return $strScript;
         }
     }
     return null;
 }
 /**
  * This function displays helpful development info like queries sent to database and memory usage.
  * By default it shows only if database profiling is enabled in any configured database connections.
  * 
  * If forced to show when profiling is disabled you can monitor qcodo memory usage more accurately,
  * as collecting database profiling information tends to noticeable bigger memory consumption.
  * 
  * @param boolean $blnForceDisplay optional parameter, set true to always display info even if DB profiling is disabled
  * @return void
  */
 public static function DisplayProfilingInfo($blnForceDisplay = false)
 {
     if (QDatabaseBase::IsAnyDatabaseProfilingEnabled() || $blnForceDisplay) {
         print '<br style="clear: both; font-size: 0px"/>';
         print '<div style="padding: 1em; text-align: left; margin: 1em; border: 1px solid #888; color: #000; background-color: #FFF;">';
         // Output DB Profiling Data
         foreach (QApplication::$Database as $objDb) {
             if ($objDb->EnableProfiling == true) {
                 $objDb->OutputProfiling();
             }
         }
         // Output runtime statistics / settings
         print 'memory_get_peak_usage: ' . QString::GetByteSize(memory_get_peak_usage(true)) . ' / ' . ini_get('memory_limit') . '<br/>';
         print 'max_execution_time: ' . ini_get('max_execution_time') . '&nbsp;s<br/>';
         print 'max_input_time: ' . ini_get('max_input_time') . '&nbsp;s<br/>';
         print 'upload_max_filesize: ' . ini_get('upload_max_filesize') . '<br/>';
         // Output any other PHPINI issues
         if (ini_get('safe_mode')) {
             print '<span style="color: red;">safe_mode need to be disabled</span><br/>';
         }
         if (ini_get('magic_quotes_gpc')) {
             print '<span style="color: red;">magic_quotes_gpc need to be disabled</span><br/>';
         }
         if (ini_get('magic_quotes_runtime')) {
             print '<span style="color: red;">magic_quotes_runtime need to be disabled</span><br/>';
         }
         print '<a href="#" onClick="qcodo.loadFirebugLite(); return false;">load Firebug Lite</a><br/>';
         print '</div>';
     }
 }
Beispiel #23
0
<div class="<?php 
_p($_FORM->RenderTopicCss($_ITEM));
?>
" title="<?php 
_p($_ITEM->SidenavTitle);
?>
" onmouseover="topicOver(this);" onmouseout="topicOut(this);" onclick="document.location='<?php 
_p($_FORM->RenderTopicLink($_ITEM));
?>
'">
	<div class="title"><div style="width: 600px;">
		<a href="<?php 
_p($_FORM->RenderTopicLink($_ITEM));
?>
" title="<?php 
_p($_ITEM->SidenavTitle);
?>
"><?php 
_p(QString::Truncate($_ITEM->Name, 60), false);
?>
</a>
	</div></div>
	<div class="count"><?php 
_p($_ITEM->MessageCount);
?>
</div>
</div>
Beispiel #24
0
    } else {
        printf("CodeGen settings (as evaluted from %s):\r\n%s\r\n\r\n", $_SERVER['argv'][1], QCodeGen::GetSettingsXml());
    }
    foreach (QCodeGen::$CodeGenArray as $objCodeGen) {
        printf("%s\r\n---------------------------------------------------------------------\r\n", $objCodeGen->GetTitle());
        printf("%s\r\n", $objCodeGen->GetReportLabel());
        printf("%s\r\n", $objCodeGen->GenerateAll());
        if ($strErrors = $objCodeGen->Errors) {
            printf("The following errors were reported:\r\n%s\r\n", $strErrors);
        }
        print "\r\n";
    }
    foreach (QCodeGen::GenerateAggregate() as $strMessage) {
        printf("%s\r\n\r\n", $strMessage);
    }
} catch (Exception $objExc) {
    print 'error: ' . trim($objExc->getMessage()) . "\r\n";
    exit(1);
}
$intEndTime = microtime();
$intEndTime = explode(" ", $intEndTime);
$intEndTime = $intEndTime[1] + $intEndTime[0];
echo 'Codegen took ', round($intEndTime - $intStartTime, 2), "s (";
if (ini_get('max_execution_time') == 0) {
    echo 'no execution time limit';
} else {
    echo 'maximum execution time ', ini_get('max_execution_time'), 's';
}
echo ").\n";
echo 'Peak memory usage was ', QString::GetByteSize(memory_get_peak_usage(true)), ' (', ini_get('memory_limit'), " maximum available).\n";
Beispiel #25
0
 protected function RenderAjax()
 {
     // Update the Status
     $this->intFormStatus = QFormBase::FormStatusRenderBegun;
     // Create the Control collection
     $strToReturn = '<controls>';
     // Include each control (if applicable) that has been changed/modified
     foreach ($this->GetAllControls() as $objControl) {
         if (!$objControl->ParentControl) {
             //					$strToReturn .= $objControl->RenderAjax(false) . "\r\n";
             $strToReturn .= $this->RenderAjaxHelper($objControl);
         }
     }
     // First, go through all controls and gather up any JS or CSS to run or Form Attributes to modify
     $strJavaScriptToAddArray = array();
     $strStyleSheetToAddArray = array();
     $strFormAttributeToModifyArray = array();
     foreach ($this->GetAllControls() as $objControl) {
         // Include any JavaScripts?  The control would have a
         // comma-delimited list of javascript files to include (if applicable)
         if ($strScriptArray = $this->ProcessJavaScriptList($objControl->JavaScripts)) {
             $strJavaScriptToAddArray = array_merge($strJavaScriptToAddArray, $strScriptArray);
         }
         // Include any StyleSheets?  The control would have a
         // comma-delimited list of stylesheet files to include (if applicable)
         if ($strScriptArray = $this->ProcessStyleSheetList($objControl->StyleSheets)) {
             $strStyleSheetToAddArray = array_merge($strStyleSheetArray, $strScriptArray);
         }
         // Form Attributes?
         if ($objControl->FormAttributes) {
             foreach ($objControl->FormAttributes as $strKey => $strValue) {
                 if (!array_key_exists($strKey, $this->strFormAttributeArray)) {
                     $this->strFormAttributeArray[$strKey] = $strValue;
                     $strFormAttributeToModifyArray[$strKey] = $strValue;
                 } else {
                     if ($this->strFormAttributeArray[$strKey] != $strValue) {
                         $this->strFormAttributeArray[$strKey] = $strValue;
                         $strFormAttributeToModifyArray[$strKey] = $strValue;
                     }
                 }
             }
         }
     }
     // Render the JS Commands to Execute
     $strCommands = '';
     // First, get all controls that need to run regC
     $strControlIdToRegister = array();
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             array_push($strControlIdToRegister, '"' . $objControl->ControlId . '"');
         }
     }
     if (count($strControlIdToRegister)) {
         $strCommands .= sprintf('qc.regCA(new Array(%s)); ', implode(',', $strControlIdToRegister));
     }
     // Next, go through all controls and groupings for their GetEndScripts
     foreach ($this->GetAllControls() as $objControl) {
         if ($objControl->Rendered) {
             $strJavaScript = $objControl->GetEndScript();
             if (trim($strJavaScript)) {
                 $strCommands .= trim($strJavaScript);
             }
         }
     }
     foreach ($this->objGroupingArray as $objGrouping) {
         $strRender = $objGrouping->Render();
         if (trim($strRender)) {
             $strCommands .= trim($strRender);
         }
     }
     // Next, look to the Application object for any commands to run
     $strCommands .= QApplication::RenderJavaScript(false);
     // Finally, bring in "high priority commands"
     // First, alter any <Form> settings that need to be altered
     foreach ($strFormAttributeToModifyArray as $strKey => $strValue) {
         $strCommands = sprintf('document.getElementById("%s").%s = "%s"; ', $this->strFormId, $strKey, $strValue) . $strCommands;
     }
     // Next, add any new CSS files that haven't yet been included to the end of the High Priority commands string
     foreach ($strStyleSheetToAddArray as $strScript) {
         $strCommands = 'qc.loadStyleSheetFile("' . $strScript . '", "all"); ' . $strCommands;
     }
     // Next, add any new JS files that haven't yet been included to the BEGINNING of the High Priority commands string
     // (already rendered HP commands up to this point will be placed into the callback)
     foreach ($strJavaScriptToAddArray as $strScript) {
         if ($strCommands) {
             $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", function() {' . $strCommands . '}); ';
         } else {
             $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", null); ';
         }
     }
     // Set Up the Command Node
     if (trim($strCommands)) {
         $strCommands = '<command>' . QString::XmlEscape(trim($strCommands)) . '</command>';
     }
     // Persist Controls (if applicable)
     foreach ($this->objPersistentControlArray as $objControl) {
         $objControl->Persist();
     }
     // Add in the form state
     $strFormState = QForm::Serialize($this);
     $strToReturn .= sprintf('<control id="Qform__FormState">%s</control>', $strFormState);
     // close Control collection, Open the Command collection
     $strToReturn .= '</controls><commands>';
     $strToReturn .= $strCommands;
     // close Command collection
     $strToReturn .= '</commands>';
     $strContents = trim(ob_get_contents());
     if (strtolower(substr($strContents, 0, 5)) == 'debug') {
     } else {
         ob_clean();
         // Response is in XML Format
         header('Content-Type: text/xml');
         // Output it and update render state
         if (QApplication::$EncodingType) {
             printf("<?xml version=\"1.0\" encoding=\"%s\"?><response>%s</response>\r\n", QApplication::$EncodingType, $strToReturn);
         } else {
             printf("<?xml version=\"1.0\"?><response>%s</response>\r\n", $strToReturn);
         }
     }
     // Update Render State
     $this->intFormStatus = QFormBase::FormStatusRenderEnded;
 }
Beispiel #26
0
 public function __construct($strJavaScript)
 {
     $this->strJavaScript = trim($strJavaScript);
     if (QString::LastCharacter($this->strJavaScript) == ';') {
         $this->strJavaScript = substr($this->strJavaScript, 0, strlen($this->strJavaScript) - 1);
     }
 }
Beispiel #27
0
 public function PullDataFromLdap()
 {
     $objResult = ldap_search($this->objLdap, 'OU=People,dc=ir,dc=alcf,dc=net', 'CN=*');
     $arrResults = ldap_get_entries($this->objLdap, $objResult);
     unset($arrResults['count']);
     $this->arrGroups = array();
     $this->arrPeople = array();
     $this->arrContacts = array();
     foreach ($arrResults as $intKey => $arrResult) {
         $blnIsPerson = false;
         $blnIsGroup = false;
         foreach ($arrResult["objectclass"] as $strClass) {
             if ($strClass == "user") {
                 $blnIsPerson = true;
             }
             if ($strClass == "group") {
                 $blnIsGroup = true;
             }
         }
         if (!array_key_exists('samaccountname', $arrResult)) {
             $this->arrContacts[] = $arrResult;
         } else {
             if ($blnIsPerson && $blnIsGroup) {
                 throw new Exception('Record appears to be BOTH person AND group');
             } else {
                 if ($blnIsPerson) {
                     $this->arrPeople[] = $arrResult;
                 } else {
                     if ($blnIsGroup) {
                         // Valid groups must have tokens that begin with gg_ and must have actual members
                         // and must have names that do NOT begin with "*"
                         $strArray = AlcfLdap::GetValuesFromPath($arrResult["distinguishedname"][0]);
                         $strHierarchyArray = $strArray['OU'];
                         $strGroupName = $strHierarchyArray[0];
                         $strToken = strtolower($arrResult['samaccountname'][0]);
                         if (array_key_exists('member', $arrResult) && substr($strToken, 0, 3) == 'gg_' && QString::FirstCharacter($strGroupName) != '*') {
                             $this->arrGroups[] = $arrResult;
                         }
                     } else {
                         throw new Exception('Record appears to be NEITHER person NOR group');
                     }
                 }
             }
         }
     }
 }
Beispiel #28
0
 /**
  * A better version of strrpos which also allows for the use of RegExp-based matching
  * @param string $strHaystack the text content to search through
  * @param string $strNeedle either a plain-text item or a regexp pattern item to search for - if regexp used, this will update as the actual string of the content found
  * @param integer $intOffset optional position offset
  * @return mixed the position number OR false if not found
  */
 public static function StringReversePosition($strHaystack, &$strNeedle, $intOffset = null)
 {
     if (strlen($strNeedle) >= 3 && QString::FirstCharacter($strNeedle) == '/' && QString::LastCharacter($strNeedle) == '/') {
         $arrMatches = array();
         preg_match_all($strNeedle, $strHaystack, $arrMatches);
         $arrMatches = $arrMatches[0];
         if (count($arrMatches)) {
             $strNeedle = $arrMatches[count($arrMatches) - 1];
         } else {
             return false;
         }
     }
     if (is_null($intOffset)) {
         return strrpos($strHaystack, $strNeedle);
     } else {
         return strrpos($strHaystack, $strNeedle, $intOffset);
     }
 }
 protected function paintEvent($event)
 {
     $this->painter = new QPainter($this);
     $this->painter->drawText(200, 200, tr("Angle = ") . QString::number($this->currentAngle));
 }
Beispiel #30
0
 public function GetXml()
 {
     $strToReturn = "\t<item>\r\n";
     $strToReturn .= sprintf("\t\t<title>%s</title>\r\n", QString::XmlEscape($this->strTitle));
     $strToReturn .= sprintf("\t\t<link>%s</link>\r\n", QString::XmlEscape($this->strLink));
     $strToReturn .= sprintf("\t\t<description>%s</description>\r\n", QString::XmlEscape($this->strDescription));
     if ($this->strAuthor) {
         $strToReturn .= sprintf("\t\t<author>%s</author>\r\n", QString::XmlEscape($this->strAuthor));
     }
     foreach ($this->objCategoryArray as $objCategory) {
         $strToReturn .= $objCategory->GetXml();
     }
     if ($this->strComments) {
         $strToReturn .= sprintf("\t\t<comments>%s</comments>\r\n", QString::XmlEscape($this->strComments));
     }
     if ($this->strGuid) {
         $strToReturn .= sprintf("\t\t<guid isPermaLink=\"%s\">%s</guid>\r\n", $this->blnGuidPermaLink ? 'true' : 'false', $this->strGuid);
     }
     if ($this->dttPubDate) {
         $strToReturn .= sprintf("\t\t<pubDate>%s</pubDate>\r\n", $this->dttPubDate->__toString(QDateTime::FormatRfc822));
     }
     $strToReturn .= "\t</item>\r\n";
     return $strToReturn;
 }