Find possible php exploit files
grep '((eval.*(base64_decode|gzinflate|\$_))|\$[0O]{4,}|FilesMan|JGF1dGhfc|IIIl|die\(PHP_OS|posix_getpwuid|Array\(base64_decode|document\.write\("\\u00|sh(3(ll|11)))' /my/path/to/vhosts/ -lroE --include=*.php*
Really Huge CSV
If you have a really large csv you might have a big DB query before it that will take some time. The browser will have to sit there and wait for data to come in before it sends the headers and tells the browser to start downloading which can sometimes timeout. to fix this place the code below right under your headers and before you data processing.
ob_implicit_flush(true); ob_end_flush();
Add Attachments to C5 Forms
If you have a file input field on a C5 form and you want it to send those files in the notify email
First open concrete/helpers/mail.php it should look like this
defined('C5_EXECUTE') or die("Access Denied."); class MailHelper extends Concrete5_Helper_Mail { }
Make it look like this
defined('C5_EXECUTE') or die("Access Denied."); class MailHelper extends Concrete5_Helper_Mail { protected $files = array(); /** * Add an attachement to the email by the file id * @param int $fileId */ public function AddAttachmentById($fileId) { Loader::model('file'); $this->files[] = File::getByID($fileId); } /** * Add an attachment to the email * @param File $file */ public function addAttachment($file) { $this->files[] = $file; } /** * Sends the email * @return void */ public function sendMail($resetData = true) { $_from[] = $this->from; $fromStr = $this->generateEmailStrings($_from); $toStr = $this->generateEmailStrings($this->to); $replyStr = $this->generateEmailStrings($this->replyto); if (ENABLE_EMAILS) { $zendMailData = self::getMailerObject(); $mail=$zendMailData['mail']; $transport=(isset($zendMailData['transport']))?$zendMailData['transport']:NULL; if (is_array($this->from) && count($this->from)) { if ($this->from[0] != '') { $from = $this->from; } } if (!isset($from)) { $from = array(EMAIL_DEFAULT_FROM_ADDRESS, EMAIL_DEFAULT_FROM_NAME); $fromStr = EMAIL_DEFAULT_FROM_ADDRESS; } // The currently included Zend library has a bug in setReplyTo that // adds the Reply-To address as a recipient of the email. We must // set the Reply-To before any header with addresses and then clear // all recipients so that a copy is not sent to the Reply-To address. if(is_array($this->replyto)) { foreach ($this->replyto as $reply) { $mail->setReplyTo($reply[0], $reply[1]); } } $mail->clearRecipients(); $mail->setFrom($from[0], $from[1]); $mail->setSubject($this->subject); foreach($this->to as $to) { $mail->addTo($to[0], $to[1]); } if(is_array($this->cc) && count($this->cc)) { foreach($this->cc as $cc) { $mail->addCc($cc[0], $cc[1]); } } if(is_array($this->bcc) && count($this->bcc)) { foreach($this->bcc as $bcc) { $mail->addBcc($bcc[0], $bcc[1]); } } $mail->setBodyText($this->body); if ($this->bodyHTML != false) { $mail->setBodyHTML($this->bodyHTML); } if (!empty($this->files)) { Loader::library('3rdparty/Zend/Mime/Part'); Loader::library('3rdparty/Zend/Mime'); foreach ($this->files as $file) { $part = new Zend_Mime_Part(file_get_contents($file->getPath())); $part->filename = basename($file->getPath()); $part->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; $part->encoding = Zend_Mime::ENCODING_BASE64; $mail->addAttachment($part); } } try { $mail->send($transport); } catch(Exception $e) { $l = new Log(LOG_TYPE_EXCEPTIONS, true, true); $l->write(t('Mail Exception Occurred. Unable to send mail: ') . $e->getMessage()); $l->write($e->getTraceAsString()); if (ENABLE_LOG_EMAILS) { $l->write(t('Template Used') . ': ' . $this->template); $l->write(t('To') . ': ' . $toStr); $l->write(t('From') . ': ' . $fromStr); if (isset($this->replyto)) { $l->write(t('Reply-To') . ': ' . $replyStr); } $l->write(t('Subject') . ': ' . $this->subject); $l->write(t('Body') . ': ' . $this->body); } $l->close(); } } // add email to log if (ENABLE_LOG_EMAILS) { $l = new Log(LOG_TYPE_EMAILS, true, true); if (ENABLE_EMAILS) { $l->write('**' . t('EMAILS ARE ENABLED. THIS EMAIL WAS SENT TO mail()') . '**'); } else { $l->write('**' . t('EMAILS ARE DISABLED. THIS EMAIL WAS LOGGED BUT NOT SENT') . '**'); } $l->write(t('Template Used') . ': ' . $this->template); $l->write(t('To') . ': ' . $toStr); $l->write(t('From') . ': ' . $fromStr); if (isset($this->replyto)) { $l->write(t('Reply-To') . ': ' . $replyStr); } $l->write(t('Subject') . ': ' . $this->subject); $l->write(t('Body') . ': ' . $this->body); $l->close(); } // clear data if applicable if ($resetData) { $this->to = array(); $this->cc = array(); $this->bcc = array(); $this->replyto = array(); $this->from = array(); $this->template = ''; $this->subject = ''; $this->body = ''; $this->bodyHTML = ''; } } }
Then Find /concrete/core/controllers/blocks/form.php. In the function action_submit_form() there is a spot that looks like
$mh = Loader::helper('mail'); $mh->to( $this->recipientEmail ); $mh->from( $formFormEmailAddress ); $mh->replyto( $replyToEmailAddress ); $mh->addParameter('formName', $this->surveyName); $mh->addParameter('questionSetId', $this->questionSetId); $mh->addParameter('questionAnswerPairs', $questionAnswerPairs); $mh->load('block_form_submission'); $mh->setSubject(t('%s Form Submission', $this->surveyName)); //echo $mh->body.'<br>'; @$mh->sendMail();
change that to
$mh = Loader::helper('mail'); $mh->to( $this->recipientEmail ); $mh->from( $formFormEmailAddress ); $mh->replyto( $replyToEmailAddress ); $mh->addParameter('formName', $this->surveyName); $mh->addParameter('questionSetId', $this->questionSetId); $mh->addParameter('questionAnswerPairs', $questionAnswerPairs); $mh->load('block_form_submission'); $mh->setSubject(t('%s Form Submission', $this->surveyName)); if (!empty($tmpFileIds)) { foreach ($tmpFileIds as $tmpFileId) { $mh->AddAttachmentById($tmpFileId); } } //echo $mh->body.'<br>'; @$mh->sendMail();
Thats it!
Filter A Text String In WordPress
Add the following to your theme’s functions.php file to edit a string of text.
Useful for changing something in a core file without editing it.
function youruniqueprefix_filter_gettext( $translated, $original, $domain ) { // This is an array of original strings // and what they should be replaced with $strings = array( 'View all posts filed under %s' => 'See all articles filed under %s', 'Howdy, %1$s' => 'Greetings, %1$s!', // Add some more strings here ); // See if the current string is in the $strings array // If so, replace it's translation if ( isset( $strings[$original] ) ) { // This accomplishes the same thing as __() // but without running it through the filter again $translations = &get_translations_for_domain( $domain ); $translated = $translations->translate( $strings[$original] ); } return $translated; } add_filter( 'gettext', 'youruniqueprefix_filter_gettext', 10, 3 );
Add Content Width To WordPress 3.5
WordPress 3.5 removed the oembed content width option from the admin.
Add this code to your theme’s functions.php file to set it.
/** Define contet width */ if ( ! isset( $content_width ) ) $content_width = 580;
Recent Comments