//echo "running";
//define( 'SHORTINIT', true );
//require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
global $wpdb;
//checks for list of entries to generate docs;
$leads = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "tpl_docs  WHERE cron_status = 0  ", ""));
if (!empty($leads)) {
    echo "There are leads<br/> ";
    foreach ($leads as $lead) {
        $form = GFAPI::get_form($lead->form_id);
        $entry = GFAPI::get_entry($lead->lead_id);
        //echo $form;
        $generateStatus = cron_merge_template($form, $entry, $lead->file_id, $lead->invoice_number);
        //if order made and no pdf to generate so we need to let the admin know and notified.
        if ($generateStatus == false) {
            if (sendMailNotification($lead->form_id, $lead->lead_id)) {
                echo "<br> Sent notification to admin that no pdf is to be generated";
            } else {
                echo "<br> Failed to send notification to admin that no pdf is to be generated";
            }
        } else {
            echo "<H1> PDF generated";
        }
    }
} else {
    echo "<br> No Leads To Generate Docs";
}
//Initialising document generation process and email trigger
function cron_merge_template($form, $entry, $fileid, $invoice_number = "")
{
    $return = "";
Пример #2
0
/**
 * Process a comment for moderation. Action 1 = allow,
 * action 2 = delete.
 *
 * When allowed, the comment is changed in the entry, so it is displayed, and it
 * is added to the latest_comments. Whene deleted it'll be deleted from the entry
 *
 * @param array $comm
 * @param integer $action
 */
function moderateProcessComment($comm, $action)
{
    global $PIVOTX;
    if (!isset($db)) {
        $db = new db();
    }
    if ($action == 1) {
        // Allow comment.
        // First, get the entry..
        $entry = $PIVOTX['db']->read_entry($comm['entry_uid']);
        $send_notification = false;
        foreach ($entry['comments'] as $key => $loopcomm) {
            if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) {
                // fix the entry..
                $entry['comments'][$key]['moderate'] = 0;
                // Store the comment that's approved. We need it a bit later on to send the notifications
                $modcomment = $entry['comments'][$key];
                // Save it..
                $PIVOTX['db']->set_entry($entry);
                $PIVOTX['db']->save_entry();
                // Remove the compiled/parsed pages from the cache.
                if ($PIVOTX['config']->get('smarty_cache')) {
                    $PIVOTX['template']->clear_cache();
                }
                $lastcommfile = $PIVOTX['paths']['db_path'] . "ser_lastcomm.php";
                // Add it to the 'latest comments'..
                if (file_exists($lastcommfile)) {
                    $lastcomm = loadSerialize($lastcommfile, true, true);
                } else {
                    $lastcomm = array();
                }
                $lastcomm[] = $comm;
                saveSerialize($lastcommfile, $lastcomm);
                $send_notification = true;
            }
        }
        if ($send_notification && $PIVOTX['config']->get('dont_send_mail_notification') != 1) {
            // Handle the users that want to be notified via email..
            sendMailNotification('comment', array($entry, $modcomment));
        }
    } else {
        if ($action == 2) {
            // Delete comment.
            // First, get the entry..
            $entry = $PIVOTX['db']->read_entry($comm['entry_uid']);
            foreach ($entry['comments'] as $key => $loopcomm) {
                if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) {
                    // fix the entry..
                    unset($entry['comments'][$key]);
                    // Save it..
                    $PIVOTX['db']->set_entry($entry);
                    $PIVOTX['db']->save_entry();
                }
            }
            // Remove the compiled/parsed pages from the cache.
            if ($PIVOTX['config']->get('smarty_cache')) {
                $PIVOTX['template']->clear_cache();
            }
        }
    }
}
Пример #3
0
 /**
  * Checks if any entries set to 'timed publish' should be published.
  *
  * @return void
  */
 function checkTimedPublish()
 {
     global $PIVOTX;
     $date = date("Y-m-d-H-i", getCurrentDate());
     $entries = $this->read_entries(array('full' => true, 'status' => 'timed'));
     foreach ($entries as $entry) {
         if ($entry['publish_date'] <= $date) {
             $entry['date'] = $entry['publish_date'];
             $entry['status'] = "publish";
             $this->set_entry($entry);
             $this->save_entry(TRUE);
             if (!$PIVOTX['config']->get('disable_new_entry_notifications')) {
                 sendMailNotification('entry', $this->entry);
             }
             writeTags($this->entry['keywords'], '', $this->entry['code']);
             updateSearchIndex($this->entry);
         }
     }
 }
Пример #4
0
/**
 * Display 'Entry' page.
 */
function pageEntry()
{
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    if ($_GET['uid'] == "") {
        $PIVOTX['template']->assign('title', __('New Entry'));
    } else {
        $PIVOTX['template']->assign('title', __('Edit Entry'));
    }
    $currentuser = $PIVOTX['users']->getUser($PIVOTX['session']->currentUsername());
    if (!empty($_GET['uid'])) {
        // Editing an entry.. Get it from the DB..
        $entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
        $PIVOTX['events']->add('edit_entry', intval($_GET['uid']), $entry['title']);
        if (!$PIVOTX['users']->allowEdit('entry', $entry['user'])) {
            $PIVOTX['template']->assign('heading', __("PivotX encountered an error"));
            $PIVOTX['template']->assign('html', "<p>" . __("You are not allowed to edit this entry.") . "</p>");
            renderTemplate('generic.tpl');
            return;
        }
        // Make sure we tweak the </textarea> in the intro or body text (since
        // that would break our own textarea, if we didn't)..
        $entry['introduction'] = str_replace("<textarea", "&lt;textarea", $entry['introduction']);
        $entry['introduction'] = str_replace("</textarea", "&lt;/textarea", $entry['introduction']);
        $entry['body'] = str_replace("<textarea", "&lt;textarea", $entry['body']);
        $entry['body'] = str_replace("</textarea", "&lt;/textarea", $entry['body']);
        // If the entry was written in 'convert LB', 'textile' or 'markdown', and is now
        // being edited in 'Plain XHTML' or 'WYSIWYG', we must convert it.
        if (($entry['convert_lb'] == "1" || $entry['convert_lb'] == "2" || $entry['convert_lb'] == "3") && ($currentuser['text_processing'] == "0" || $currentuser['text_processing'] == "5")) {
            $entry['introduction'] = parse_intro_or_body($entry['introduction'], false, $entry['convert_lb'], true);
            $entry['body'] = parse_intro_or_body($entry['body'], false, $entry['convert_lb'], true);
        }
        // Otherwise, if the entry was written in 'Plain XHTML' or 'WYSIWYG', and is now
        // being edited in 'convert LB', 'textile' or 'markdown', there is not much more we
        // can do than strip out the <p> and <br/> tags to replace with linebreaks.
        if (($entry['convert_lb'] == "0" || $entry['convert_lb'] == "5") && ($currentuser['text_processing'] == "1" || $currentuser['text_processing'] == "2" || $currentuser['text_processing'] == "3")) {
            $entry['introduction'] = unparse_intro_or_body($entry['introduction']);
            $entry['body'] = unparse_intro_or_body($entry['body']);
        }
        list($entry['link'], $entry['link_end']) = explode($entry['uri'], $entry['link']);
    } else {
        // Make a new entry.
        $entry = array();
        if ($PIVOTX['config']->get('default_category') != "") {
            $entry['category'] = array($PIVOTX['config']->get('default_category'));
        }
        if ($PIVOTX['config']->get('allow_comments') != "") {
            $entry['allow_comments'] = $PIVOTX['config']->get('allow_comments');
        }
        if ($PIVOTX['config']->get('default_post_status') != "") {
            $entry['status'] = $PIVOTX['config']->get('default_post_status');
        }
        $entry['user'] = $currentuser['username'];
        $entry['link'] = makeFileLink(array('uri' => 'xxx', 'date' => date("Y-m-d-H-i-s")), "", "");
        list($entry['link'], $entry['link_end']) = explode('xxx', $entry['link']);
    }
    // Make sure we only show the allowed categories.. Superadmins can always
    // see and use all categories..
    $categories = $PIVOTX['categories']->getCategories();
    if ($currentuser['userlevel'] < PIVOTX_UL_SUPERADMIN) {
        $allowedcats = $PIVOTX['categories']->allowedCategories($currentuser['username']);
        foreach ($categories as $key => $value) {
            if (!in_array($value['name'], $allowedcats)) {
                unset($categories[$key]);
            }
        }
    }
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        // Ignore URI if we aren't using mod_rewrite.
        if ($PIVOTX['config']->get('mod_rewrite') == 0) {
            unset($entry['uri']);
        }
        $PIVOTX['extensions']->executeHook('entry_edit_beforeedit', $entry);
        // Show the screen..
        $PIVOTX['template']->assign('entry', $entry);
        $PIVOTX['template']->assign('categories', $categories);
        $PIVOTX['template']->assign('pivotxsession', $PIVOTX['session']->getCSRF());
        $PIVOTX['template']->assign('users', $PIVOTX['users']->getUsers());
        $PIVOTX['template']->assign('entryuser', $PIVOTX['users']->getUser($entry['user']));
        renderTemplate('editentry.tpl');
    } else {
        if ($_POST['code'] != $_GET['uid']) {
            $PIVOTX['events']->add('fatal_error', intval($_GET['uid']), "Tried to fake editing an entry");
            echo "Code is wrong! B0rk!";
            die;
        }
        // Make sure the current user is properly logged in, and that the request is legitimate
        $PIVOTX['session']->checkCSRF($_POST['pivotxsession']);
        // Sanitize the $_POST into an entry we can store
        $entry = sanitizePostedEntry($entry);
        $PIVOTX['extensions']->executeHook('entry_edit_beforesave', $entry);
        $entry = $PIVOTX['db']->set_entry($entry);
        if ($PIVOTX['db']->save_entry(TRUE)) {
            $PIVOTX['messages']->addMessage(sprintf(__('Your entry "%s" was successfully saved.'), '<em>' . trimText($entry['title'], 25) . '</em>'));
            $PIVOTX['extensions']->executeHook('entry_edit_aftersave', $entry);
        } else {
            $PIVOTX['messages']->addMessage(sprintf(__('Your entry "%s" was NOT successfully saved.'), '<em>' . trimText($entry['title'], 25) . '</em>'));
            $PIVOTX['extensions']->executeHook('entry_edit_aftersave_failed', $entry);
        }
        // Remove the compiled/parsed pages from the cache.
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->clear_cache();
        }
        // only trigger the ping if it's a new entry..
        if ($entry['code'] == ">" && $entry['status'] == "publish") {
            $ping = TRUE;
        } else {
            $ping = FALSE;
        }
        // only notify if entry is published, and is either new or status changed to publish.
        if ($entry['status'] == "publish" && !$PIVOTX['config']->get('disable_new_entry_notifications')) {
            if ($entry['code'] == ">" || $entry['oldstatus'] != "publish") {
                $notified = sendMailNotification('entry', $PIVOTX['db']->entry);
                $notified = "<br /><br />" . $notified;
            }
        }
        // perhaps send a trackback ping.
        if ($_POST['tb_url'] != "" && $entry['status'] == "publish") {
            require_once 'includes/send_trackback.php';
            $weblogs = $PIVOTX['weblogs']->getWeblogsWithCat($PIVOTX['db']->entry['category']);
            $entry_url = $PIVOTX['paths']['host'] . makeFileLink($PIVOTX['db']->entry['code'], $weblogs[0], '');
            $weblogdata = $PIVOTX['weblogs']->getWeblog($weblogs[0]);
            $weblog_title = $weblogdata['name'];
            $excerpt = parse_intro_or_body($entry['introduction'], false, $entry['convert_lb']);
            $excerpt = trimText(strip_tags($excerpt), 255);
            $tb_urls = explode("\n", $_POST['tb_url']);
            foreach ($tb_urls as $tb_url) {
                $tb_url = trim($tb_url);
                if (isUrl($tb_url)) {
                    $PIVOTX['messages']->addMessage(sprintf(__('A trackback ping has been sent to "%s".'), $tb_url));
                    trackback_send($tb_url, $entry_url, $entry['title'], $weblog_title, $excerpt);
                }
            }
        }
        // TODO: check input for valid categories for user
        // If we use 'save and continue' on a new Entry, we need to redirect to the page
        // for editing, or we can stop displaying stuff here.. We redirect to
        // that entry, because otherwise we would end up with several double entries.
        if ($_POST['postedfrom'] == "continue") {
            if ($_POST['code'] == "") {
                // New entry..
                echo "<script type='text/javascript'>";
                echo "window.top.location.href ='index.php?page=entry&uid=" . $PIVOTX['db']->entry['uid'] . "';";
                echo "</script>";
            } else {
                // nothing..
            }
        } else {
            // Redirect to the listing page
            header('Location: ' . makeAdminPageLink('entries'));
            exit;
        }
    }
}
Пример #5
0
 function regUser($user)
 {
     global $PIVOTX;
     $name_md5 = strtolower(md5(strtolower($user['name'])));
     if (saveSerialize($PIVOTX['paths']['db_path'] . 'users/' . $name_md5 . '.php', $user)) {
         $text = sprintf("<h2>%s</h2>\n\n", __('User stored!'));
     } else {
         $text = sprintf("<h2>%s</h2>\n\n", __('Could not store new user!!'));
     }
     $mail1 = __("You have registered as a user on PivotX \"%s\" \n\n");
     $mail2 = __("To verify your account, click the following link:\n%s\n\n");
     $url = sprintf("%s&amp;name=%s&amp;code=%s", $PIVOTX['paths']['host'] . makeVisitorPageLink('verify'), urlencode($user['name']), md5($user['pass'] . "email"));
     $mail = sprintf($mail1 . $mail2, $PIVOTX['config']->get('sitename'), str_replace('&amp;', '&', $url));
     if (!pivotxMail($user['email'], __('Registration confirmation'), $mail)) {
         $mail2 = '<a href="%s">' . __('Verify your account') . '</a>';
         $mail = sprintf($mail1 . $mail2, $PIVOTX['config']->get('sitename'), $url);
         $text = "\n<br />" . nl2br($mail) . "<br />\n";
     } else {
         $text = sprintf(__('Mail verification sent to %s. ' . 'Please check your email in a minute to confirm your account.'), $user['email']);
     }
     $this->input['message'] = $text;
     sendMailNotification('visitor_registration', array('add', $user['name']));
 }