2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-02-12 17:30:49 +01:00
|
|
|
* Copyright (c) 2008-2014, Tomasz Sowa
|
2008-12-30 02:05:03 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-12-30 02:05:03 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2010-02-15 01:31:14 +01:00
|
|
|
#include "misc.h"
|
2010-11-21 01:19:17 +01:00
|
|
|
#include "core/request.h"
|
|
|
|
#include "core/misc.h"
|
|
|
|
#include "core/bbcodeparser.h"
|
|
|
|
#include "core/textstream.h"
|
2012-01-16 11:12:38 +01:00
|
|
|
#include "miscspace.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
2010-06-30 20:42:50 +02:00
|
|
|
static BBCODEParser bbcode_parser;
|
2011-01-20 19:37:51 +01:00
|
|
|
static HtmlTextStream item_run_content;
|
|
|
|
static EzcGen ezc_generator;
|
2010-06-30 20:42:50 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_is(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->is_item;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-27 00:30:25 +02:00
|
|
|
void item_no_is(Info & i)
|
|
|
|
{
|
|
|
|
i.res = !cur->request->is_item;
|
|
|
|
}
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
void item_id(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.id;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_subject(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.subject;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_subject_noescape(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << R(cur->request->item.subject);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_content(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.content;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_content_noescape(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << R(cur->request->item.content);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
void item_content_type_is(Item & item, Info & i)
|
2009-06-05 22:29:06 +02:00
|
|
|
{
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = false;
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
if( item.content_type == Item::ct_text && i.par == L"text" )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2010-08-10 22:43:38 +02:00
|
|
|
else
|
2010-11-21 01:19:17 +01:00
|
|
|
if( item.content_type == Item::ct_formatted_text && i.par == L"formatted text" )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2010-08-10 22:43:38 +02:00
|
|
|
else
|
2010-11-21 01:19:17 +01:00
|
|
|
if( item.content_type == Item::ct_html && i.par == L"html" )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2010-08-10 22:43:38 +02:00
|
|
|
else
|
2010-11-21 01:19:17 +01:00
|
|
|
if( item.content_type == Item::ct_bbcode && i.par == L"bbcode" )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2010-08-10 22:43:38 +02:00
|
|
|
else
|
2010-11-21 01:19:17 +01:00
|
|
|
if( item.content_type == Item::ct_raw && i.par == L"raw" )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2010-01-11 15:47:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
void item_content_type_is(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
item_content_type_is(cur->request->item, i);
|
2010-08-10 22:43:38 +02:00
|
|
|
}
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
void item_print_content(HtmlTextStream & out, const std::wstring & content, Item::ContentType content_type)
|
2010-01-11 15:47:52 +01:00
|
|
|
{
|
|
|
|
if( content_type == Item::ct_text )
|
|
|
|
{
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
out << content;
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
else
|
2010-01-11 15:47:52 +01:00
|
|
|
if( content_type == Item::ct_formatted_text )
|
2009-06-05 22:29:06 +02:00
|
|
|
{
|
2010-01-11 15:47:52 +01:00
|
|
|
HtmlEscapeFormTxt(out, content);
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
else
|
2010-06-30 20:42:50 +02:00
|
|
|
if( content_type == Item::ct_html || content_type == Item::ct_raw )
|
2009-06-05 22:29:06 +02:00
|
|
|
{
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
out << R(content);
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
else
|
2010-01-11 15:47:52 +01:00
|
|
|
if( content_type == Item::ct_bbcode )
|
2009-06-05 22:29:06 +02:00
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
static std::wstring out_temp;
|
2010-06-30 20:42:50 +02:00
|
|
|
out_temp.clear();
|
|
|
|
out_temp.reserve(content.size()*2);
|
|
|
|
|
|
|
|
bbcode_parser.Filter(content.c_str(), out_temp);
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
out << R(out_temp);
|
2010-01-11 15:47:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-13 00:16:13 +01:00
|
|
|
void item_content_is_empty(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.content.empty();
|
2010-02-13 00:16:13 +01:00
|
|
|
}
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
void item_print_content(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
item_print_content(i.out, cur->request->item.content, cur->request->item.content_type);
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
void item_privileges(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << Toa(cur->request->item.privileges, 8);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_dir(Info & i)
|
|
|
|
{
|
|
|
|
dir(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_url(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.url;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-08 21:02:16 +01:00
|
|
|
void item_url_is(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->request->is_item )
|
2010-02-15 01:31:14 +01:00
|
|
|
return; // default false
|
2010-02-08 21:02:16 +01:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = (cur->request->item.url == i.par);
|
2010-02-08 21:02:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-27 00:30:25 +02:00
|
|
|
void item_url_is_no(Info & i)
|
|
|
|
{
|
|
|
|
if( !cur->request->is_item )
|
|
|
|
i.res = true;
|
|
|
|
else
|
|
|
|
i.res = (cur->request->item.url != i.par);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
void item_link(Info & i)
|
|
|
|
{
|
2011-08-18 01:09:47 +02:00
|
|
|
doc_proto(i);
|
2012-04-22 20:23:44 +02:00
|
|
|
|
|
|
|
if( !cur->request->subdomain.empty() )
|
|
|
|
i.out << cur->request->subdomain << '.';
|
|
|
|
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
i.out << config->base_url;
|
2008-12-30 02:05:03 +01:00
|
|
|
item_dir(i);
|
|
|
|
item_url(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-30 21:46:12 +01:00
|
|
|
|
|
|
|
|
2010-12-10 22:07:01 +01:00
|
|
|
void item_filetype_is_none(Info & i)
|
2009-12-30 21:46:12 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.file_type == WINIX_ITEM_FILETYPE_NONE;
|
2009-12-30 21:46:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-10 22:07:01 +01:00
|
|
|
void item_filetype_is_image(Info & i)
|
2009-12-30 21:46:12 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.file_type == WINIX_ITEM_FILETYPE_IMAGE;
|
2009-12-30 21:46:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
void item_has_static_file(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.file_type != WINIX_ITEM_FILETYPE_NONE && !cur->request->item.file_path.empty();
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 23:55:48 +01:00
|
|
|
void item_has_thumb(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.has_thumb;
|
2010-12-11 23:55:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
void item_can_read(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = system->HasReadAccess(cur->request->item);
|
2009-03-23 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
void item_can_write(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = system->HasWriteAccess(cur->request->item);
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
2009-03-23 00:54:15 +01:00
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
|
|
|
|
void item_can_remove(Info & i)
|
|
|
|
{
|
2010-08-10 18:12:50 +02:00
|
|
|
// !! tutaj trzeba bedzie cos innego zrobic
|
|
|
|
// zwlaszcza jak dojdzie sticky bit
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = system->HasWriteAccess(*cur->request->dir_tab.back());
|
2010-02-11 21:56:52 +01:00
|
|
|
}
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
|
|
|
|
void item_user(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
User * puser = system->users.GetUser(cur->request->item.user_id);
|
|
|
|
print_user_name(i, puser, cur->request->item.guest_name);
|
2010-06-22 23:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_modification_user(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
User * puser = system->users.GetUser(cur->request->item.modification_user_id);
|
|
|
|
print_user_name(i, puser, cur->request->item.guest_name);
|
2010-06-22 23:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_users_different(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = (cur->request->item.user_id != cur->request->item.modification_user_id);
|
2009-03-23 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_date_creation(Info & i)
|
|
|
|
{
|
2012-05-30 21:04:18 +02:00
|
|
|
PT::Date date = system->ToLocal(cur->request->item.date_creation);
|
2012-05-27 01:04:49 +02:00
|
|
|
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
|
2009-03-23 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_date_modification(Info & i)
|
|
|
|
{
|
2012-05-30 21:04:18 +02:00
|
|
|
PT::Date date = system->ToLocal(cur->request->item.date_modification);
|
2012-05-27 01:04:49 +02:00
|
|
|
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
|
2009-03-23 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
void item_date_creation_nice(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
print_date_nice(i, cur->request->item.date_creation);
|
2010-02-15 01:31:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_date_modification_nice(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
print_date_nice(i, cur->request->item.date_modification);
|
2010-02-15 01:31:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
void item_dates_equal(Info & i)
|
|
|
|
{
|
2012-05-27 01:04:49 +02:00
|
|
|
PT::Date & date1 = cur->request->item.date_creation;
|
|
|
|
PT::Date & date2 = cur->request->item.date_modification;
|
2009-03-23 00:54:15 +01:00
|
|
|
|
2012-05-27 01:04:49 +02:00
|
|
|
i.res = date1 == date2;
|
2009-03-23 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
void item_run(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->request->is_item )
|
2009-03-23 00:54:15 +01:00
|
|
|
{
|
|
|
|
i.out << "<!-- there is no an item to run -->";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( system->HasReadExecAccess(cur->request->item) )
|
2009-03-23 00:54:15 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item);
|
2010-01-11 15:47:52 +01:00
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
item_run_content.Clear();
|
2014-10-19 23:20:09 +02:00
|
|
|
InitGenerator(ezc_generator);
|
2014-10-18 20:12:04 +02:00
|
|
|
ezc_generator.SetPattern(*p);
|
2015-11-15 23:23:36 +01:00
|
|
|
|
|
|
|
if( config->allow_ezc_out_in_executable_items )
|
|
|
|
ezc_generator.Generate(item_run_content, cur->request->out_streams);
|
|
|
|
else
|
|
|
|
ezc_generator.Generate(item_run_content);
|
2010-01-11 15:47:52 +01:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
item_print_content(i.out, item_run_content.Str(), cur->request->item.content_type);
|
2011-01-20 19:37:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << "<!-- run: permission denied -->";
|
|
|
|
}
|
2009-03-23 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2009-11-17 00:36:38 +01:00
|
|
|
void item_guest_name(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.guest_name;
|
2009-11-17 00:36:38 +01:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
void item_html_template(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.html_template;
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_has_html_template(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = !cur->request->item.html_template.empty();
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
void item_type_is_dir(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.type == Item::dir;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_type_is_file(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.type == Item::file;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_type_is_symlink(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.type == Item::symlink;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_is_link_to(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = !cur->request->item.link_to.empty();
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_link_to(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.link_to;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_is_link_redirect(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item.link_redirect == 1;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
void item_file_size(Info & i)
|
|
|
|
{
|
|
|
|
i.res = cur->request->item.file_size;
|
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2011-08-02 02:10:45 +02:00
|
|
|
void item_sort(Info & i)
|
|
|
|
{
|
|
|
|
i.out << cur->request->item.sort_index;
|
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
void item_meta_str(Info & i)
|
|
|
|
{
|
|
|
|
cur->request->item.meta.Serialize(i.out, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-16 11:12:38 +01:00
|
|
|
void item_meta(Info & i)
|
|
|
|
{
|
2012-11-04 22:01:02 +01:00
|
|
|
space(i, cur->request->last_item->meta); // !! a new interface (last_item instead of item)
|
2012-01-16 11:12:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-04 22:01:02 +01:00
|
|
|
|
|
|
|
|
2012-01-16 11:12:38 +01:00
|
|
|
void item_meta_tab(Info & i)
|
|
|
|
{
|
|
|
|
spaces_tab(i, cur->request->last_item->meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_meta_tab_value(Info & i)
|
|
|
|
{
|
|
|
|
spaces_tab_value(i, cur->request->last_item->meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_meta_tab_has_next(Info & i)
|
|
|
|
{
|
|
|
|
spaces_tab_has_next(i, cur->request->last_item->meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-04 22:01:02 +01:00
|
|
|
void item_admin_meta_str(Info & i)
|
|
|
|
{
|
|
|
|
cur->request->item.ameta.Serialize(i.out, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_admin_meta(Info & i)
|
|
|
|
{
|
|
|
|
space(i, cur->request->last_item->ameta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_admin_meta_tab(Info & i)
|
|
|
|
{
|
|
|
|
spaces_tab(i, cur->request->last_item->ameta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_admin_meta_tab_value(Info & i)
|
|
|
|
{
|
|
|
|
spaces_tab_value(i, cur->request->last_item->ameta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_admin_meta_tab_has_next(Info & i)
|
|
|
|
{
|
|
|
|
spaces_tab_has_next(i, cur->request->last_item->ameta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
static size_t item_index;
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab(Info & i)
|
|
|
|
{
|
|
|
|
item_index = i.iter;
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = item_index < cur->request->item_tab.size();
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-02 02:10:45 +02:00
|
|
|
void item_tab_index(Info & i)
|
|
|
|
{
|
|
|
|
i.out << item_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
void item_tab_id(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].id;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_subject(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].subject;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void item_tab_subject_noescape(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << R(cur->request->item_tab[item_index].subject);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_content(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].content;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_content_noescape(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << R(cur->request->item_tab[item_index].content);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
void item_tab_print_content(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index >= cur->request->item_tab.size() )
|
2009-06-05 22:29:06 +02:00
|
|
|
return;
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
std::wstring & content = cur->request->item_tab[item_index].content;
|
|
|
|
Item::ContentType type = cur->request->item_tab[item_index].content_type;
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
item_print_content(i.out, content, type);
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
void item_tab_privileges(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << "0" << Toa(cur->request->item_tab[item_index].privileges, 8);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_dir(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring path;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( system->dirs.MakePath(cur->request->item_tab[item_index].parent_id, path) )
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
i.out << path;
|
2008-12-30 02:05:03 +01:00
|
|
|
else
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
i.out << "/the path does not exist/"; // !! do konfiga
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_url(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].url;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_link(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2011-08-18 01:09:47 +02:00
|
|
|
doc_proto(i);
|
2012-04-22 20:23:44 +02:00
|
|
|
|
|
|
|
if( !cur->request->subdomain.empty() )
|
|
|
|
i.out << cur->request->subdomain << '.';
|
|
|
|
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
i.out << config->base_url;
|
2008-12-30 02:05:03 +01:00
|
|
|
item_tab_dir(i);
|
|
|
|
item_tab_url(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
void item_tab_filetype_is_none(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].file_type == WINIX_ITEM_FILETYPE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_filetype_is_image(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].file_type == WINIX_ITEM_FILETYPE_IMAGE;
|
|
|
|
}
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
void item_tab_can_read(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( system->HasReadAccess(cur->request->item_tab[item_index]) )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2009-04-21 01:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-30 21:56:32 +02:00
|
|
|
|
|
|
|
void item_tab_can_write(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-06-30 21:56:32 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( system->HasWriteAccess(cur->request->item_tab[item_index]) )
|
2010-06-30 21:56:32 +02:00
|
|
|
i.res = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
void item_tab_user(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
User * puser = system->users.GetUser(cur->request->item_tab[item_index].user_id);
|
|
|
|
print_user_name(i, puser, cur->request->item_tab[item_index].guest_name);
|
2009-04-21 01:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-22 23:09:37 +02:00
|
|
|
|
|
|
|
void item_tab_modification_user(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-06-22 23:09:37 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
User * puser = system->users.GetUser(cur->request->item_tab[item_index].modification_user_id);
|
|
|
|
print_user_name(i, puser, cur->request->item_tab[item_index].guest_name);
|
2010-06-22 23:09:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_users_different(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-06-22 23:09:37 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = (cur->request->item_tab[item_index].user_id != cur->request->item_tab[item_index].modification_user_id);
|
2010-06-22 23:09:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
void item_tab_group(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-02-22 23:52:09 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
long group_id = cur->request->item_tab[item_index].group_id;
|
2010-08-10 18:12:50 +02:00
|
|
|
Group * pgroup = system->groups.GetGroup(group_id);
|
2010-02-22 23:52:09 +01:00
|
|
|
|
|
|
|
if( pgroup )
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
i.out << pgroup->name;
|
2010-02-22 23:52:09 +01:00
|
|
|
else
|
|
|
|
i.out << group_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
void item_tab_date_creation(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
2012-05-30 21:04:18 +02:00
|
|
|
PT::Date date = system->ToLocal(cur->request->item_tab[item_index].date_creation);
|
2012-05-27 01:04:49 +02:00
|
|
|
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
|
2009-04-21 01:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_date_modification(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
2012-05-30 21:04:18 +02:00
|
|
|
PT::Date date = system->ToLocal(cur->request->item_tab[item_index].date_modification);
|
2012-05-27 01:04:49 +02:00
|
|
|
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
|
2009-04-21 01:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
void item_tab_date_creation_nice(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-02-15 01:31:14 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
print_date_nice(i, cur->request->item_tab[item_index].date_creation);
|
2010-02-15 01:31:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-22 23:09:37 +02:00
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
void item_tab_date_modification_nice(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-02-15 01:31:14 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
print_date_nice(i, cur->request->item_tab[item_index].date_modification);
|
2010-02-15 01:31:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
void item_tab_dates_equal(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
2012-05-27 01:04:49 +02:00
|
|
|
PT::Date & date1 = cur->request->item_tab[item_index].date_creation;
|
|
|
|
PT::Date & date2 = cur->request->item_tab[item_index].date_modification;
|
2009-04-21 01:49:28 +02:00
|
|
|
|
2012-05-27 01:04:49 +02:00
|
|
|
i.res = date1 == date2;
|
2009-04-21 01:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_run(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( system->HasReadExecAccess(cur->request->item_tab[item_index]) )
|
2011-01-20 19:37:51 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item_tab[item_index]);
|
2011-01-20 19:37:51 +01:00
|
|
|
item_run_content.Clear();
|
2014-10-19 23:20:09 +02:00
|
|
|
InitGenerator(ezc_generator);
|
2014-10-18 20:12:04 +02:00
|
|
|
ezc_generator.SetPattern(*p);
|
2015-11-15 23:23:36 +01:00
|
|
|
|
|
|
|
if( config->allow_ezc_out_in_executable_items )
|
|
|
|
ezc_generator.Generate(item_run_content, cur->request->out_streams);
|
|
|
|
else
|
|
|
|
ezc_generator.Generate(item_run_content);
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
item_print_content(i.out, item_run_content.Str(), cur->request->item_tab[item_index].content_type);
|
2011-01-20 19:37:51 +01:00
|
|
|
}
|
|
|
|
else
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
|
|
|
i.out << "<!-- run: permission denied -->";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-30 21:56:32 +02:00
|
|
|
void item_tab_can_use_emacs(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2010-06-30 21:56:32 +02:00
|
|
|
{
|
2010-08-10 18:12:50 +02:00
|
|
|
// !!
|
2011-01-23 15:15:30 +01:00
|
|
|
//i.res = cur->request->CanUseEmacs(cur->request->item_tab[item_index], true);
|
2010-06-30 21:56:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
void item_tab_has_static_file(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
2011-01-05 22:24:11 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->request->item_tab[item_index].file_type != WINIX_ITEM_FILETYPE_NONE &&
|
|
|
|
!cur->request->item_tab[item_index].file_path.empty();
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
void item_tab_has_thumb(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].has_thumb;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_type_is_dir(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].type == Item::dir;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_type_is_file(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].type == Item::file;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_type_is_symlink(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].type == Item::symlink;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_is_link_to(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = !cur->request->item_tab[item_index].link_to.empty();
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_link_to(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].link_to;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_is_link_redirect(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.res = cur->request->item_tab[item_index].link_redirect == 1;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
2009-04-21 01:49:28 +02:00
|
|
|
|
2009-01-14 21:11:12 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
void item_tab_file_size(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].file_size;
|
|
|
|
}
|
|
|
|
|
2011-08-02 02:10:45 +02:00
|
|
|
void item_tab_sort(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
i.out << cur->request->item_tab[item_index].sort_index;
|
|
|
|
}
|
2011-06-24 22:53:21 +02:00
|
|
|
|
|
|
|
void item_tab_has_next(Info & i)
|
|
|
|
{
|
|
|
|
i.res = item_index + 1 < cur->request->item_tab.size();
|
|
|
|
}
|
|
|
|
|
2013-02-26 12:49:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
void item_tab_meta_str(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
cur->request->item_tab[item_index].meta.Serialize(i.out, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_meta(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
space(i, cur->request->item_tab[item_index].meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_meta_tab(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
spaces_tab(i, cur->request->item_tab[item_index].meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_meta_tab_value(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
spaces_tab_value(i, cur->request->item_tab[item_index].meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_tab_meta_tab_has_next(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < cur->request->item_tab.size() )
|
|
|
|
spaces_tab_has_next(i, cur->request->item_tab[item_index].meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|