/**
 * Activate a named plugin.
 *
 * Parses the plugins directory to look for a pluginname.yaml
 * file and adds the plugin to the plugins database, setting
 * the inst_version field to the version specified in the yaml file.
 *
 * @param string $name Name of plugin to be activated.
 * @return bool Returns true if plugin directory was found.
 * @see deactivate_plugin
 */
function activate_plugin($name)
{
    $plugins_dir = dirname(__FILE__) . '/../plugins/';
    $plugin_dir = $plugins_dir . $name;
    if (file_exists($plugin_dir)) {
        $plugin_yaml = get_plugin_yaml("{$plugin_dir}/{$name}.yaml", false);
        # If no yaml, or yaml file but no description present, attempt to read an 'about.txt' file
        if ($plugin_yaml['desc'] == '') {
            $about = $plugins_dir . $name . '/about.txt';
            if (file_exists($about)) {
                $plugin_yaml['desc'] = substr(file_get_contents($about), 0, 95) . '...';
            }
        }
        # escape the plugin information
        $plugin_yaml_esc = array();
        foreach (array_keys($plugin_yaml) as $thekey) {
            $plugin_yaml_esc[$thekey] = escape_check($plugin_yaml[$thekey]);
        }
        # Add/Update plugin information.
        # Check if the plugin is already in the table.
        $c = sql_value("SELECT name as value FROM plugins WHERE name='{$name}'", '');
        if ($c == '') {
            sql_query("INSERT INTO plugins(name) VALUE ('{$name}')");
        }
        sql_query("UPDATE plugins SET config_url='{$plugin_yaml_esc['config_url']}', " . "descrip='{$plugin_yaml_esc['desc']}', author='{$plugin_yaml_esc['author']}', " . "inst_version='{$plugin_yaml_esc['version']}', " . "priority='{$plugin_yaml_esc['default_priority']}', " . "update_url='{$plugin_yaml_esc['update_url']}', info_url='{$plugin_yaml_esc['info_url']}' " . "WHERE name='{$plugin_yaml_esc['name']}'");
        hook("after_activate_plugin", "", array($name));
        return true;
    } else {
        return false;
    }
}
 /**
  * 新增或更新一个文档
  * @param array  $data 手动传入的数据
  * @return boolean fasle 失败 , int  成功 返回完整的数据
  * @author huajie <*****@*****.**>
  */
 public function update($data = null)
 {
     /* 获取数据对象 */
     $data = $this->token(false)->create($data);
     if (empty($data)) {
         return false;
     }
     /* 添加或新增基础内容 */
     if (empty($data['id'])) {
         //新增数据
         $id = $this->add($_POST);
         //添加基础内容
         if (!$id) {
             $this->error = '新增基础内容出错!';
             return false;
         }
     } else {
         //更新数据
         $status = $this->save();
         //更新基础内容
         if (false === $status) {
             $this->error = '更新基础内容出错!';
             return false;
         }
     }
     hook('documentSaveComplete', array('model_id' => $data['model_id']));
     //行为记录
     if ($id) {
         action_log('add_document', 'document', $id, UID);
     }
     //内容添加或更新完成
     return $data;
 }
 public function displayHtmlContent($content)
 {
     $content = parse_popup($content);
     $content = parse_at_users($content);
     hook('parseContent', array('content' => &$content));
     return $content;
 }
Exemple #4
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (access('Dev.*') && cogear()->config->development) {
         hook('done', array($this, 'finish'));
     }
 }
Exemple #5
0
 /**
  * 构造方法,添加消息提醒的钩子
  */
 function __construct()
 {
     $this->message = new Message();
     $hook = hook();
     $hook->add('FollowManagement_follow', [$this, 'mail_follow_me']);
     $hook->add('FollowManagement_follow', [$this, 'message_follow_me']);
     $hook->add('FollowManagement_follow_gallery', [$this, 'mail_follow_gallery']);
     $hook->add('FollowManagement_follow_gallery', [$this, 'message_follow_gallery']);
     $hook->add('PictureComment_comment', [$this, 'mail_comment_picture']);
     $hook->add('PictureComment_comment', [$this, 'message_comment_picture']);
     $hook->add('GalleryComment_comment', [$this, 'mail_comment_gallery']);
     $hook->add('GalleryComment_comment', [$this, 'message_comment_gallery']);
     $hook->add('Comment_reply', [$this, 'mail_comment_reply']);
     $hook->add('Comment_reply', [$this, 'message_comment_reply']);
     $hook->add('Picture_like', [$this, 'mail_like_pic']);
     $hook->add('Picture_like', [$this, 'message_like_pic']);
     $hook->add('Gallery_like', [$this, 'mail_like_gallery']);
     $hook->add('Gallery_like', [$this, 'message_like_gallery']);
     $hook->add('CommentManagement_like', [$this, 'mail_like_comment']);
     $hook->add('CommentManagement_like', [$this, 'message_like_comment']);
     $hook->add('Message_send_success', [$this, 'mail_send_message']);
     $hook->add('Message_send_success', [$this, 'mail_send_system_message']);
     $hook->add('UserLogin_PostLogin_Success', [$this, 'mail_exception_login']);
     $hook->add('UserLogin_PostLogin_Success', [$this, 'message_exception_login']);
     $hook->add('UserLogin_PostLogin_restrictions', [$this, 'mail_login_restrictions']);
     $hook->add('UserLogin_PostLogin_restrictions', [$this, 'message_login_restrictions']);
 }
Exemple #6
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->clear();
     Template::bindGlobal('scripts', $this->scripts);
     Template::bindGlobal('styles', $this->styles);
     hook('head', array($this, 'output'));
 }
 function send_research_request()
 {
     # Insert a search request into the requests table.
     # Resolve resource types
     $rt = "";
     $types = get_resource_types();
     for ($n = 0; $n < count($types); $n++) {
         if (getval("resource" . $types[$n]["ref"], "") != "") {
             if ($rt != "") {
                 $rt .= ", ";
             }
             $rt .= $types[$n]["ref"];
         }
     }
     global $userref;
     $as_user = getvalescaped("as_user", $userref, true);
     # If userref submitted, use that, else use this user
     # Insert the request
     sql_query("insert into research_request(created,user,name,description,deadline,contact,email,finaluse,resource_types,noresources,shape)\n\tvalues (now(),'{$as_user}','" . getvalescaped("name", "") . "','" . getvalescaped("description", "") . "'," . (getvalescaped("deadline", "") == "" ? "null" : "'" . getvalescaped("deadline", "") . "'") . ",'" . getvalescaped("contact", "") . "','" . getvalescaped("email", "") . "','" . getvalescaped("finaluse", "") . "','" . $rt . "'," . (getvalescaped("noresources", "") == "" ? "null" : "'" . getvalescaped("noresources", "") . "'") . ",'" . getvalescaped("shape", "") . "')");
     # E-mails a resource request (posted) to the team
     global $applicationname, $email_from, $baseurl, $email_notify, $username, $userfullname, $useremail, $lang;
     $templatevars['ref'] = sql_insert_id();
     $templatevars['teamresearchurl'] = $baseurl . "/pages/team/team_research.php";
     $templatevars['username'] = $username;
     $templatevars['userfullname'] = $userfullname;
     $templatevars['useremail'] = getvalescaped("email", $useremail);
     # Use provided e-mail (for anonymous access) or drop back to user email.
     $templatevars['url'] = $baseurl . "/pages/team/team_research_edit.php?ref=" . $templatevars['ref'];
     $message = "'{$username}' ({$userfullname} - {$useremail}) " . $lang["haspostedresearchrequest"] . ".\n\n";
     $message .= $templatevars['teamresearchurl'];
     hook("modifyresearchrequestemail");
     send_mail($email_notify, $applicationname . ": " . $lang["newresearchrequestwaiting"], $message, $useremail, "", "emailnewresearchrequestwaiting", $templatevars);
 }
 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     foreach ($files as $key => $file) {
         $ext = strtolower($file['ext']);
         if (in_array($ext, array('jpg', 'jpeg', 'bmp', 'png'))) {
             hook('dealPicture', $file['tmp_name']);
         }
     }
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             /* 记录文件信息 */
             if (strtolower($driver) == 'sae') {
                 $value['path'] = $config['rootPath'] . 'Picture/' . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
             } else {
                 if (strtolower($driver) == 'qiniu') {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 } elseif (strtolower($driver) != 'local') {
                     $value['path'] = $value['url'];
                 } else {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                     //在模板里的url路径
                 }
             }
             $value['type'] = strtolower($driver);
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         foreach ($info as &$t_info) {
             if ($t_info['type'] == 'local') {
                 $t_info['path'] = fixAttachUrl($t_info['path']);
             } else {
                 $t_info['path'] = $t_info['path'];
             }
         }
         /*  dump(getRootUrl());
             dump($info);
             exit;*/
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
function save_themename()
{
    global $baseurl, $link, $themename, $collection_column;
    $sql = "update collection set\t" . $collection_column . "='" . getvalescaped("rename", "") . "' where " . $collection_column . "='" . escape_check($themename) . "'";
    sql_query($sql);
    hook("after_save_themename");
    redirect("pages/" . $link);
}
Exemple #10
0
function catch_selected_project()
{
    if (projectSelected() == true) {
        hook("site_begin", "projectDisplayers");
    } else {
        hook("site_begin", "dirtiness");
    }
}
Exemple #11
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     hook('form.page-createdit.init', array($this, 'extendPageForm'));
     hook('Pages.showPage.after', array($this, 'attachCommentsToPage'));
     hook('stack.Page.info', array($this, 'extendPageInfo'));
     allow_role(array('comments post'), 100);
 }
function themeSettings()
{
    global $manager;
    if (countHooks("design-settings") == 0) {
        hook("big_message", "noDesignSettings");
        return;
    }
}
Exemple #13
0
 /**
  * Отбражение региона
  *
  * @return string
  */
 public function render()
 {
     // Делаем всё через хуки, чтобы другие тоже могли выводить
     hook($this->options->name, array($this, 'output'));
     ob_start();
     event($this->options->name);
     return ob_get_clean();
 }
Exemple #14
0
 /**
  * Конструктор
  *
  * @param string $path
  * @param string $section
  */
 public function __construct($path = '', $section = '')
 {
     if ($path) {
         $this->file = $path;
         $this->load($path, $section);
         hook('exit', array($this, 'store'));
     }
 }
Exemple #15
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $cogear = getInstance();
     $this->api = new Loginza_API();
     hook('form.user-login.result.before', array($this, 'hookUserForm'));
     hook('form.user-register.result.before', array($this, 'hookUserForm'));
     hook('form.user-profile.init', array($this, 'hookUserProfile'));
 }
Exemple #16
0
 private function setConfig()
 {
     $cfg = hook()->apply("Mail_setConfig", cfg()->get('mail'));
     foreach ($cfg as $name => $value) {
         if (isset($this->{$name})) {
             $this->{$name} = $value;
         }
     }
 }
Exemple #17
0
 /**
  * Check cron
  */
 public function check()
 {
     if (time() - $this->get('cron.last_run') > self::STEP) {
         // Set cron execute time
         $this->set('cron.last_run', time());
         // It's highly important to run cron after server response will be sent to user
         hook('after', array($this, 'poorMansCron'));
     }
 }
function get_extension($resource, $size)
{
    $pextension = $size == 'original' ? $resource["file_extension"] : 'jpg';
    $replace_extension = hook('replacedownloadextension', '', array($resource, $pextension));
    if (!empty($replace_extension)) {
        return $replace_extension;
    }
    return $pextension;
}
Exemple #19
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     Template::bindGlobal('meta', $this->info);
     title(t(config('site.name', SITE_URL)));
     hook('head', array($this, 'head'), 0);
     hook('menu.setActive', array($this, 'menuTitleHook'));
     hook('Pages.showPage.before', array($this, 'showObjectTitle'));
     hook('admin.gear.request', array($this, 'showObjectTitle'));
 }
 public function index()
 {
     hook('homeIndex');
     $default_url = C('DEFUALT_HOME_URL');
     //获得配置,如果为空则显示聚合,否则跳转
     if ($default_url != '') {
         redirect(get_nav_url($default_url));
     }
     $this->display();
 }
Exemple #21
0
 /**
  * 获取浏览器UA
  * @return string
  */
 public function getUA()
 {
     static $ua = NULL;
     if ($ua !== NULL) {
         return $ua;
     }
     $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     $ua = hook()->apply("Input_getUA", $ua);
     return $ua;
 }
Exemple #22
0
 /**
  * 构造器,对生成异常进行捕获
  * @param array      $setting 可写数据库配置信息,当仅仅配置该数据库时,读写为同一数据库
  * @param array|null $read    只读数据库配置
  */
 public function __construct($setting, $read = NULL)
 {
     if (!is_array($setting)) {
         return;
     }
     hook()->add("Log_write", [$this, 'log_hook']);
     $this->_setting = $setting;
     $this->_setting_read = $read;
     $this->reopen();
 }
Exemple #23
0
 /**
  * Конструктор
  */
 public function __construct($config)
 {
     $this->lang = config('lang.lang', 'ru');
     hook('lang.transliterate', array($this, 'transliterate_' . $this->lang));
     $this->locale = config('lang.locale') . '.UTF-8';
     $options = config('lang');
     $this->object(Lang::factory('index', $options));
     config('lang.ignore_native') && $this->lang == 'ru' or $this->object->load();
     setlocale(LC_ALL, $this->locale);
     parent::__construct($config);
 }
Exemple #24
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if ($rules = $this->system_cache->read('access/rules', TRUE)) {
         $this->rules->adopt($rules);
     }
     if ($roles = $this->system_cache->read('access/roles', TRUE)) {
         $this->roles->adopt($roles);
     }
     $this->getRights();
     hook('exit', array($this, 'save'));
 }
Exemple #25
0
 /**
  * Show feed
  */
 public function hookFeed($items)
 {
     if ($this->input->get('rss') !== NULL) {
         $tpl = new Template('Syndicate/templates/rss');
         $tpl->title = $this->meta->info->title->toString(config('meta.title.delimiter', ' &raquo; '));
         $tpl->link = l() . $this->router->getUri() . '?rss';
         $tpl->items = $items;
         $this->code = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . $tpl->render();
     } else {
         hook('head', array($this, 'hookMeta'));
     }
 }
Exemple #26
0
function HookEmbedvideoViewAfterresourceactions()
{
    global $embedvideo_resourcetype, $ffmpeg_preview_extension, $resource, $ref, $ffmpeg_preview_max_width, $ffmpeg_preview_max_height, $userfixedtheme, $baseurl, $lang;
    if ($resource["resource_type"] != $embedvideo_resourcetype) {
        return false;
    }
    # Not the right type.
    ?>

	<?php 
    # FLV player - plays the FLV file created to preview video resources.
    if (file_exists(get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension))) {
        $flashpath = get_resource_path($ref, false, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
    } else {
        $flashpath = get_resource_path($ref, false, "", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
    }
    $flashpath = urlencode($flashpath);
    $thumb = get_resource_path($ref, false, "pre", false, "jpg");
    $thumb = urlencode($thumb);
    # Choose a colour based on the theme.
    # This is quite hacky, and ideally of course this would be CSS based, but the FLV player requires that the colour
    # is passed as a parameter.
    # The default is a neutral grey which should be acceptable for most user generated themes.
    $theme = isset($userfixedtheme) && $userfixedtheme != "" ? $userfixedtheme : getval("colourcss", "greyblu");
    $colour = "505050";
    if ($theme == "greyblu") {
        $colour = "446693";
    }
    ?>
<li><a href="#" onClick="
if (document.getElementById('embedvideo').style.display=='block') {document.getElementById('embedvideo').style.display='none';} else {document.getElementById('embedvideo').style.display='block';}
if (document.getElementById('embedvideo2').style.display=='block') {document.getElementById('embedvideo2').style.display='none';} else {document.getElementById('embedvideo2').style.display='block';}
 return false;">&gt;&nbsp;<?php 
    echo $lang["embed"];
    ?>
</a></li>
<p id="embedvideo2" style="display:none;float:left;padding:10px 0 3px 0;"><?php 
    echo $lang["embed_help"];
    ?>
</p>
<textarea id="embedvideo" style="width:335px;height:200px;display:none;"><?php 
    if (!hook("replaceembedcode")) {
        echo htmlspecialchars('
<object type="application/x-shockwave-flash" data="' . $baseurl . '/lib/flashplayer/player_flv_maxi.swf" width="' . $ffmpeg_preview_max_width . '" height="' . $ffmpeg_preview_max_height . '" class="Picture"><param name="allowFullScreen" value="true" /><param name="movie" value="' . $baseurl . '/lib/flashplayer/player_flv_maxi.swf" /><param name="FlashVars" value="flv=' . $flashpath . '&amp;width=' . $ffmpeg_preview_max_width . '&amp;height=' . $ffmpeg_preview_max_height . '&amp;margin=0&amp;buffer=10&amp;showvolume=1&amp;volume=200&amp;showtime=1&amp;autoplay=1&amp;autoload=0&amp;showfullscreen=1&amp;showstop=1&amp;playercolor=' . $colour . '&startimage=' . $thumb . '" /></object>
');
    }
    // end hook replaceembedcode
    ?>
</textarea>

	<?php 
    return true;
}
Exemple #27
0
 function init()
 {
     parent::init();
     language();
     hook('controller');
     /*
      * load modules 
      * 加载模块
      */
     if (!cache_pre('all_modules')) {
         \app\core\Modules::load();
     }
 }
Exemple #28
0
function sql_filter()
{
    if (!($args = func_get_args())) {
        return false;
    }
    $sql = array_shift($args);
    $count_args = count($args);
    $sql = str_replace('%', '[!]', $sql);
    if (!$count_args || $count_args < 1) {
        return str_replace('[!]', '%', $sql);
    }
    if ($count_args == 1 && is_array($args[0])) {
        $args = $args[0];
    }
    $_args = array();
    foreach ($args as $i => $arg) {
        if (strpos($arg, '/***/') !== false) {
            $_args[$i] = $arg;
        } else {
            $_args[$i] = sql_escape($arg);
        }
    }
    $args = $_args;
    foreach ($args as $i => $row) {
        if (strpos($row, 'addquotes') !== false) {
            $e_row = explode(',', $row);
            array_shift($e_row);
            foreach ($e_row as $j => $jr) {
                $e_row[$j] = "'" . $jr . "'";
            }
            $args[$i] = implode(',', $e_row);
        }
    }
    array_unshift($args, str_replace(w('?? ?'), w("%s '%s'"), $sql));
    // Conditional deletion of lines if input is zero
    if (strpos($args[0], '-- ') !== false) {
        $e_sql = explode("\n", $args[0]);
        $matches = 0;
        foreach ($e_sql as $i => $row) {
            $e_sql[$i] = str_replace('-- ', '', $row);
            if (strpos($row, '%s')) {
                $matches++;
            }
            if (strpos($row, '-- ') !== false && !$args[$matches]) {
                unset($e_sql[$i], $args[$matches]);
            }
        }
        $args[0] = implode($e_sql);
    }
    return str_replace('[!]', '%', hook('sprintf', $args));
}
Exemple #29
0
 /**
  * 添加钩子,并初始化部分信息
  */
 public function add()
 {
     if (!db()->status()) {
         hook()->add('UriInfo_process', array($this, 'sql_error'));
     } else {
         c_lib()->load('cookie')->add('cookie', new \CLib\Cookie(cfg()->get('cookie', 'encode')));
         lib()->load('setting', 'user', 'plugin', 'version_hook')->add('setting', new Setting());
         lib()->add('user', new User(true));
         lib()->add("version_hook", new Version_Hook());
         l_h('theme.php');
         hook()->add('UriInfo_process', array($this, 'router'));
         lib()->add('plugin', new Plugin(_BasePath_ . "/ex/plugin"));
     }
 }
Exemple #30
0
 /**
  * 创建图片资源文件
  * @param $code
  * @return resource
  */
 private function create_resource($code)
 {
     $resource = hook()->apply("Captcha_create_resource", NULL, $code);
     if (!is_resource($resource)) {
         $resource = imagecreate(60, 20);
         $black = ImageColorAllocate($resource, 0, 0, 0);
         //RGB黑色标识符
         $white = ImageColorAllocate($resource, 255, 255, 255);
         //RGB白色标识符
         imagefill($resource, 0, 0, $white);
         imagestring($resource, 5, 10, 3, $code, $black);
     }
     return $resource;
 }