SNIPPETS Python And Php
#16
Bellow is a form the you enter text like a couple of posts up but
this time the text will be encoded so its gibberish
in till its read by the python script bellow

PHP---TEXT-----ENCODE
PYTHON-----TEXT-----DECODE

PHP Code:
#Make Sure You Import base64 at the top of your addon
import base64 

PHP Code:
# This Text Goes After your Imports It Reads The .TXT Or .PHP
# File From Location Below The File Reads SGVsbG8gVGhpcyBpcyBhIHRlc3Qg
message=urllib.urlopen('http://YOURSITE/update.txt').read() 

PHP Code:
# Example of decoding file above and using it as the name
# the text will be decoded changing SGVsbG8gVGhpcyBpcyBhIHRlc3Qg
# to "hollo this is a text"  
addDir('%s'%(message).decode('base64'),'URL',1,'ICON'


Save File As form.php
PHP Code:
<form action="write.php" method="get" id="text">
        <
input name="text" type="text" />
  <
input type="submit" name="Submit" />
</
form
save file as write.php
PHP Code:
#the only change i had to make to encode it is add base64_encode($_GET['text'])
#if you wish for normal txt change base64_encode($_GET['text']) $_GET['text'] 
# removing base64_encode and one set of brackets ()
<?php
$file 
fopen("update.txt","w");
echo 
fwrite($file,base64_encode($_GET['text']));
fclose($file);
echo 
' File Saved';
?>
Reply
#17
(2015-05-02, 00:06)pipcan Wrote: Show A Message On First Run Once

PHP Code:
# ADD This to your setttings.xml 
<setting id="firstrun" type="bool" label="First Run" default="false" visible="true"/>

# Add To Top Of Addon After The Imports
#The ADDON is just to make it easier in the future instead of writing plugin.video.YOUPLUGINNAME
# you can Just use ADDON Now Addon Meens plugin.video.YOURPLUGINNAME
#                                            v------- The Name of Your Plugin
ADDON xbmcaddon.Addon(id='plugin.video.YOURPLUGINNAME')
# Now Reading Settings ID firstrun To See If It Equals true else continue
firstrun=xbmcplugin.getSetting(int(sys.argv[1]), 'firstrun')
if 
firstrun == 'true':
    
dialog xbmcgui.Dialog()
    
dialog.ok("HEADING"" ENTER YOUR TEXT HERE " )
    
ADDON.setSetting('firstrun','false'

Great stuff, Thanks! exactly what I needed!!!
Reply

Logout Mark Read Team Forum Stats Members Help
SNIPPETS Python And Php1