public function runJob()
 {
     global $cfg, $cfgClient, $client, $recipient;
     $iCount = 0;
     if ($this->get("status") == 2) {
         // Job is currently running, check start time and restart if
         // started 5 minutes ago
         $dStart = strtotime($this->get("started"));
         $dNow = time();
         if ($dNow - $dStart > 5 * 60) {
             $this->set("status", 1);
             $this->set("started", "0000-00-00 00:00:00", false);
             $oLogs = new cNewsletterLogCollection();
             $oLogs->setWhere("idnewsjob", $this->get($this->primaryKey));
             $oLogs->setWhere("status", "sending");
             $oLogs->query();
             while ($oLog = $oLogs->next()) {
                 $oLog->set("status", "error (sending)");
                 $oLog->store();
             }
         }
     }
     if ($this->get("status") == 1) {
         // Job waiting for sending
         $this->set("status", 2);
         $this->set("started", date("Y-m-d H:i:s"), false);
         $this->store();
         // Initialization
         $aMessages = array();
         $oLanguage = new cApiLanguage($this->get("idlang"));
         $sFormatDate = $oLanguage->getProperty("dateformat", "date");
         $sFormatTime = $oLanguage->getProperty("dateformat", "time");
         unset($oLanguage);
         if ($sFormatDate == "") {
             $sFormatDate = 'Y-m-d';
         }
         if ($sFormatTime == "") {
             $sFormatTime = 'h:i a';
         }
         // Get newsletter data
         $sFrom = $this->get("newsfrom");
         $sFromName = $this->get("newsfromname");
         $sSubject = $this->get("subject");
         $sMessageText = $this->get("message_text");
         $sMessageHTML = $this->get("message_html");
         $dNewsDate = strtotime($this->get("newsdate"));
         $sEncoding = $this->get("encoding");
         $bIsHTML = false;
         if ($this->get("type") == "html" && $sMessageHTML != "") {
             $bIsHTML = true;
         }
         $bDispatch = false;
         if ($this->get("dispatch") == 1) {
             $bDispatch = true;
         }
         // Single replacements
         // Replace message tags (text message)
         $sMessageText = str_replace("MAIL_DATE", date($sFormatDate, $dNewsDate), $sMessageText);
         $sMessageText = str_replace("MAIL_TIME", date($sFormatTime, $dNewsDate), $sMessageText);
         $sMessageText = str_replace("MAIL_NUMBER", $this->get("rcpcount"), $sMessageText);
         // Replace message tags (html message)
         if ($bIsHTML) {
             $sMessageHTML = str_replace("MAIL_DATE", date($sFormatDate, $dNewsDate), $sMessageHTML);
             $sMessageHTML = str_replace("MAIL_TIME", date($sFormatTime, $dNewsDate), $sMessageHTML);
             $sMessageHTML = str_replace("MAIL_NUMBER", $this->get("rcpcount"), $sMessageHTML);
             # Link to online article -->
             if (!is_object($db)) {
                 $db = new DB_Contenido();
             }
             $sql = 'SELECT idart
                     FROM ' . $cfg['tab']['news'] . '
                     WHERE (idnews=' . $this->get('idnews') . ')';
             $db->query($sql);
             $db->next_record();
             $news_idart = $db->f('idart');
             $link = Contenido_Url::getInstance()->build(array('idart' => $news_idart, 'client' => $this->get('idclient'), 'lang' => $this->get("idlang"), 'nl' => $this->get('idnewsjob'), 'rcp' => '{RCP}'), true);
             $p1 = strpos($sMessageHTML, '<body');
             if ($p1 !== false) {
                 $p1 = strpos($sMessageHTML, '>', $p1) + 1;
             } else {
                 $p1 = 0;
             }
             $sOnlineText = getEffectiveSetting('newsletter-online-text', $this->get("idlang"), 'If the newsletter is not shown properly, please click here to view the online version.');
             $sMessageHTML = substr($sMessageHTML, 0, $p1) . '<div style="text-align: center; background-color: #FFF;"><a href="' . $link . '" style="font-weight: bold;">' . $sOnlineText . '</a></div>' . substr($sMessageHTML, $p1);
             # <-- Link to online article
             // Remove base tag
             $sMessageHTML = preg_replace('/<base href=(.*?)>/is', '', $sMessageHTML, 1);
             // Fix source path
             // TODO: Test any URL specification that may exist under the sun...
             $sMainURL = Contenido_Url::getInstance()->build(array('idcat' => getEffectiveSetting('navigation', 'idcat-home', 1), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true);
             $sSelfURL = Contenido_Url::getInstance()->build(array('idart' => $this->get("idart"), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true);
             $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')([^(http|#)])(\\/)?/", "\$1=" . "\$2" . $sMainURL . "\$3", $sMessageHTML);
             $sMessageHTML = preg_replace('/url\\([\\"\'](.*)[\\"\']\\)/', 'url(\'' . $sMainURL . '$1\')', $sMessageHTML);
             $sMessageHTML = str_replace('/cms//', '/', $sMessageHTML);
             // Now replace anchor tags to the newsletter article itself just by the anchor
             $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')" . str_replace('/', '\\/', $sSelfURL) . "(.*)#(.*)(\"|\\')/", "\$1=" . "\$2" . "#" . "\$4" . "\$5", $sMessageHTML);
             // Now correct mailto tags
             $sMessageHTML = str_replace($sMainURL . 'mailto:', 'mailto:', $sMessageHTML);
             # Remove the <noscript> info from the newsletter message
             $sMessageHTML = str_replace(array('This website is powered by drugCMS, the Content Management System with addictive potential.', 'For more info and download visit <a href="http://www.drugcms.org">www.drugcms.org</a>.', 'drugCMS is made in Germany.'), '', $sMessageHTML);
         }
         // Enabling plugin interface
         $bPluginEnabled = false;
         if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") {
             $bPluginEnabled = true;
             $aPlugins = array();
             if (is_array($cfg['plugins']['recipients'])) {
                 foreach ($cfg['plugins']['recipients'] as $sPlugin) {
                     plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php");
                     if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) {
                         $aPlugins[$sPlugin] = call_user_func("recipients_" . $sPlugin . "_wantedVariables");
                     }
                 }
             }
         }
         // Get recipients (from log table)
         if (!is_object($oLogs)) {
             $oLogs = new cNewsletterLogCollection();
         } else {
             $oLogs->resetQuery();
         }
         $oLogs->setWhere("idnewsjob", $this->get($this->primaryKey));
         $oLogs->setWhere("status", "pending");
         if ($bDispatch) {
             $oLogs->setLimit(0, $this->get("dispatch_count"));
         }
         $oLogs->query();
         while ($oLog = $oLogs->next()) {
             $iCount++;
             $oLog->set("status", "sending");
             $oLog->store();
             $sRcpMsgText = $sMessageText;
             $sRcpMsgHTML = $sMessageHTML;
             $sKey = $oLog->get("rcphash");
             $sEMail = $oLog->get("rcpemail");
             $bSendHTML = false;
             if ($oLog->get("rcpnewstype") == 1) {
                 $bSendHTML = true;
                 // Recipient accepts html newsletter
             }
             if (strlen($sKey) == 30) {
                 // Prevents sending without having a key
                 $sRcpMsgText = str_replace("{KEY}", $sKey, $sRcpMsgText);
                 $sRcpMsgText = str_replace("MAIL_MAIL", $sEMail, $sRcpMsgText);
                 $sRcpMsgText = str_replace("MAIL_NAME", $oLog->get("rcpname"), $sRcpMsgText);
                 // Replace message tags (html message)
                 if ($bIsHTML && $bSendHTML) {
                     $sRcpMsgHTML = str_replace("{KEY}", $sKey, $sRcpMsgHTML);
                     $sRcpMsgHTML = str_replace("MAIL_MAIL", $sEMail, $sRcpMsgHTML);
                     $sRcpMsgHTML = str_replace("MAIL_NAME", $oLog->get("rcpname"), $sRcpMsgHTML);
                     $sRcpMsgHTML = str_replace(urlencode('{RCP}'), $sKey, $sRcpMsgHTML);
                 }
                 if ($bPluginEnabled) {
                     // Don't change name of $recipient variable as it is used in plugins!
                     $recipient = new Recipient();
                     $recipient->loadByPrimaryKey($oLog->get("idnewsrcp"));
                     foreach ($aPlugins as $sPlugin => $aPluginVar) {
                         foreach ($aPluginVar as $sPluginVar) {
                             // Replace tags in text message
                             $sRcpMsgText = str_replace("MAIL_" . strtoupper($sPluginVar), call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar), $sRcpMsgText);
                             // Replace tags in html message
                             if ($bIsHTML && $bSendHTML) {
                                 $sRcpMsgHTML = str_replace("MAIL_" . strtoupper($sPluginVar), call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar), $sRcpMsgHTML);
                             }
                         }
                     }
                     unset($recipient);
                 }
                 $oMail = new PHPMailer();
                 $oMail->CharSet = $sEncoding;
                 $oMail->IsHTML($bIsHTML && $bSendHTML);
                 $oMail->From = $sFrom;
                 $oMail->FromName = $sFromName;
                 $oMail->AddAddress($sEMail);
                 # Mailer Configuration -->
                 $sMailer = strtolower(getEffectiveSetting('newsletter', 'mailer'));
                 $sHost = getEffectiveSetting('newsletter', 'host');
                 $iPort = intval(getEffectiveSetting('newsletter', 'port'));
                 $sUsername = getEffectiveSetting('newsletter', 'username');
                 $sPassword = getEffectiveSetting('newsletter', 'password');
                 if (strlen($sMailer) == 0) {
                     $sMailer = strtolower(getEffectiveSetting('email', 'mailer'));
                     $sHost = getEffectiveSetting('email', 'host');
                     $iPort = intval(getEffectiveSetting('email', 'port'));
                     $sUsername = getEffectiveSetting('email', 'username');
                     $sPassword = getEffectiveSetting('email', 'password');
                 }
                 if (strlen($sMailer) == 0) {
                     setSystemProperty('newsletter', 'mailer', 'mail');
                     $sMailer = 'mail';
                 }
                 if (strlen($sHost) == 0) {
                     setSystemProperty('newsletter', 'host', '');
                 }
                 if ($iPort == 0) {
                     setSystemProperty('newsletter', 'port', '25');
                     $iPort = 25;
                 }
                 if (strlen($sUsername) == 0) {
                     setSystemProperty('newsletter', 'username', '');
                 }
                 if (strlen($sPassword) == 0) {
                     setSystemProperty('newsletter', 'password', '');
                 }
                 $oMail->Mailer = $sMailer;
                 if ($sMailer == 'smtp') {
                     $oMail->SMTPAuth = true;
                     $oMail->Host = $sHost;
                     $oMail->Port = $iPort;
                     $oMail->Username = $sUsername;
                     $oMail->Password = $sPassword;
                 }
                 # <-- Mailer Configuration
                 $oMail->Subject = $sSubject;
                 if ($bIsHTML && $bSendHTML) {
                     $oMail->Body = $sRcpMsgHTML;
                     $oMail->AltBody = $sRcpMsgText . "\n\n";
                 } else {
                     $oMail->Body = $sRcpMsgText . "\n\n";
                 }
                 if ($oMail->Send()) {
                     $oLog->set("status", "successful");
                     $oLog->set("sent", date("Y-m-d H:i:s"), false);
                 } else {
                     $oLog->set("status", "error (sending)");
                 }
             } else {
                 $oLog->set("status", "error (key)");
             }
             $oLog->store();
         }
         $this->set("sendcount", $this->get("sendcount") + $iCount);
         if ($iCount == 0 || !$bDispatch) {
             // No recipients remaining, job finished
             $this->set("status", 9);
             $this->set("finished", date("Y-m-d H:i:s"), false);
         } else {
             if ($bDispatch) {
                 // Check, if there are recipients remaining - stops job faster
                 $oLogs->resetQuery();
                 $oLogs->setWhere("idnewsjob", $this->get($this->primaryKey));
                 $oLogs->setWhere("status", "pending");
                 $oLogs->setLimit(0, $this->get("dispatch_count"));
                 $oLogs->query();
                 if ($oLogs->next()) {
                     // Remaining recipients found, set job back to pending
                     $this->set("status", 1);
                     $this->set("started", "0000-00-00 00:00:00", false);
                 } else {
                     // No remaining recipients, job finished
                     $this->set("status", 9);
                     $this->set("finished", date("Y-m-d H:i:s"), false);
                 }
             } else {
                 // Set job back to pending
                 $this->set("status", 1);
                 $this->set("started", "0000-00-00 00:00:00", false);
             }
         }
         $this->store();
     }
     return $iCount;
 }
                `sortorder` int(10) NOT NULL DEFAULT "0",
                PRIMARY KEY (`idpica_alloc`)
            )';
    $db->query($sql);
    $sql = 'CREATE TABLE `' . $cfg['sql']['sqlprefix'] . '_pica_alloc_con` (
                `idpica_alloc` int(10) NOT NULL DEFAULT "0",
                `idartlang` int(10) NOT NULL DEFAULT "0",
                PRIMARY KEY (`idpica_alloc`,`idartlang`)
            )';
    $db->query($sql);
    $sql = 'CREATE TABLE `' . $cfg['sql']['sqlprefix'] . '_pica_lang` (
                `idpica_alloc` int(10) NOT NULL DEFAULT "0",
                `idlang` int(10) NOT NULL DEFAULT "0",
                `name` varchar(255) DEFAULT NULL,
                `online` tinyint(1) NOT NULL DEFAULT "0",
                PRIMARY KEY (`idpica_alloc`,`idlang`)
            )';
    $db->query($sql);
}
if (!$db) {
    $db = new DB_Contenido();
}
$sql = 'SELECT idpica_alloc
        FROM ' . $cfg['sql']['sqlprefix'] . '_pica_alloc
        LIMIT 0, 1';
if (!$db->query($sql)) {
    picaCreateDbTables($db, $cfg);
}
plugin_include('content_allocation', 'includes/functions.chains.php');
$_cecRegistry->addChainFunction("Contenido.Article.RegisterCustomTab", "pica_RegisterCustomTab");
$_cecRegistry->addChainFunction("Contenido.Article.GetCustomTabProperties", "pica_GetCustomTabProperties");
예제 #3
0
/**
 * Register a plugin with MantisBT.
 * The plugin class must already be loaded before calling.
 * @param string Plugin classname without 'Plugin' postfix
 */
function plugin_register($p_basename, $p_return = false, $p_child = null)
{
    global $g_plugin_cache;
    $t_basename = is_null($p_child) ? $p_basename : $p_child;
    if (!isset($g_plugin_cache[$t_basename])) {
        if (is_null($p_child)) {
            $t_classname = $p_basename . 'Plugin';
        } else {
            $t_classname = $p_child . 'Plugin';
        }
        # Include the plugin script if the class is not already declared.
        if (!class_exists($t_classname)) {
            if (!plugin_include($p_basename, $p_child)) {
                return null;
            }
        }
        # Make sure the class exists and that it's of the right type.
        if (class_exists($t_classname) && is_subclass_of($t_classname, 'MantisPlugin')) {
            plugin_push_current(is_null($p_child) ? $p_basename : $p_child);
            $t_plugin = new $t_classname(is_null($p_child) ? $p_basename : $p_child);
            plugin_pop_current();
            # Final check on the class
            if (is_null($t_plugin->name) || is_null($t_plugin->version)) {
                return null;
            }
            if ($p_return) {
                return $t_plugin;
            } else {
                $g_plugin_cache[$t_basename] = $t_plugin;
            }
        }
    }
    return $g_plugin_cache[$t_basename];
}
 *   created 2007-01-01, Björn Behrens (HerrB)
 *   modified 2008-06-27, Dominik Ziegler, add security fix
 *
 *   $Id$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
$oPage = new cPage();
$oRecipients = new RecipientCollection();
if (is_array($cfg['plugins']['recipients'])) {
    foreach ($cfg['plugins']['recipients'] as $plugin) {
        plugin_include("recipients", $plugin . "/" . $plugin . ".php");
    }
}
// Note, that the object name has to be $recipient for plugins
if ($action == "recipients_create" && $perm->have_perm_area_action($area, $action)) {
    $recipient = $oRecipients->create("*****@*****.**", " " . i18n("-- new recipient --", $plugin_name));
    $oPage->setReload();
} elseif ($action == "recipients_delete" && $perm->have_perm_area_action($area, $action)) {
    $oRecipients->delete($idrecipient);
    $recipient = new Recipient();
    $oPage->setReload();
} elseif ($action == "recipients_purge" && $perm->have_perm_area_action($area, "recipients_delete")) {
    $oClient = new cApiClient($client);
    $timeframe = $oClient->getProperty("newsletter", "purgetimeframe");
    if (!$timeframe) {
        $timeframe = 30;
 /**
  * Sends test newsletter directly to specified recipients (single or group)
  *
  * Note: Sending in chunks not supported! Only usable for tests and only a few
  * recipients.
  *
  * @param integer  $iIDCatArt     idcatart of newsletter handler article
  * @param integer  $iIDNewsRcp    If specified, newsletter recipient id, ignored, if group specified
  * @param integer  $iIDNewsGroup  If specified, newsletter recipient group id
  * @param array    $aSendRcps     As reference: Filled with a list of succesfull recipients
  * @param string   $sEncoding     Message (and header) encoding, e.g. iso-8859-1
  */
 public function sendDirect($iIDCatArt, $iIDNewsRcp = false, $iIDNewsGroup = false, &$aSendRcps, $sEncoding = "iso-8859-1")
 {
     global $lang, $client, $cfg, $cfgClient, $contenido, $recipient;
     // Initialization
     $aMessages = array();
     $oLanguage = new cApiLanguage($lang);
     $sFormatDate = $oLanguage->getProperty("dateformat", "date");
     $sFormatTime = $oLanguage->getProperty("dateformat", "time");
     unset($oLanguage);
     if ($sFormatDate == "") {
         $sFormatDate = 'Y-m-d';
     }
     if ($sFormatTime == "") {
         $sFormatTime = 'h:i a';
     }
     #$sPath = $cfgClient[$client]["path"]["htmlpath"]."front_content.php?changelang=".$lang."&idcatart=".$iIDCatArt."&";
     $sPath = Contenido_Url::getInstance()->build(array('idcatart' => $iIDCatArt, 'client' => $client, 'lang' => $lang), true);
     $sPath .= strpos($sPath, '?') === false ? '?' : '&';
     // Get newsletter data
     $sFrom = $this->get("newsfrom");
     $sFromName = $this->get("newsfromname");
     if ($sFromName == "") {
         $sFromName = $sFrom;
     }
     $sSubject = $this->get("subject");
     $sMessageText = $this->get("message");
     $bIsHTML = false;
     if ($this->get("type") == "html") {
         $sMessageHTML = $this->getHTMLMessage();
         if ($sMessageHTML === false) {
             // There was a problem getting the html message (maybe article
             // deleted). Exit with error instead of sending as text message only
             if ($contenido) {
                 // Use i18n only in backend
                 $sError = i18n("Newsletter could not be sent: No html message available", $plugin_name);
             } else {
                 $sError = "Newsletter could not be sent: No html message available";
             }
             $this->_sError = $sError;
             return false;
         } else {
             $bIsHTML = true;
         }
     }
     // Preventing double lines in mail, you may wish to disable this function on windows servers
     if (!getSystemProperty("newsletter", "disable-rn-replacement")) {
         $sMessageText = str_replace("\r\n", "\n", $sMessageText);
     }
     // Single replacements
     // Replace message tags (text message)
     $this->_replaceTag($sMessageText, false, "date", date($sFormatDate));
     $this->_replaceTag($sMessageText, false, "time", date($sFormatTime));
     // Replace message tags (html message)
     if ($bIsHTML) {
         $this->_replaceTag($sMessageHTML, true, "date", date($sFormatDate));
         $this->_replaceTag($sMessageHTML, true, "time", date($sFormatTime));
     }
     // Enabling plugin interface
     if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") {
         $bPluginEnabled = true;
         $aPlugins = array();
         if (is_array($cfg['plugins']['recipients'])) {
             foreach ($cfg['plugins']['recipients'] as $sPlugin) {
                 plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php");
                 if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) {
                     $aPlugins[$sPlugin] = call_user_func("recipients_" . $sPlugin . "_wantedVariables");
                 }
             }
         }
     } else {
         setSystemProperty("newsletter", "newsletter-recipients-plugin", "false");
         $bPluginEnabled = false;
     }
     $aRecipients = array();
     if ($iIDNewsGroup !== false) {
         $oGroupMembers = new RecipientGroupMemberCollection();
         $aRecipients = $oGroupMembers->getRecipientsInGroup($iIDNewsGroup, false);
     } else {
         if ($iIDNewsRcp !== false) {
             $aRecipients[] = $iIDNewsRcp;
         }
     }
     $iCount = count($aRecipients);
     if ($iCount > 0) {
         $this->_replaceTag($sMessageText, false, "number", $iCount);
         // Replace message tags (html message)
         if ($bIsHTML) {
             $this->_replaceTag($sMessageHTML, true, "number", $iCount);
         }
         foreach ($aRecipients as $iID) {
             $sRcpMsgText = $sMessageText;
             $sRcpMsgHTML = $sMessageHTML;
             // Don't change name of $recipient variable as it is used in plugins!
             $recipient = new Recipient();
             $recipient->loadByPrimaryKey($iID);
             $sEMail = $recipient->get("email");
             $sName = $recipient->get("name");
             if (empty($sName)) {
                 $sName = $sEMail;
             }
             $sKey = $recipient->get("hash");
             $bSendHTML = false;
             if ($recipient->get("news_type") == 1) {
                 $bSendHTML = true;
                 // Recipient accepts html newsletter
             }
             $this->_replaceTag($sRcpMsgText, false, "name", $sName);
             $this->_replaceTag($sRcpMsgText, false, "unsubscribe", $sPath . "unsubscribe=" . $sKey);
             $this->_replaceTag($sRcpMsgText, false, "change", $sPath . "change=" . $sKey);
             $this->_replaceTag($sRcpMsgText, false, "stop", $sPath . "stop=" . $sKey);
             $this->_replaceTag($sRcpMsgText, false, "goon", $sPath . "goon=" . $sKey);
             // Replace message tags (html message)
             if ($bIsHTML && $bSendHTML) {
                 $this->_replaceTag($sRcpMsgHTML, true, "name", $sName);
                 $this->_replaceTag($sRcpMsgHTML, true, "unsubscribe", $sPath . "unsubscribe=" . $sKey);
                 $this->_replaceTag($sRcpMsgHTML, true, "change", $sPath . "change=" . $sKey);
                 $this->_replaceTag($sRcpMsgHTML, true, "stop", $sPath . "stop=" . $sKey);
                 $this->_replaceTag($sRcpMsgHTML, true, "goon", $sPath . "goon=" . $sKey);
                 # Link to online article -->
                 if (!is_object($db)) {
                     $db = new DB_Contenido();
                 }
                 $sql = 'SELECT idart
                         FROM ' . $cfg['tab']['news'] . '
                         WHERE (idnews=' . $this->get('idnews') . ')';
                 $db->query($sql);
                 $db->next_record();
                 $news_idart = $db->f('idart');
                 $link = Contenido_Url::getInstance()->build(array('idart' => $news_idart, 'client' => $this->get('idclient'), 'lang' => $this->get("idlang"), 'rcp' => $sKey), true);
                 $p1 = strpos($sMessageHTML, '<body');
                 if ($p1 !== false) {
                     $p1 = strpos($sMessageHTML, '>', $p1) + 1;
                 } else {
                     $p1 = 0;
                 }
                 $sOnlineText = getEffectiveSetting('newsletter-online-text', $this->get("idlang"), 'If the newsletter is not shown properly, please click here to view the online version.');
                 $sMessageHTML = substr($sMessageHTML, 0, $p1) . '<div style="text-align: center; background-color: #FFF;"><a href="' . $link . '" style="font-weight: bold;">' . $sOnlineText . '</a></div>' . substr($sMessageHTML, $p1);
                 # <-- Link to online article
                 // Remove base tag
                 $sMessageHTML = preg_replace('/<base href=(.*?)>/is', '', $sMessageHTML, 1);
                 // Fix source path
                 // TODO: Test any URL specification that may exist under the sun...
                 $sMainURL = Contenido_Url::getInstance()->build(array('idcat' => getEffectiveSetting('navigation', 'idcat-home', 1), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true);
                 $sSelfURL = Contenido_Url::getInstance()->build(array('idart' => $this->get("idart"), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true);
                 $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')([^(http|#)])(\\/)?/", "\$1=" . "\$2" . $sMainURL . "\$3", $sMessageHTML);
                 $sMessageHTML = preg_replace('/url\\([\\"\'](.*)[\\"\']\\)/', 'url(\'' . $sMainURL . '$1\')', $sMessageHTML);
                 $sMessageHTML = str_replace('/cms//', '/', $sMessageHTML);
                 // Now replace anchor tags to the newsletter article itself just by the anchor
                 $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')" . str_replace('/', '\\/', $sSelfURL) . "(.*)#(.*)(\"|\\')/", "\$1=" . "\$2" . "#" . "\$4" . "\$5", $sMessageHTML);
                 // Now correct mailto tags
                 $sMessageHTML = str_replace($sMainURL . 'mailto:', 'mailto:', $sMessageHTML);
                 # Remove the <noscript> info from the newsletter message
                 $sMessageHTML = str_replace(array('This website is powered by drugCMS, the Content Management System with addictive potential.', 'For more info and download visit <a href="http://www.drugcms.org">www.drugcms.org</a>.', 'drugCMS is made in Germany.'), '', $sMessageHTML);
             }
             if ($bPluginEnabled) {
                 foreach ($aPlugins as $sPlugin => $aPluginVar) {
                     foreach ($aPluginVar as $sPluginVar) {
                         // Replace tags in text message
                         $this->_replaceTag($sRcpMsgText, false, $sPluginVar, call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar));
                         // Replace tags in html message
                         if ($bIsHTML && $bSendHTML) {
                             $this->_replaceTag($sRcpMsgHTML, true, $sPluginVar, call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar));
                         }
                     }
                 }
             }
             if (strlen($sKey) != 30) {
                 // Prevents sending without having a key
                 if ($contenido) {
                     // Use i18n only in backend
                     $sError = i18n("Newsletter to %s could not be sent: Recipient has an incompatible or empty key", $plugin_name);
                 } else {
                     $sError = "Newsletter to %s could not be sent: Recipient has an incompatible or empty key";
                 }
                 $aMessages[] = $sName . " (" . $sEMail . "): " . sprintf($sError, $sEMail);
             } else {
                 if (!isValidMail($sEMail)) {
                     if ($contenido) {
                         // Use i18n only in backend
                         $sError = i18n("Newsletter to %s could not be sent: No valid e-mail address specified", $plugin_name);
                     } else {
                         $sError = "Newsletter to %s could not be sent: No valid e-mail address specified";
                     }
                     $aMessages[] = $sName . " (" . $sEMail . "): " . sprintf($sError, $sEMail);
                 } else {
                     $oMail = new PHPMailer();
                     $oMail->CharSet = $sEncoding;
                     $oMail->IsHTML($bIsHTML && $bSendHTML);
                     $oMail->From = $sFrom;
                     $oMail->FromName = $sFromName;
                     $oMail->AddAddress($sEMail);
                     # Mailer Configuration -->
                     $sMailer = strtolower(getEffectiveSetting('newsletter', 'mailer'));
                     $sHost = getEffectiveSetting('newsletter', 'host');
                     $iPort = intval(getEffectiveSetting('newsletter', 'port'));
                     $sUsername = getEffectiveSetting('newsletter', 'username');
                     $sPassword = getEffectiveSetting('newsletter', 'password');
                     if (strlen($sMailer) == 0) {
                         $sMailer = strtolower(getEffectiveSetting('email', 'mailer'));
                         $sHost = getEffectiveSetting('email', 'host');
                         $iPort = intval(getEffectiveSetting('email', 'port'));
                         $sUsername = getEffectiveSetting('email', 'username');
                         $sPassword = getEffectiveSetting('email', 'password');
                     }
                     if (strlen($sMailer) == 0) {
                         setClientProperty('email', 'mailer', 'mail');
                         $sMailer = 'mail';
                     }
                     if (strlen($sHost) == 0) {
                         setClientProperty('email', 'host', '');
                     }
                     if ($iPort == 0) {
                         setClientProperty('email', 'port', '25');
                         $iPort = 25;
                     }
                     if (strlen($sUsername) == 0) {
                         setClientProperty('email', 'username', '');
                     }
                     if (strlen($sPassword) == 0) {
                         setClientProperty('email', 'password', '');
                     }
                     $oMail->Mailer = $sMailer;
                     if ($sMailer == 'smtp') {
                         $oMail->SMTPAuth = true;
                         $oMail->Host = $sHost;
                         $oMail->Port = $iPort;
                         $oMail->Username = $sUsername;
                         $oMail->Password = $sPassword;
                     }
                     # <-- Mailer Configuration
                     $oMail->Subject = $sSubject;
                     if ($bIsHTML && $bSendHTML) {
                         $oMail->Body = $sRcpMsgHTML;
                         $oMail->AltBody = $sRcpMsgText . "\n\n";
                     } else {
                         $oMail->Body = $sRcpMsgText . "\n\n";
                     }
                     if ($oMail->Send()) {
                         $aSendRcps[] = $sName . " (" . $sEMail . ")";
                     } else {
                         if ($contenido) {
                             // Use i18n only in backend
                             $sError = i18n("Newsletter to %s could not be sent", $plugin_name);
                         } else {
                             $sError = "Newsletter to %s could not be sent";
                         }
                         $aMessages[] = $sName . " (" . $sEMail . "): " . sprintf($sError, $sEMail);
                     }
                 }
             }
         }
     } else {
         if ($contenido) {
             // Use i18n only in backend
             $sError = i18n("No recipient with specified recipient/group id %s/%s found", $plugin_name);
         } else {
             $sError = "No recipient with specified recpient/group id %s/%s found";
         }
         $aMessages[] = sprintf($sError, $iIDNewsRcp, $iIDNewsGroup);
     }
     if (count($aMessages) > 0) {
         $this->_sError = implode("<br />", $aMessages);
         return false;
     } else {
         return true;
     }
 }
 * 
 * {@internal 
 *   created  2003-05-26
 *   modified 2010-05-20, Murat Purc, removed request check during processing ticket [#CON-307]
 *   
 *   $Id$
 * }}
 * 
 */
define('CON_FRAMEWORK', true);
// Contenido startup process
include_once '../../../includes/startup.php';
cInclude("includes", "cfg_language_de.inc.php");
cInclude("includes", "functions.con.php");
plugin_include('workflow', 'classes/class.workflow.php');
plugin_include('workflow', 'includes/functions.workflow.php');
$workflowartallocations = new WorkflowArtAllocations();
$workflowusersequences = new WorkflowUserSequences();
$workflowartallocations->select();
while ($obj = $workflowartallocations->next()) {
    $starttime = $obj->get("starttime");
    $idartlang = $obj->get("idartlang");
    $lastidusersequence = $obj->get("lastusersequence");
    $usersequence = getCurrentUserSequence($idartlang, 0);
    if ($usersequence != $lastidusersequence) {
        $workflowusersequences->select("idusersequence = '{$usersequence}'");
        if ($wfobj = $workflowusersequences->next()) {
            $wfitem = $wfobj->get("idworkflowitem");
            $pos = $wfobj->get("position");
            $timeunit = $wfobj->get("timeunit");
            $timelimit = $wfobj->get("timelimit");
if ((int) $client == 0 && $cronjob != true) {
    $notification->displayNotification("error", i18n("No Client selected"));
    exit;
}
// If no mode defined, use mode three
if (empty($_GET['mode'])) {
    $_GET['mode'] = 3;
}
// If no action definied
if (empty($_GET['action'])) {
    $_GET['action'] = 'linkchecker';
    $action = "linkchecker";
}
plugin_include('linkchecker', 'includes/config.plugin.php');
plugin_include('linkchecker', 'includes/include.checkperms.php');
plugin_include('linkchecker', 'includes/include.linkchecker_tests.php');
cInclude('pear', 'PEAR.php');
cInclude('pear', 'Cache/Lite.php');
// Initialization
$actionID = 500;
$aCats = array();
$aSearchIDInfosArt = array();
$aSearchIDInfosCatArt = array();
$aSearchIDInfosNonID = array();
$iWhitelist_timeout = 2592000;
// 30 days
// Var initialization
$aUrl = array('cms' => $cfgClient[$client]['path']['htmlpath'], 'contenido' => $cfg['path']['contenido_fullhtml']);
// Template- and languagevars
if ($cronjob != true) {
    $tpl->set('s', 'FULLHTML', $aUrl['contenido']);
 * @license    http://www.contenido.org/license/LIZENZ.txt
 * @link       http://www.4fb.de
 * @link       http://www.contenido.org
 * 
 * {@internal 
 *   created 2006-01-13
 *   
 *   $Id$
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$iIdMarked = (int) $_GET['idworkflow'];
plugin_include('workflow', 'classes/class.workflow.php');
$workflows = new Workflows();
$sScript = '';
if ($action == "workflow_delete") {
    $workflows->delete($idworkflow);
    $sScript = '<script type="text/javascript">
                    var right_top = top.content.frames["right"].frames["right_top"];
                    var right_bottom = top.content.frames["right"].frames["right_bottom"];

                    if (right_top) {
                        right_top.location.href = "' . $sess->url('main.php?area=workflow&frame=3') . '";
                    }
                    if (right_bottom) {
                        right_bottom.location.href = "' . $sess->url('main.php?area=workflow&frame=4') . '";
                    }
                </script>';
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$cfg["tab"]["workflow"] = $cfg['sql']['sqlprefix'] . "_piwf_workflow";
$cfg["tab"]["workflow_allocation"] = $cfg['sql']['sqlprefix'] . "_piwf_allocation";
$cfg["tab"]["workflow_art_allocation"] = $cfg['sql']['sqlprefix'] . "_piwf_art_allocation";
$cfg["tab"]["workflow_items"] = $cfg['sql']['sqlprefix'] . "_piwf_items";
$cfg["tab"]["workflow_user_sequences"] = $cfg['sql']['sqlprefix'] . "_piwf_user_sequences";
$cfg["tab"]["workflow_actions"] = $cfg['sql']['sqlprefix'] . "_piwf_actions";
plugin_include('workflow', 'classes/class.workflowactions.php');
plugin_include('workflow', 'classes/class.workflowallocation.php');
plugin_include('workflow', 'classes/class.workflowartallocation.php');
plugin_include('workflow', 'classes/class.workflowitems.php');
plugin_include('workflow', 'classes/class.workflowusersequence.php');
/**
 * Class Workflows
 * Class for workflow management
 * @author Timo A. Hummel <*****@*****.**>
 * @version 0.2
 * @copyright four for business 2003
 */
class Workflows extends ItemCollection
{
    /**
     * Constructor Function
     * @param none
     */
    function __construct()
    {
 * {@internal 
 *   created 2005
 *   modified 2005-10-27, Willi Man, debug option
 *   modified 2005-11-16, Willi Man, new method findMatchingContentByContentAllocationByCategories
 *   modified 2005-11-21, Willi Man, new method findMarchingCOntentByContentAllocation_OR_Categories
 *   modified 2008-04-06, Holger Librenz, direct mysql_* calls remoced, using DB_Contenido:: methods instead
 *   modified 2008-07-02, Frederic Schneider, add security fix
 *
 *   $Id$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
plugin_include('repository', 'custom/FrontendNavigation.php');
class pApiContentAllocation
{
    /**
     * References database object
     *
     * @var DB_Contenido
     */
    var $db = null;
    var $table = null;
    var $lang = null;
    var $client = null;
    var $treeObj = null;
    /**
     *
     * @modified 27.10.2005 new class variable $this->bDebug (if true print debug information)
<?php

if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
if (!$perm->have_perm_area_action($plugin_name, $plugin_name) && !$cronjob) {
    exit;
}
$plugin_name = "db_backup";
plugin_include($plugin_name, 'includes/config.plugin.php');
$oTpl = new Template();
# Check for the requirements
if (!$pathfinder || !$permissionfinder) {
    $oTpl->set('s', 'HEADLINE', i18n("Configuration", $plugin_name));
    $oTpl->set('s', 'INTRO', i18n("Backup requires a folder named 'backup' in /drugcms/data/ with write permission for the web server user.", $plugin_name));
    $oTpl->set('s', 'LABEL_SETTINGS', i18n("Current settings", $plugin_name));
    $oTpl->set('s', 'LABEL_PATHFINDER', i18n("Backup folder", $plugin_name));
    $oTpl->set('s', 'PATHFINDER', $pathfinder ? i18n("The backup folder exists", $plugin_name) : i18n("The backup folder doesn't exist, please create it", $plugin_name));
    $oTpl->set('s', 'LABEL_CHMOD', i18n("Folder permissions", $plugin_name));
    $oTpl->set('s', 'CHMOD', $permissionfinder ? i18n("Write permission granted", $plugin_name) : i18n("Write permission denied", $plugin_name));
    $oTpl->generate($cfg[$plugin_name]['templates']['config']);
} else {
    switch (intval($_GET['action'])) {
        case 1:
            $fStart = isset($_GET['start']) ? floatval($_GET['start']) : microtime(true);
            $sFile = isset($_GET['file']) ? $_GET['file'] : $contenido_database . '_' . date("Y\\-m\\-d\\_H\\-i\\-s", time()) . '.sql';
            $ret = backup_tables($backup_path . $sFile, $contenido_host, $contenido_user, $contenido_password, $contenido_database, $_GET['table'], intval($_GET['row']));
            if (is_array($ret)) {
                $oTpl->set('s', 'PATH', $cfg['path']['contenido_fullhtml']);
                $oTpl->set('s', 'LABEL_WAIT', i18n("Please wait", $plugin_name) . '&hellip;');
                $oTpl->set('s', 'MESSAGE', i18n("Current table", $plugin_name) . ': ' . $ret['table'] . '<br />' . i18n("Current row", $plugin_name) . ': ' . $ret['row']);