Jump to content

Search the Community

Showing results for tags 'howto'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General Discussion
    • Announcements
    • Business Discussion
    • Business Services
    • Sell and Buy
  • Themes & templates
    • KVS default theme
    • KVS tablet theme
    • KVS paysite theme
    • KVS basic theme 1
    • KVS basic theme 2
    • KVS basic theme 3
  • Educational / support
    • Technical Support
    • FAQ
    • Educational Series

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me

  1. This article provides step by step instruction on how to get categories dropdown in site header. Please note the CSS styles described here are not 100% perfect, as they in some way overlap with styles for upload item dropdown. Please adjust them as needed by your site design. Step 1. Go to Website UI -> Global blocks and click on Add block button at the bottom. In the new block line specify block name as Header Categories and under block type select list_categories. Save. Step 2. Open the newly appeared Header Categories block for editing. Configure block parameters as needed, e.g. items_per_page if you want to limit the number of categories displayed, and other filters if you want to limit which categories are displayed. Enter the following code into template code area and save: {{if count($data)>0}} <li class="drop"> <span>{{$lang.header.primary_menu_categories}}</span> <ul> {{foreach from=$data item="item"}} <li> <a href="{{$lang.urls.videos_by_category|replace:"%DIR%":$item.dir|replace:"%ID%":$item.category_id}}">{{$item.title}}</a> </li> {{/foreach}} </ul> </li> {{/if}} Step 3. Go to Website UI -> Page components -> include_header_general.tpl for editing. Find the <LI> node that renders categories menu item, similar to this: <li {{if $page_id=='categories_videos' || $page_id=='categories_albums'}}class="selected"{{/if}}> <a href="{{$lang.urls.categories_videos}}" id="item6">{{$lang.header.primary_menu_categories}}</a> </li> And replace it with this block insert: {{insert name="getGlobal" global_id="list_categories_header_categories"}} Step 4. To make styles look better, add the following basic styling into your theme CSS file: .navigation .primary .drop > span { display: block; position: relative; background-color: #e0dfdf; padding: 12px 38px 12px 17px; cursor: pointer; } .navigation .primary .drop > span:after { position: absolute; z-index: 1; content: "\e901"; font-family: "icomoon" !important; speak: none; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-size: 5px; top: calc(50% - 1px); right: 20px; will-change: transform; -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-transform: translateY(-50%) rotate(0); transform: translateY(-50%) rotate(0); -webkit-transition: -webkit-transform 0.3s; transition: -webkit-transform 0.3s; transition: transform 0.3s; transition: transform 0.3s, -webkit-transform 0.3s; } .navigation .primary .drop:hover > span { background-color: #276fdb; color: #fff; } .navigation .primary .drop:hover > span::after { -webkit-transform: translateY(-50%) rotate(180deg); transform: translateY(-50%) rotate(180deg); }
  2. Most of KVS themes come with popups for utility forms, such as login and signup. If you need to refer login or signup popups, you can do that without actually having them as separate pages: https://kvs-demo.com/?login https://kvs-demo.com/?signup If you want to create separate pages for them with custom design, you can also do that by following this guide. Creating login page Step 1. In Website UI -> Pages create a new page with the following template code: {{assign var="page_title" value=$lang.html.login_title}} {{assign var="page_canonical" value=$lang.urls.login}} {{include file="include_header_general.tpl"}} <div class="content"> <div class="main-content"> <div class="main-container"> {{insert name="getBlock" block_id="logon" block_name="Logon Form"}} </div> </div> </div> {{include file="include_footer_general.tpl"}} Set page External ID to login, you can set title to Login, this is only title for admin panel. NOTE: if you have error message saying that there are no permissions to create files, you have 2 choices: Either put 777 permissions on the directory where KVS is installed (using FTP client or server File manager tool) Or manually create /login.php file in the document root with the following code: <?php require_once("admin/include/process_page.php");?> Step 2. After you saved page in Step 1, you should see Logon Form block added to this page's blocks list at the bottom. Open it for editing. Now open another browser tab and go to Website UI -> Global blocks -> Logon Form and copy template code and block parameters from there into the settings of Logon Form on the new login page. Step 3. In /.htaccess file in the root directory of your project find these 2 lines: RewriteRule ^login/$ index.php?mode=async&function=get_block&block_id=logon_logon_form&global=true [L,QSA] RewriteRule ^login-required/$ index.php?mode=async&function=get_block&block_id=logon_logon_form&global=true&error=only_for_members [L,QSA] and change them to these: RewriteRule ^login/$ login.php [L,QSA] RewriteRule ^login-required/$ login.php?error=only_for_members [L,QSA] Step 4. In Website UI -> Texts add new text for rendering title of your newly selected login page: External ID: html.login_title Default: Login Page Title Now you should be able to click on login link in header and see your new login page. Do you still see it is open in popup instead of separate page? If yes, please update this file on your server with a newer version from kvs-demo.com (only for KVS default theme): https://kvs-demo.com/static/js/main.min.js Creating signup page Step 1. In Website UI -> Pages create a new page with the following template code: {{assign var="page_title" value=$lang.html.signup_title}} {{assign var="page_canonical" value=$lang.urls.signup}} {{include file="include_header_general.tpl"}} <div class="content"> <div class="main-content"> <div class="main-container"> {{insert name="getBlock" block_id="signup" block_name="Signup Form"}} </div> </div> </div> {{include file="include_footer_general.tpl"}} Set page External ID to signup, you can set title to Signup, this is only title for admin panel. NOTE: if you have error message saying that there are no permissions to create files, you have 2 choices: Either put 777 permissions on the directory where KVS is installed (using FTP client or server File manager tool) Or manually create /login.php file in the document root with the following code: <?php require_once("admin/include/process_page.php");?> Step 2. After you saved page in Step 1, you should see Signup Form block added to this page's blocks list at the bottom. Open it for editing. Now open another browser tab and go to Website UI -> Global blocks -> Signup Form XXX and copy template code and block parameters from there into the settings of Signup Form on the new signup page. NOTE: There are multiple different signup forms support in KVS themes: Simple signup form is default, Simple2 signup form requires email as a login, Advanced signup form renders additional profile fields on signup; finally Premium signup form renders paid access options. Choose the form that you need and copy its template and settings. Step 3. In /.htaccess file in the root directory of your project find this line: RewriteRule ^signup/$ index.php?mode=async&function=get_block&block_id=signup_signup_form_simple&global=true [L,QSA] and change it to this: RewriteRule ^signup/$ signup.php [L,QSA] Step 4. In Website UI -> Texts add new text for rendering title of your newly selected signup page: External ID: html.signup_title Default: Signup Page Title Now you should be able to click on signup link in header and see your new signup page. Do you still see it is open in popup instead of separate page? If yes, please update this file on your server with a newer version from kvs-demo.com (only for KVS default theme): https://kvs-demo.com/static/js/main.min.js
  3. KVS serves and stores different types of static content, like video files, photo images, video screenshots, user avatars, theme design styles / scripts. For video files and album photos KVS supports multi-server architecture and this is completely another story described here. This topic describes how to move static to CDN or another server for the rest of static content. Theme design files These are typically files located under /static folder on your main server. In most cases you will need to move these design elements to CDN for faster load. You should do that manually following any guideline you have for CDN. Please note that you should also check with CDN guide / support about crossdomain security issues (for example fonts can be only loaded from another domain if they provide Access-Control-Allow-Origin "*" header and etc.) From KVS side you only need to adjust one option in /admin/include/setup.php file: $config['statics_url']="$config[project_url]"; By default it points to the project URL, you should change it to your CDN: $config['statics_url']="//cdn.domain.com"; It will force all design static files to be loaded from this domain. NOTE: If your project is running under HTTPS, you should use CDN which also supports HTTPS. In most cases CDN will cache files from your original server for some time (can be forever). If you do any changes in these files on your server, your site will still continue using old versions. You may need to reset your CDN cache so that it pulled new versions. Another option is to increment version of the modified file when it is linked from template (not sure if all CDNs support this). For example templates use this tag to include CSS style file: <link href="{{$config.statics_url}}/styles/all-responsive-white.css?v=5.0" rel="stylesheet" type="text/css"/> If this file is loaded from CDN and you modify it, you can increment its version so that CDN will update it from your server again. The actual numbers don't matter, it should be different from the old one: <link href="{{$config.statics_url}}/styles/all-responsive-white.css?v=5.0.1" rel="stylesheet" type="text/css"/> Video screenshots from CDN By default video screenshots are stored under this folder on your main server: /contents/videos_screenshots You can move them to CDN as well, however you should consider the problem of invalidation here. Screenshots can be changed from time to time in admin panel. For example if you create 20 screenshots per each video and then leave only 10 best screenshots, or if rotator automatically removes badly clickable screenshots, your CDN will still show the old ones incorrectly. There is no solution for this issue from KVS side, you should check with your CDN provider on which options are available. For example they can ping files from your server from time to time and check if they were changed or not. But if you don't commit any screenshots editing you will probably be fine with leaving this as it is, since in your case the files will unlikely be changed. In order to switch screenshots to CDN you should first configure CDN per their guidelines and then in /admin/include/setup.php file of your KVS installation you should modify this URL: $config['content_url_videos_screenshots']="$config[project_url]/contents/videos_screenshots"; Please make sure to modify the correct option, as there are some similarly spelling options around. Your change should be something like: $config['content_url_videos_screenshots']="//cdn.domain.com/contents/videos_screenshots"; NOTE: If your project is running under HTTPS, you should use CDN which also supports HTTPS. If you want to make screenshot loading even faster, you can define alternate URLs for screenshots via different subdomains. The reason is that browsers do have limits to the number of concurrent connections for a single server (~6 at the same time). If there are many screenshots on your page they will be loaded in portions, but you can make this happen in parallel by loading them from different subdomains. They should all be configured as aliases for the same server and should serve the same content. In order to do that there is another option in /admin/include/setup.php config file: $config['alt_urls_videos_screenshots']=array(); You can list several alternate URLs there in the following format (make sure you retain the correct syntax or you may brake the code): $config['alt_urls_videos_screenshots']=array("//cdn2.domain.com/contents/videos_screenshots", "//cdn3.domain.com/contents/videos_screenshots"); This will force KVS to randomly load screenshots from these 3 URLs: //cdn.domain.com/contents/videos_screenshots (configured as main URL) //cdn2.domain.com/contents/videos_screenshots (configured as alternate URL 1) //cdn3.domain.com/contents/videos_screenshots (configured as alternate URL 2) Video screenshots from another server but not CDN If you want to use another server for serving video screenshots, you have 2 options: Option 1. Use rsync to push updates in KVS /contents/videos_screenshots folder to another server. This should be configured by your server admins. In this case you need to modify screenshots URL (see Video screenshots from CDN section). However this approach is not recommended, because rsync works asynchronously with some delay, so the common problem is that for new videos the screenshots may not yet been synced to remote server. If you know the interval between each rsynс push, you can workaround this problem by configuring KVS to postpone new content for some time. You should then change this option in /admin/include/setup.php: $config['post_dates_offset']="0"; It indicates the number of minutes all new content will be delayed. For example if rsync works every 1 hour you can configure it to be 70 or 80 minutes, to make sure that screenshots of new videos have been pushed to remote server in the moment when video appears on your site. Option 2. The second option is to move the whole screenshots storage folder to a remote server using network filesystem (NFS mount). This can be a good solution if remote server is located with the same datacenter for stability reason. You should ask your admins to create writable NFS mount to the remote server and move all existing content from /contents/videos_screenshots there. Then you should modify these 2 options in /admin/include/setup.php file: $config['content_path_videos_screenshots']="$config[project_path]/contents/videos_screenshots"; ... there are some other options in between ... $config['content_url_videos_screenshots']="$config[project_url]/contents/videos_screenshots"; The first option is a filesystem path and the second one is URL. Your changes should look like this: $config['content_path_videos_screenshots']="/mnt/server2/contents/videos_screenshots"; // should be a real path of the mounted folder ... $config['content_url_videos_screenshots']="//server2.domain.com/contents/videos_screenshots"; NOTE: If your PHP is configured with open_basedir restriction you should also update it to include /mnt/server2 path, otherwise KVS will not be able to write new screenshots into the mounted folder. You can check if this folder is writable or not with KVS audit plugin. Using the 2nd approach is more preferred, as there won't be any delay in screenshots availability. But it needs stable connection between servers. Other static files Other static files are normally user avatars and images of categorization objects like categories, channels, models. You can use the same approach for them as for screenshots, either move them to CDN (see Video screenshots from CDN), or move to another server (see Video screenshots from another server but not CDN). The only difference is in what options you should change in /admin/include/setup.php. Here they are: $config['content_url_categories']="$config[project_url]/contents/categories"; // URL for categories $config['content_url_content_sources']="$config[project_url]/contents/content_sources"; // URL for content sources $config['content_url_models']="$config[project_url]/contents/models"; // URL for models $config['content_url_dvds']="$config[project_url]/contents/dvds"; // URL for channels / series / DVDs $config['content_url_posts']="$config[project_url]/contents/posts"; // URL for posts $config['content_url_avatars']="$config[project_url]/contents/avatars"; // URL for users $config['content_url_referers']="$config[project_url]/contents/referers"; // URL for referers, not used in most cases $config['content_url_other']="$config[project_url]/contents/other"; // URL for uncategorized static files By default these all point to your main server, you can switch them to CDN or another server in the same way.
  4. For a video site most of the bandwidth is being used for serving videos. In many cases you will have a limited channel like 100mbit or 1000mbit, so you will not save any money by saving bandwidth, however there are several cases when saving bandwidth can make great benefit for you: When your channel is fully loaded with serving videos, your site may become unresponsive for some users and you may get SEO penalty. One solution is to buy a new server or extend bandwidth limit, but you can save this money with KVS by trying to limit video streaming speed. When you are using CDN, in most cases you pay for the maximum bandwidth peak. You can save some money by paying less if your maximum peak becomes less. Why limiting streaming speed can save your bandwidth? Many users do not watch videos in full length, they may skip up and down to different fragments. However if their internet speed is high, they can download full video at a max speed shortly even if they didn't watch most of it. With a speed limit you will reduce % of downloaded bandwidth by each user and finally you will get some cut in your global bandwidth usage. KVS provides 2 way to limit video streaming speed: Limit speed to fixed bitrate. This is not a good solution, since it can be inaccurate in many cases - since video bitrate is often dynamic and you won't know the exact bitrate to limit. Limit speed to dynamic bitrate with a multiplier. This option is much better as it will make sure different speed limits for videos of different bitrates and you don't need to investigate the average bitrate of your videos. However, there is one important issue which you should know about streaming MP4 files. Each MP4 file has a metadata atom in the beginning (MOOV atom). This atom contains keyframes from video file and can take up to 4MB depending on video duration and geometry. Player needs to download this atom before it can start playing videos. Therefore if you limit download speed, your videos will start playing with a big delay. However Nginx provides a way to fix that, we will describe this later. NOTE: limiting streaming speed is only possible with serving videos with Nginx or CDN. In case of CDN the implementation of speed limit is fully dependent on your CDN provider (BTW some CDNs are not interested in doing this for an obvious reason). KVS will pass speed limit info to the CDN integration script, which may or may not use it - but this is not KVS issue. How to configure download speed limit In KVS you can configure download speed limit per each video format separately. Go to Settings -> Video formats and for each video format you can set speed limit: Global speed limit: Dynamic bitrate x 1.2 (we recommend multipliers from 1.1 to 1.5) You can set other options under Speed limitation section as needed. For example you can give your premium or active members unlimited download speed. You can also limit speed for visitors from certain countries only, so that you main audience is not affected. In order to define list of countries you want to limit please take a look at Stats -> Countries for reference.
  5. How do I recover or find my admin password that I lost? There is no password reset button if you are locked out of admin panel.
  6. Is it possible to add filter videos by satellite in next update? Let's say I have Main Site A and Satellite B , I would like to filter videos uploaded from Satellite B and in the process give administrators access only to videos uploaded from satellite sites. Or Show videos from Satellite B in Satellite B admin also so admin from satellite B can add , delete or changes videos only owned by him, Videos from all satellites will show on Main site too .
  7. There are many sites which can be used to download videos from 3rd-party tube sites. For example this one: tubeninja.net KVS tube script comes with a fully-featured protection mechanism, which can do 3 things for your tube site: Prevent other users from downloading your videos via web tube downloaders. Prevent any other scripts from parsing and downloading your videos. Prevent other tube sites from hotlinking your videos and stealing your traffic. The settings are in Settings -> Content Settings under Video download script protection settings section: What you should do is to make sure that Enable protection for video download script is ON, Hotlink protection type is set to IP and Enable links obfuscation option is also switched ON. Link obfuscation will only work in KVS player. If you are using 3rd-party video player, then you cannot use this option. However, if your hotlink protection type is set to IP this will also prevent using web tube downloaders for your site. But your site will be vulnerable for other scripts to parse and download your content. If it is important for you to prevent that, you should use KVS video player and enable this option.
  8. KVS doesn't support video popularity stats per country yet, but it is possible to emulate this for the end users, providing some personal attitude to every visitor: Step 1. In /admin/include/pre_initialize_page_code.php add the following line: $_GET['GEOIP_COUNTRY_CODE'] = $_REQUEST['GEOIP_COUNTRY_CODE'] = strtolower($_SERVER['GEOIP_COUNTRY_CODE']); This is needed to pass environmental variable with country code to request variables, that can be used by KVS site engine. Step 2. In Website UI -> Texts add the following text that will be rendered as a header: External ID: videos.list_title_by_country Default: Popular in %1% <img class="flag" title="%1%" alt="%2%" src="/static/images/flags/%2%.gif"> This text also contains IMG with reference to flag image. Step 3. Open Website UI -> Pages -> Index -> Videos Watched Right Now for editing. Change its Template code to the following: {{query_kvs select="single" table="list_countries" where_country_code=$smarty.get.GEOIP_COUNTRY_CODE where_language_code="en" assign="country"}} {{assign var="country_title" value=$country.title}} {{if !$country_title || $country.is_system==1}} {{assign var="list_videos_title" value=$lang.videos.list_title_watched_right_now}} {{else}} {{assign var="list_videos_title" value=$lang.videos.list_title_by_country|replace:"%1%":$country.title|replace:"%2%":$smarty.get.GEOIP_COUNTRY_CODE|smarty:nodefaults}} {{/if}} {{assign var="list_videos_use_h1" value="true"}} {{include file="include_list_videos_block_common.tpl"}} NOTE: KVS only supports country names in English and Russian languages, if your site is in Russian please change where_language_code="en" with "ru" to have country name in Russian. In block settings down the page specify GEOIP_COUNTRY_CODE under Dynamic HTTP parameters. This is needed for correct caching logic for this block. If you don't do that, KVS admin panel will show error that using $smarty.get.GEOIP_COUNTRY_CODE variable will not work correctly. The code does the following. First it queries KVS database and selects country record that matches the current visitor's country code using query_kvs template function. Then it checks whether any non-system country record is found (system countries are some satellite ISPs and anonymous proxies). If nothing is found, this code will show old "Videos Watched Right Now" text. Otherwise it will show the new text with country code and flag icon. Step 4. For better icon styling add this block into theme CSS file: h1 img.flag, h2 img.flag { vertical-align: middle; }
  9. If you want to get rid of Apache and have your site working purely on Nginx, please consider these steps to migrate Apache-specific configurations into Nginx. NOTE: we do not support this officially. Apache + mod_rewrite will still be required for KVS and all functionality we add or change in KVS is always tested in Apache environment. We cannot guarantee these steps are everything you need to migrate to pure Nginx. Also we cannot guarantee that any future features will work in pure Nginx environment or will not require changes in Nginx configuration to make them working correctly. Nginx should set the following environmental variables which are typically set by Apache: REMOTE_ADDR SCRIPT_FILENAME SCRIPT_NAME REQUEST_METHOD QUERY_STRING REQUEST_URI DOCUMENT_ROOT These are typically set by default fastcgi configuration, but worth mentioning. You can find nginx rewrites in _INSTALL/nginx_config.txt file in your installation archive.
  10. Please add the following code to your header template to prepare your video pages for Yandex.Video: {{if $storage.video_view_video_view.video_id>0}} <meta property="og:url" content="{{$storage.video_view_video_view.canonical_url}}"/> <meta property="og:video" content="{{$config.project_url}}/embed/{{$storage.video_view_video_view.video_id}}"/> <meta property="og:type" content="video.other"/> <meta property="og:video:type" content="video/mp4"/> {{if $storage.video_view_video_view.file_dimensions.0>0}} <meta property="og:video:width" content="{{$storage.video_view_video_view.file_dimensions.0}}"/> <meta property="og:video:height" content="{{$storage.video_view_video_view.file_dimensions.1}}"/> {{/if}} {{if $page_og_description==''}} <meta property="og:description" content="{{$storage.video_view_video_view.title|mb_ucfirst}}"/> {{/if}} <meta property="video:duration" content="{{$storage.video_view_video_view.duration_minutes*60+$storage.video_view_video_view.duration_seconds}}"/> {{if $storage.video_view_video_view.tags_as_string}} <meta property="video:tag" content="{{$storage.video_view_video_view.tags_as_string}}"/> {{/if}} <meta property="ya:ovs:upload_date" content="{{$storage.video_view_video_view.post_date|replace:" ":"T"}}"/> <meta property="ya:ovs:adult" content="false"/> <meta property="ya:ovs:allow_embed" content="true"/> <meta property="ya:ovs:views_total" content="{{$storage.video_view_video_view.video_viewed}}"/> <meta property="ya:ovs:comments" content="{{$storage.video_view_video_view.comments_count}}"/> <meta property="ya:ovs:rating" content="{{$storage.video_view_video_view.rating*2}}"/> {{if $storage.video_view_video_view.is_hd==1}} <meta property="ya:ovs:quality" content="HD"/> {{/if}} {{/if}} Also add the following attribute to your <html> tag in header: prefix="og: http://ogp.me/ns# video: http://ogp.me/ns#video"
  11. In KVS you can define watermark image for each video format in Settings -> Video formats. Typically this is PNG image with some transparency and your site logo / name. How to make sure that watermark is stable for all video formats Since in most cases videos are provided in multiple formats, there is a common problem of watermark scaling. For example, consider a video file that is only 800px in width and the one that is 1920px in width. If your screen size is 1920px also, the first video file will be upscaled 2.5 times when displaying on full screen, while the last file won't be scaled at all. How do you decide which size watermark image should be rendered for each of this format, so that it remain stable size whether user is watching 800px format or 1920px one? The solution is very simple - you should upload watermark image with a big size in all formats, but configure it to take only specific % of video size. There are special options in video format settings: Having this set to 20% in all your video formats you will make sure despite of user chosen display format and user screen size the watermark will always be scaled to 20% of screen width. NOTE: we are not recommending using 20% and 40% values, this is something that you should decide yourself. And this is correct that max width for vertical videos is bigger than for landscape - their width in pixels is smaller. NOTE: KVS supports 2 different watermarks at the same time. Please note that for watermark #2 you specify max height, not width. This is on purpose for cases when you want to display running text; in some cases text length can be bigger than video file width, so in order to resize it correctly you will need to adjust max height for it. Running texts KVS allows showing running texts together with normal watermark images. We recommend using Watermark #2 for running text and Watermark for normal images. Running text should be still uploaded as image, e.g. you should first use image editor and create a text of your wish on transparent background; then save it into PNG and upload PNG into KVS. Then as a Watermark position you should select Top scrolling, or Bottom scrolling. These choices will show several more options where you configure scrolling speed and video positions when scrolling starts. This screenshot defines a scrolling watermark at bottom that will appear 3 times per video: on 10% duration, on 50% and on 90%. Watermark will be visible for 20 seconds, and this defines how fast it will scroll by dividing video width per watermark width: NOTE: it was configured that watermark takes max 5% of video height for landscape videos and max 3% of video height for portrait videos in order to make its size consistent across all formats and devices. Rendering customized watermarks If you want to apply different watermarks for different videos, one of the possible ways is to use custom fields of content sources to provide different watermark images for videos from different content sources. In order to use this approach, you should have well defined way of adding / importing videos with content source for each video that needs custom watermarks. The idea is each content source can define its custom watermark image and all videos that are tagged with this content source will be converted with this custom watermark image. In order to configure this approach, you should first go to Settings -> Customization and enable any available custom file field for content sources. Once enabled, go to each video format settings and select the activated custom field in Customize watermark for content sources field: After that you should go to each content source for which videos you want to customize watermark image and upload a custom image into Custom watermark field. Now, all videos that are created or imported with this content source, will have this custom watermark image. If you want to programmatically generate watermarks (e.g. type username who uploaded this video, or any other custom text which can be different), you can create custom PHP script providing hook method for KVS to use custom watermark image. The script should be put into /admin/include/kvs_watermark_video.php Here is sample script implementation, which creates watermark image with the following text: Uploaded by <username> <?php function kvs_watermark_video($format_postfix, $video_data) { global $config; // here you should create and return image path with your custom watermark text // this file will be deleted, so you need to create it each time // check $format_postfix if you need watermark to be limited to specific formats only, e.g. // if ($format_postfix == '.mp4' || $format_postfix == 'trailer.mp4') // for example you can query user data and render "uploaded by <username>" watermark $user_data = mr2array_single(sql_pr("select * from $config[tables_prefix]users where user_id=?", $video_data['user_id'])); if ($user_data['user_id'] > 0) { $watermark_file = "$config[temporary_path]/custom_watermark.png"; // settings: text, font, size and offset $watermark_text = "Uploaded by $user_data[display_name]"; $font = "$config[project_path]/admin/data/system/verdanaz.ttf"; $font_size = 10; $offset = 20; // rendering logic $box = imagettfbbox($font_size, 0, $font, $watermark_text); $im = imagecreatetruecolor(abs($box[2] - $box[0]) + 2 * $offset, abs($box[7] - $box[1]) + 2 * $offset); imagealphablending($im, false); imagefilledrectangle($im, 0, 0, abs($box[2] - $box[0]) + 2 * $offset, abs($box[7] - $box[1]) + 2 * $offset, imagecolorallocatealpha($im, 0, 0, 0, 127)); imagealphablending($im, true); imagettftext($im, $font_size, 0, abs($box[0]) + $offset, abs($box[5]) + $offset, imagecolorallocate($im, 255, 255, 255), $font, $watermark_text); // save image to temp file imagesavealpha($im, true); imagepng($im, $watermark_file); imagedestroy($im); // return temp file back to KVS engine return $watermark_file; } return null; } If you need similar functionality (just plain text with custom wording), you can copy-paste this code and modify only these lines: $watermark_text = "Uploaded by $user_data[display_name]"; // text will render "Uploaded by <username>" $font = "$config[project_path]/admin/data/system/verdanaz.ttf"; // this font comes with KVS for captcha rendering, but you can use any other TTF font $font_size = 10; // text size $offset = 20; // offset from video edges, means 20 pixels from corner Here is a sample watermark created by this code. You can see that the font is a bit specific, so you should better use other font: Some notes: Please do not replace KVS font file with your custom font, or captcha functionality may not work correctly. If you want to use custom font, you can put it near by and correct font filename in the code. This watermark will be applied to all video formats that are created by KVS. If you want to limit it to specific video format, you need to add "if" check on the $format_postfix value passed to this function and return null for formats where watermark is not needed. The position of watermark will still be controlled by the Watermark position option of video format settings. By default it is set to Random, so if you don't change it then watermark will be positioned at random corner of the video. Testing watermark function You can test your watermark function by executing test_watermark.php script from your browser: http://yourdomain.com/test_watermark.php Here is code for test script: <?php require_once('admin/include/setup.php'); require_once('admin/include/setup_db.php'); require_once('admin/include/functions_base.php'); require_once('admin/include/functions.php'); error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', 1); require_once('admin/include/kvs_watermark_video.php'); $video = mr2array_single(sql("select * from ktvs_videos order by rand() limit 1")); $path = kvs_watermark_video(".mp4", $video); if ($path) { header("Content-Type: image/png"); readfile($path); } Running this file will show you a watermark image created for random video and video format with ".mp4" postfix. If you want to test your code for another postfix, then change ".mp4" with another postfix you need.
  12. Step 1. Open Website UI -> Pages -> View Video page -> Related Videos block for editing. Step 2. Change parameters: Under sort_by make sure you deselect Pseudo-random sorting and choose another sorting, as pseudo random sorting doesn't support pagination. Enable var_from = from. Step 3. Add the following 3 lines: {{assign var="pagination_use_load_more" value="true"}} {{assign var="pagination_no_links" value="more"}} {{include file="include_pagination_block_common.tpl"}} into block template code right after this one: {{include file="include_list_videos_block_common.tpl"}} Step 4. Adjust styles to add some spacing after load more button: .related-videos { padding-bottom: 15px; }
  13. Unfortunately it is not possible to update KVS theme like you can normally update KVS. Theme is subject to intensive customization: you modify styles and advertising (yes, advertising in KVS is part of theme as ads are displayed inside theme layout), you change texts and configure SEO. Updating theme with keeping your custom changes is not technically possible. The only possible way is to reset theme to a new version. When we say reset, we mean that your site will start looking like it was at initial KVS installation: You will lose all custom styling You will lose all site advertising (except in-player advertising, as player is not part of theme) You will lose all text changes, logo change You will lose all SEO changes (e.g. HTML titles, descriptions, SEO texts will be reset to their default values) So, this is only feasible if you still didn't start your site, or you didn't put much customization into it and can re-do everything quickly. Is there any sense to update theme at all? - We would say "no", since we don't put much changes into themes. The vast majority of theme changes are cosmetic changes only. All changes that we considered to be really important (e.g. search suggestions, chunked upload), were provided with a guide on how to put them into old theme version, examples: If you still for any reason want to reset to a new theme version, please contact support to get instructions, we do not want to print them publicly to prevent from accidentally resetting theme.
  14. KVS Project backup plugin can be used to either restore theme from a specific date, or to move theme from one project to another. Step1. In order to create theme backup for copy please go to Plugins -> Project backup and choose backup website option there. It will create an archive with theme backup in the backup directory configured in plugin: You can also choose any of the automated backup file, every of them contains theme backup. IMPORTANT! Theme backup also includes advertising defined in Website UI -> Advertising section, as advertising is part of theme. By using backup archive to restore theme you will also restore advertising to the date of backup. Step 2. When you have the needed backup archive, unpack it locally to some directory. Backup archive may contain multiple sub-directories, but the only needed sub-directory is website. Step 3. By using FTP client connect to your server and drag and drop the contents of website sub-directory on top. Using drag and drop is the best way to make sure that you NEVER EVER use "sync" function, because "sync" function can destroy your project without ability to restore it later. We recommended using free Filezilla FTP client: After the copying is finished, your project will have theme version from backup. Step 4. If you move theme from one project to another, it may not work correctly after copying. The reason is that theme may refer screenshot and album formats that are not available in your new project. Go to Website UI -> Theme settings and check if there are any errors displayed about formats being used. You may need to either choose another formats, or create the missing formats in your new project. Another issue could be that your theme is using some 3rd-party files, scripts, images that are not known to KVS backup plugin, so that they were not included into backup archive. Then you should typically see some 404 errors in your project when looking into Network or Console section of browser DEV tools. You should solve these by manually copying the missing files and / or sub-directories from your old project. Finally you may also experience lack of editing permissions in KVS admin panel when opening certain objects in Website UI section. To make sure you won't have this, please login to your server command line with administrative user and apply these command after opening your project www root to correct permissions for the copied files: find template -type d | xargs chmod 777 find template -type f \( ! -iname ".htaccess" \) | xargs chmod 666 find admin/data/config -type d | xargs chmod 777 find admin/data/config -type f \( -iname "*.dat" \) | xargs chmod 666 find admin/data/advertisements -type f \( -iname "*.dat" \) | xargs chmod 666
  15. Migrating categorization In most cases you don't need to consider categorization, as it will be automatically migrated along with content. However if you want to migrate categorization details as well (such as model details, screenshots, or custom fields) the only way to do that is to use Migrator plugin in KVS. Migrator plugin will connect to another KVS database and will pull categorization that you choose to pull. There are certain important aspects that you should consider when using Migrator plugin: Migrator plugin only supports categorization for KVS migrator. Content migration should be done using export and import functionality, which has much more options. Migrator plugin needs direct connection to other project's database. This works fine if your other project is on the same server, but won't work if your projects are on different servers. One option is to ask admins to expose KVS database on the other project's server to be available for public connections, which is not good from security point. Another option is to create a temporary local database and import backup from the other project's database into it, then configure Migrator plugin to migrate from this local temporary database. Migrator plugin needs your new database to be fully empty (e.g. no new categorization objects in it), as it will migrate objects by using the same IDs and will replace any existing objects that have the same IDs that are migrated from the other project's database. WARNING! If you try using Migrator plugin on project where you already have some categorization, it can be lost. It is recommended that both projects have the same KVS version before you try migration. Otherwise it is not guaranteed to fully succeed. Having these in mind, if your other project is on the same server and your new project is just installed, you can easily pull up all categories, tags, models, content sources with all their data within 5 minutes. All you need is to specify database connection to the other project's database. If you don't know MySQL connection details, please open /admin/include/setup_db.php file to find them. Here is an example: NOTE: for the Old path please specify any existing empty directory path, you can specify path to /tmp directory in your www root. Manually migrating video or album content Use manual content export / import when you want to do a one time migration of all (or part) of your content from older project and then allow these projects run separately. If you want to constantly sync one project based on another project, you need to use feeds, which are explained in the next section. The idea is that you first export content data into a text file and then use this text file to import the exported content into another project. Export / import of albums and videos works in exactly same way, so we will describe on videos. You can access export function in Videos -> Export videos (Import videos for import). The important thing is to create a named pattern of export (and later import), so that you can return to it later if you do any mistakes with fields or options. The recommended way is to first export a dozen of test videos and then try importing them to test the whole scheme and that you get the result you need; and only after you are fine with the imported content you can do the full migration. Another important thing to consider is which video content types you have (file uploads, embeds, hotlinks, or mixed) and how you want them to be imported. The most common scenario is that you have file uploads (videos that store files in KVS storage) and you want to migrate them in the same way. Another possible scenario is that you have videos embedded from other sites and you want to migrate them in the same way. In these cases when you have ALL videos of the same content type, you just do one time export of them ALL and one time import of them ALL. However, there are rare cases when you have some videos uploaded to your servers, some more videos embedded and another set of videos just hotlinked. In this specific case you should do separate export and import for each content type that you have. This is needed because videos of different content types have different data structure. Video export GUI offers Loaded as filter that allows you separating videos by their content type. With regard to Field and Line separators it is recommended to leave them as default. This may not work only if you have videos with multiline descriptions, but in this case manual export and import won't work for you at all and you have to fallback to using KVS feeds. In general it is recommended to leave all export and import options to their default values, unless you need anything specific. The main area where you should put your effort is Fields for export (Fields for import). First of all you should be using the same Field and Line separators in both export and import, we recommend use them as set by default. Next you should make sure that you select the same sets of fields in both export and import. Many fields like title and description are obvious, how about the rest of them? Here is a short summary: Use Video ID only if you want to keep the same IDs across 2 projects. In most cases this is not needed. Use Directory only if you had some specific rules on directory generation or transliteration. In most case this is not needed as directory is usually generated from title. If you want to migrate rating, make sure you select both Rating and Rating (votes). If you want to migrate usernames of video creators, you can do that by selecting User field, but please note that this will only migrate the username, not the whole user data. KVS will create new fake users with the given usernames in new projects. Finally there is a set of fields under Content group, which are related to content structure. As we noted before, depending on video content type these fields structure will be different: For file upload content type, you should first get understanding which video formats you want to migrate. In many cases video formats on your new site will be configured in the same way as on your old site, so you will need to migrate all video formats. But in some cases your new site may have less formats, for example it could have no video preview format, or you occasionally want video preview to be generated differently on this new site. Based on this understanding you should export Video file "XXX" (for hotlink) field for each of the video formats you want to migrate. At the same time you should select the corresponding Video file "XXX" (without processing) field in import fields configuration. For embed content type, you should export and import these fields: Embed code (embedded video), Duration, Main screenshot number and Overview screenshots (sources comma-separated). For hotlink content type, you should export and import these fields: Hosted file URL (hotlinking), Duration, Main screenshot number and Overview screenshots (sources comma-separated). For pseudo video content type, you should export and import these fields: Outgoing URL (pseudo video), Duration, Main screenshot number and Overview screenshots (sources comma-separated). NOTE: if you have mixed content types, remember to do separate export and import for each content type with different set of content fields. NOTE: change Sorting to Video ID Asc so that videos are exported and imported in the same order as on the original site. IMPORTANT! When importing uploaded videos you should make sure that source site has video download protection disabled for the whole period of import. You can disable this in Settings -> Content settings -> Enable protection for video download script option. After import is fully completed, please enable it back. With regard to screenshots, for file uploads they are optional and it is up to you if you want to migrate them or not. In any way KVS will create new screenshots if needed. When migrating screenshots, please make sure that you export their source files, not files of any specific format. And also make sure you migrate main screenshot number. Here is example of how we selected fields in export and import to migrate some uploaded videos from one site to another: Automating content sync with feed You only need to use feeds if you plan to repeatedly sync other sites from the content of you primary site, or in case descriptions of your videos may contain line breaks, so that it is not possible to normally transfer them via manual CSV import. For a one time content transfer it is better to use manual import, as it provides more options and features. It also worth mentioning that only KVS Ultimate supports exporting feeds, so your primary project should have ultimate license. Importing feeds are supported in all KVS licenses. Also at the moment KVS doesn't support feeds for albums. Part 1: Exporting feed. You should start with creating exporting feed in your primary project, you can do that in Videos -> Exporting feeds. The most important section is Feed data and its Content type option. This option indicates which content details you want to expose in feed, and this depends on how you plan to sync your content into another KVS project (please find several examples of how to create site network from a single KVS site in How to build your tube empire with KVS article): Use Website link option if you want to migrate these videos as pseudo videos. Use Hotlink option if you plan to hotlink video files from this project on another projects. Use Embed option if you want to embed these videos on your another projects. Finally use Download link option if you are going to fully sync video files of videos of this project to your another projects. IMPORTANT! When using this option you should make sure that source site has video download protection disabled for the whole period of import. You can disable this in Settings -> Content settings -> Enable protection for video download script option. After import is fully completed, please enable it back. For other options make sure to enable all categorization data, screenshot and poster sources, custom and translated fields. Increase Max limit option to 10000, or bigger value that you want to use (see explanation below). If you plan to use embed codes or pseudo videos and you need some tracking of all traffic that comes to your primary site, you may also need to set some Traffic tracking parameters that you can later specify in feed builder. After your new exporting feed is saved, open its Feed access point to see feed builder form that provides ability to query the needed data from the feed. You should have Feed format set to KVS. Use Filters section if you want to sync only subset of content. If you are going to embed videos on another projects, check URLs and embeds section options. You will also need to specify details for any Traffic tracking parameters there if you enabled them. If you plan to hotlink video files on another projects, check Video files section that provides ability to select either quality factor for hotlinked URLs, or choose a specific video format to hotlink. In most cases you won't need anything specific for download mode, as it works fine by default. Another important thing to consider at this point is how many videos your feed would contain. If your database has less than 10k videos, you won't face any issue in most cases. More videos mean more memory and database load to generate all feed data, which will reach red line at one point and feed will stop working or hang for a long time. In order to solve this, you should use feed limit and pagination control to paginate over the whole list. E.g. import the first 10k videos with the first iteration, then import another 10k videos, and etc. In order to do that you should generate all feed URLs once, don't leave it for the latter time, as later you may forget which options you selected. Change Sorting to Biggest ID last so that videos are exported in the order as they were added. First specify Limit = 10000 and press Get videos button. It should open another tab with feed URL that queries the first 10k videos. Copy URL and save it to a text document. Then in feed constructor set Skip to 10000 and press Get videos button again. You will get another URL that queries the second 10k videos. Repeat the same by incrementing Skip by 10000 again and again until you finally get empty list that will indicate end of paginated data. You can try increasing limit to 20000 and see if feed works with more videos, so that you do less iterations. This will give you some set of URLs to query all your existing videos. Finally you need the last URL that will query some set of new videos for repeated sync. Change Sorting to Most recent first to make sure that now only new videos are in the feed. Set Limit to 1000 now and get URL for querying most recent 1000 videos that you will later use to sync new videos. Part 2: Importing feeds. Now you should go to admin panels of sites that you want to pull videos from your exporting feeds. Go to Videos -> Importing feeds and create a new importing feed. In Feed URL set the first URL of your URLs list that you created when using feed builder. Choose KVS (XML) parser. In Duplicates prefix specify domain name of your primary project you export videos from. If you create multiple importing feeds for the same project, please make sure that all share that same duplicates prefix, so that's why the best idea is to use source project domain name here. Under Interval field choose Run this feed only once and deactivate. Since you have paginated data (if source site contains more than 10k videos you will most likely end up with feed data split into 10k-volume pages), you will need to import each page separately. The proposed way is to first configure feed to import all videos from the first page, then wait for it to be deactivated and re-configure to import from the second page URL, and etc. until you import all pages with all existing videos. After that you should change Feed URL to the last URL you created that will pull latest 1000 videos and configure its Interval to how often you want feed to pull new videos. Then feed will automatically pull new videos for the rest of time. Under Feed data check all data fields you want to import. In Video data section set Video status to Active, Video screenshots to Use screenshots from feed, Video publishing dates to Use publishing date from feed. Finally in Video adding mode option you should choose whether you want to embed, or hotlink, or download videos. If you want to download, then in most cases you will need to set All formats that have match by postfixes (without processing) in Format option. However in order this option to work correctly, you should go to Settings -> Video formats in this project and make sure the formats are configured in the same way they are configured on source site. At least the formats that you want to be downloaded via feeds. When we say "in the same way", we mean that their postfixes and statuses should be set accordingly. For example if on source project you have 480p, 720p formats and MP4 preview format, then you should make sure your importing site also have these formats with the same postfixes. If you don't want, for example, to download MP4 preview format and you want it to be created on the importing project with some other options - create it with another postfix syntax and required status. Then importing feed should download 480p and 720p files only and KVS will auto-create your custom MP4 preview from them. NOTE: for testing purposes it is recommended to set Max videos per execution to some small number (e.g. 10-100) for the first iteration to make sure you configured importing feed correctly. Then you can remove this limit and run feed again allowing it importing the whole set of data.
  16. KVS doesn't provide any specific GUI controls to manage indexing, as it is not virtually possible due to very custom theme structure. However you can get everything you need with a very few fixes. Step 1. First of all you need to add noindex tag into site header template. Go to Website UI -> Page components -> include_header_general.tpl and add the following code somewhere inside its <head> section: {{if $page_noindex=='true'}} <meta name="robots" content="noindex" /> {{/if}} This code check if there is a page variable named page_noindex and it is equal to true, then this page should not be indexed by SE. Step 2. Set page_noindex variable anywhere you want this page to be not indexable: {{assign var="page_noindex" value="true"}} somewhere in page template around these values (the example is from Index page): How do you find where to add it? If you have KVS 5.3.0 or above, you should be able to see KVS Admin Toolbar at the bottom of each page and you can open page editor right from the toolbar menu. If your KVS version doesn't support toolbar yet, just add ?debug=true to the URL you are looking at and it should open debugger that will print link to open page editor.
  17. Before moving KVS please make sure that your new server complies with KVS server requirements and has all required libraries installed. Please contact your host support to migrate all KVS files and database to a new server. KVS files should be put into TAR archive, so that they keep the same filesystem permissions. Once migrated, it is not recommended to switch DNS until you make sure that KVS installation on the new server is fully operational. In order to do this, you can locally switch your domain to a new IP (by adding local record into hosts file), access your site on the new server and check it. Here are steps that you should do to reconfigure KVS on a new server: Step 1. In /admin/include/setup.php update project_path option if KVS installation path was changed. Step 2. In /admin/include/setup_db.php update database connection details. Step 3. Try to login to admin panel by locally changing DNS to a new server. You should not have any issues with accessing admin panel at this point. Step 4. In admin panel go to Administration -> Installation info and make sure PHP, FFmpeg and Imagemagick libraries do not display any errors: If you see errors like "sh: 1: /usr/bin/php: not found", edit /admin/include/setup.php and fix each path that produces error to refer valid binary path for this library. Step 5. In admin panel go to Settings -> Storage servers and fix path for every local storage server that you have, if KVS installation path was changed. Step 6. In admin panel go to Settings -> Conversion servers and fix path for every local conversion server that you have, if KVS installation path was changed. Step 7. In admin panel go to Plugins -> Project backup and fix path for backup copies, if KVS installation path was changed. Step 8. In admin panel go to Administration -> Installation info and copy Cron command. Schedule this command on crontab to run every minute. Step 9. In admin panel go to Plugins -> System audit and run all checks except video content and album content. You can also run these checks if you want, but running them may take a lot of time if you have many videos and / or albums; therefore we recommend to run them later in a separate audit check. Make sure audit doesn't display any errors or fix any server configuration errors indicated by audit. Step 10. Open your site and verify its basic functions. The end. If everything is OK at this point, you can switch public DNS to a new server. If you have audit errors / warnings that you don't understand how to fix, please contact KVS support.
  18. Signle Sign On (SSO) login feature is designed to provide easy integration of members from one site, either KVS or 3rd-party engine, into another KVS site. SSO requires user to have an active profile on original site and being logged in there. Then it is possible to render a special encrypted link from source site to KVS site and by clicking this link user will be automatically logged in to KVS site without need to register, or enter their credentials. So users will not even notice that they are being logged in to another site behind the scene. KVS will automatically create user's account in KVS database using some information provided in the encrypted link. Here are most common scenarios for using SSO in your projects: 1) You have a forum or any other site and you want to allow your forum users to upload videos into KVS, which could be installed somewhere in videos.domain.com subdomain. With very few lines of code on your forum's end you can link your forum pages to KVS upload page or KVS profile page without any other integration effort. 2) You have a primary KVS paysite and you want to provide additional access to several bonus sites also built with KVS. In this case you can build a page with listing bonus sites and providing SSO login link for every site. There are some limitations using SSO that should be well acknowledged: Users that are created by SSO will all have Active status. This means that if your KVS site has some content available to paid members only, it should be configured for Active members, not for Premium members. Users should not be allowed to register or login using other methods. SSO can't check for username or email duplicates and it basically expects that all your users are unique and managed in other application (e.g. forum or primary KVS site). By providing SSO link to your users you guarantee that each user has unique username and email. Creating SSO page in target KVS site Please go to Website UI -> Pages -> Add page and create a new page with the following data: - Title: SSO - External ID: sso - Template code: {{insert name="getBlock" block_id="logon" block_name="SSO login"}} Save and open SSO login block that will appear in this page editor after saving. In block's template code put anything that you want to be displayed in case of unexpected error, e.g.: The link you are using is not valid, please contact support Under block parameters enable these 2 (change secretkey to something random): - single_sign_on (String): secretkey - redirect_to (String): / Then save and you are done with KVS settings. Displaying SSO login links on source sites Here is the example code you need to use in your forum on any other 3rd-party site to display login link. Please note that it should only be displayed to users that are already logged in with your forum or site. Also this link should not be cached and it should be displayed in real time. Each link will expire after 1 hour. $username = 'admin'; $email = 'admin@site.com'; $time = time(); $secret_key = 'secretkey'; $sso_token = [ 'username' => $username, 'email' => $email, 'token' => $time, 'digest' => md5($username . $time . $secret_key) ]; echo "https://domain.com/sso.php?sso=" . base64_encode(json_encode($sso_token)); If you are using KVS on the other end as well, you can use the following code in KVS template (make sure to change secretkey and domain.com with your real data): {{if $smarty.session.user_id>0}} {{php}} $username = $_SESSION['user_info']['username']; $email = $_SESSION['user_info']['email']; $time = time(); $secret_key = 'secretkey'; $sso_token = [ 'username' => $username, 'email' => $email, 'token' => $time, 'digest' => md5($username . $time . $secret_key) ]; $this->assign('sso_link', "https://domain.com/sso.php?sso=" . base64_encode(json_encode($sso_token))); {{/php}} <a href="{{$sso_link}}" target="_blank">Click here to login to domain.com</a> {{/if}}
  19. KVS will allow embedding your content from anywhere by default. If you want to completely disallow embedding your videos on other sites, please check this guide: How to disable embedding your content on other sites and redirect embeds to your site Blacklisting domains You can see which 3rd-party domains embed your videos in Stats -> Embed usage. These stats may contain data for long period, so it makes sense to use filters to limit data to the last week or month. If you want to disallow specific domains from using your embed codes, go to Settings -> Embed player settings and specify blacklisted domains under Embed code access limitation: Whitelisting domains Another common configuration scenario is when you want to only allow your other projects to embed your videos, and disallow any other 3rd-party sites. This should be configured in 2 steps: 1) Go to Settings -> Embed player settings and create a new Embed player profile. Specify whitelisted domains under this profile settings and make sure this profile is configured as you need (e.g. video formats display, advertising), because the new profile will only copy few display options from default profile: 2) In Settings -> Embed player settings switch to default Embed player profile and under Video formats display remove all slots: Such settings will prevent embedding your videos on all sites except domains listed under Whitelisted embed profile that you created in step 1. If you need to whitelist more domains, just edit Whitelisted profile and add more domains. If you need different embed player settings on different whitelisted domains, you can create more embed player profiles up to a single profile per domain: each with unique settings, e.g. branding or advertising.
  20. KVS can be used as a backend for any other frontend technology, such as mobile apps, rich desktop apps and etc. While KVS doesn't have API in its traditional sense, virtually any API can be created using KVS Website UI builder feature. In this article we will provide example on creating JSON API for displaying list of videos, video player and data for any video, as well as processing signup and login actions. The very same approach can be extended to any other data supported by KVS: categorization, posts, photos and other. It is expected that you also have some client code (typically implemented using some other technology) that can send HTTP GET / POST requests, parse JSON responses and render data in some way. This code is up to you and not explained in this article. Creating API page The idea is to create a single page that will host all blocks providing the needed data and functionality. You will need this page to set up block settings. Then you will use async method of querying and posting data to communicate with individual blocks on this page. First, create a new page In Website UI -> Pages section of admin panel. Give it any name (e.g. API) and any external ID (e.g. api). Add 4 blocks to this page: list_videos block to query various lists of videos with different sorting and filtering options; video_view block to query data for each video; signup block to process signup requests and register new users; logon block to process login requests and authenticate existing users. There is no need to do any code formatting here, as we are not going to display this page in a direct way: {{insert name="getBlock" block_id="list_videos" block_name="API videos"}} {{insert name="getBlock" block_id="video_view" block_name="API video view"}} {{insert name="getBlock" block_id="signup" block_name="API signup"}} {{insert name="getBlock" block_id="logon" block_name="API logon"}} After you save this page, you will see 4 blocks appear under it where you need to configure options and their templates. Displaying video list Open API videos block for editing. In template use the following code: {{php}} header('Content-Type: application/json'); {{/php}} [{{foreach name="data" item="item" from=$data}} { "video_id": {{$item.video_id|default:0}}, "title": {{$item.title|json_encode}}, "description": {{$item.description|json_encode}}, "duration": {{$item.duration|default:0}}, "screen_url": {{$item.screen_url|json_encode}}, "screen_main": {{$item.screen_main|default:0}}, "screen_amount": {{$item.screen_amount|default:0}}, "video_viewed": {{$item.video_viewed|default:0}}, "rating": {{$item.rating|default:0}}, "rating_amount": {{$item.rating_amount|default:0}}, "post_date": {{$item.post_date|json_encode}}, "view_page_url": {{$item.view_page_url|json_encode}}, {{if count($item.categories)>0}} "categories": [{{foreach name="data_categories" item="item_categories" from=$item.categories}}{"id": {{$item_categories.category_id|default:0}}, "title": {{$item_categories.title|json_encode}}, "dir": {{$item_categories.dir|json_encode}}}{{if !$smarty.foreach.data_categories.last}},{{/if}}{{/foreach}}], {{/if}} {{if count($item.tags)>0}} "tags": [{{foreach name="data_tags" item="item_tags" from=$item.tags}}{"id": {{$item_tags.tag_id|default:0}}, "title": {{$item_tags.title|json_encode}}, "dir": {{$item_tags.dir|json_encode}}}{{if !$smarty.foreach.data_tags.last}},{{/if}}{{/foreach}}], {{/if}} {{if count($item.models)>0}} "models": [{{foreach name="data_models" item="item_models" from=$item.models}}{"id": {{$item_models.model_id|default:0}}, "title": {{$item_models.title|json_encode}}, "dir": {{$item_models.dir|json_encode}}}{{if !$smarty.foreach.data_models.last}},{{/if}}{{/foreach}}], {{/if}} {{if count($item.content_source)>0}} "content_source": {"id": {{$item.content_source.content_source_id|default:0}}, "title": {{$item.content_source.title|json_encode}}, "dir": {{$item.content_source.dir|json_encode}}}, {{/if}} {{if count($item.dvd)>0}} "dvd": {"id": {{$item.dvd.dvd_id|default:0}}, "title": {{$item.dvd.title|json_encode}}, "dir": {{$item.dvd.dir|json_encode}}}, {{/if}} {{if count($item.user)>0}} "user": {"id": {{$item.user.user_id|default:0}}, "display_name": {{$item.user.display_name|json_encode}}}, {{/if}} "type": "{{if $item.is_private==2}}premium{{elseif $item.is_private==1}}private{{else}}public{{/if}}", "status": "{{if $item.status_id==0}}inactive{{elseif $item.status_id==1}}active{{elseif $item.status_id==2}}error{{elseif $item.status_id==3}}processing{{elseif $item.status_id==4}}deleting{{elseif $item.status_id==5}}deleted{{/if}}", "is_hd": {{if $item.is_hd==1}}true{{else}}false{{/if}} }{{if !$smarty.foreach.data.last}},{{/if}} {{/foreach}}] This code is designed to render list of video items in JSON formatting instead of typical HTML formatting. NOTE: there are basically 2 general rules of rendering JSON code with Smarty template. Use |json_encode modifier to format strings, as strings need some quoting using double quotes and escaping of system characters. Also use |default:0 modifier to format numbers, this will make sure that at least 0 will be displayed and JSON formatting will not be broken. In block parameters do the following: make sure you configure items_per_page and enable var_items_per_page if you want to display lists with different number of items per page; make sure you enable var_from parameter to be able to use pagination; make sure you configure sort_by and enable var_sort_by; enable all var_xxx parameters under Dynamic filters; you can use them for displaying filtered lists, e.g. by category, or by tag; enable var_search parameter and configure other search related options as needed under Search videos by text; enable show_categories_info, show_tags_info, show_models_info, show_content_source_info, show_dvd_info, show_user_info under Select additional data for each video only for data that you want to display in your list; please note that these parameters have a huge performance impact. Now if your page was created with api external ID, you can display your videos list sending GET request to this base URL: https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=list_videos_api_videos NOTE: if you want to query data from another block (e.g. categories list, albums list), replace list_videos_api_videos in URL with the unique ID of your other block added to API page. In Firefox, you should see this URL formatted as JSON array: In order to use pagination, sorting or filters, simply add the needed parameters to the base URL: https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=list_videos_api_videos&from=2 https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=list_videos_api_videos&sort_by=rating https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=list_videos_api_videos&category_id=2 Displaying video info Open API video view block for editing. In template use the following code: {{php}} header('Content-Type: application/json'); {{/php}} { "video_id": {{$data.video_id|default:0}}, "title": {{$data.title|json_encode}}, "description": {{$data.description|json_encode}}, "duration": {{$data.duration|default:0}}, "screen_url": {{$data.screen_url|json_encode}}, "screen_main": {{$data.screen_main|default:0}}, "screen_amount": {{$data.screen_amount|default:0}}, "video_viewed": {{$data.video_viewed|default:0}}, "rating": {{$data.rating|default:0}}, "rating_amount": {{$data.rating_amount|default:0}}, "post_date": {{$data.post_date|json_encode}}, "view_page_url": {{$data.canonical_url|json_encode}}, {{if count($data.categories)>0}} "categories": [{{foreach name="data_categories" item="item_categories" from=$data.categories}}{"id": {{$item_categories.category_id|default:0}}, "title": {{$item_categories.title|json_encode}}, "dir": {{$item_categories.dir|json_encode}}}{{if !$smarty.foreach.data_categories.last}},{{/if}}{{/foreach}}], {{/if}} {{if count($data.tags)>0}} "tags": [{{foreach name="data_tags" item="item_tags" from=$data.tags}}{"id": {{$item_tags.tag_id|default:0}}, "title": {{$item_tags.title|json_encode}}, "dir": {{$item_tags.dir|json_encode}}}{{if !$smarty.foreach.data_tags.last}},{{/if}}{{/foreach}}], {{/if}} {{if count($data.models)>0}} "models": [{{foreach name="data_models" item="item_models" from=$data.models}}{"id": {{$item_models.model_id|default:0}}, "title": {{$item_models.title|json_encode}}, "dir": {{$item_models.dir|json_encode}}}{{if !$smarty.foreach.data_models.last}},{{/if}}{{/foreach}}], {{/if}} {{if count($data.content_source)>0}} "content_source": {"id": {{$data.content_source.content_source_id|default:0}}, "title": {{$data.content_source.title|json_encode}}, "dir": {{$data.content_source.dir|json_encode}}}, {{/if}} {{if count($data.dvd)>0}} "dvd": {"id": {{$data.dvd.dvd_id|default:0}}, "title": {{$data.dvd.title|json_encode}}, "dir": {{$data.dvd.dir|json_encode}}}, {{/if}} {{if count($data.user)>0}} "user": {"id": {{$data.user.user_id|default:0}}, "display_name": {{$data.user.display_name|json_encode}}}, {{/if}} "type": "{{if $data.is_private==2}}premium{{elseif $data.is_private==1}}private{{else}}public{{/if}}", "status": "{{if $data.status_id==0}}inactive{{elseif $data.status_id==1}}active{{elseif $data.status_id==2}}error{{elseif $data.status_id==3}}processing{{elseif $data.status_id==4}}deleting{{elseif $data.status_id==5}}deleted{{/if}}", {{if $data.status_id==5}} "delete_reason": {{$data.delete_reason|json_encode}}, {{/if}} {{if count($data.formats)>0}} "files": [{{foreach name="data_formats" item="item_formats" from=$data.formats}}{"postfix": {{$item_formats.postfix|json_encode}}, "duration": {{$item_formats.duration|default:0}}, "filesize": {{$item_formats.file_size|default:0}}, "url": {{$item_formats.file_url|json_encode}}}{{if !$smarty.foreach.data_formats.last}},{{/if}}{{/foreach}}], {{/if}} "is_hd": {{if $data.is_hd==1}}true{{else}}false{{/if}} } In block parameters make sure to enable var_video_id parameter. Use the following GET request to query video data for any specific video by passing its ID in the URL parameters: https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=video_view_api_video_view&id=123 In Firefox, you should see this URL formatted as JSON object: Sending signup request Open API signup block for editing and modify its parameters as needed. Probably you need to activate disable_captcha parameter so that captcha is not required during signup. There is no need to change anything in template, because in most cases you will render signup form in your app and will only use KVS signup block to process requests. In cases with paid access you will need to display access packages to your users, then use this template code: {{php}} header('Content-Type: application/json'); {{/php}} [{{foreach name="data" item="item" from=$card_packages}} { "access_package_id": {{$item.package_id|default:0}}, "title": {{$item.title|json_encode}} }{{if !$smarty.foreach.data.last}},{{/if}} {{/foreach}}] In order to use signup functionality you should send POST request to the following base URL: https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=signup_api_signup To see which fields should be sent, take a look at default template of signup block, which renders all supported fields: action = signup username = <username> pass = <password> pass2 = <password confirmation> email = <email> ... Also make you to include these fields with each POST request to make sure response is formatted correctly: mode = async format = json As a result of your POST request you should get success or failure response with the list of errors. Sending login request Login functionality is very similar to signup. Open API logon block and configure parameters as needed. Ignore its template code. In order to log user in you should send POST request to the following base URL: https://kvs-demo.com/api.php?mode=async&function=get_block&block_id=logon_api_logon Specify the following data in POST fields: mode = async format = json action = login username = <username or email> pass = <password> As a result of your POST request you should get success or failure response with the list of errors. NOTE: KVS uses PHP session functionality to manage user sessions. This functionality sends PHPSESSID cookie with every response and requires you to send it back with every request. You must send this cookie with every request to have member-specific functionality working.
  21. Please follow these steps to configure your VestaCP to use KVS Nginx rules. 1) Find out which rules you need first. Go to Settings -> Storage servers and open every storage that is located on this specific physical server (usually Local Videos and Local Albums). Each storage server displays Nginx config rules that you should add (storage servers for albums typically do not have any rules): Copy-paste all rules into the same text file one by one, if you have them from multiple storage servers. 2) Use WinSCP program to connect to your server via SFTP protocol as a root user. Open /home/admin/conf/web directory and create 2 text files in this directory: nginx.kvs-demo.com.conf_kvs snginx.kvs-demo.com.conf_kvs NOTE: replace kvs-demo.com with your domain name, you can see some similar files in this directory and you can check how your domain name is spelled in these files. Use the same spelling. Put the same nginx rules into both created files: the rules that you've copied on step 1. 3) Login to VestaCP with root account. Go to Server tab on the top. Find Nginx service, mouse over it and use restart option: 4) Finished. In order to check, go to Plugins -> System audit in KVS admin panel and run Installation, Servers and Content Protection checks. You should not have any errors and warning regarding content protection.
  22. You can use KVS advertising feature in Website UI -> Advertising section to limit some parts of HTML code to be displayed for specific categories or to be excluded for specific categories. Go to advertising and create spot (Add Spot option). After creating a new spot, you will see its insert code that you should use in template where you need to display some advertising or HTML code of your choice: After inserting advertising spot into template, you can add advertising to it and select whether this advertising should be displayed only for specific categories or should be excluded for specific categories: These restrictions will include: Video lists for the given categories (e.g. these pages https://www.kvs-demo.com/categories/rock-music/) Video pages for all videos from the given categories (e.g. these pages https://www.kvs-demo.com/videos/181/boyce-avenue-dynamite/) Album lists for the given categories (e.g. these pages https://www.kvs-demo.com/albums/categories/rock-music/) Album pages for all albums from the given categories (e.g. these pages https://www.kvs-demo.com/albums/74/dan-mihai-b-lan/)
  23. Multiple conversion servers can be used only in KVS ultimate package. They will let you reduce CPU load on main server and make video conversion faster, but only to some point. It is a common misunderstanding to assume that the more conversion servers you add, the more videos can be converted for the same time. This is not always true. The overall conversion speed depends not only on the actual conversion (e.g. video encoding), but on many other factors as well. Please read more about KVS conversion engine here. Adding new conversion server in KVS System requirements for a conversion server in KVS: PHP 7.1+ IonCube Loader 10.2+ (not required if your have open source code option with your license) PHP Client URL Library (curl) PHP FTP PHP Image Processing and GD PHP.ini disable_functions should not contain "exec" FFmpeg 1.0+ with libx264, libavfilter and AAC codec (libfaac, libfdk_aac or native ffmpeg aac codec) ImageMagick You can add a content server in admin panel in Settings -> Conversion servers. For Maximum tasks option it is recommended to keep it in 5-10 interval. This option doesn't mean how many tasks are executed in parallel; instead it affects how many tasks are uploaded to this conversion server. High values for this option may result on overall conversion performance degradation. For Optimize content copying options we provided complete explanation in this post. The next set of options are related to server connection. KVS uses these settings to copy tasks to conversion servers. In most cases you will need to specify FTP connection details here. The most confusing option here can be FTP folder. In order to specify it correctly you should first login to your FTP using standard FTP client and see where you come into. It can be possible that your FTP is directly configured to the needed folder, but in most cases FTP will be configured into home folder of FTP user or www root folder. NOTE: conversion folder doesn't require any HTTP access to it. Therefore it can be ANY folder on your remote server, but it should be unique and should belong to only 1 conversion server in KVS. Here is an example configuration for a remote conversion server: Configuring cron on remote conversion server NOTE: on conversion server with local connection you don't need to add any cron schedule for it, it will be automatically executed by KVS engine. After conversion server is created in KVS and its connection is validated, KVS will copy remote_cron.php file into the specified remote folder. This file is needed to perform remote conversion tasks. In order for it to start working, you should put it on cron every minute using the following command (please note that you should specify the valid filesystem path to remote_cron.php script): php /path/to/remote_cron.php > /dev/null 2>&1 Once configured, this script will create several files in the same folder, which will mean that this command works fine. KVS will change status for this conversion server from Initializing to Active within 5 minutes. After switching to Active status this server will be utilized by KVS conversion engine and will start processing conversion tasks. Troubleshooting issues KVS will validate basic issues when you try to save server settings in admin panel. After you add server, KVS will validate it on background every 5 minutes to check if it operates successfully. Even if initially you didn't have any errors, new errors may appear later due to various factors. First, FTP connection or remote server configuration may be changed externally and some functionality will simply stop working. All issues found on background are immediately reported to KVS start page as they all are considered CRITICAL and may indicate that your remote server is not working correctly and conversion may be blocked. You should make sure to fix them ASAP. Errors from background checks are not very detailed and just indicate some set of issues. In order to get more details you should try to save server settings in admin panel. NOTE: if server reports an error and you have already fixed it, please give it 5 minutes to do re-check and verify this error is fixed. Until that, server may still show this error. This only applies for background checks on existing servers. When you save server settings in admin panel, all issues are validated right a way without any delay. If saving server in admin panel still shows validation errors, these errors are not yet fixed. Here is the list of errors you can get when saving server settings: - This connection folder is already used by another server. This issue means that you are trying to configure this server into a folder, which is already used by another storage or conversion server. You should never do this, each storage or conversion server in KVS should be configured into a separate folder on filesystem. - Unable to connect to host : post. KVS is not able to connect to the specified FTP host or port. If the entered data is valid, most probably your FTP is protected by firewall and you should make sure that your main server's IP is whitelisted. Also sometimes your FTP may be configured for using non standard FTP port, you should check this as well. - Unable to login with credentials provided. Either FTP username or password is not valid. - Put / get / chmod / delete operations failed, insufficient permissions possible. When validating server connection, KVS will try to put a test file to the server and then delete it. You will get this error if any of the mentioned operations failed, which probably indicates wrong FTP folder or FTP configuration issue. Try to log in to FTP manually using desktop FTP client and try to copy any file into the specified folder. Can you do this manually? Also this error can happen if /tmp folder on your main KVS installation does not exist or is not writable. In order to check that go to Plugins -> Audit and run installation check. It will show error for tmp folder if anything is wrong. - No PHP extension for FTP was found. Your remote server's PHP doesn't have support for FTP module and therefore it is not possible to enable allow this server to copy content to storage servers option for this server. - No PHP extension for CURL was found. Your remote server's PHP doesn't have support for CURL module and therefore it is not possible to enable allow this server to pull source files from primary server option for this server. - Conversion script not configured / not working on this server. - Conversion script is not working. - Conversion script executed more than 15 minutes ago. These errors indicate that your remote server either doesn't have a cron task to execute remote_cron.php script every minute, or executing this script results in critical PHP error. Please check if you have cron task set. If you have it, then try executing this command manually from command line to see its output (please note that you should specify the valid filesystem path to remote_cron.php script): php /path/to/remote_cron.php In some cases if your remote server has another timezone than your main server, KVS may think that its remote_cron.php script is not executed, while it does. Open conversion server settings in KVS admin panel and specify its timezone offset under Configuration. Save conversion server settings and give it 5 minutes to re-check and remove this error. - Some libraries are not configured correctly on this server. This error indicates that KVS was not able to locate ffmpeg / imagemagick executables on your remote server. First of all you should make sure that these libraries are installed on the server. If not - please install them. If the libraries are installed, then most probably their binaries are not located using standard paths. Open conversion server settings in KVS admin panel and specify the correct paths for libraries that were not detected correctly under Configuration. Save conversion server settings and give it 5 minutes to re-check and remove this error.
  24. With the new KVS 5.0 we fully changed the code base for payment processing in KVS, so that it now becomes relatively easy for a 3rd-party developer to add support for a custom payment processor and no KVS knowledge is required. This post provides comprehensive instruction on how to do that. Some basic concepts Here is the list of common terms used in KVS payment processing: Payment processor: an external billing or provider that is integrated into KVS and can be used to collect payments from users in any form. Access package: a single purchase item, that either provides unlimited premium access, or premium access with a certain duration, or a number of tokens (KVS internal currency) to the user's account. Typically KVS access package matches the same concept on payment processor's website (but may be called differently, for example "price point"). However when using dynamic pricing, KVS access package doesn't have corresponding item on payment processor's website. Dynamic pricing: a pricing method, when payment processor allows you to charge payments with any reasonable amounts without pre-defining them in payment processor's admin area. In this case you can define price and currency in KVS admin panel and they will work immediately. In comparison to dynamic pricing, static pricing requires you first to define access packages and their prices on payment processor's website, then replicate them in KVS. Only few payment processors in KVS support dynamic pricing. Tokens: KVS internal currency used for purchases inside KVS, such as pay per view, internal subscriptions, donations and messaging. Trials: a concept of providing time-limited access to preview paid content before subscribing with the full price. KVS supports separating trial access from regular paid access and allows using tokens for trial users to limit the number of content they can access before upgrading to premium status. Payment page URL: in KVS all payment processors should support external URL (usually on payment processor's website) that will be used to accept sensitive payment data, such as credit card numbers. Each access package defines its own payment page URL, typically the same URL for all access packages but with different parameter that indicates pre-selected access package or price point. Payment processing flow in KVS KVS uses its own signup or upgrade form in most cases. Exceptions are NATS and MPA3, that provide their own payment solutions and thus have their own signup forms. It is not strictly required to use KVS signup form when processing payments, but if you want to use external signup form, you should make sure that your postback script is verifying uniqueness of usernames being registered. Users first submit their registration data (typically username, password, email and access package selection) to KVS signup or upgrade block, which provide some basic validation logic. After the data is fully validated, KVS will redirect to the payment page URL of the selected access package, typically hosted on payment processor's website. Payment processor will in most cases duplicate the data that was entered into KVS registration form and also query payment info, such as credit card or another methods. After user's data is validated on payment processor's end, payment processor will execute KVS postback script and notify about initial signup or declined transaction. Users will then be redirected to KVS website where they can enter username / password they have chosen during registration and log in. Most payment processors also provide ability to notify KVS postback about other payment events that may happen during subscription cycle: rebills refunds chargebacks These are coming on background and are not connected to any user interaction. Adding payment processor support Please follow these steps to add new payment processor support into KVS. 1) Choose internal ID for a new processor: a short string without any spaces, e.g. myprocessor. 2) Add information about payment processor into KVS database: insert into `ktvs_card_bill_providers`(`internal_id`,`title`,`url`,`cf_pkg_trials`,`cf_pkg_rebills`,`cf_pkg_tokens`,`cf_pkg_oneclick`,`cf_pkg_setprice`) values ('myprocessor', 'My Processor', 'https://www.myprocessor.com', 0, 0, 0, 0, 0); The last 5 boolean columns should be set to 1 if your payment processor supports the following concepts: cf_pkg_trials: set 1 if trials are supported cf_pkg_rebills: set 1 if recurring payments are supported cf_pkg_tokens: set 1 if tokens are supported cf_pkg_oneclick: set 1 if one click upgrade is supported cf_pkg_setprice: set 1 if this is dynamic pricing payment processor 3) Create payment processor PHP postback file /admin/billings/myprocessor/myprocessor.php (should match your processor's internal ID) with the following template: <?php $is_postback_request = false; if (!isset($config) || !is_array($config)) { $is_postback_request = true; require_once("../../include/setup.php"); } require_once("$config[project_path]/admin/billings/KvsPaymentProcessor.php"); class KvsPaymentProcessorMyProcessor extends KvsPaymentProcessor { public function get_provider_id() { return "myprocessor"; } protected function get_logged_request_params() { // list all postback parameters that you want to be logged return array("param1", "param2", "param3"); } protected function get_shredded_request_params() { // list all logged postback parameters that you want to be replaced with [deleted], so that personal info such as email or password didn't get into logs in open form return array("password", "email", "ip", "country"); } protected function requires_auto_expire() { // return true if payment processor will not use postback to expire members and thus KVS needs to do that automatically // this is typically true for processors that do not support rebills or have very limited functionality return false; } public function get_payment_page_url($access_package, $signup_page_url, $user_data) { $url = $access_package["payment_page_url"]; // this is the URL configured in access package settings $username = $user_data["username"]; // this is the submitted username $password= $user_data["pass"]; // this is the submitted password, if user is using signup block (will be empty if user is already logged in and is using upgrade block) $email = $user_data["email"]; // this is the submitted email // return payment processor page URL where user should be redirected for payment processing // typically username, password and email are added so that they are pre-populated on payment processor's website return "$url"; } protected function process_request_impl() { // process external request to this postback and return true if processing is successful // typically check $_REQUEST values to define whether this is initial signup or rebill, or anything else and fallback to parent method return true; } protected function process_schedule_impl() { // process any scheduled tasks here, executed every 10 minutes } } if ($is_postback_request) { if (strpos($_SERVER["REQUEST_URI"], $_SERVER["SCRIPT_NAME"]) !== false) { header("HTTP/1.0 403 Forbidden"); die; } $processor = new KvsPaymentProcessorMyProcessor(); if ($processor->process_request()) { echo "OK"; } else { echo "ERROR"; } } KvsPaymentProcessorFactory::register_payment_processor("myprocessor", "KvsPaymentProcessorMyProcessor"); Here are KvsPaymentProcessor's methods that you can use to handle specific types of events: // initial signup gets declined by payment processor, KVS should increment decline stats $this->process_decline($transaction_id); // returns true if such username already registered; false otherwise $this->process_username_check($username); // processes initial subscription or tokens purchase for a user; if no such user already registered ($username check), KVS will create one with the given username, password, email, IP and country code // provide the valid $access_package_id that matches KVS access package external ID, so that KVS can correctly define access level for this purchase (either premium for N days, or M tokens) // $transaction_guid may be set the same as $transaction_id $this->process_purchase($transaction_id, $transaction_guid, $subscription_id, $price, $currency_code, $access_package_id, $is_trial, $username, $password, $email, $ip, $country_code, $duration_initial = 0, $duration_rebill = 0); // processes rebill or conversion (trial -> regular subscription) for a user; if no such user already registered ($subscription_id, then $username check), KVS will create one with the given username, password, email, IP and country code, or if they are not provided, then this function will result in error // $transaction_guid may be set the same as $transaction_id $this->process_rebill_or_conversion($transaction_id, $transaction_guid, $subscription_id, $price, $currency_code, $access_package_id = "", $username = "", $password = "", $email = "", $ip = "", $country_code = ""); // processes chargeback for the given transaction ($related_transaction_id), otherwise if not specified for the last open transaction of the given subscription ($subscription_id) or user ($username) $this->process_chargeback($transaction_id, $transaction_guid, $subscription_id, $price, $currency_code, $related_transaction_id = "", $username = ""); // processes refund for the given transaction ($related_transaction_id), otherwise if not specified for the last open transaction of the given subscription ($subscription_id) or user ($username) $this->process_refund($transaction_id, $transaction_guid, $subscription_id, $price, $currency_code, $related_transaction_id = "", $username = ""); // processes void for the given transaction ($related_transaction_id), otherwise if not specified for the last open transaction of the given subscription ($subscription_id) or user ($username) $this->process_void($transaction_id, $transaction_guid, $subscription_id, $price, $currency_code, $related_transaction_id = "", $username = ""); // expires access of the given subscription ($subscription_id) or user ($username) $this->process_expiration($subscription_id, $username = ""); // should be used when payment processor doesn't support postbacks for access expiration; may notify KVS that this subscription ($subscription_id) or user ($username) stopped subscription and it should be automatically expired when its end date comes $this->process_cancellation($subscription_id, $username = ""); // use for your custom log messages, where $message_type is one of the following: self::MESSAGE_TYPE_DEBUG, self::MESSAGE_TYPE_ERROR, self::MESSAGE_TYPE_INFO $this->log_message($message_type, $message_text, $message_details = ""); 4) In order to debug your postback code you should first find its URL, which is randomly generated for every project and is visible in admin panel in payment processor settings: You can use this URL to test requests to your postback by passing the needed parameters via GET query.
×
×
  • Create New...