PConnect($DBHOST, $DBUSER, $DBPASSWORD, $DBNAME); $sql = "SELECT * from sconfig"; $rsc = $conn->Execute($sql); if($rsc){while(!$rsc->EOF) { $field = $rsc->fields['soption']; $config[$field] = $rsc->fields['svalue']; STemplate::assign($field, $config[$field]); @$rsc->MoveNext(); }} STemplate::assign('bgcolor','#E8E8E8'); STemplate::assign('BASE_URL', $config['BASE_URL']); STemplate::assign('BASE_DIR', $config['BASE_DIR']); STemplate::assign('IMG_URL', $config['IMG_URL']); STemplate::assign('baseurl', $config['BASE_URL']); STemplate::assign('basedir', $config['BASE_DIR']); STemplate::assign('imgurl', $config['IMG_URL']); STemplate::assign('vdourl', $config['VDO_URL']); STemplate::assign('adourl', $config['ADO_URL']); STemplate::assign('flvdourl', $config['FLVDO_URL']); STemplate::assign('tmburl', $config['TMB_URL']); STemplate::assign('photourl', $config['PHO_URL']); STemplate::assign('captcha', $config['captcha']); STemplate::assign('downloads', $config['downloads']); STemplate::assign('site_name', $config['site_name']); STemplate::setCompileDir($config['basedir']."/templates_c"); STemplate::setTplDir($config['basedir']."/templates"); // joempie playak added next for cookie auto-login // also required small changes in login.php and logout.php function rememberme($remember = 1) { if ($remember) setcookie('rememberme', gzcompress(serialize(array($_SESSION[USERNAME], $_SESSION[pwd]))), time()+60*60*24*365); else setcookie ("rememberme", "", time()-3600); } if (!isset($_SESSION["USERNAME"])) { if (isset($_COOKIE['rememberme'])) { list($username, $pwd) = @unserialize(gzuncompress(stripslashes($_COOKIE['rememberme']))); $q="SELECT * FROM signup WHERE username='$username' AND pwd='$pwd' AND account_status='Active'"; $r = $conn->execute($q); if($r->recordcount()) { SESSION_REGISTER("myUID");$_SESSION['myUID']=$r->fields['UID']; SESSION_REGISTER("UID");$_SESSION['UID']=$r->fields['UID']; SESSION_REGISTER("EMAIL");$_SESSION['EMAIL']=$r->fields['email']; SESSION_REGISTER("USERNAME");$_SESSION['USERNAME']=$r->fields['username']; SESSION_REGISTER("pwd");$_SESSION['pwd']=$r->fields['pwd']; SESSION_REGISTER("EMAILVERIFIED");$_SESSION['EMAILVERIFIED']=$r->fields['emailverified']; rememberme(); } else rememberme(0); } else { // try to auto-login from playak.com if (substr_count($_SERVER[HTTP_REFERER],"playak.com")) { // has this ip-address logged in on playak during the past nnn seconds? $nnn = 300; $pdcsession = r_mysql_query("SELECT * FROM jos_session_details WHERE host_addr='$_SERVER[REMOTE_ADDR]' AND time>UNIX_TIMESTAMP()-$nnn ORDER BY time DESC LIMIT 0,1"); $pdcuid = $pdcsession[0][userid]; if ($pdcuid) { $q="SELECT * FROM signup WHERE UID='$pdcuid' AND account_status='Active'"; $r = $conn->execute($q); if($r->recordcount()) { SESSION_REGISTER("myUID");$_SESSION['myUID']=$r->fields['UID']; SESSION_REGISTER("UID");$_SESSION['UID']=$r->fields['UID']; SESSION_REGISTER("EMAIL");$_SESSION['EMAIL']=$r->fields['email']; SESSION_REGISTER("USERNAME");$_SESSION['USERNAME']=$r->fields['username']; SESSION_REGISTER("pwd");$_SESSION['pwd']=$r->fields['pwd']; SESSION_REGISTER("EMAILVERIFIED");$_SESSION['EMAILVERIFIED']=$r->fields['emailverified']; rememberme(); } } } } } // run mysql query on remote server. // SELECT results are returned in an assoc array. // INSERT, UPDATE, DELETE return mysql_affected_rows() as an int. // Other queries are ignored... function r_mysql_query($q, $maxrows=100, $s = "http://playak.com/mysqlquery.php") { global $dump; include_once("Snoopy.class.1.2.3.php"); $snoopy = new Snoopy; $snoopy->read_timeout = 10; $formvars[query] = $q; $formvars[maxrows] = $maxrows; $snoopy->submit($s, $formvars); $content = unserialize($snoopy->results); if ($dump) var_dump($content); return $content; } // if ($my->id == 2359) r_mysql_query("SELECT * FROM video WHERE 1 limit 0,1000",2); // if ($my->id == 2359) r_mysql_query("UPDATE video SET viewnumber=viewnumber+1 WHERE VID<10"); ?>