Example #1
0
 public function update()
 {
     $group_id = $this->input['hid_gid'] ? intval($this->input['hid_gid']) : -1;
     if ($group_id <= 0) {
         $this->errorOutput(OBJECT_NULL);
     }
     $res = $this->group->check_group_exists($group_id);
     if (!$res) {
         $this->errorOutput(OBJECT_NULL);
     }
     $group_name = trim(urldecode($this->input['gname']));
     $group_domain = trim(urldecode($this->input['domain']));
     $desc = isset($this->input['description']) ? trim(urldecode($this->input['description'])) : '暂无描述...';
     $fatherid = isset($this->input['fatherid']) ? intval($this->input['fatherid']) : 0;
     $group_type = isset($this->input['group_type']) ? intval($this->input['group_type']) : 0;
     $group_tag = trim(urldecode($this->input['tags']));
     $permission = isset($this->input['permission']) ? intval($this->input['permission']) : 6;
     //$lat = isset($this->input['hid_lat']) ? trim(urldecode($this->input['hid_lat'])) : 0;
     //$lng = isset($this->input['hid_lng']) ? trim(urldecode($this->input['hid_lng'])) : 0;
     //$group_addr = isset($this->input['hid_addr']) ? trim(urldecode($this->input['hid_addr'])) : '';
     if (empty($group_name)) {
         $this->errorOutput(OBJECT_NULL);
     }
     $update_field = array('name' => $group_name, 'group_domain' => $group_domain, 'description' => $desc, 'fatherid' => $fatherid, 'group_type' => $group_type, 'permission' => $permission, 'column_id' => $this->input['column_id']);
     $result = $this->group->update($update_field, $group_id);
     if ($group_tag && $result) {
         include_once ROOT_PATH . 'lib/class/mark.class.php';
         $mark = new mark();
         $mark->updateMarkByNames($group_tag, $group_id, 1);
     }
     $this->addItem($result);
     $this->output();
 }
Example #2
0
 public function detail()
 {
     if (isset($this->input['id'])) {
         $group_id = intval($this->input['id']);
     } elseif (isset($this->input['group_id'])) {
         $group_id = intval($this->input['group_id']);
     } else {
         $group_id = -1;
     }
     if ($group_id < 0) {
         $this->errorOutput(PARAM_WRONG);
     }
     $group = $this->group->detail($group_id, true);
     include_once ROOT_PATH . 'lib/class/mark.class.php';
     $mark = new mark();
     $tags = $mark->getInfoByType($group_id, 1);
     $group['tag'] = $tags;
     $this->setXmlNode('group_info', 'group');
     $this->addItem($group);
     $this->output();
 }
Example #3
0
 public function update()
 {
     $count = $this->input['count'] ? intval($this->input['count']) : 10;
     include_once ROOT_PATH . 'lib/class/mark.class.php';
     $obj_mark = new mark();
     $ret = $obj_mark->get_hot_mark(array('source' => 'topic', 'count' => -1));
     $info = array();
     $i = array();
     foreach ($ret as $k => $v) {
         $i[$v['parent_id']]++;
         if ($i[$v['parent_id']] > $count) {
             continue;
         }
         $info[$v['parent_id']][] = $v['mark_name'];
     }
     $sql = "UPDATE " . DB_PREFIX . "team SET ";
     foreach ($info as $k => $v) {
         $extra = "hot_topic_tags='" . implode(',', $v) . "' WHERE team_id=" . $k;
         $this->db->query($sql . $extra);
     }
 }
Example #4
0
function update_driver_sqlite($t)
{
    $builder = new SQLMaker('sqlite');
    do {
        list($sql, $binds) = $builder->update('user', array('name' => 'john', 'email' => '*****@*****.**'), array('user_id' => 3));
        $t->is($sql, 'UPDATE "user" SET "name" = ?, "email" = ? WHERE ("user_id" = ?)');
        $t->is(implode(',', $binds), 'john,john@example.com,3');
    } while (false);
    do {
        list($sql, $binds) = $builder->update('foo', array('bar' => 'baz', 'john' => 'man'), array('yo' => 'king'));
        $t->is($sql, 'UPDATE "foo" SET "bar" = ?, "john" = ? WHERE ("yo" = ?)');
        $t->is(implode(',', $binds), 'baz,man,king');
    } while (false);
    do {
        list($sql, $binds) = $builder->update('foo', array('bar' => 'baz', 'john' => 'man'));
        $t->is($sql, 'UPDATE "foo" SET "bar" = ?, "john" = ?');
        $t->is(implode(',', $binds), 'baz,man');
    } while (false);
    do {
        list($sql, $binds) = $builder->update('foo', array('created_at' => mark::raw('NOW( )')));
        $t->is($sql, 'UPDATE "foo" SET "created_at" = NOW( )');
        $t->is(implode(',', $binds), '');
    } while (false);
}
Example #5
0
 function recoverTopicTags()
 {
     $mark = new mark();
     $result = $dataSeach = array();
     $dataSeach = array('source' => 'topic', 'count' => -1);
     //
     $result = $mark->get_id_by_name($dataSeach);
     if ($result) {
         $topic_arr = array();
         foreach ($result as $k => $v) {
             $topic_arr[$v['source_id']][] = $v['mark_name'];
         }
         if ($topic_arr) {
             echo "topic标签更新开始<br/>";
             foreach ($topic_arr as $k => $v) {
                 $data = array();
                 if ($v) {
                     $data['tags'] = implode(',', $v);
                 }
                 if ($data) {
                     $this->libactivity->update('topic', $data, array('topic_id' => $k), array());
                     echo "...topic" . $k . "标签更新完毕<br/>";
                 }
             }
             echo "topic标签更新完毕<br/>";
         }
     }
 }
Example #6
0
function str_to_html($string)
{
    $code = array();
    $lang = array();
    $re = '#(<code)([ ]?lang=["]?(abap|actionscript|actionscript3|ada|apache|applescript|apt_sources|asm|asp|autoit|avisynth|bash|basic4gl|bf|bibtex|blitzbasic|bnf|boo|c|c_mac|caddcl|cadlisp|cfdg|cfm|cil|cmake|cobol|cpp|cpp-qt|csharp|css|d|dcs|delphi|diff|div|dos|dot|eiffel|e-mail|erlang|fo|fortran|freebasic|genero|gettext|glsl|gml|gnuplot|groovy|haskell|hq9plus|html4strict|idl|ini|inno|intercal|io|java|java5|javascript|kixtart|klonec|latex|lisp|locobasic|lolcode|lotusformulas|lotusscript|lscript|lsl2|lua|m68k|make|matlab|mirc|modula3|mpasm|mxml|mysql|nsis|oberon2|objc|ocaml|ocaml-brief|oobas|oracle11|oracle8|pascal|per|perl|php|php-brief|pic16|pixelbender|plsql|povray|powershell|progress|prolog|providex||python|qbasic|rails|rebol|reg|robots|ruby|sas|scala|scheme|scilab|sdlbasic|smalltalk|smarty|sql|tcl|teraterm|text|thinbasic|tsql|typoscript|vb|vbnet|verilog|vhdl|vim|visualfoxpro|visualprolog|whitespace|whois|winbatch|xml|xorg_conf|xpp|z80)["]?)?(>)((?!</code>).*?)(</code>)#suim';
    $vh = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $lang[$i] = $match[3][$i];
        $with_breaks = mark::highlight(html_entity_decode($match[5][$i], ENT_QUOTES), $match[3][$i], "librarys/geshi/geshi");
        $code[$i] = $with_breaks;
        $string = str_replace($match[0][$i], '⓬' . $i . '⓬', $string);
    }
    $latex = array();
    $latex_re = '#(<latex>)(.*?)(</latex>)#suim';
    $vh = preg_match_all($latex_re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $with_breaks = mark::make_latex($match[2][$i]);
        $latex[$i] = $with_breaks;
        $string = str_replace($match[0][$i], '☣' . $i . '☣', $string);
    }
    $math = array();
    $re = '#(<m>)(.*?)(</m>)#suim';
    $vh = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $with_breaks = mark::make_formula($match[2][$i]);
        $math[$i] = $with_breaks;
        $string = str_replace($match[0][$i], 'ᴥ' . $i . 'ᴥ', $string);
    }
    $string = htmlspecialchars($string);
    $string = str_replace('\\', '&#92;', $string);
    $string = preg_replace("#(&lt;b&gt;)(.*?[^&lt;/b&gt;]?)(&lt;/b&gt;)#suim", "<b>\$2</b>", $string);
    $string = preg_replace("#(&lt;span class=&quot;spoiler&quot;&gt;)((?!&lt;/span&gt).*?)(&lt;/span&gt;)#suim", "<span class=\"spoiler\">\$2</span>", $string);
    $string = preg_replace("#(&lt;i&gt;)(.*?[^&lt;/i&gt;]?)(&lt;/i&gt;)#suim", "<i>\$2</i>", $string);
    $string = preg_replace("#(&lt;u&gt;)(.*?[^&lt;/u&gt;]?)(&lt;/u&gt;)#suim", "<u>\$2</u>", $string);
    $string = preg_replace("#(&lt;s&gt;)(.*?[^&lt;/s&gt;]?)(&lt;/s&gt;)#suim", "<s>\$2</s>", $string);
    $string = preg_replace("#(&lt;sub&gt;)(.*?[^&lt;/sub&gt;]?)(&lt;/sub&gt;)#suim", "<sub>\$2</sub>", $string);
    $string = preg_replace("#(&lt;sup&gt;)(.*?[^&lt;/sup&gt;]?)(&lt;/sup&gt;)#suim", "<sup>\$2</sup>", $string);
    $string = str_replace('imgh://', 'http://', $string);
    $string = str_replace('imghs://', 'https://', $string);
    $string = preg_replace("#(&lt;) ?(br) ?/?(&gt;)#suim", "<br>", $string);
    $qoute_re = "#(&lt;q&gt;)(.*?(?!&lt;q))(&lt;/q&gt;)#suim";
    $vt = preg_match_all($qoute_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = preg_replace($qoute_re, "<div class=\"quote\"><pre>\$2</pre></div>", $string, 1);
        $with_breaks = preg_replace('/^(\\r\\n)+/', '', $match[2][$i]);
        $with_breaks = preg_replace('/(\\r\\n)+$/', '', $with_breaks);
        $string = str_replace($match[2][$i], $with_breaks, $string);
    }
    $list_re = "#(&lt;ul&gt;)(.*?(?!ul&gt;))(&lt;/ul&gt;)#suim";
    $vt = preg_match_all($list_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = preg_replace($list_re, "<ul>\$2</ul>", $string, 1);
        $with_breaks = preg_replace('/^(\\r\\n)+/', '', $match[2][$i]);
        $with_breaks = preg_replace('/(\\r\\n)+$/', '', $with_breaks);
        $with_breaks = preg_replace('#&lt;li&gt;#suim', '<li>&nbsp;', $with_breaks);
        $string = str_replace($match[2][$i], $with_breaks, $string);
    }
    $num_re = "#(&lt;ol&gt;)(.*?(?!ol&gt;))(&lt;/ol&gt;)#suim";
    $vt = preg_match_all($num_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = preg_replace($num_re, "<ol start=\"1\">\$2</ol>", $string, 1);
        $with_breaks = preg_replace('/^(\\r\\n)+/', '', $match[2][$i]);
        $with_breaks = preg_replace('/(\\r\\n)+$/', '', $with_breaks);
        $with_breaks = preg_replace('#&lt;li&gt;#suim', '<li>&nbsp;', $with_breaks);
        $string = str_replace($match[2][$i], $with_breaks, $string);
    }
    $string = preg_replace('#(&lt;p align=&quot;)(left|right|center)(&quot;&gt;)(.*?(^/p&gt;)?)(&lt;/p&gt;)#suim', "<p align=\"\$2\">\$4</p>", $string);
    $img_re = '#(&lt;img) ?(align=&quot;)?(left|right|middle|top|bottom)?(&quot;)?(src=&quot;)((?!&quot;).*?)(&quot;&gt;)#suim';
    $vt = preg_match_all($img_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (!empty($match[3][$i])) {
            $string = preg_replace($img_re, "<img src=\"\$6\" align=\"\$3\" style=\"max-width: 1024px\" alt=\"[путь к изображению некорректен]\" />", $string, 1);
        } else {
            $string = preg_replace($img_re, "<img src=\"\$6\" style=\"max-width: 1024px\" alt=\"[путь к изображению некорректен]\" />", $string, 1);
        }
    }
    $user_re = "#(&lt;span class=&quot;user&quot;&gt;)((?!&lt;/span&gt;).*?)(&lt;/span&gt;)#suim";
    $arr = preg_match_all($user_re, $string, $match);
    for ($i = 0; $i < $arr; $i++) {
        $where_arr = array(array("key" => 'nick', "value" => $match[2][$i], "oper" => '='));
        $sel = base::select('users', '', '*', $where_arr, 'AND');
        if (!empty($sel)) {
            $string = preg_replace($user_re, "<b><a href=\"/profile.php?user=\$2\">\$2</a></b>", $string, 1);
        } else {
            $string = preg_replace($user_re, "\$2", $string, 1);
        }
    }
    $url_re = '#(&lt;a href=&quot;)((?!&quot;).*?)(&quot;&gt;)((?!&lt;/a&gt;).*?)(&lt;/a&gt;)#suim';
    $vt = preg_match_all($url_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (filter_var($match[2][$i], FILTER_VALIDATE_URL)) {
            $string = preg_replace($url_re, "<a href=\"\$2\">\$4</a>", $string);
        }
    }
    $string = '<p>' . $string . '</p>';
    $re = "#(⓬)([0-9]+)(⓬)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('⓬' . $match[2][$i] . '⓬', '<fieldset><legend>' . $lang[$match[2][$i]] . '</legend>' . $code[$match[2][$i]] . '</fieldset>', $string);
    }
    $re = "#(ᴥ)([0-9]+)(ᴥ)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('ᴥ' . $match[2][$i] . 'ᴥ', $math[$match[2][$i]], $string);
    }
    $re = "#(☣)([0-9]+)(☣)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('☣' . $match[2][$i] . '☣', $latex[$match[2][$i]], $string);
    }
    return $string;
}
Example #7
0
		$this->addItem($result);
		$this->output();
	}
	*/
    /*
	//批量审核话题数据
	public function audit()
	{	
		$topic_ids = $this->validate_data();
		$result = $this->topic->update(array('state' => 1), $topic_ids);
		$this->setXmlNode('topic_info', 'topic');
		$this->addItem($result);
		$this->output();
	}
	*/
    /*
	//批量打回(屏蔽)话题数据
	public function back()
	{
		$topic_ids = $this->validate_data();
		$result = $this->topic->update(array('state' => -1), $topic_ids);
		$this->setXmlNode('topic_info', 'topic');
		$this->addItem($result);
		$this->output();
	}
Example #8
0
<?php

require 'classes/core.php';
if (!empty($_GET['id'])) {
    $mark_id = (int) $_GET['id'];
} else {
    $mark_id = $uinfo['mark'];
}
$mark_info = mark::get_mark_info($mark_id);
$mark_name = $mark_info['name'];
$title = ' - Разметка ' . $mark_name;
$rss_link = 'rss';
require 'header.php';
$description = $mark_info['description'];
$langs = $coreC->get_settings_by_name('langs');
$math = $coreC->get_settings_by_name('math');
require 'themes/' . $theme . '/templates/mark/main.tpl.php';
require 'footer.php';
Example #9
0
            $mark = new mark();
            $markData = array('source' => 'topic', 'source_id' => $topic_ids, 'state' => $state, 'type_state' => 'team');
            $mark->update_mark_state($markData);
            if ($state == 0) {
                //删除话题搜索
                $this->teamApi->delete_search($topic_ids, 'topic');
            } elseif ($state == 1) {
                //插入话题搜索
                $this->teamApi->add_search($topic_ids, 'topic');
            }
            //删除话题
            $this->topic->update(array('state' => $state, 'type_state' => 'team'), $topic_ids);
        }
    }
    /**
	 * 删除小组所有信息
	 * @param String $ids
	 */
    public function real_del()
    {
        $team_ids = trim(urldecode($this->input['team_id']));
        //删除小组的关注
        $option = new option();
        $attenData = array('source' => 'team', 'source_id' => $team_ids, 'action' => 'attention');
        $option->delete($attenData);
        //删除小组的标签
        $mark = new mark();
        $markData = array('source' => 'team', 'source_id' => $team_ids, 'action' => 'team_tag');
        $mark->delete_source_id_mark($markData);
        //删除小组的主题标签
        $themeMarkData = array('source' => 'team', 'source_id' => $team_ids, 'action' => 'team_theme');
        $mark->delete_source_id_mark($themeMarkData);
        //删除小组下的行动召集者
        $this->team->del_apply($team_ids);
        //删除小组下的黑名单
Example #10
0
        $condition = array();
        if ($op == 'add') {
            $condition[$action] = 1;
        } elseif ($op == 'reduction') {
            $condition[$action] = 0;
        }
        $result = $this->topic->update($condition, $topic_id);
        $this->addItem($result);
        $this->output();
    }
    /**
	 * (删除|屏蔽)话题
	 */
    public function delete()
    {
        $topic_id = isset($this->input['topic_id']) ? intval($this->input['topic_id']) : -1;
        if ($topic_id < 0) {
            $this->errorOutput(PARAM_WRONG);
        }
        $topic_info = $this->topic->detail($topic_id, 1);
        if (!$topic_info) {
            $this->errorOutput(TEAM_NO_TOPIC);
        }
        $action = trim(urldecode($this->input['action']));
        if (empty($action)) {
            $action = 'drop';
        }
        $condition = array();
        if ($action == 'drop') {
            $condition['state'] = 0;
        } elseif ($action == 'hidden') {
            $condition['state'] = -1;
        }
        //删除话题回复
        $this->topic->update_reply($condition, '', $topic_id);
        //删除附件
        $this->topic->update_topic_material($topic_id, 0);
        //删除视频
        $this->topic->update_topic_video($topic_id, 0);
        //删除赞
        $option = new option();
        $favorData = array('source' => 'topic', 'action' => 'favor', 'source_id' => $topic_id, 'state' => 0);
        $option->updateState($favorData);
        //删除标签
        $mark = new mark();
        $markData = array('source' => 'topic', 'source_id' => $topic_id, 'state' => 0);
Example #11
0
 /**
  * 地主权限设置
  */
 public function setting()
 {
     $user_id = isset($this->user['user_id']) ? intval($this->user['user_id']) : -1;
     $group_id = isset($this->input['group_id']) ? intval($this->input['group_id']) : -1;
     if ($group_id < 0 || $user_id < 0) {
         $this->errorOutput(PARAM_WRONG);
     }
     $res = $this->group->check_group_exists($group_id);
     if (!$res) {
         $this->errorOutput(OBJECT_NULL);
     }
     $num = $this->group->is_creater($group_id, $user_id, true);
     //判断是否为地主
     if ($num == 0) {
         $this->errorOutput(NO_PERMISSION);
     }
     $group_name = trim(urldecode($this->input['name']));
     $group_desc = isset($this->input['description']) ? trim(urldecode($this->input['description'])) : '暂无描述...';
     $group_tag = trim(urldecode($this->input['group_tags']));
     $thread_list = intval($this->input['thread_list']);
     $permission = intval($this->input['permissions']);
     $per_add_time = intval($this->input['per_add_time']);
     $auto_delete_time = intval($this->input['auto_delete_time']);
     if (empty($group_name)) {
         $this->errorOutput(PARAM_WRONG);
     }
     $data = array('name' => $group_name, 'description' => $group_desc, 'thread_list' => $thread_list, 'permission' => $permission, 'per_add_time' => $per_add_time, 'auto_delete_time' => $auto_delete_time);
     $result = $this->group->setting($data, $group_id);
     if ($group_tag && $result) {
         include_once ROOT_PATH . 'lib/class/mark.class.php';
         $mark = new mark();
         $mark->updateMarkByNames($group_tag, $group_id, 1);
     }
     $this->addItem($result);
     $this->output();
 }
Example #12
0
function str_to_html($string)
{
    $code = array();
    $lang = array();
    $re = '#(``)(@(abap|actionscript|actionscript3|ada|apache|applescript|apt_sources|asm|asp|autoit|avisynth|bash|basic4gl|bf|bibtex|blitzbasic|bnf|boo|c|c_mac|caddcl|cadlisp|cfdg|cfm|cil|cmake|cobol|cpp|cpp-qt|csharp|css|d|dcs|delphi|diff|div|dos|dot|eiffel|e-mail|erlang|fo|fortran|freebasic|genero|gettext|glsl|gml|gnuplot|groovy|haskell|hq9plus|html4strict|idl|ini|inno|intercal|io|java|java5|javascript|kixtart|klonec|latex|lisp|locobasic|lolcode|lotusformulas|lotusscript|lscript|lsl2|lua|m68k|make|matlab|mirc|modula3|mpasm|mxml|mysql|nsis|oberon2|objc|ocaml|ocaml-brief|oobas|oracle11|oracle8|pascal|per|perl|php|php-brief|pic16|pixelbender|plsql|povray|powershell|progress|prolog|providex||python|qbasic|rails|rebol|reg|robots|ruby|sas|scala|scheme|scilab|sdlbasic|smalltalk|smarty|sql|tcl|teraterm|text|thinbasic|tsql|typoscript|vb|vbnet|verilog|vhdl|vim|visualfoxpro|visualprolog|whitespace|whois|winbatch|xml|xorg_conf|xpp|z80)@)?(.*?[^``]?)(``)#sim';
    $vh = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $lang[$i] = $match[3][$i];
        $with_breaks = mark::highlight(html_entity_decode($match[4][$i], ENT_QUOTES), $match[3][$i], "librarys/geshi/geshi");
        $code[$i] = $with_breaks;
        $string = str_replace($match[0][$i], '⓬' . $i . '⓬', $string);
    }
    $latex = array();
    $latex_re = '#(\\{%\\{)(.*?)(\\}%\\})#suim';
    $vh = preg_match_all($latex_re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $with_breaks = mark::make_latex($match[2][$i]);
        $latex[$i] = $with_breaks;
        $string = str_replace($match[0][$i], '☣' . $i . '☣', $string);
    }
    $re = '#(\\{\\{)(.*?)(\\}\\})#suim';
    $vh = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $with_breaks = mark::make_formula($match[2][$i]);
        $math[$i] = $with_breaks;
        $string = str_replace($match[0][$i], 'ᴥ' . $i . 'ᴥ', $string);
    }
    $string = htmlspecialchars($string);
    $string = str_replace('\\', '&#92;', $string);
    $string = '<p>' . $string . '</p>';
    $string = preg_replace("#(\\*\\*)(.*?(^\\*\\*)?)(\\*\\*)#sim", "<b>\$2</b>", $string);
    $string = preg_replace("#(%%)(.*?(^%%)?)(%%)#sim", "<span class=\"spoiler\">\$2</span>", $string);
    $string = preg_replace("#(__)(.*?(^__)?)(__)#sim", "<b>\$2</b>", $string);
    $string = preg_replace("#(\\*)([^ ].*?(^\\*)?)(\\*)#sim", "<i>\$2</i>", $string);
    $string = preg_replace("#(_)(.*?(^_)?)(_)#sim", "<i>\$2</i>", $string);
    $string = preg_replace("#(\\\$)(.*?(^\\\$)?)(\\\$)#sim", "<u>\$2</u>", $string);
    $string = preg_replace("#( |&nbsp;|<p>)([A-zА-я0-9<&;>/]*)(\\^W)#suim", "\$1<s>\$2</s>", $string);
    $string = preg_replace("@(##)(.*?([^##])?)(##)@sim", "<sub>\$2</sub>", $string);
    $string = preg_replace("@(#)(.*?(^#)?)(#)@sim", "<sup>\$2</sup>", $string);
    $string = str_replace('imgh://', 'http://', $string);
    $string = str_replace('imghs://', 'https://', $string);
    $string = preg_replace("#(\\* |\\+ |- ){2,}+#", "\$1", $string);
    $re = '#(\\* |\\+ |- )(.*?[^((\\r\\n){2,}|</p>)]?)((\\r\\n){2,}|</p>)#sim';
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = preg_replace($re, "<ul><li>&nbsp;\$2</ul>", $string, 1);
        $with_breaks = preg_replace('/(\\r\\n)(\\* |\\+ |- )/', '<li>&nbsp;', $match[2][$i]);
        $string = str_replace($match[2][$i], $with_breaks, $string);
    }
    $string = preg_replace("#([0-9]\\. ){2,}+#", "\$1", $string);
    $re = '#([0-9]\\. )(.*?[^((\\r\\n){2,}|</p>)]?)((\\r\\n){2,}|</p>)#sim';
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = preg_replace($re, "<ol><li>&nbsp;\$2</ol>", $string, 1);
        $with_breaks = preg_replace('/(\\r\\n)([0-9]\\. )/', '<li>&nbsp;', $match[2][$i]);
        $string = str_replace($match[2][$i], $with_breaks, $string);
    }
    $string = preg_replace("#(>>|&gt;&gt;)(.*?(^>>|&gt;&gt;)?)(>>|&gt;&gt;)#sim", "<p align=\"right\">\$2</p>", $string);
    $string = preg_replace("#(<<|&lt;&lt;)(.*?(^<<|&lt;&lt;)?)(<<|&lt;&lt;)#sim", "<p align=\"left\">\$2</p>", $string);
    $string = preg_replace("#(<>|&lt;&gt;)(.*?(^<>|&lt;&gt;)?)(<>|&lt;&gt;)#sim", "<p align=\"center\">\$2</p>", $string);
    $quote = array();
    $re = '#(`)([^`].*?[^`]?)(`)#sim';
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = preg_replace($re, "<div class=\"quote\"><pre>\$2</pre></div>", $string, 1);
        $with_breaks = preg_replace('/^(\\r\\n)+/', '', $match[2][$i]);
        $with_breaks = preg_replace('/(\\r\\n)+$/', '', $with_breaks);
        //$with_breaks = preg_replace('/\n/', '<li>&nbsp;', $with_breaks);
        $quote[$i] = $with_breaks;
        $string = str_replace($match[2][$i], '⓬⓬' . $i . '⓬⓬', $string);
    }
    $user_re = "#(\\^)(.*?[^\\^]?)(\\^)#sim";
    $arr = preg_match_all($user_re, $string, $match);
    for ($i = 0; $i < $arr; $i++) {
        $where_arr = array(array("key" => 'nick', "value" => $match[2][$i], "oper" => '='));
        $sel = base::select('users', '', '*', $where_arr, 'AND');
        if (!empty($sel)) {
            $string = preg_replace($user_re, "<b><a href=\"/profile.php?user=\$2\">\$2</a></b>", $string, 1);
        } else {
            $string = preg_replace($user_re, "\$2", $string, 1);
        }
    }
    $url_re = '#(~)((@)(.*?[^@]?)(@))?(.*?[^~]?)(~)#sim';
    $vt = preg_match_all($url_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (filter_var($match[6][$i], FILTER_VALIDATE_URL)) {
            if (empty($match[4][$i])) {
                $string = preg_replace($url_re, "<a href=\"\$6\">\$6</a>", $string, 1);
            } else {
                $string = preg_replace($url_re, "<a href=\"\$6\">\$4</a>", $string, 1);
            }
        }
    }
    $img_re = '#(~~)((@)(left|right|middle|top|bottom)(@))?(.*?[^~]{2}?)(~~)#sim';
    $vt = preg_match_all($img_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (!empty($match[3][$i])) {
            $string = preg_replace($img_re, "<img src=\"\$6\" align=\"\$4\" style=\"max-width: 1024px\" alt=\"[путь к изображению некорректен]\" />", $string, 1);
        } else {
            $string = preg_replace($img_re, "<img src=\"\$6\" style=\"max-width: 1024px\" alt=\"[путь к изображению некорректен]\" />", $string, 1);
        }
    }
    $string = preg_replace("#(\r\n|<p>|^)(>|&gt;)(.*?[^\n]?)(\n|\$)#sim", "\$1<i>>\$3</i><br>", $string);
    $string = preg_replace("#(\r\n)+#", '<br>', $string);
    $re = "#(⓬⓬)([0-9]+)(⓬⓬)#sim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('⓬⓬' . $match[2][$i] . '⓬⓬', $quote[$match[2][$i]], $string);
    }
    $re = "#(⓬)([0-9]+)(⓬)#sim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('⓬' . $match[2][$i] . '⓬', '<fieldset><legend>' . $lang[$match[2][$i]] . '</legend>' . $code[$match[2][$i]] . '</fieldset>', $string);
    }
    $re = "#(ᴥ)([0-9]+)(ᴥ)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('ᴥ' . $match[2][$i] . 'ᴥ', $math[$match[2][$i]], $string);
    }
    $re = "#(☣)([0-9]+)(☣)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('☣' . $match[2][$i] . '☣', $latex[$match[2][$i]], $string);
    }
    return $string;
}
Example #13
0
 function __construct()
 {
     self::$baseC = new base();
     self::$latex = new LaTeXMark();
 }
Example #14
0
function str_to_html($string)
{
    $code = array();
    $lang = array();
    $code_re = "#(\\[code)=?(abap|actionscript|actionscript3|ada|apache|applescript|apt_sources|asm|asp|autoit|avisynth|bash|basic4gl|bf|bibtex|blitzbasic|bnf|boo|c|c_mac|caddcl|cadlisp|cfdg|cfm|cil|cmake|cobol|cpp|cpp-qt|csharp|css|d|dcs|delphi|diff|div|dos|dot|eiffel|e-mail|erlang|fo|fortran|freebasic|genero|gettext|glsl|gml|gnuplot|groovy|haskell|hq9plus|html4strict|idl|ini|inno|intercal|io|java|java5|javascript|kixtart|klonec|latex|lisp|locobasic|lolcode|lotusformulas|lotusscript|lscript|lsl2|lua|m68k|make|matlab|mirc|modula3|mpasm|mxml|mysql|nsis|oberon2|objc|ocaml|ocaml-brief|oobas|oracle11|oracle8|pascal|per|perl|php|php-brief|pic16|pixelbender|plsql|povray|powershell|progress|prolog|providex||python|qbasic|rails|rebol|reg|robots|ruby|sas|scala|scheme|scilab|sdlbasic|smalltalk|smarty|sql|tcl|teraterm|text|thinbasic|tsql|typoscript|vb|vbnet|verilog|vhdl|vim|visualfoxpro|visualprolog|whitespace|whois|winbatch|xml|xorg_conf|xpp|z80)?(\\])(.*?[^\\[/code\\]]?)(\\[/code\\])#sim";
    $arr = preg_match_all($code_re, $string, $match);
    for ($i = 0; $i < $arr; $i++) {
        $lang[$i] = $match[3][$i];
        $with_breaks = mark::highlight(html_entity_decode($match[4][$i], ENT_QUOTES), $match[2][$i], "librarys/geshi/geshi");
        $code[$i] = $with_breaks;
        $string = str_replace($match[0][$i], '⓬' . $i . '⓬', $string);
    }
    $latex = array();
    $latex_re = '#(\\[latex\\])(.*?)(\\[/latex\\])#suim';
    $vh = preg_match_all($latex_re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $with_breaks = mark::make_latex($match[2][$i]);
        $latex[$i] = $with_breaks;
        $string = str_replace($match[0][$i], '☣' . $i . '☣', $string);
    }
    $math = array();
    $re = '#(\\[math\\])(.*?)(\\[/math\\])#suim';
    $vh = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vh; $i++) {
        $with_breaks = mark::make_formula($match[2][$i]);
        $math[$i] = $with_breaks;
        $string = str_replace($match[0][$i], 'ᴥ' . $i . 'ᴥ', $string);
    }
    $string = htmlspecialchars($string);
    $string = str_replace('\\', '&#92;', $string);
    $string = preg_replace("#(\\[b\\])(.*?[^\\[/b\\]]?)(\\[/b\\])#sim", "<b>\$2</b>", $string);
    $string = preg_replace("#(\\[spoiler\\])(.*?[^\\[/spoiler\\]]?)(\\[/spoiler\\])#sim", "<span class=\"spoiler\">\$2</span>", $string);
    $string = preg_replace("#(\\[i\\])(.*?[^\\[/i\\]]?)(\\[/i\\])#sim", "<i>\$2</i>", $string);
    $string = preg_replace("#(\\[u\\])(.*?[^\\[/u\\]]?)(\\[/u\\])#sim", "<u>\$2</u>", $string);
    $string = preg_replace("#(\\[s\\])(.*?[^\\[/s\\]]?)(\\[/s\\])#sim", "<s>\$2</s>", $string);
    $string = preg_replace("#(\\[sub\\])(.*?[^\\[/sub\\]]?)(\\[/sub\\])#sim", "<sub>\$2</sub>", $string);
    $string = preg_replace("#(\\[sup\\])(.*?[^\\[/sup\\]]?)(\\[/sup\\])#sim", "<sup>\$2</sup>", $string);
    $string = str_replace('imgh://', 'http://', $string);
    $string = str_replace('imghs://', 'https://', $string);
    $tags = array('list' => '<ul>', 'num' => '<ol>', 'quote' => '<div class="quote"><pre>');
    foreach ($tags as $tag => $val) {
        if ($tag == 'list') {
            $re = '#(\\[list\\])(.*?[^\\[/list\\]]?)(\\[/list\\])#sim';
            $vt = preg_match_all($re, $string, $match);
            for ($i = 0; $i < $vt; $i++) {
                $string = preg_replace($re, "{$val}\$2</ul>", $string, 1);
                $with_breaks = str_replace('[*]', '<li>&nbsp;', $match[2][$i]);
                $string = str_replace($match[2][$i], $with_breaks, $string);
            }
        }
        if ($tag == 'num') {
            $re = '#(\\[num\\])(.*?[^\\[/num\\]]?)(\\[/num\\])#sim';
            $vt = preg_match_all($re, $string, $match);
            for ($i = 0; $i < $vt; $i++) {
                $string = preg_replace($re, "{$val}\$2</ol>", $string, 1);
                $with_breaks = str_replace('[*]', '<li>&nbsp;', $match[2][$i]);
                $string = str_replace($match[2][$i], $with_breaks, $string);
            }
        }
        if ($tag == 'quote') {
            $re = '#(\\[quote\\])(.*?[^\\[/quote\\]]?)(\\[/quote\\])#sim';
            $vt = preg_match_all($re, $string, $match);
            for ($i = 0; $i < $vt; $i++) {
                $string = preg_replace($re, "{$val}\$2</pre></div>", $string, 1);
                $with_breaks = $match[2][$i];
                $string = str_replace($match[2][$i], $with_breaks, $string);
            }
        }
    }
    $string = preg_replace('#(\\[p align=)(left|right|center)(\\])(.*?[^\\[/p\\]]?)(\\[/p\\])#sim', "<p align=\"\$2\">\$4</p>", $string);
    $img_re = '#(\\[img) ?(align=)?(left|right|middle|top|bottom)?(\\])(.*?[^\\[/img\\]]?)(\\[/img\\])#sim';
    $vt = preg_match_all($img_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (!empty($match[3][$i])) {
            $string = preg_replace($img_re, "<img src=\"\$5\" align=\"\$3\" style=\"max-width: 1024px\" alt=\"[путь к изображению некорректен]\" />", $string, 1);
        } else {
            $string = preg_replace($img_re, "<img src=\"\$5\" style=\"max-width: 1024px\" alt=\"[путь к изображению некорректен]\" />", $string, 1);
        }
    }
    $user_re = "#(\\[user\\])(.*?[^\\[/user\\]]?)(\\[/user\\])#sim";
    $arr = preg_match_all($user_re, $string, $match);
    for ($i = 0; $i < $arr; $i++) {
        $where_arr = array(array("key" => 'nick', "value" => $match[2][$i], "oper" => '='));
        $sel = base::select('users', '', '*', $where_arr, 'AND');
        if (!empty($sel)) {
            $string = preg_replace($user_re, "<b><a href=\"/profile.php?user=\$2\">\$2</a></b>", $string, 1);
        } else {
            $string = preg_replace($user_re, "\$2", $string, 1);
        }
    }
    $url_re = '#(\\[url\\])(.*?[^\\[/url\\]]?)(\\[/url\\])#sim';
    $vt = preg_match_all($url_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (filter_var($match[2][$i], FILTER_VALIDATE_URL)) {
            $string = preg_replace($url_re, "<a href=\"\$2\">\$2</a>", $string);
        }
    }
    $url_par_re = '#(\\[url=)(.*?[^\\]]?)(\\])(.*?[^\\[/url\\]]?)(\\[/url\\])#sim';
    $vt = preg_match_all($url_par_re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        if (filter_var($match[2][$i], FILTER_VALIDATE_URL)) {
            $string = preg_replace($url_par_re, "<a href=\"\$2\">\$4</a>", $string);
        }
    }
    $string = '<p>' . $string . '</p>';
    $string = str_replace("\r\n", '</p><p>', $string);
    $re = "#(⓬)([0-9]+)(⓬)#sim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('⓬' . $match[2][$i] . '⓬', '<fieldset><legend>' . $lang[$match[2][$i]] . '</legend>' . $code[$match[2][$i]] . '</fieldset>', $string);
    }
    $re = "#(ᴥ)([0-9]+)(ᴥ)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('ᴥ' . $match[2][$i] . 'ᴥ', $math[$match[2][$i]], $string);
    }
    $re = "#(☣)([0-9]+)(☣)#suim";
    $vt = preg_match_all($re, $string, $match);
    for ($i = 0; $i < $vt; $i++) {
        $string = str_replace('☣' . $match[2][$i] . '☣', $latex[$match[2][$i]], $string);
    }
    return $string;
}
Example #15
0
if (!$installed) {
    echo '<html lang="ru"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>Проведите <a href="install/install.php">первичную инициализацию</a>. <br><b>ВНИМАНИЕ:</b> при проведении первичной нинциализации все данные из базы будут удалены<br>Если вы уже проводили первичную инициализацию, но по-прежнему видите это сообщение, то выствите в файле config/install.ini значение 1 параметру installed.</html>';
    exit;
}
require_once "classes/templates.class.php";
// $templatesC = new templates;
require_once "classes/search.class.php";
$searchC = new search();
require_once "classes/users.class.php";
$usersC = new users();
require_once "classes/auth.class.php";
$authC = new auth();
$uinfo = $usersC->get_user_info($_SESSION['user_id']);
require_once "classes/latex.class.php";
require_once "classes/mark.class.php";
$markC = new mark();
$mark_file = $markC->get_mark_file($uinfo['mark']);
require_once 'mark/' . $mark_file;
require_once "classes/filters.class.php";
$filtersC = new filters();
require_once "classes/sections.class.php";
$sectionsC = new sections();
require_once "classes/threads.class.php";
$threadsC = new threads();
require_once "classes/messages.class.php";
$messagesC = new messages();
require_once "classes/faq.class.php";
$faqC = new faq();
require_once "classes/security.class.php";
$security = new Security($_SERVER['DOCUMENT_ROOT'] . '/config/security.ini');
require 'classes/rss.class.php';
Example #16
0
 public function actionEditMolUser($table, $action, $id, $value)
 {
     switch ($table) {
         case 'po_name':
             switch ($action) {
                 case 'add':
                     $po_name = new po_name();
                     $po_name->po_name = $value;
                     $po_name->po_type_id = $id;
                     if ($po_name->save()) {
                         $result = 'ПО добавлено';
                     }
                     break;
                 case 'delete':
                     $po_name = po_name::findOne($id);
                     if ($po_name->active == '1') {
                         $po_name->active = '0';
                     } else {
                         $po_name->active = '1';
                     }
                     if ($po_name->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $po_name = po_name::findOne($id);
                         $po_name->po_name = $value;
                         if ($po_name->save()) {
                             $result = 'ПО переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'po_type':
             switch ($action) {
                 case 'add':
                     $po_type = new po_type();
                     $po_type->po_type = $value;
                     if ($po_type->save()) {
                         $result = 'Тип ПО добавлен';
                     }
                     break;
                 case 'delete':
                     $po_type = po_type::findOne($id);
                     if ($po_type->active == '1') {
                         $po_type->active = '0';
                     } else {
                         $po_type->active = '1';
                     }
                     if ($po_type->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $po_type = po_type::findOne($id);
                         $po_type->po_type = $value;
                         if ($po_type->save()) {
                             $result = 'Тип ПО переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'mol':
             switch ($action) {
                 case 'add':
                     $mol = new mol();
                     $mol->value = $value;
                     if ($mol->save()) {
                         $result = 'МОЛ добавлено';
                     }
                     break;
                 case 'delete':
                     $mol = mol::findOne($id);
                     if ($mol->active == '1') {
                         $mol->active = '0';
                     } else {
                         $mol->active = '1';
                     }
                     if ($mol->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $mol = mol::findOne($id);
                         $mol->value = $value;
                         if ($mol->save()) {
                             $result = 'МОЛ переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'cpu':
             switch ($action) {
                 case 'add':
                     $cpu = new cpu();
                     $cpu->name = $value;
                     if ($cpu->save()) {
                         $result = 'Процессор добавлен';
                     }
                     break;
                 case 'delete':
                     $cpu = cpu::findOne($id);
                     if ($cpu->active == '1') {
                         $cpu->active = '0';
                     } else {
                         $cpu->active = '1';
                     }
                     if ($cpu->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $cpu = cpu::findOne($id);
                         $cpu->name = $value;
                         if ($cpu->save()) {
                             $result = 'Процессор переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'cartridge_type':
             switch ($action) {
                 case 'add':
                     $type = new CartridgeType();
                     $type->type = $value;
                     if ($type->save()) {
                         $result = 'Тип картриджа добавлен';
                     }
                     break;
                 case 'delete':
                     $type = CartridgeType::find()->where(['type' => $id])->One();
                     if ($type->delete()) {
                         $result = 'Тип картриджа удален';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $type = CartridgeType::find()->where(['type' => $id])->One();
                         $type->type = $value;
                         if ($type->update()) {
                             $result = 'Картридж переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'consignment':
             switch ($action) {
                 case 'add':
                     $consignment = new consignment();
                     $consignment->name = $value;
                     if ($consignment->save()) {
                         $result = 'Партия добавлена';
                     } else {
                         $result = 'Партия НЕ добавлена';
                     }
                     break;
                 case 'delete':
                     // $query_str = 'UPDATE consignment SET active = NOT active WHERE id = "'.$id.'"';
                     //$consignment = consignment::findOne($id);
                     //if ($consignment -> active == '1') $consignment -> active = '0'; else $consignment -> active = '1';
                     //$consignment -> save();
                     //$result = 'Статус изменен';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $consignment = consignment::findOne($id);
                         $consignment->name = $value;
                         if ($consignment->save()) {
                             $result = 'Партия переименована';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'type':
             switch ($action) {
                 case 'add':
                     $device_type = new deviceType();
                     $device_type->value = $value;
                     if ($device_type->save()) {
                         $result = 'Тип добавлен';
                     }
                     break;
                 case 'delete':
                     $device_type = deviceType::findOne($id);
                     if ($device_type->active == '1') {
                         $device_type->active = '0';
                     } else {
                         $device_type->active = '1';
                     }
                     if ($device_type->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $device_type = deviceType::findOne($id);
                         $device_type->value = $value;
                         if ($device_type->save()) {
                             $result = 'Тип переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'mark':
             switch ($action) {
                 case 'add':
                     $mark = new trademarks();
                     $mark->value = $value;
                     if ($mark->save()) {
                         $result = 'Марка добавлена';
                     }
                     break;
                 case 'delete':
                     $mark = mark::findOne($id);
                     if ($mark->active == '1') {
                         $mark->active = '0';
                     } else {
                         $mark->active = '1';
                     }
                     if ($mark->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $mark = mark::findOne($id);
                         $mark->value = $value;
                         if ($mark->save()) {
                             $result = 'Марка переименована';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'user':
             switch ($action) {
                 case 'add':
                     $user = new user();
                     $user->name = $value;
                     $user->password = sha1('1');
                     if ($user->save()) {
                         $result = 'Сотрудник добавлен';
                     }
                     break;
                 case 'delete':
                     if ($value != '') {
                         $user = user::findOne($id);
                         if ($user->active == '1') {
                             $user->active = '0';
                         } else {
                             $user->active = '1';
                         }
                         if ($user->save()) {
                             $result = 'Статус изменен';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
                 case 'edit':
                     $user = user::findOne($id);
                     $user->name = $value;
                     if ($user->save()) {
                         $result = 'Сотрудник переименован';
                     }
                     break;
             }
             break;
         case 'room':
             switch ($action) {
                 case 'add':
                     $room = new room();
                     $room->value = $value;
                     $room->building_id = $id;
                     if ($room->save()) {
                         $result = 'Кабинет добавлен';
                     } else {
                         $result = print_r($room->getErrors());
                     }
                     break;
                 case 'delete':
                     $room = room::findOne($id);
                     if ($room->active == '1') {
                         $room->active = '0';
                     } else {
                         $room->active = '1';
                     }
                     $room->save();
                     //$result = 'Статус изменен';
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $room = room::findOne($id);
                         $room->value = $value;
                         if ($room->save()) {
                             $result = 'Кабинет переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'device':
             switch ($action) {
                 case 'add':
                     switch (substr($id, 0, 3)) {
                         case 'mrk':
                             $result = 'Марка не добавлена! Выберите тип устройства для добавления!';
                             break;
                         case 'typ':
                             $type_id = intval(substr($id, 4));
                             $trademark = new trademark();
                             $trademark->value = $value;
                             $TypeLinkMark = new TypeLinkMark();
                             $TypeLinkMark->type_id = $type_id;
                             $TypeLinkMark->mark_id = Yii::app()->db->getLastInsertID();
                             if ($TypeLinkMark->save() && $trademark->save()) {
                                 $result = 'Марка добавлена';
                             }
                             break;
                     }
                     break;
                 case 'delete':
                     $device = new device();
                     $device->value = $value;
                     if ($device->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     $query_str = 'UPDATE user SET value = "' . $value . '" WHERE id = "' . $id . '"';
                     $result = 'Сотрудник переименован';
                     break;
             }
             break;
         case 'model':
             switch ($action) {
                 case 'add':
                     $model = new model();
                     $model->value = $value;
                     $model->save();
                     $result = 'Модель добавлена';
                     break;
                 case 'delete':
                     $model = model::findOne($id);
                     if ($model->active == '1') {
                         $model->active = '0';
                     } else {
                         $model->active = '1';
                     }
                     $model->save();
                     //$result = 'Статус изменен';
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $model = model::findOne($id);
                         $model->value = $value;
                         if ($model->save()) {
                             $result = 'Модель переименована';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'department':
             switch ($action) {
                 case 'delete':
                     //$result = 'Статус изменен';
                     $department = department::findOne($id);
                     if ($department->active == '1') {
                         $department->active = '0';
                     } else {
                         $department->active = '1';
                     }
                     $department->save();
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $department = department::findOne($id);
                         $department->value = $value;
                         if ($department->save()) {
                             $result = 'Подразделение переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
                 case 'add':
                     $department = new Department();
                     $department->value = $value;
                     if ($department->save()) {
                         $result = 'Подразделение добавлено';
                     }
                     break;
             }
             break;
         case 'building':
             switch ($action) {
                 case 'delete':
                     $building = building::findOne($id);
                     if ($building->active == '1') {
                         $building->active = '0';
                     } else {
                         $building->active = '1';
                     }
                     $building->save();
                     //$result = 'Статус изменен';
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $building = building::findOne($id);
                         $building->value = $value;
                         if ($building->save()) {
                             $result = 'Здание переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
                 case 'add':
                     $building = new Building();
                     $building->value = $value;
                     $building->department_id = $id;
                     if ($building->save()) {
                         $result = 'Здание добавлено';
                     }
                     break;
             }
             break;
     }
     echo $result;
 }
Example #17
0
 public function detail()
 {
     $group_id = isset($this->input['group_id']) ? intval($this->input['group_id']) : -1;
     $action_id = isset($this->input['action_id']) ? intval($this->input['action_id']) : 0;
     $flag = !!$this->input['flag'];
     if ($group_id < 0 && $action_id <= 0) {
         $this->errorOutput(PARAM_WRONG);
     }
     if ($action_id > 0) {
         $sql = "SELECT group_id FROM " . DB_PREFIX . "group WHERE action_id = " . $action_id;
         $group = $this->db->query_first($sql);
         $group_id = $group['group_id'];
     }
     $this->setXmlNode('group_info', 'group');
     $group = $this->group->detail($group_id, $flag, $action_id);
     if (!$flag) {
         if (!$group['status']) {
             $this->errorOutput(OBJECT_NULL);
         }
     }
     $offset = isset($this->input['offset']) ? intval($this->input['offset']) : 0;
     $count = isset($this->input['count']) ? intval($this->input['count']) : 20;
     $threads = $this->thread->show($offset, $count, array('group_id' => $group_id, 'state' => 2));
     $material_num = isset($this->input['material_num']) ? intval($this->input['material_num']) : 3;
     $data_limit = 'LIMIT ' . $material_num;
     foreach ($threads as $k => $v) {
         $type = ' AND thread_id = ' . $v['thread_id'];
         $threads[$k]['material'] = $this->group->get_material_info($type, $data_limit);
     }
     $group['threads'] = $threads;
     $members = $this->group->get_member($group_id, false, array('state' => 1));
     $group['members'] = $members;
     $group['members_count'] = $this->group->get_member_num($group_id, array('state' => 1));
     include_once ROOT_PATH . 'lib/class/mark.class.php';
     $mark = new mark();
     $tags = $mark->getInfoByType($group_id, 1);
     $group['tag'] = $tags;
     $this->addItem($group);
     $this->output();
 }
Example #18
0
 public function edit_member_mark($mark, $user_id)
 {
     if (empty($user_id) || empty($mark)) {
         return false;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "member_info WHERE member_id=" . $user_id;
     $f = $this->db->query_first($sql);
     $sql = "";
     if (empty($f)) {
         $sql = "INSERT INTO " . DB_PREFIX . "member_info(member_id,mark) VALUES(" . $user_id . ",'" . $mark . "')";
     } else {
         $sql = "UPDATE " . DB_PREFIX . "member_info SET mark='" . $mark . "' WHERE member_id=" . $user_id;
     }
     $this->db->query($sql);
     include_once ROOT_PATH . 'lib/class/mark.class.php';
     $obj_mark = new mark();
     $data = array('user_id' => $user_id, 'source' => 'user', 'source_id' => $user_id, 'action' => 'myself', 'name' => $mark);
     $mark = $obj_mark->create_source_id_mark($data);
     //file_put_contents('./cache/1.php',var_export($mark,true));
     return true;
 }
Example #19
0
 public function get_marks($test)
 {
     $marks = array();
     foreach ($test->get_items() as $item => $value) {
         if (strlen($value['data']) != 0) {
             $xml_data = $this->dir_user . "/" . $this->user->get_id() . "/" . $value['data'];
         } else {
             $xml_data = $this->dir_item . "/" . $item . "/" . $item . ".xml";
         }
         if (file_exists($xml_data)) {
             $simple_xml_data = simplexml_load_file($xml_data);
         } else {
             return false;
         }
         $mark = new mark($simple_xml_data);
         $mark->set_timestamp($value['timestamp']);
         $mark->set_task($item);
         $marks[] = $mark;
     }
     return $marks;
 }
Example #20
0
            die('<meta http-equiv="Refresh" content="0; URL=http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 'admin.php?action=manage_marks_ui">');
        } else {
            require 'header.php';
            $legend = 'Ошибка установки стиля разметки';
            $text = 'Не получилось установить стиль разметки. Возможно недоступна база данных';
            require 'themes/' . $theme . '/templates/fieldset.tpl.php';
            require 'footer.php';
            exit;
        }
    }
}
if ($_GET['action'] == 'remove_mark') {
    $error = 0;
    foreach ($_POST as $key => $value) {
        if (preg_match('/check_([0-9]*)/', $key, $matches)) {
            $count = mark::get_marks_count();
            $ret = $adminC->remove_mark($_POST['file_' . $matches[1]], $count);
            if ($ret != 1) {
                $error = 1;
            }
        }
    }
    if ($error) {
        require 'header.php';
        $legend = 'Ошибка удаления стиля разметки';
        $text = 'Не получилось удалить стиль разметки. Возможно недоступна база данных';
        require 'themes/' . $theme . '/templates/fieldset.tpl.php';
        require 'footer.php';
        exit;
    } else {
        die('<meta http-equiv="Refresh" content="0; URL=http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 'admin.php?action=manage_marks_ui">');
Example #21
0
        $this->output();
    }
    /**
	 * 设置小组信息操作
	 */
    public function setting()
    {
        $team_id = intval($this->input['team_id']);
        //检测对应的小组是否存在
        $team_info = $this->team->detail($team_id, 1);
        if (!$team_info) {
            $this->errorOutput(TEAM_NO_EXISTS);
        }
        if ($team_info['creater_id'] != $this->user['user_id']) {
            $this->errorOutput(NO_PERMISSION);
        }
        $data = $this->filter_data();
        $verify_data = array();
        //检测小组类型是否存在
        if (isset($data['team_type']) && $data['team_type']) {
            $result_type = $this->team->check_team_type($data['team_type']);
            if (!$result_type) {
                $this->errorOutput(PARAM_WRONG);
            }
            $verify_data['team_type'] = $data['team_type'];
        }
        if ($team_info['team_category'] != $data['team_category']) {
            //检测小组分类是否存在
            $result_category = $this->team->check_team_category($data['team_category']);
            if (!$result_category) {
                $this->errorOutput(PARAM_WRONG);
            }
            $verify_data['team_category'] = $data['team_category'];
        }
        if ($team_info['team_name'] != $data['team_name']) {
            //检测更新的小组名称是否存在
            $result_name = $this->team->check_team_name($data['team_name'], $team_id);
            if ($result_name) {
                $this->errorOutput(TEAM_EXISTS);
            }
            $verify_data['team_name'] = $data['team_name'];
        }
        if ($team_info['introduction'] != $data['introduction']) {
            $verify_data['introduction'] = $data['introduction'];
        }
        if (isset($data['team_logo']) && $data['team_logo']) {
            $verify_data['team_logo'] = $data['team_logo'];
        }
        if (isset($data['notice'])) {
            if ($team_info['notice'] != $data['notice']) {
                $verify_data['notice'] = $data['notice'];
            }
        }
        $verify_data['update_time'] = TIMENOW;
        $result = $this->team->update($verify_data, $team_id);
        //标签更新
        if ($team_info['tags'] != $data['tags']) {
            $team_mark = $data['tags'];
        }
        if (isset($team_mark) && $result) {
            $mark = new mark();
            $data = array('source' => 'team', 'source_id' => $team_id, 'parent_id' => $team_id, 'action' => 'team_tag', 'user_id' => $team_info['creater_id']);
            if ($team_mark) {
                $data['name'] = $team_mark;
            }
            $result_mark = $mark->update_source_id_mark($data);
            if ($result_mark) {
                $this->team->update(array('tags' => $team_mark), $team_id);
            } else {
                $this->errorOutput(FAIL_OP);
            }
        }
        if ($verify_data['notice'] && $result) {
            //获取关注小组的用户信息
            $option = new option();
            $member = $option->members('team', $team_id, 'attention', 0, -1);
            //发送通知
            $send_arr = array();
            if ($member['data']['attention']) {
                $send_con = array();
                foreach ($member['data']['attention']['infos'] as $v) {
                    $send_con['from_id'] = 0;
                    $send_con['to_id'] = $v['user_id'];
                    $send_con['content'] = '您关注的"' . $team_info['team_name'] . '小组"有新公告!';
                    $send_con['page_link'] = 'team.php?team_id=' . $team_id;
                    $send_con['link_text'] = '点击查看';
                    $send_arr[] = $send_con;
                }
            }
            if ($send_arr) {
                $this->notify->notify_send(json_encode($send_arr), 0);
            }
        }
        //更新搜索