public function set_status($status) { $API = new PerchAPI(1.0, 'perch_blog'); $Settings = $API->get('Settings'); $akismet_api_key = $Settings->get('perch_blog_akismet_key')->val(); // Are we using akismet? if ($akismet_api_key) { if ($this->commentStatus() == 'SPAM' && $status == 'LIVE') { // was marked as spam, but isn't. So tell askismet. $spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true); if (PerchUtil::count($spam_data)) { PerchBlog_Akismet::submit_ham($akismet_api_key, $spam_data['fields'], $spam_data['environment']); } } if ($status == 'SPAM') { // was marked as not spam, but is spam. $spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true); if (PerchUtil::count($spam_data)) { PerchBlog_Akismet::submit_spam($akismet_api_key, $spam_data['fields'], $spam_data['environment']); } } } $data = array('commentStatus' => $status); $this->update($data); $Posts = new PerchBlog_Posts(); $Post = $Posts->find($this->postID()); if (is_object($Post)) { $Post->update_comment_count(); } }
/** * Import data from CSV file into database */ public function import() { $API = new PerchAPI(1.0, 'root_locator'); $Lang = $API->get('Lang'); $Template = $API->get('Template'); $Template->set('locator/address.html', 'locator'); $Addresses = new RootLocator_Addresses($API); $Tasks = new RootLocator_Tasks($API); $data = $this->reader->fetchAssoc(); foreach ($data as $row) { $errors = $this->getRowErrors($row); $warnings = $this->getRowWarnings($row); if ($errors) { $this->addError($row, $Lang->get('‘%s’ columns are missing required data', $errors)); continue; } if ($warnings) { $this->addWarning($row, $Lang->get('‘%s’ columns are recommended to prevent geocoding errors.', $warnings)); } $imported = $Addresses->create(['addressTitle' => $row['addressTitle'], 'addressBuilding' => $row['addressBuilding'], 'addressStreet' => $row['addressStreet'], 'addressTown' => $row['addressTown'], 'addressRegion' => $row['addressRegion'], 'addressPostcode' => $row['addressPostcode'], 'addressCountry' => $row['addressCountry']]); $imported->index($Template); $Tasks->add('address.geocode', $imported->id()); $this->addSuccess($row); } }
/** * get campaign data from the API and store it in our table */ public function populate($api_key, $list_id, $echo_feedback = false) { $MailChimp = new MailChimp($api_key); if ($echo_feedback) { $API = new PerchAPI(1.0, 'perch_mailchimp'); $Lang = $API->get('Lang'); } $opts = array('apikey' => $api_key, 'filters' => array('list_id' => $list_id, 'status' => 'sent')); $result = $MailChimp->call('campaigns/list', $opts); if ($result && isset($result['total']) && $result['total'] > 0) { foreach ($result['data'] as $item) { $campaignID = $item['id']; //get the content $content_opts = array('apikey' => $api_key, 'cid' => $campaignID); $content = $MailChimp->call('campaigns/content', $content_opts); if (isset($content['html'])) { $campaignHTML = $content['html']; } if (isset($content['text'])) { $campaignText = $content['text']; } // array for insertion $campaign = array('campaignCID' => $campaignID, 'campaignWebID' => $item['web_id'], 'campaignTitle' => $item['title'], 'campaignCreateTime' => $item['create_time'], 'campaignSendTime' => $item['send_time'], 'campaignSent' => $item['emails_sent'], 'campaignSubject' => $item['subject'], 'campaignArchiveURL' => $item['archive_url'], 'campaignHTML' => $campaignHTML, 'campaignText' => $campaignText, 'campaignSlug' => PerchUtil::urlify(date('d M Y', strtotime($item['create_time'])) . ' ' . $item['subject'])); //insert into our table $this->db->insert($this->table, $campaign); if ($echo_feedback) { echo '<li class="icon success">'; echo $Lang->get('Importing campaign %s (%s)', $item['title'], $item['create_time']); echo '</li>'; flush(); } } } }
function jw_activity_log_prune($last_run_date) { include_once 'JwActivityLog_Actions.class.php'; include_once 'JwActivityLog_Action.class.php'; $API = new PerchAPI(1.0, 'jw_activity_log'); $Settings = $API->get('Settings'); $Actions = new JwActivityLog_Actions($API); $total_pruned = $Actions->prune_logs((int) $Settings->get('jw_activity_log_prune_time')->settingValue()); return array('result' => 'OK', 'message' => $total_pruned . ' logs pruned'); }
public function update($data, $do_cats = true, $do_tags = true) { $PerchBlog_Posts = new PerchBlog_Posts(); if (isset($data['cat_ids'])) { $catIDs = $data['cat_ids']; unset($data['cat_ids']); } else { $catIDs = false; } // Update the post itself parent::update($data); // slug if (isset($data['postTitle'])) { $API = new PerchAPI(1.0, 'perch_blog'); $Settings = $API->get('Settings'); $format = $Settings->get('perch_blog_slug_format')->val(); if (!$format) { $format = '%Y-%m-%d-{postTitle}'; } $this->tmp_slug_vars = $this->details; $slug = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array($this, "substitute_slug_vars"), $format); $this->tmp_slug_vars = array(); $data['postSlug'] = strtolower(strftime($slug, strtotime($data['postDateTime']))); parent::update($data); } if ($do_tags) { // Delete existing tags $this->db->delete(PERCH_DB_PREFIX . 'blog_posts_to_tags', $this->pk, $this->id()); // Split tag string into array if (isset($data['postTags']) && $data['postTags'] != '') { $a = explode(',', $data['postTags']); if (is_array($a)) { for ($i = 0; $i < sizeOf($a); $i++) { $tmp = array(); $tmp['postID'] = $this->id(); $tag_str = trim($a[$i]); //does this tag exist $sql = 'SELECT tagID, tagTitle FROM ' . PERCH_DB_PREFIX . 'blog_tags WHERE tagTitle = ' . $this->db->pdb($tag_str) . ' LIMIT 1'; $row = $this->db->get_row($sql); if (is_array($row)) { $tmp['tagID'] = $row['tagID']; } else { $tag = array(); $tag['tagTitle'] = $tag_str; $tag['tagSlug'] = PerchUtil::urlify($tag_str); $tmp['tagID'] = $this->db->insert(PERCH_DB_PREFIX . 'blog_tags', $tag); } $this->db->insert(PERCH_DB_PREFIX . 'blog_posts_to_tags', $tmp); } } } } return true; }
function perch_mailchimp_form($template, $content = array(), $return = false) { $API = new PerchAPI(1.0, 'perch_mailchimp'); $Template = $API->get('Template'); $Template->set('mailchimp/' . $template, 'mailchimp'); $html = $Template->render($content); $html = $Template->apply_runtime_post_processing($html, $content); if ($return) { return $html; } echo $html; }
function perch_form($template, $return = false) { $API = new PerchAPI(1.0, 'perch_forms'); $Template = $API->get('Template'); $Template->set('forms' . DIRECTORY_SEPARATOR . $template, 'forms'); $html = $Template->render(array()); $html = $Template->apply_runtime_post_processing($html); if ($return) { return $html; } echo $html; }
public static function get_backup_search_sql($key) { $API = new PerchAPI(1.0, 'perch_blog'); $db = $API->get('DB'); $sql = 'SELECT \'' . __CLASS__ . '\' AS source, campaignSendTime AS score, campaignSubject, campaignSlug, campaignSendTime, campaignText, campaignID, "", "", "" FROM ' . PERCH_DB_PREFIX . 'mailchimp_campaigns WHERE ( concat(" ", campaignSubject, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", campaignHTML, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' ) '; return $sql; }
public static function get_backup_search_sql($key) { $API = new PerchAPI(1.0, 'perch_event'); $db = $API->get('DB'); $sql = 'SELECT \'' . __CLASS__ . '\' AS source, eventDateTime AS score, eventTitle, eventSlug, eventDateTime, eventDescHTML, eventID, "", "", "" FROM ' . PERCH_DB_PREFIX . 'events WHERE eventDateTime>' . $db->pdb(date('Y-m-d H:i:s')) . ' AND ( concat(" ", eventTitle, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", eventDescRaw, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' ) '; return $sql; }
function pinboard_bookmarks($tag) { $API = new PerchAPI(1.0, 'pinboard'); $Settings = $API->get('Settings'); $username = $Settings->get('pinboard_username')->settingValue(); $password = $Settings->get('pinboard_password')->settingValue(); $pinboard = new PinboardAPI($username, $password); $items = $pinboard->search_by_tag($tag); $result = []; foreach ($items as $key => $value) { $result[$key] = array('title' => $value->title, 'description' => $value->description, 'url' => $value->url, 'date' => gmdate("l dS F Y", $value->timestamp)); } return $result; }
/** * Perform a basic search if no results are returned from primary search * * @param string $key * * @return string */ public static function get_backup_search_sql($key) { $API = new PerchAPI(1.0, 'root_locator'); $db = $API->get('DB'); $sql = ' SELECT \'' . __CLASS__ . '\' AS source, addressTitle AS score, addressTitle, addressBuilding, addressStreet, addressPostcode, addressID, "", "", "" FROM ' . PERCH_DB_PREFIX . 'root_locator_addresses WHERE addressLatitude IS NOT NULL AND addressLongitude IS NOT NULL AND ( concat(" ", addressTitle, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", addressBuilding, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", addressStreet, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", addressPostcode, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ')'; return $sql; }
public static function get_backup_search_sql($key) { $API = new PerchAPI(1.0, 'perch_blog'); $db = $API->get('DB'); $sql = 'SELECT \'' . __CLASS__ . '\' AS source, postDateTime AS score, postTitle, postSlug, postDateTime, postDescHTML, postID, sectionSlug, "", "" FROM ' . PERCH_DB_PREFIX . 'blog_posts p, ' . PERCH_DB_PREFIX . 'blog_sections s WHERE postStatus=\'Published\' AND postDateTime<' . $db->pdb(date('Y-m-d H:i:s')) . ' AND p.sectionID=s.sectionID AND ( concat(" ", postTitle, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", postDescRaw, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' OR concat(" ", postTags, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ' ) '; return $sql; }
function scheduled_comments_delete_spam($last_run) { $API = new PerchAPI(1.0, 'perch_comments'); $Settings = $API->get('Settings'); $days = $Settings->get('perch_comments_max_spam_days')->val(); if (!$days) { return array('result' => 'OK', 'message' => 'Spam message deletion not configured.'); } $count = perch_comments_delete_old_spam($days); if ($count == 1) { $comments = 'comment'; } else { $comments = 'comments'; } return array('result' => 'OK', 'message' => $count . ' old spam ' . $comments . ' deleted.'); }
/** * */ public function populate($api_key, $list_id, $echo_feedback = false) { $MailChimp = new MailChimp($api_key); if ($echo_feedback) { $API = new PerchAPI(1.0, 'perch_mailchimp'); $Lang = $API->get('Lang'); } $opts = array('apikey' => $api_key, 'filters' => array('list_id' => $list_id)); $result = $MailChimp->call('lists/list', $opts); if ($result) { $this->db->execute('TRUNCATE TABLE ' . $this->table); //store title in data array $stats_array = array('title' => $result['data'][0]['name'], 'total' => $result['data'][0]['stats']['member_count']); $list_opts = array('apikey' => $api_key, 'id' => $list_id); $activity = $MailChimp->call('lists/activity', $list_opts); PerchUtil::debug($activity); foreach ($activity as $stat) { if ($stat['day'] == date('Y-m-d', strtotime('-1 days'))) { $stats_array['yesterday'] = $stat['subs'] + $stat['other_adds']; } elseif ($stat['day'] == date('Y-m-d')) { $stats_array['today'] = $stat['subs'] + $stat['other_adds']; } } //insert stats array $this->db->insert($this->table, $stats_array); if ($echo_feedback) { echo '<li class="icon success">'; echo $Lang->get('Importing statistics for list %s', $list_id); echo '</li>'; flush(); } // history table $sql = 'SELECT * FROM ' . PERCH_DB_PREFIX . 'mailchimp_history WHERE historyDate = ' . $this->db->pdb(date('Y-m-d', strtotime('-1 days'))) . ' LIMIT 1'; if (!($row = $this->db->get_row($sql))) { //insert a row for yesterday $history_data = array('historyDate' => date('Y-m-d', strtotime('-1 days')), 'historyTotal' => $stats_array['yesterday']); $this->db->insert(PERCH_DB_PREFIX . 'mailchimp_history', $history_data); if ($echo_feedback) { echo '<li class="icon success">'; echo $Lang->get('Importing history for list %s', $list_id); echo '</li>'; flush(); } } } return true; }
function update_perch_mailchimp($last_update) { $API = new PerchAPI(1.0, 'perch_mailchimp'); include 'PerchMailchimp_Stats.class.php'; include 'PerchMailchimp_Stat.class.php'; $Settings = $API->get('Settings'); $api_key = $Settings->get('perch_mailchimp_api_key')->settingValue(); $list_id = $Settings->get('perch_mailchimp_list_id')->settingValue(); $Stats = new PerchMailchimp_Stats($API); if (!$api_key || $api_key == '' || !$list_id || $list_id == '') { return array('result' => 'FAILED', 'message' => 'API key or list ID not provided in Settings.'); } else { if ($Stats->populate($api_key, $list_id)) { return array('result' => 'OK', 'message' => 'List statistics updated.'); } else { return array('result' => 'WARNING', 'message' => 'Unable to update list statistics.'); } } }
/** * * Get the content of a specific field * @param mixed $id_or_slug the id or slug of the event * @param string $field the name of the field you want to return * @param bool $return */ function perch_events_event_field($id_or_slug, $field, $return = false) { $API = new PerchAPI(1.0, 'perch_events'); $Events = new PerchEvents_Events($API); $r = false; if (is_numeric($id_or_slug)) { $eventID = intval($id_or_slug); $Event = $Events->find($eventID); } else { $Event = $Events->find_by_slug($id_or_slug); } if (is_object($Event)) { $r = $Event->{$field}(); } if ($return) { return $r; } $HTML = $API->get('HTML'); echo $HTML->encode($r); }
function perch_comments_form($parentID, $parentTitle = false, $opts = false, $return = false) { $API = new PerchAPI(1.0, 'perch_comments'); $defaults = array(); $defaults['template'] = 'comment_form.html'; if (is_array($opts)) { $opts = array_merge($defaults, $opts); } else { $opts = $defaults; } if ($parentTitle == false) { $parentTitle = perch_pages_title(true); } $Template = $API->get('Template'); $Template->set('comments/' . $opts['template'], 'comments'); $html = $Template->render(array('parentID' => $parentID, 'parentTitle' => PerchUtil::html($parentTitle, true))); $html = $Template->apply_runtime_post_processing($html); if ($return) { return $html; } echo $html; }
public function dispatch_form($key, $post, $files) { $key = base64_decode($key); $parts = explode(':', $key); $formID = $parts[0]; $appIDs = $parts[1]; $template = $parts[2]; $timestamp = isset($parts[3]) ? $parts[3] : false; if ($appIDs) { $appIDs = explode(' ', $appIDs); if (is_array($appIDs)) { foreach ($appIDs as $appID) { if (function_exists($appID . '_form_handler')) { $API = new PerchAPI(1.0, $appID); $SubmittedForm = $API->get('SubmittedForm'); $SubmittedForm->populate($formID, $template, $post, $files, $timestamp); call_user_func($appID . '_form_handler', $SubmittedForm); } else { PerchUtil::debug($appID . ' form handler not found.', 'error'); } } } } }
<?php include 'PerchGallery_Albums.class.php'; include 'PerchGallery_Album.class.php'; include 'PerchGallery_Images.class.php'; include 'PerchGallery_Image.class.php'; include 'PerchGallery_ImageVersions.class.php'; include 'PerchGallery_ImageVersion.class.php'; $API = new PerchAPI(1.0, 'perch_gallery'); $Lang = $API->get('Lang'); $Albums = new PerchGallery_Albums($API); $albums = $Albums->return_all(); $Images = new PerchGallery_Images($API); $images = $Images->get_recent_for_dashboard(5); ?> <div class="widget"> <h2> <?php echo $Lang->get('Gallery'); ?> <a href="<?php echo PerchUtil::html(PERCH_LOGINPATH . '/addons/apps/perch_gallery/edit/'); ?> " class="add button"><?php echo $Lang->get('Add Album'); ?> </a> </h2> <div class="bd"> <?php if (PerchUtil::count($images)) {
<?php # include the API include '../../../../core/inc/api.php'; $API = new PerchAPI(1.0, 'perch_events'); $Lang = $API->get('Lang'); if (!$CurrentUser->has_priv('perch_events.categories.manage')) { PerchUtil::redirect($API->app_path()); } # include your class files include '../PerchEvents_Categories.class.php'; include '../PerchEvents_Category.class.php'; # Set the page title $Perch->page_title = $Lang->get('Manage Event Categories'); # Do anything you want to do before output is started include '../modes/cat.list.pre.php'; # Top layout include PERCH_CORE . '/inc/top.php'; # Display your page include '../modes/cat.list.post.php'; # Bottom layout include PERCH_CORE . '/inc/btm.php';
<?php # include the API include '../../../../core/inc/api.php'; $API = new PerchAPI(1.0, 'perch_gallery'); $Lang = $API->get('Lang'); # include your class files include '../PerchGallery_Albums.class.php'; include '../PerchGallery_Album.class.php'; include '../PerchGallery_Images.class.php'; include '../PerchGallery_Image.class.php'; include '../PerchGallery_ImageVersions.class.php'; include '../PerchGallery_ImageVersion.class.php'; # Set the page title $Perch->page_title = $Lang->get('Gallery: List Images'); $Perch->add_css($API->app_path() . '/admin.css'); $Perch->add_javascript($API->app_path() . '/upload.js'); # Do anything you want to do before output is started include '../modes/images.list.pre.php'; # Top layout include PERCH_CORE . '/inc/top.php'; # Display your page include '../modes/images.list.post.php'; # Bottom layout include PERCH_CORE . '/inc/btm.php';
<?php include __DIR__ . '/../../../../core/inc/api.php'; // Perch API $API = new PerchAPI(1.0, 'root_locator'); // APIs $Lang = $API->get('Lang'); $Paging = $API->get('Paging'); $db = $API->get('DB'); // Page settings $Perch->page_title = $Lang->get('Update Locator'); // Page Initialising include '../modes/update.pre.php'; // Perch Frame include PERCH_CORE . '/inc/top.php'; // Page include '../modes/update.post.php'; // Perch Frame include PERCH_CORE . '/inc/btm.php';
<?php # include the API include '../../../../../core/inc/api.php'; $API = new PerchAPI(1.0, 'perch_blog'); $Lang = $API->get('Lang'); # include your class files include '../../PerchBlog_Posts.class.php'; include '../../PerchBlog_Post.class.php'; include '../../PerchBlog_Sections.class.php'; include '../../PerchBlog_Section.class.php'; include '../../PerchBlog_Tags.class.php'; include '../../PerchBlog_Tag.class.php'; include '../../PerchBlog_Comments.class.php'; include '../../PerchBlog_Comment.class.php'; include '../../PerchBlog_Authors.class.php'; include '../../PerchBlog_Author.class.php'; include '../../PerchBlog_Cache.class.php'; include '../../PerchBlog_Util.class.php'; # Set the page title $Perch->page_title = $Lang->get('Posterous Import'); $Perch->add_css($API->app_path() . '/assets/css/blog.css'); # Do anything you want to do before output is started include '../../modes/import.posterous.pre.php'; # Top layout include PERCH_CORE . '/inc/top.php'; # Display your page include '../../modes/import.posterous.post.php'; # Bottom layout include PERCH_CORE . '/inc/btm.php';
<?php include __DIR__ . '/../../../core/inc/api.php'; // Perch API $API = new PerchAPI(1.0, 'root_locator'); // APIs $Lang = $API->get('Lang'); $HTML = $API->get('HTML'); $Settings = $API->get('Settings'); // Page settings $Perch->page_title = $Lang->get('Locator'); $Perch->add_css($API->app_path() . '/assets/css/locator.css'); // Page Initialising include 'modes/addresses.list.pre.php'; // Perch Frame include PERCH_CORE . '/inc/top.php'; // Page include 'modes/addresses.list.post.php'; // Perch Frame include PERCH_CORE . '/inc/btm.php';
<?php // Prevent running directly: if (!defined('PERCH_DB_PREFIX')) { exit; } // Let's go $sql = "\n CREATE TABLE IF NOT EXISTS `__PREFIX__events` (\n `eventID` int(11) NOT NULL AUTO_INCREMENT,\n `eventTitle` varchar(255) NOT NULL DEFAULT '',\n `eventSlug` varchar(255) NOT NULL DEFAULT '',\n `eventDateTime` datetime DEFAULT NULL,\n `eventDescRaw` text,\n `eventDescHTML` text,\n `eventDynamicFields` text,\n PRIMARY KEY (`eventID`),\n KEY `idx_date` (`eventDateTime`),\n FULLTEXT KEY `idx_search` (`eventTitle`,`eventDescRaw`)\n ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n \n CREATE TABLE IF NOT EXISTS `__PREFIX__events_categories` (\n `categoryID` int(11) NOT NULL AUTO_INCREMENT,\n `categoryTitle` varchar(255) NOT NULL DEFAULT '',\n `categorySlug` varchar(255) NOT NULL DEFAULT '',\n `categoryEventCount` int(10) unsigned NOT NULL DEFAULT '0',\n `categoryFutureEventCount` int(10) unsigned NOT NULL DEFAULT '0',\n `categoryDynamicFields` text,\n PRIMARY KEY (`categoryID`),\n KEY `idx_slug` (`categorySlug`)\n ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n \n CREATE TABLE IF NOT EXISTS `__PREFIX__events_to_categories` (\n `eventID` int(11) NOT NULL DEFAULT '0',\n `categoryID` int(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`eventID`,`categoryID`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;"; $sql = str_replace('__PREFIX__', PERCH_DB_PREFIX, $sql); $statements = explode(';', $sql); foreach ($statements as $statement) { $statement = trim($statement); if ($statement != '') { $this->db->execute($statement); } } $API = new PerchAPI(1.0, 'perch_events'); $UserPrivileges = $API->get('UserPrivileges'); $UserPrivileges->create_privilege('perch_events', 'Access events'); $UserPrivileges->create_privilege('perch_events.categories.manage', 'Manage categories'); $sql = 'SHOW TABLES LIKE "' . $this->table . '"'; $result = $this->db->get_value($sql); return $result;
private function build_message_with_perch() { if (isset($this->app_id)) { $API = new PerchAPI($this->version, $this->app_id); $Template = $API->get('Template'); $Template->set($this->template, $this->template_ns); } else { $Template = new PerchTemplate($this->template, 'email'); } $html = $Template->render_group(array($this->vars), true); $html = $Template->apply_runtime_post_processing($html); $this->subject($this->find_subject_from_html($html)); return $html; }
<?php // Prevent running directly: if (!defined('PERCH_DB_PREFIX')) { exit; } $API = new PerchAPI(1.0, 'perch_mailchimp'); $Settings = $API->get('Settings'); if ($Settings->get('perch_mailchimp_update')->val() != '2.0') { $db = $API->get('DB'); $api_key = $Settings->get('perch_mailchimp_api_key')->settingValue(); $list_id = $Settings->get('perch_mailchimp_list_id')->settingValue(); $sql = 'SHOW TABLES LIKE "' . PERCH_DB_PREFIX . 'mailchimp_campaigns"'; $result = $db->get_value($sql); if (!$result) { // Let's go $sql = "\n\t\t CREATE TABLE IF NOT EXISTS `__PREFIX__mailchimp_campaigns` (\n\t\t `campaignID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t `campaignCID` char(64) NOT NULL,\n\t\t `campaignWebID` int(11) NOT NULL,\n\t\t `campaignCreateTime` datetime,\n\t\t `campaignSendTime` datetime,\n\t\t `campaignSent` int(11),\n\t\t `campaignSubject` varchar(255) NOT NULL DEFAULT '',\n\t\t `campaignArchiveURL` varchar(255) NOT NULL DEFAULT '',\n\t\t `campaignTitle` varchar(255) NOT NULL DEFAULT '',\n\t\t `campaignText` text,\n\t\t `campaignHTML` text,\n\t\t `campaignSlug` varchar(255) NOT NULL DEFAULT '',\n\t\t PRIMARY KEY (`campaignID`),\n \t\t\t\tUNIQUE KEY `idx_cid` (`campaignCID`),\n \t\t\t\tKEY `idx_slug` (`campaignSlug`),\n \t\t\t\tFULLTEXT KEY `idx_search` (`campaignSubject`,`campaignHTML`)\n\t\t ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n\t\t\t\n\t\t\tCREATE TABLE IF NOT EXISTS `__PREFIX__mailchimp_log` (\n\t\t `logID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t `logEvent` varchar(255),\n\t\t `logDate` datetime,\n\t\t `logType` varchar(255),\n\t\t PRIMARY KEY (`logID`)\n\t\t ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n\t\t\t"; $sql = str_replace('__PREFIX__', PERCH_DB_PREFIX, $sql); $statements = explode(';', $sql); foreach ($statements as $statement) { $statement = trim($statement); if ($statement != '') { $db->execute($statement); } } $db->execute($sql); $secret = $Settings->get('perch_mailchimp_secret')->val(); if (!$secret) { $Settings->set('perch_mailchimp_secret', md5(uniqid())); } }
/** * Take the original uploaded file and make all the different versions, based on the given template. * * @param string $filename * @param string $Template * @return void * @author Drew McLellan */ public function process_versions($filename, $Template, $bucket) { $this->delete_versions(); $result = false; $image_file = PerchUtil::file_path($bucket['file_path'] . '/' . $filename); PerchUtil::debug('123: ' . $image_file); if (!file_exists($image_file)) { return false; } $API = new PerchAPI(1.0, 'perch_gallery'); $Image = $API->get('Image'); $Versions = new PerchGallery_ImageVersions(); $tags = $Template->find_all_tags(); $Perch = Perch::fetch(); if (!is_array($tags)) { $tags = array(); } // add defaults we need for admin $tags[] = new PerchXMLTag('<perch:gallery id="image" type="image" />'); // default full size $tags[] = new PerchXMLTag('<perch:gallery id="image" type="image" width="80" height="80" crop="true" key="admin_thumb" />'); // admin thumb $tags[] = new PerchXMLTag('<perch:gallery id="image" type="image" width="180" key="admin_preview" />'); // admin preview if (PerchUtil::count($tags)) { foreach ($tags as $Tag) { if ($Tag->id() == 'image' && $Tag->type() == 'image') { //$bucket = $Perch->get_resource_bucket($Tag->bucket()); $Image->reset_defaults(); if ($Tag->quality()) { $Image->set_quality($Tag->quality()); } if ($Tag->sharpen()) { $Image->set_sharpening($Tag->sharpen()); } if ($Tag->density()) { $Image->set_density($Tag->density()); } if ($Tag->width() || $Tag->height()) { $details = $Image->resize_image($image_file, $Tag->width(), $Tag->height(), $Tag->crop()); } else { $details = array(); $details['file_name'] = $filename; PerchUtil::debug('152: ' . $filename); $info = getimagesize($image_file); if (is_array($info)) { $details['w'] = $info[0]; $details['h'] = $info[1]; } } if ($details) { $data = array(); $data['imageID'] = $this->id(); if (strpos($details['file_name'], DIRECTORY_SEPARATOR) !== false) { $parts = explode(DIRECTORY_SEPARATOR, $details['file_name']); $details['file_name'] = array_pop($parts); } $data['versionPath'] = $details['file_name']; //PerchUtil::debug('167: '. $details['file_name']); if ($Tag->key()) { $data['versionKey'] = $Tag->key(); } else { $data['versionKey'] = $this->_generate_version_key($Tag->width(), $Tag->height()); } if ($Tag->crop()) { $data['versionWidth'] = $Tag->width(); $data['versionHeight'] = $Tag->height(); } else { $data['versionWidth'] = $details['w']; $data['versionHeight'] = $details['h']; } $Version = $Versions->create($data); if (is_object($Version)) { $result = true; } } } } } return $result; }
<?php # include the API include __DIR__ . '/../../../core/inc/api.php'; $API = new PerchAPI(1.0, 'perch_mailchimp'); $Lang = $API->get('Lang'); $HTML = $API->get('HTML'); $message = ''; # Set the page title $Perch->page_title = $Lang->get($title); # Do anything you want to do before output is started include 'modes/' . $mode . '.pre.php'; # Top layout include PERCH_CORE . '/inc/top.php'; # Display your page include 'modes/' . $mode . '.post.php'; # Bottom layout include PERCH_CORE . '/inc/btm.php';
<?php $API = new PerchAPI('categories', 1.0); $HTML = $API->get('HTML'); $Sets = new PerchCategories_Sets(); $Categories = new PerchCategories_Categories(); $setID = false; $Set = false; if (isset($_GET['id']) && $_GET['id'] != '') { $setID = (int) $_GET['id']; $Set = $Sets->find($setID); } if ($setID == false) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } $cats = $Categories->get_tree($setID);