示例#1
0
 public function setFile($filePath)
 {
     if (self::$_instance !== null) {
         throw new Exception('You need to set the path before calling ' . __CLASS__ . '::getInstance() method', 0);
     } else {
         self::$_configFile = $filePath;
     }
 }
 public function index()
 {
     if (\Configer::get('maintain') == 'on') {
         return view('maintain');
     } else {
         return view('form', ['config' => \Configer::get(), 'alert' => \Configer::check()]);
     }
 }
 public function setting()
 {
     $setting = [];
     $result = \DB::table('setting')->get();
     foreach ($result as $item) {
         $setting[$item->name] = $item->value;
     }
     $langs = ['en' => 'English', 'zh-hant' => '正體中文', 'zh-hans' => '简体中文'];
     $themes = ["cerulean", "cosmo", "cyborg", "darkly", "flatly", "journal", "paper", "readable", "sandstone", "simplex", "slate", "united", "yeti", "lumen", "superhero", "spacelab"];
     $frequency = [60, 120, 180, 240, 300];
     return view('admin.setting', ['config' => \Configer::get(), 'setting' => $setting, 'langs' => $langs, 'themes' => $themes, 'frequency' => $frequency]);
 }
 public static function check()
 {
     $main_config = \Config::get('publisher');
     $custom_setting = \Configer::getSetting();
     $config = array_merge(array_filter($main_config), array_filter($custom_setting));
     @($license = explode("\n", $config['license']));
     if (count($license)) {
         $config['license'] = $license;
     }
     $result = [];
     foreach (\Lang::get('alert') as $key => $value) {
         if (count(explode('.', $key)) == 2) {
             $exp = explode('.', $key);
             $check = $config[$exp[0]][$exp[1]];
         } else {
             $check = $config[$key];
         }
         if (empty($check)) {
             array_push($result, $value);
         }
     }
     return $result;
 }
示例#5
0
$input = $_GET['p'];
$input = (array)json_decode($input);

$result = $db->insert( $input );
var_dump($result);
echo $db->error;
*/
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
// change accordingly
if (!file_exists('./conf/config.php')) {
    //header('Location: ''/');
    header("location: ./install.php");
} else {
    Configer::setFile('./conf/config.php');
    $config = Configer::getInstance();
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    $db = new Mysql($config);
    if ($db->insert()) {
        if (isset($_REQUEST['redirect_url'])) {
            header("Location: {$_REQUEST['redirect_url']}");
            exit;
        } else {
            die('ok');
        }
    } else {
        die($db->error);
    }
}
 public function check()
 {
     @($key = strip_tags(\Route::input('key')));
     if (empty($key)) {
         return redirect('/');
     } else {
         $result = \DB::table('post')->where('post_key', $key)->first();
         if (isset($result->id)) {
             if ($result->post_state == 1) {
                 $exp = explode('_', $result->facebook_url);
                 $url = 'https://facebook.com/' . $exp[0] . '/posts/' . $exp[1];
                 return redirect($url);
             } else {
                 if ($result->publish_time - time() >= 0) {
                     $state = '<div class="alert alert-danger text-center" role="alert">' . \Lang::get('check.do_not_close_window') . '</div><h4>' . \Lang::get('check.remaining_time') . ': <span id="countdown" data-timestamp="' . $result->publish_time . '"></span></h4><p>' . \Lang::get('check.auto_redirect_message') . '</p>';
                     $foot = '<script src="/js/check.js" type="text/javascript"></script>';
                 } elseif ($result->publish_time - time() < 0 && $result->post_state == 0) {
                     $last = \DB::table('post')->where('post_state', '1')->orderBy('id', 'desc')->first();
                     if (count($last) > 0) {
                         $query = 'UPDATE post SET post_state = 8 WHERE id < ' . $last->id . ' AND post_state = 0';
                         \DB::update(\DB::raw($query));
                     }
                     $this->publishPostToFacebook($result);
                     header("Refresh:0");
                     exit;
                 } elseif ($result->publish_time - time() < 0 && $result->post_state == 5) {
                     $state = '<h4>' . \Lang::get('check.pending') . '</h4><p>' . \Lang::get('check.pending_message') . '</p>';
                     $foot = '';
                 } else {
                     $state = '<h4>' . \Lang::get('check.oops') . '</h4><p>' . \Lang::get('check.oops_message') . '<br />' . \Lang::get('check.try_contact_with') . '<a href="http://facebook.com/' . \Configer::get('page_id') . '">' . \Lang::get('check.page_admin') . '</a></p>';
                     $foot = '';
                 }
                 return view('check', ['config' => \Configer::get(), 'state' => $state, 'foot' => $foot]);
             }
         } else {
             return redirect('/');
         }
     }
 }
 private function handleText($text)
 {
     if (empty($text)) {
         $text = \Configer::get('page_name');
     }
     if (mb_strlen($text, 'utf-8') > 140) {
         $text = mb_substr($text, 0, 140, 'utf-8');
     }
     $text = str_replace('\\n', "\n", $text);
     $text = $this->autoWrap($text);
     return $text;
 }
 public function unpublishPostFromFacebook($post)
 {
     $response = ['state' => 'error', 'message' => 'Something wrong.'];
     $fb = new Facebook(\Configer::get('fb_app_setting'));
     $fb->setDefaultAccessToken(\Configer::get('fb_page_token'));
     try {
         $callback = $fb->delete('/' . $post->facebook_url);
         $callback = $callback->getDecodedBody();
         if ($callback['success'] == 1) {
             \DB::table('post')->where('id', $post->id)->update(['post_state' => 2]);
             $response = ['state' => 'success', 'message' => 'Post unpublished.'];
         } else {
             $response = ['state' => 'failed', 'message' => 'Post unpublish failed.'];
         }
     } catch (Exception $e) {
         $response = ['state' => 'failed', 'message' => 'Post unpublish failed.'];
     }
     return $response;
 }