function log($msg) { $f = fopen(ROOT . DS . "cache" . DS . "moblog.txt", "a"); fwrite($f, date('Y-m-d H:i:s') . " {$msg}\r\n"); fclose($f); if ($msg[0] == '*') { global $pop3logs; array_push($pop3logs, Moblog::decorate_log(substr($msg, 2))); } }
/** ------------------------- /** Check Moblog /** -------------------------*/ function check_moblog() { if (!($id = $this->EE->input->get('moblog_id'))) { return FALSE; } $where = array('moblog_enabled' => 'y', 'moblog_id' => $id); $query = $this->EE->db->get_where('moblogs', $where); if ($query->num_rows() == 0) { return $this->EE->output->show_user_error('submission', array(lang('invalid_moblog'))); } if (!class_exists('Moblog')) { require PATH_MOD . 'moblog/mod.moblog.php'; } $MP = new Moblog(); $MP->moblog_array = $query->row_array(); $error = FALSE; if ($MP->moblog_array['moblog_email_type'] == 'imap') { if (!$MP->check_imap_moblog()) { $display = $MP->message_array; $cp_message = ''; foreach ($MP->message_array as $val) { $cp_message .= lang($val) . '<br>'; } $this->EE->session->set_flashdata('message_failure', $cp_message); } else { $message = lang('moblog_successful_check') . '<br />'; $message .= lang('emails_done') . NBS . NBS . $MP->emails_done . '<br />'; $message .= lang('entries_added') . NBS . NBS . $MP->entries_added . '<br />'; $message .= lang('attachments_uploaded') . NBS . NBS . $MP->uploads . '<br />'; if (count($MP->message_array) > 0) { $message .= $MP->errors(); $error = TRUE; } $this->EE->session->set_flashdata(array('message' => $message, 'error' => $error)); $this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=moblog'); } } else { if (!$MP->check_pop_moblog()) { $display = $MP->message_array; $cp_message = ''; foreach ($MP->message_array as $val) { $cp_message .= lang($val) . '<br>'; } $this->EE->session->set_flashdata('message_failure', $cp_message); } else { $message = lang('moblog_successful_check') . '<br />'; $message .= lang('emails_done') . NBS . NBS . $MP->emails_done . '<br />'; $message .= lang('entries_added') . NBS . NBS . $MP->entries_added . '<br />'; $message .= lang('attachments_uploaded') . NBS . NBS . $MP->uploads . '<br />'; if (count($MP->message_array) > 0) { $message .= $MP->errors(); $error = TRUE; } $this->EE->session->set_flashdata(array('message' => $message, 'error' => $error)); $this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=moblog'); } } $this->EE->session->set_flashdata(array('message' => $MP->errors(), 'error' => TRUE)); $this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=moblog'); }
} else { $lastrun = 0; } // Set the new timestamp. $now = date("U"); if ($_GET['force'] == 'yes' || $now - $lastrun >= $scheduler['frequency']) { // Write the new timestamp, if we start doing stuff.. $fp = fopen($db_path . "scheduler.txt", w); fwrite($fp, $now); fclose($fp); // Here we call the functions that need to be run. cleanCache(); $PIVOTX['db']->checkTimedPublish(); $PIVOTX['pages']->checkTimedPublish(); if ($PIVOTX['config']->get('moblog_active')) { $moblog = new Moblog(); $messages = $moblog->execute(); if (!empty($messages)) { debug(implode("\n", $messages)); } } // Execute a hook, if present. $PIVOTX['extensions']->executeHook('scheduler', $dummy); } else { // debug("Scheduler: Nothing to do yet.. " . ($now - $lastrun) . " secs. "); } // Process the last hook, after we're done with everything else. $PIVOTX['extensions']->executeHook('after_execution', $dummy); die; // ------------------------ /**