public function heading3filter($string, $opts, $arg = 'by')
 {
     $Perch = new PerchAdmin();
     $s = '<h3 class="em"><span>' . $this->Lang->get($string) . '<span class="filter">';
     foreach ($opts as $opt) {
         $s .= '<a href="' . PerchUtil::html($Perch->get_page()) . '?' . $arg . '=' . $opt['slug'] . '" class="filter-' . $opt['slug'] . ' ' . ($opt['selected'] ? 'selected' : '') . '">' . $this->Lang->get($opt['title']) . '</a> ';
     }
     $s .= '</span></span></h3>';
     return $s;
 }
Example #2
0
 public static function fetch()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Example #3
0
<?php

include realpath(__DIR__ . '/../../../../..') . '/inc/pre_config.php';
include realpath(__DIR__ . '/../../../../../..') . '/config/config.php';
include PERCH_CORE . '/inc/loader.php';
$Perch = PerchAdmin::fetch();
include PERCH_CORE . '/inc/auth.php';
if (!PERCH_RUNWAY) {
    exit;
}
$Perch->page_title = PerchLang::get('Collection');
$app_path = PERCH_CORE . '/apps/content';
include $app_path . '/PerchContent_Item.class.php';
include $app_path . '/PerchContent_Items.class.php';
include $app_path . '/PerchContent_Page.class.php';
include $app_path . '/PerchContent_Pages.class.php';
include $app_path . '/PerchContent_Region.class.php';
include $app_path . '/PerchContent_Regions.class.php';
include PERCH_CORE . '/runway/apps/content/PerchContent_Collections.class.php';
include PERCH_CORE . '/runway/apps/content/PerchContent_Collection.class.php';
include PERCH_CORE . '/runway/apps/content/PerchContent_CollectionItems.class.php';
include PERCH_CORE . '/runway/apps/content/PerchContent_CollectionItem.class.php';
include PERCH_CORE . '/runway/apps/content/modes/collection.edit.pre.php';
include PERCH_CORE . '/inc/top.php';
include PERCH_CORE . '/runway/apps/content/modes/collection.edit.post.php';
include PERCH_CORE . '/inc/btm.php';
 private function activate()
 {
     /*
         Any attempt to circumvent activation invalidates your license.
         We're a small company trying to make something useful at a fair price.
         Please don't steal from us.
     */
     $Perch = PerchAdmin::fetch();
     $host = 'activation.grabaperch.com';
     $path = '/activate/';
     $url = 'http://' . $host . $path;
     $data = '';
     $data['key'] = PERCH_LICENSE_KEY;
     $data['host'] = $_SERVER['SERVER_NAME'];
     $data['version'] = $Perch->version;
     $data['php'] = phpversion();
     $content = http_build_query($data);
     $result = false;
     $use_curl = false;
     if (function_exists('curl_init')) {
         $use_curl = true;
     }
     if ($use_curl) {
         PerchUtil::debug('Activating via CURL');
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
         $result = curl_exec($ch);
         PerchUtil::debug($result);
         $http_status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($http_status != 200) {
             $result = false;
             PerchUtil::debug('Not HTTP 200: ' . $http_status);
         }
         curl_close($ch);
     } else {
         if (function_exists('fsockopen')) {
             PerchUtil::debug('Activating via sockets');
             $fp = fsockopen($host, 80, $errno, $errstr, 10);
             if ($fp) {
                 $out = "POST {$path} HTTP/1.1\r\n";
                 $out .= "Host: {$host}\r\n";
                 $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
                 $out .= "Content-Length: " . strlen($content) . "\r\n";
                 $out .= "Connection: Close\r\n\r\n";
                 $out .= $content . "\r\n";
                 fwrite($fp, $out);
                 stream_set_timeout($fp, 10);
                 while (!feof($fp)) {
                     $result .= fgets($fp, 128);
                 }
                 fclose($fp);
             }
             if ($result != '') {
                 $parts = preg_split('/[\\n\\r]{4}/', $result);
                 if (is_array($parts)) {
                     $result = $parts[1];
                 }
             }
         }
     }
     // Should have a $result now
     if ($result) {
         $json = PerchUtil::json_safe_decode($result);
         if (is_object($json) && $json->result == 'SUCCESS') {
             // update latest version setting
             $Settings = new PerchSettings();
             $Settings->set('latest_version', $json->latest_version);
             $Settings->set('on_sale_version', $json->on_sale_version);
             PerchUtil::debug($json);
             PerchUtil::debug('Activation: success');
             return true;
         } else {
             PerchUtil::debug('Activation: failed');
             $this->activation_failed = true;
             return false;
         }
     }
     // If activation can't complete, assume honesty. That's how I roll.
     return true;
 }
 public function action()
 {
     $Perch = PerchAdmin::fetch();
     $url = $Perch->get_page(true);
     $url = str_replace('created=true&', '', $url);
     $url = str_replace('&created=true', '', $url);
     $url = str_replace('created=true', '', $url);
     return $url;
 }
 public static function get_current_app()
 {
     $Perch = PerchAdmin::fetch();
     $page = $Perch->get_page();
     $apps = $Perch->get_apps();
     if (PerchUtil::count($apps)) {
         foreach ($apps as $app) {
             if (strpos($page, $app['section']) !== false) {
                 return $app;
             }
         }
     }
     return false;
 }