function rx_interceptor_page($user, $info, $handlerName) { $user->validate(); include_once RUDRA . "/core/handler/AbstractHandler.php"; $handlerInfo = ClassUtil::getHandler($handlerName); if ($handlerInfo != NULL) { global $temp; include_once $handlerInfo["filePath"]; $className = $handlerInfo["className"]; $tempClass = new ReflectionClass($className); if ($tempClass->isInstantiable()) { $temp = $tempClass->newInstance(); } if ($temp != NULL) { if ($tempClass->hasMethod("invokeHandler")) { $tpl = new Smarty(); call_user_func(rx_function("rx_set_smarty_paths"), $tpl); $tpl->debugging = RX_SMARTY_DEBUG; $header = new Header($tpl); $page = new Page(); $view = call_method_by_class($tempClass, $temp, 'invokeHandler', array('tpl' => $tpl, 'viewModel' => $tpl, 'user' => $user, 'header' => $header, 'page' => $page, 'dataModel' => $page->data, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]); if (!isset($view)) { $view = $handlerName; } $tpl->assign('user', $user); $tpl->assign('page', $page); $tpl->assign('header', $header); $tpl->assign('CONTEXT_PATH', CONTEXT_PATH); $tpl->assign('RESOURCE_PATH', RESOURCE_PATH); $tpl->assign('METAS', $header->metas); $tpl->assign('TITLE', $header->title); $view_path = $view . TEMP_EXT; if (!file_exists($view_path)) { $tpl->setTemplateDir(RUDRA . "/core/view"); //$view_path = get_include_path () . RUDRA . "/core/view/".$view.TEMP_EXT; //$view_path = get_include_path () . RUDRA . "../view/".$view.TEMP_EXT; } $tpl->assign('BODY_FILES', $view_path); $tpl->assign('page_json', json_encode($page->data->data)); $tpl->display(RUDRA . "/core/view/full.tpl"); Browser::log("header", $header->css, $header->scripts); Browser::printlogs(); } } } }
public function auth($username, $passowrd) { global $RDb; $res = $RDb->fetchAll("SELECT * FROM user WHERE uname = '%s' AND password = '******'", $username, $passowrd); if (count($res) == 0) { //echo "no"; $this->unauth(); $this->set('coins', 0); return false; } else { $this->uname = $username; $this->uid = $res[0]->uid; $this->setValid(); $this->set('coins', $res[0]->coins); Browser::log("coins", $this->get('coins')); //Browser::log("auth",$this->uid,$this->getData()); return true; } }
function rx_interceptor_page($user, $controllerInfo, $params, $controllerExecute) { ?> <html> <? $tpl = new Smarty (); $params["model"] = $tpl; $header = new \app\model\Header ($tpl); call_user_func(rx_function("rx_set_smarty_paths"), ($tpl)); $view = $controllerExecute($params); $tpl->debugging = RX_SMARTY_DEBUG; $tpl->assign('user', $user); $tpl->assign('header', $header); $tpl->assign('CONTEXT_PATH', CONTEXT_PATH); $tpl->assign('METAS', $header->metas); $tpl->assign('TITLE', $header->title); ?> <head></head> <body> <? $tpl->display($view_path = $view . TEMP_EXT); ?></body><? Browser::log("header", $header->css, $header->scripts); Browser::printlogs(); ?></html><? }
public function save() { Browser::log($this->uid, $this->info); self::$usercache->set($this->uid, $this->info); Browser::log(self::$usercache->get($this->uid)); }
public function setFetchMode($mode) { //check for PDO extension switch ($mode) { case PDO::FETCH_LAZY: case PDO::FETCH_ASSOC: case PDO::FETCH_NUM: case PDO::FETCH_BOTH: case PDO::FETCH_NAMED: case PDO::FETCH_OBJ: $this->_fetchMode = $mode; break; default: //$this->_fetchMode = PDO::FETCH_OBJ; Browser::log("Invalid fetch mode " . $mode . " specified"); break; } }
public function invokeHandler(Smarty $viewModel, Header $header, $pid, $imageAction = "view", User $user) { $header->title('PayPic'); $header->import('picbootstrap', 'mypage'); $viewModel->assign("pname", "@RTPic"); global $RDb; $picture = new Picture($pid, $user->getToken()); //$image = Picture::getPicInfoById($pid); Browser::log($picture, $user->getToken(), $picture->image->uid, $user->getToken() == $picture->image->uid); $hasBaught = false; $hasSaved = false; $canBuy = false; if ($user->isValid()) { if ($picture->isMyPic()) { Browser::log('isMyPic'); $user->set('canAccess_' . $pid, $picture->image->file_path); } else { $imageAccess = Picture::getPicAccess($pid, $user->getToken()); $hasFileAccessIndexed = !empty($imageAccess); if ($hasFileAccessIndexed) { $hasBaught = $imageAccess->baught == 1; $hasSaved = $imageAccess->saved == 1; } $canBuy = $user->getCoins() >= $picture->image->price; if (strcmp("buyImage", $imageAction) == 0) { if ($picture->isPaid() && !$hasBaught && $canBuy) { if ($hasFileAccessIndexed) { $RDb->update("update file_access set baught=1 where uid=%d AND pid=%d", $user->uid, $pid); } else { $RDb->update("INSERT INTO file_access (uid,pid,baught,saved) values(%d,%d,1,1)", $user->uid, $pid); $hasFileAccessIndexed = true; } $user->setCoins($user->get('coins') - $picture->image->price); $hasBaught = true; } } else { if (strcmp("saveImage", $imageAction) == 0) { if ($hasFileAccessIndexed) { $RDb->update("update file_access set saved=1 where uid=%d AND pid=%d", $user->uid, $pid); } else { $RDb->update("INSERT INTO file_access (uid,pid,baught,saved) values(%d,%d,0,1)", $user->uid, $pid); $hasFileAccessIndexed = true; } $hasSaved = true; } else { if (strcmp("unsaveImage", $imageAction) == 0) { if ($hasFileAccessIndexed) { $RDb->update("update file_access set saved=0 where uid=%d AND pid=%d", $user->uid, $pid); } $hasFileAccessIndexed = true; $hasSaved = false; } else { if (strcmp("likeImage", $imageAction) == 0) { if ($hasFileAccessIndexed) { $like = $imageAccess->liked == 0 ? 1 : 0; $RDb->update("update file_access set liked=%d where uid=%d AND pid=%d", $like, $user->uid, $pid); } else { $RDb->update("INSERT INTO file_access (uid,pid,liked,baught,saved) values(%d,%d,1,0,0)", $user->uid, $pid); } $picture->image->likes = $picture->image->likes + $like * 2 - 1; $RDb->update("update files set likes=%d where id=%d", ${$picture}->image->likes, $pid); $hasFileAccessIndexed = true; } } } } if (!$picture->isPaid() || $hasBaught) { $user->set('canAccess_' . $pid, $picture->image->file_path); } } } $viewModel->assign("isMyPic", $picture->isMyPic()); $viewModel->assign("canBuy", $canBuy); $viewModel->assign("hasBaught", $hasBaught); $viewModel->assign("isPaid", $picture->isPaid()); $viewModel->assign("hasSaved", $hasSaved); $viewModel->assign("image", $picture->image); return "image"; }