Allora, proviamo ad abbozzare!
ho creato un file html per inserire i dati che andranno inseriti nel file "example.py":
Codice:
<!DOCTYPE html>
<html lang="it">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="resources/css/layout.css">
<script type="text/javascript" src="resources/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="resources/js/custom.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<header>
<h2 class="logo">Vincistabot</h2>
<h1>Vincistabot</h1>
</header>
<section>
<div class="content-wrapper-dark">
<h2>Compila il tuo instagram Bot</h2>
<hr class="big-dashed" />
<h3>login</h3><input class="input-social" type="text" value="username" />
<h3>password</h3><input class="input-social flt-lft" type="password" value="password" />
<br class="clearfix" />
<h3>like per day</h3><input class="input-social" type="text" value="1000" />
<h3>tag list (separati da una virgola)</h3><input class="input-social" type="text" value="follow4follow" />
<h3>follow per day</h3><input class="input-social flt-lft" type="text" value="50" /><br class="clearfix" />
<h3>unfollow per day</h3><input class="input-social flt-lft" type="text" value="50" /><br class="clearfix" />
<h3>comments (separati da una virgola)</h3><input class="input-social flt-lft" type="text" value="wow, beautiful" />
<br class="clearfix" />
<button class="button-go button-go2 flt-lft">VAI</button><br class="clearfix" />
</div>
</section>
<footer>
</footer>
</div>
</body>
</html>
con questo layout.css
Codice:
.flt-lft{
float:left;
}
.flt-rgt{
float:right;
}
.container{
position:relative;
margin:auto;
width:640px;
height:960px;
background:#999;
}
header{
position:relative;
height:188px;
overflow:hidden;
background:#2f2f2f;
box-shadow:0 -2px 7px rgba(0,0,0,.3);
}
h1{
position:absolute;
z-index:9;
width:100%;
text-transform:uppercase;
font-size:24px;
line-height:44px;
bottom:0;
font-family:helvetica,arial,sans-serif;
color:#333;
text-align:center;
background:#ffde00;
/*box-shadow:10px 1px 10px rgba(0,0,0,1);*/
}
section{
background:#2f2f2f;
height:606px;
overflow:auto;
padding-bottom:100px;
}
.header-item{
color:#ff8400;
text-transform:uppercase;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
display:block;
font-size:24px;
line-height:18px;
}
.item-img{
width:96px;
}
.item-img img{
padding:3px;
background:#fff;
}
.header-update{
color:#2f2f2f;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
display:block;
font-size:17px;
}
.item-content{
width:80%;
}
.item-drag span{
display:block;
width:52px;
height:12px;
background:url(../img/drag-item-icon.png) no-repeat;
}
.item-rate span{
display:block;
width:41px;
height:36px;
background:url(../img/rating-star.png) no-repeat;
}
.item-rate span.on{
background-position:0 -36px;
}
footer ul{
position:absolute;
z-index:9;
bottom:0;
display:table;
table-layout:fixed;
width:100%;
height:146px;
border-top:solid 20px #fff;
background:#2f2f2f;
box-shadow:0 2px 7px rgba(0,0,0,.3);
}
footer ul li{
width:25%;
display:table-cell;
text-align:center;
height:136px;
text-align:center;
}
footer ul li a{
background-image:url(../img/footer-menu-icons.png);
background-repeat:no-repeat;
display:block;
height:126px;
overflow:hidden;
color:#fff;
font-family:helvetica,arial,sans-serif;
font-size:17px;
line-height:240px;
text-transform:uppercase;
text-decoration:none;
border-top:solid 12px #2f2f2f;
}
footer ul li a.foot-menu-puntate{
background-position:center 30px;
}
footer ul li a.foot-menu-preferiti{
background-position:center -170px;
}
footer ul li a.foot-menu-cerca{
background-position:center -370px;
}
footer ul li a.foot-menu-impostazioni{
background-position:center -570px;
}
footer ul li a:hover{
border-top-color:#ff8400;
}
.content-wrapper{
margin:auto;
background:#fff;
width:96%;
}
.content-wrapper-dark{
margin:auto;
width:96%;
}
.icon-header{
font-size:48px;
color:#ff8400;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
text-align:center;
height:150px;
line-height:150px;
}
.icon-h-search{
padding-left:60px;
background:url(../img/icon-h-search.png) 16% 50% no-repeat;
}
.search-wrapper{
width:420px;
height:108px;
margin:20px auto 0;
}
.search-wrapper input{
font-size:24px;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
border:solid 3px #c2c2c2;
padding:10px;
margin:0;
display:block;
float:left;
width:284px;
height:32px;
}
.button-search{
background:#ff8400;
color:#fff;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
font-size:36px;
line-height:60px;
width:110px;
border:0;
height:58px;
text-transform:uppercase;
margin-left:-2px;
float:right;
cursor:pointer;
}
h2.logo{
position:absolute;
left:50%;
margin-left:-48px;
display:block;
width:70px;
height:98px;
background:url(../img/logo.png) no-repeat;
overflow:hidden;
text-indent:-10000px;
top:23px;
}
.transparent-wrapper{
background: transparent;
}
.content-wrapper-dark h2{
color:#ffde00;
font-family:helvetica,arial,sans-serif;
font-size:26px;
text-align:center;
line-height:45px;
}
.content-wrapper-dark h3{
color:#ffde00;
font-family:Trebuchet,helvetica,arial,sans-serif;
font-size:20px;
padding-top:20px;
line-height:45px;
}
.big-dashed{
border:0;
border-top:dashed 2px #fff;
margin-bottom:20px;
}
.header-social{
background-image:url(../img/bg-social-share.png);
background-repeat:no-repeat;
height:50px;
color:#fff;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
font-size:36px;
line-height: 50px;
margin:15px 0 10px 0;
}
.input-social{
font-size:20px;
padding:7px 15px;
line-height:27px;
font-family:helvetica,arial,sans-serif;
border:solid 3px #c2c2c2;
color:#c2c2c2;
display:block;
border-radius:3px;
margin-bottom:4px;
width:250px;
}
.button-go{
float:left;
font-family:helvetica,arial,sans-serif;
font-size:36px;
text-transform: uppercase;
color:#333;
height:57px;
width:180px;
line-height:65px;
padding:0 25px;
margin-top:2px;
border:0;
cursor:pointer;
}
.button-go2{
background:#ffde00;
}
.button-base{
background:#999;
float:left;
font-family:helvetica,arial,sans-serif;
font-size:36px;
text-transform: uppercase;
color:#fff;
height:17px;
width:180px;
line-height:65px;
padding:0 25px;
margin-top:2px;
border:0;
cursor:pointer;
}
ul.set li{
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
color:#fff;
font-size:24px;
line-height:84px;
height:80px;
}
ul.set li a{
float:right;
width:75px;
height:41px;
text-indent:-10000px;
background:url(../img/switch-settings.png) 0 -100px no-repeat;
margin-top:20px;
}
ul.set li a.on{
background-position: 0 0;
}
.header-privacy{
height:50px;
color:#fff;
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
font-size:36px;
line-height: 50px;
margin:15px 0 10px 0;
text-align:center;
}
ul.privacy li{
font-family:MyriadPro-BoldCond,helvetica,arial,sans-serif;
color:#fff;
font-size:22px;
line-height:29px;
}
naturalmente i testi che leggi in grigetto dentro i form vengono letti sempre dal file "example.py", quando clicco su VAI
si collega alla pagina.php che ha questo codice:
Codice:
<?php
$fp = fopen('instabot/example.py', 'w');
fwrite($fp, '#!/usr/bin/env python ...');
fclose($fp);
require('class.php');
$crontab = new Ssh2_crontab_manager('host', 'port', 'my_username', 'my_password');
$crontab->append_cronjob('01 06 * * * /home/chand/instabot/example.py');
?>
il codice andrebbe modificato per fare in modo che il file venga duplicato e rinominato (ad es. viene rinominato con l'username inserito nel form, in questo caso "chandler.py") e che i dati vengano memorizzati tramite
fwrite (anche se non ho capito come si faccia esattamente). La classe viene richiamata tramite
require e sarà invece contenuta nel file class.php
nell'
Ssh2_crontab_manager inserisco i dati di accesso al mio server ma non so come far corrispondere il cron al file che è appena stato duplicato e rinominato.
Infine nel file class.php ci va questo codice (anche qui vorrei capire cosa inserire in ogni
function):
Codice:
Class Ssh2_crontab_manager {
private $connection;
private $path;
private $handle;
private $cron_file;
function __construct() {...}
public function exec() {...}
public function write_to_file() {...}
public function remove_file() {...}
public function append_cronjob() {...}
public function remove_cronjob() {...}
public function remove_crontab() {...}
private function crontab_file_exists() {...}
private function error_message() {...}
}
so che le idee sono ancora un pò confuse, ma ho cercato di mettere tutto in ordine... dimmi se il ragionamento è corretto
Grazie
Chand