function index_immagini()
 {
     $peer = new ImmagineProdottoServizioPeer();
     ActiveRecordUtils::updateFilters($peer);
     $elenco_immagini_prodotti_servizi = $peer->find();
     $data = ActiveRecordUtils::toArray($elenco_immagini_prodotti_servizi);
     if (is_html()) {
         $data[Block::MARKER_KEY] = "vetrine/prodotti_servizi/select_immagine_prodotto_servizio";
     }
     return $data;
 }
 function modify_image()
 {
     $peer = new GalleryImagePeer();
     $do = $peer->updateByParams();
     $peer->save($do);
     if (is_html()) {
         return Redirect::success();
     } else {
         return Redirect::failure();
     }
 }
 function modify_collection()
 {
     $peer = new GalleryCollectionPeer();
     $do = $peer->updateByParams();
     $peer->save($do);
     if (is_html()) {
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
 function delete()
 {
     $peer = new DocumentiPeer();
     $do = $peer->find_by_id(Params::get("id"));
     $final_path = $do->save_folder . $do->hash_name;
     $f = new File($final_path);
     $f->delete();
     $peer->delete($do);
     if (is_html()) {
         Flash::ok("Documento eliminato con successo.");
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
 function delete_banner_group()
 {
     $peer = new BannerPeer();
     $peer->id_banner_group__EQUAL(Params::get("id_banner_group"));
     $all_banners = $peer->find();
     foreach ($all_banners as $banner) {
         call("sponsor_banner", "delete_banner", array("id_banner" => $banner->id_banner));
     }
     $peer_group = new BannerGroupPeer();
     $peer_group->delete_by_id(Params::get("id_banner_group"));
     if (is_html()) {
         Flash::ok("Contenuto testuale eliminato con successo!!");
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
 public function onCompleted(ProxyEvent $event)
 {
     $request = $event['request'];
     $response = $event['response'];
     $url = $request->getUri();
     // we attach url_form only if this is a html response
     if (!is_html($response->headers->get('content-type'))) {
         return;
     }
     // this path would be relative to index.php that included it?
     $url_form = render_template("./templates/url_form.php", array('url' => $url));
     $output = $response->getContent();
     // does the html page contain <body> tag, if so insert our form right after <body> tag starts
     $output = preg_replace('@<body.*?>@is', '$0' . PHP_EOL . $url_form, $output, 1, $count);
     // <body> tag was not found, just put the form at the top of the page
     if ($count == 0) {
         $output = $url_form . $output;
     }
     $response->setContent($output);
 }
 function delete()
 {
     $peer = new FolderPeer();
     $result = $peer->find_by_id(Params::get("id"));
     $path = $result["path"];
     $nome = $result["nome"];
     $full_path = $path . $nome . "/";
     $tipo = $result["tipo"];
     $tipo_tokens = explode("_", $tipo);
     $controller_name = $tipo_tokens[1];
     call($controller_name, "delete_by_path", array("path" => $full_path));
     $peer->delete($result);
     if (is_html()) {
         Flash::ok("Cartella eliminata con successo.");
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
示例#8
0
echo $lang["termsandconditions"];
?>
</h1>
  <p><?php 
echo text("introtext");
?>
</p>
  
 	<div class="Question">
	<label><?php 
echo $lang["termsandconditions"];
?>
</label>
	<div class="Terms"><?php 
$termstext = text("terms");
if (is_html($termstext)) {
    echo $termstext;
} else {
    echo txt2html($termstext);
}
?>
</div>
	<div class="clearerleft"> </div>
	</div>
	
	<form method="post" action="<?php 
echo $baseurl_short;
?>
pages/terms.php?k=<?php 
echo urlencode($k);
?>
示例#9
0
function renderAdminMenu($menu, $level = 0, $current_rt = '')
{
    $result = '';
    if ($level) {
        $result .= "<ul class=\"children child{$level}\">\r\n";
    }
    foreach ($menu as $item) {
        $id = empty($item['id']) ? '' : ' id="menu_' . $item['id'] . '" ';
        // li ID
        $class = $level != 0 ? empty($item['children']) ? '' : ' class="parent" ' : ' class="top" ';
        //a class
        $href = empty($item['href']) ? '' : ' href="' . $item['href'] . '" ';
        //a href
        $onclick = empty($item['onclick']) ? '' : ' onclick="' . $item['onclick'] . '" ';
        //a href
        $child_class = "level{$level} ";
        if (!empty($item['children'])) {
            $child_class .= 'nav-parent ';
        }
        if ($item['rt'] && $current_rt == $item['rt']) {
            $child_class .= 'active ';
        }
        if ($child_class) {
            $child_class = ' class="' . $child_class . '"';
        }
        $result .= '<li' . $id . $child_class . '>';
        $result .= '<a ' . $class . $href . $onclick . '>';
        //check icon rl type html, image or none.
        if (is_html($item['icon'])) {
            $result .= $item['icon'];
        } else {
            if ($item['icon']) {
                $result .= '<img class="menu_image" src="' . HTTPS_DIR_RESOURCE . $item['icon'] . '" alt="" />';
            } else {
                $result .= '<i class="fa fa-caret-right"></i> ';
            }
        }
        $result .= '<span class="menu_text">' . $item['text'] . '</span></a>';
        //if children build inner clild trees
        if (!empty($item['children'])) {
            $result .= "\r\n" . renderAdminMenu($item['children'], $level + 1, $current_rt);
        }
        $result .= "</li>\r\n";
    }
    if ($level) {
        $result .= "</ul>\r\n";
    }
    return $result;
}
示例#10
0
function url_is_html($url, $login = false, $pass = false)
{
    return is_html(fetch_file_contents($url, false, $login, $pass));
}
示例#11
0
function buildStoreFrontMenuTree($menu_array, $level = 0)
{
    $menu_array = (array) $menu_array;
    if (!$menu_array) {
        return '';
    }
    $result = '';
    //for submenus build new UL node
    if ($level > 0) {
        $result .= "<ul class='sub_menu dropdown-menu'>\r\n";
    }
    $registry = Registry::getInstance();
    $logged = $registry->get('customer')->isLogged();
    foreach ($menu_array as $item) {
        if ($logged && $item['id'] == 'login' || !$logged && $item['id'] == 'logout') {
            continue;
        }
        //build appropriate menu id and classes for css controll
        $id = empty($item['id']) ? '' : ' data-id="menu_' . $item['id'] . '" ';
        // li ID
        if ($level != 0) {
            if (empty($item['children'])) {
                $class = $item['icon'] ? ' class="top nobackground"' : ' class="sub menu_' . $item['id'] . '" ';
            } else {
                $class = $item['icon'] ? ' class="parent nobackground" ' : ' class="parent menu_' . $item['id'] . '" ';
            }
        } else {
            $class = $item['icon'] ? ' class="top nobackground"' : ' class="top menu_' . $item['id'] . '" ';
        }
        $href = empty($item['href']) ? '' : ' href="' . $item['href'] . '" ';
        //construct HTML
        $result .= '<li ' . $id . ' class="dropdown hover">';
        $result .= '<a ' . $class . $href . '>';
        //check icon rl type html, image or none.
        if (is_html($item['icon'])) {
            $result .= $item['icon'];
        } else {
            if ($item['icon']) {
                $result .= '<img class="menu_image" src="' . HTTP_DIR_RESOURCE . $item['icon'] . '" alt="" />';
            }
        }
        $result .= '<span class="menu_text">' . $item['text'] . '</span></a>';
        //if children build inner clild tree
        if (!empty($item['children'])) {
            $result .= "\r\n" . buildStoreFrontMenuTree($item['children'], $level + 1);
        }
        $result .= "</li>\r\n";
    }
    if ($level > 0) {
        $result .= "</ul>\r\n";
    }
    return $result;
}
 function subscribe2()
 {
     $feed_url = $this->dbh->escape_string(trim($_REQUEST["feed_url"]));
     $cat_id = $this->dbh->escape_string($_REQUEST["cat_id"]);
     $from = $this->dbh->escape_string($_REQUEST["from"]);
     $feed_urls = array();
     /* only read authentication information from POST */
     $auth_login = $this->dbh->escape_string(trim($_POST["auth_login"]));
     $auth_pass = $this->dbh->escape_string(trim($_POST["auth_pass"]));
     $rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
     switch ($rc) {
         case 1:
             print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
             break;
         case 2:
             print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
             break;
         case 3:
             print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
             break;
         case 0:
             print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
             break;
         case 4:
             print_notice(__("Multiple feed URLs found."));
             $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass);
             if (is_html($contents)) {
                 $feed_urls = get_feeds_from_html($url, $contents);
             }
             break;
         case 5:
             print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
             break;
     }
     if ($feed_urls) {
         print "<form action=\"backend.php\">";
         print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
         print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
         print "<input type=\"hidden\" name=\"method\" value=\"add\">";
         print "<select name=\"feed_url\">";
         foreach ($feed_urls as $url => $name) {
             $url = htmlspecialchars($url);
             $name = htmlspecialchars($name);
             print "<option value=\"{$url}\">{$name}</option>";
         }
         print "<input type=\"submit\" value=\"" . __("Subscribe to selected feed") . "\">";
         print "</form>";
     }
     $tp_uri = get_self_url_prefix() . "/prefs.php";
     $tt_uri = get_self_url_prefix();
     if ($rc <= 2) {
         $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE\n\t\t\t\tfeed_url = '{$feed_url}' AND owner_uid = " . $_SESSION["uid"]);
         $feed_id = $this->dbh->fetch_result($result, 0, "id");
     } else {
         $feed_id = 0;
     }
     print "<p>";
     if ($feed_id) {
         print "<form method=\"GET\" style='display: inline'\n\t\t\t\taction=\"{$tp_uri}\">\n\t\t\t\t<input type=\"hidden\" name=\"tab\" value=\"feedConfig\">\n\t\t\t\t<input type=\"hidden\" name=\"method\" value=\"editFeed\">\n\t\t\t\t<input type=\"hidden\" name=\"methodparam\" value=\"{$feed_id}\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Edit subscription options") . "\">\n\t\t\t\t</form>";
     }
     print "<form style='display: inline' method=\"GET\" action=\"{$tt_uri}\">\n\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t</form></p>";
     print "</body></html>";
 }
示例#13
0
/**
 * MÈtodo Para la aplicación de seguridad
 * a bajo nivel, recibe un array de datos
 * y limpia sus elementos de manera b·sica
 * pero efectiva 
 * @param array $data
 * @param sanitiser $sanitiser: el sanitizador de html purify
 * @param bool $is_cookie: identifica si el elemento a identificar es una cookie
 */
function sanitize($data, $sanitiser, $is_cookie = false)
{
    //recorro todos los datos que me pasan
    foreach ($data as $key => $data_element) {
        //si es una cookie, sanitizo una cookie
        if ($is_cookie) {
            $data[$key] = filter_var($data_element, FILTER_SANITIZE_STRING);
            //caracteres que no gustan a php
        } else {
            //si el dato es un array, recursión
            if (is_array($data_element)) {
                sanitize($data_element, $sanitiser);
            } else {
                //en caso contrario, sanitizo mínimamente
                //si contiene cualquier etiqueta html /javascript
                if (is_html($data[$key])) {
                    $data[$key] = $sanitiser->purify($data[$key]);
                    //protección contra xss
                } else {
                    //si es una variable "normal"
                    $data[$key] = filter_var($data_element, FILTER_SANITIZE_STRING);
                    //caracteres que no gustan a php
                    $data[$key] = prevent_sqlinjection($data[$key]);
                    //protección contra sql injection
                }
            }
        }
    }
    return $data;
}
示例#14
0
 function import()
 {
     $data = Params::get("import_data");
     $peer = new TestiPeer();
     $import_export = DB::newTableDataImportExport();
     $import_export->import_data($data);
     if (is_html()) {
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
示例#15
0
    } else {
        if (class_exists('\\Proxy\\Plugin\\' . $plugin_class)) {
            // does the native plugin from php-proxy package with such name exist?
            $plugin_class = '\\Proxy\\Plugin\\' . $plugin_class;
        }
    }
    // otherwise plugin_class better be loaded already and match namespace exactly \\Vendor\\Plugin\\SuperPlugin
    $proxy->getEventDispatcher()->addSubscriber(new $plugin_class());
}
// provide URL form
$proxy->getEventDispatcher()->addListener('request.complete', function ($event) {
    $request = $event['request'];
    $response = $event['response'];
    $url = $request->getUri();
    // we attach url_form only if this is a html response
    if (!is_html($response->headers->get('content-type'))) {
        return;
    }
    #	$url_form = render_template("./templates/url_form.php", array(
    #		'url' => $url
    #	));
    $output = $response->getContent();
    // does the html page contain <body> tag, if so insert our form right after <body> tag starts
    $output = preg_replace('@<body.*?>@is', '$0' . PHP_EOL . $url_form, $output, 1, $count);
    // <body> tag was not found, just put the form at the top of the page
    if ($count == 0) {
        $output = $url_form . $output;
    }
    $response->setContent($output);
});
try {
示例#16
0
 function send_mail_phpmailer($email, $subject, $message = "", $from = "", $reply_to = "", $html_template = "", $templatevars = null, $from_name = "", $cc = "", $bcc = "")
 {
     # if ($use_phpmailer==true) this function is used instead.
     # Mail templates can include lang, server, site_text, and POST variables by default
     # ex ( [lang_mycollections], [server_REMOTE_ADDR], [text_footer] , [message]
     # additional values must be made available through $templatevars
     # For example, a complex url or image path that may be sent in an
     # email should be added to the templatevars array and passed into send_mail.
     # available templatevars need to be well-documented, and sample templates
     # need to be available.
     # Include footer
     global $email_footer, $storagedir;
     $phpversion = phpversion();
     if ($phpversion >= '5.3') {
         if (file_exists(dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/class.phpmailer.php")) {
             include_once dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/class.phpmailer.php";
             include_once dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/extras/class.html2text.php";
         }
     } else {
         // less than 5.3
         if (file_exists(dirname(__FILE__) . "/../lib/phpmailer/class.phpmailer.php")) {
             include_once dirname(__FILE__) . "/../lib/phpmailer/class.phpmailer.php";
             include_once dirname(__FILE__) . "/../lib/phpmailer/class.html2text.php";
         }
     }
     global $email_from;
     if ($from == "") {
         $from = $email_from;
     }
     if ($reply_to == "") {
         $reply_to = $email_from;
     }
     global $applicationname;
     if ($from_name == "") {
         $from_name = $applicationname;
     }
     #check for html template. If exists, attempt to include vars into message
     if ($html_template != "") {
         # Attempt to verify users by email, which allows us to get the email template by lang and usergroup
         $to_usergroup = sql_query("select lang,usergroup from user where email ='" . escape_check($email) . "'", "");
         if (count($to_usergroup) != 0) {
             $to_usergroupref = $to_usergroup[0]['usergroup'];
             $to_usergrouplang = $to_usergroup[0]['lang'];
         } else {
             $to_usergrouplang = "";
         }
         if ($to_usergrouplang == "") {
             global $defaultlanguage;
             $to_usergrouplang = $defaultlanguage;
         }
         if (isset($to_usergroupref)) {
             $modified_to_usergroupref = hook("modifytousergroup", "", $to_usergroupref);
             if ($modified_to_usergroupref !== null) {
                 $to_usergroupref = $modified_to_usergroupref;
             }
             $results = sql_query("select language,name,text from site_text where page='all' and name='{$html_template}' and specific_to_group='{$to_usergroupref}'");
         } else {
             $results = sql_query("select language,name,text from site_text where page='all' and name='{$html_template}' and specific_to_group is null");
         }
         global $site_text;
         for ($n = 0; $n < count($results); $n++) {
             $site_text[$results[$n]["language"] . "-" . $results[$n]["name"]] = $results[$n]["text"];
         }
         $language = $to_usergrouplang;
         if (array_key_exists($language . "-" . $html_template, $site_text)) {
             $template = $site_text[$language . "-" . $html_template];
         } else {
             global $languages;
             # Can't find the language key? Look for it in other languages.
             reset($languages);
             foreach ($languages as $key => $value) {
                 if (array_key_exists($key . "-" . $html_template, $site_text)) {
                     $template = $site_text[$key . "-" . $html_template];
                     break;
                 }
             }
             // Fall back to language file if not in site text
             global $lang;
             if (isset($lang[$html_template])) {
                 $template = $lang[$html_template];
             }
         }
         if (isset($template) && $template != "") {
             preg_match_all('/\\[[^\\]]*\\]/', $template, $test);
             foreach ($test[0] as $variable) {
                 $variable = str_replace("[", "", $variable);
                 $variable = str_replace("]", "", $variable);
                 # get lang variables (ex. [lang_mycollections])
                 if (substr($variable, 0, 5) == "lang_") {
                     global $lang;
                     ${$variable} = $lang[substr($variable, 5)];
                 } else {
                     if (substr($variable, 0, 7) == "server_") {
                         ${$variable} = $_SERVER[substr($variable, 7)];
                     } else {
                         if (substr($variable, 0, 15) == "embed_thumbnail") {
                             $thumbcid = uniqid('thumb');
                             ${$variable} = "<img style='border:1px solid #d1d1d1;' src='cid:{$thumbcid}' />";
                         } else {
                             if (substr($variable, 0, 15) == "img_storagedir_") {
                                 ${$variable} = "<img src='cid:" . basename(substr($variable, 15)) . "'/>";
                                 $images[] = dirname(__FILE__) . substr($variable, 15);
                             } else {
                                 if (substr($variable, 0, 4) == "img_") {
                                     $image_path = substr($variable, 4);
                                     if (substr($image_path, 0, 1) == "/") {
                                         // absolute paths
                                         $images[] = $image_path;
                                     } else {
                                         // relative paths
                                         $image_path = str_replace("../", "", $image_path);
                                         $images[] = dirname(__FILE__) . "/../" . $image_path;
                                     }
                                     ${$variable} = "<img src='cid:" . basename($image_path) . "'/>";
                                     $images[] = $image_path;
                                 } else {
                                     if (substr($variable, 0, 7) == "attach_") {
                                         ${$variable} = "";
                                         $attachments[] = substr($variable, 7);
                                     } else {
                                         if (substr($variable, 0, 5) == "text_") {
                                             ${$variable} = text(substr($variable, 5));
                                         } else {
                                             ${$variable} = getval($variable, "");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 # avoid resetting templatevars that may have been passed here
                 if (!isset($templatevars[$variable])) {
                     $templatevars[$variable] = ${$variable};
                 }
             }
             if (isset($templatevars)) {
                 foreach ($templatevars as $key => $value) {
                     $template = str_replace("[" . $key . "]", nl2br($value), $template);
                 }
             }
             $body = $template;
         }
     }
     if (!isset($body)) {
         $body = $message;
     }
     global $use_smtp, $smtp_secure, $smtp_host, $smtp_port, $smtp_auth, $smtp_username, $smtp_password;
     $mail = new PHPMailer();
     // use an external SMTP server? (e.g. Gmail)
     if ($use_smtp) {
         $mail->IsSMTP();
         // enable SMTP
         $mail->SMTPDebug = 0;
         // debugging: 1 = errors and messages, 2 = messages only
         $mail->SMTPAuth = $smtp_auth;
         // authentication enabled/disabled
         $mail->SMTPSecure = $smtp_secure;
         // '', 'tls' or 'ssl'
         $mail->Host = $smtp_host;
         // hostname
         $mail->Port = $smtp_port;
         // port number
         $mail->Username = $smtp_username;
         // username
         $mail->Password = $smtp_password;
         // password
     }
     $reply_tos = explode(",", $reply_to);
     // only one from address is possible, so only use the first one:
     if (strstr($reply_tos[0], "<")) {
         $rtparts = explode("<", $reply_tos[0]);
         $mail->From = str_replace(">", "", $rtparts[1]);
         $mail->FromName = $rtparts[0];
     } else {
         $mail->From = $reply_tos[0];
         $mail->FromName = $from_name;
     }
     // if there are multiple addresses, that's what replyto handles.
     for ($n = 0; $n < count($reply_tos); $n++) {
         if (strstr($reply_tos[$n], "<")) {
             $rtparts = explode("<", $reply_tos[$n]);
             $mail->AddReplyto(str_replace(">", "", $rtparts[1]), $rtparts[0]);
         } else {
             $mail->AddReplyto($reply_tos[$n], $from_name);
         }
     }
     # modification to handle multiple comma delimited emails
     # such as for a multiple $email_notify
     $emails = $email;
     $emails = explode(',', $emails);
     $emails = array_map('trim', $emails);
     foreach ($emails as $email) {
         if (strstr($email, "<")) {
             $emparts = explode("<", $email);
             $mail->AddAddress(str_replace(">", "", $emparts[1]), $emparts[0]);
         } else {
             $mail->AddAddress($email);
         }
     }
     if ($cc != "") {
         # modification for multiple is also necessary here, though a broken cc seems to be simply removed by phpmailer rather than breaking it.
         $ccs = $cc;
         $ccs = explode(',', $ccs);
         $ccs = array_map('trim', $ccs);
         global $userfullname;
         foreach ($ccs as $cc) {
             if (strstr($cc, "<")) {
                 $ccparts = explode("<", $cc);
                 $mail->AddCC(str_replace(">", "", $ccparts[1]), $ccparts[0]);
             } else {
                 $mail->AddCC($cc, $userfullname);
             }
         }
     }
     if ($bcc != "") {
         # modification for multiple is also necessary here, though a broken cc seems to be simply removed by phpmailer rather than breaking it.
         $bccs = $bcc;
         $bccs = explode(',', $bccs);
         $bccs = array_map('trim', $bccs);
         global $userfullname;
         foreach ($bccs as $bccemail) {
             if (strstr($bccemail, "<")) {
                 $bccparts = explode("<", $bccemail);
                 $mail->AddBCC(str_replace(">", "", $bccparts[1]), $bccparts[0]);
             } else {
                 $mail->AddBCC($bccemail, $userfullname);
             }
         }
     }
     $mail->CharSet = "utf-8";
     if (is_html($body)) {
         $mail->IsHTML(true);
     } else {
         $mail->IsHTML(false);
     }
     $mail->Subject = $subject;
     $mail->Body = $body;
     if (isset($embed_thumbnail) && isset($templatevars['thumbnail'])) {
         $mail->AddEmbeddedImage($templatevars['thumbnail'], $thumbcid, $thumbcid, 'base64', 'image/jpeg');
     }
     if (isset($images)) {
         foreach ($images as $image) {
             $mail->AddEmbeddedImage($image, basename($image), basename($image), 'base64', 'image/gif');
         }
     }
     if (isset($attachments)) {
         foreach ($attachments as $attachment) {
             $mail->AddAttachment($attachment, basename($attachment));
         }
     }
     if (is_html($body)) {
         $h2t = new html2text($body);
         $text = $h2t->get_text();
         $mail->AltBody = $text;
     }
     if (!$mail->Send()) {
         echo "Message could not be sent. <p>";
         echo "Mailer Error: " . $mail->ErrorInfo;
         exit;
     }
     hook("aftersendmailphpmailer", "", $email);
 }
 function __defaultReturn($success_message, $error_messages)
 {
     if (is_html()) {
         if (!$error_messages) {
             Flash::ok($success_message);
             return Redirect::success();
         } else {
             foreach ($error_messages as $error_msg) {
                 Flash::error($error_msg);
             }
             return Redirect::failure();
         }
     } else {
         if (!$error_messages) {
             return Result::ok();
         } else {
             return Result::error($error_messages);
         }
     }
 }
示例#18
0
 function elimina_prodotto_servizio_vetrina()
 {
     $peer = new ProdottoServizioVetrinaPeer();
     $do = $peer->find_by_id(Params::get("id_prodotto_servizio_vetrina"));
     $peer->delete($do);
     if (is_html()) {
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
示例#19
0
 function delete()
 {
     $peer = new FolderPeer();
     $result = $peer->find_by_id(Params::get("id"));
     self::delete_attributes($result);
     $peer->delete($result);
     if (is_html()) {
         Flash::ok("Cartella eliminata con successo.");
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }
示例#20
0
/**
 * @return array (code => Status code, message => error message if available)
 *
 *                 0 - OK, Feed already exists
 *                 1 - OK, Feed added
 *                 2 - Invalid URL
 *                 3 - URL content is HTML, no feeds available
 *                 4 - URL content is HTML which contains multiple feeds.
 *                     Here you should call extractfeedurls in rpc-backend
 *                     to get all possible feeds.
 *                 5 - Couldn't download the URL content.
 *                 6 - Content is an invalid XML.
 */
function subscribe_to_feed($url, $cat_id = 0, $auth_login = '', $auth_pass = '')
{
    global $fetch_last_error;
    require_once "include/rssfuncs.php";
    $url = fix_url($url);
    if (!$url || !validate_feed_url($url)) {
        return array("code" => 2);
    }
    $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass);
    if (!$contents) {
        return array("code" => 5, "message" => $fetch_last_error);
    }
    foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) {
        $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass);
    }
    if (is_html($contents)) {
        $feedUrls = get_feeds_from_html($url, $contents);
        if (count($feedUrls) == 0) {
            return array("code" => 3);
        } else {
            if (count($feedUrls) > 1) {
                return array("code" => 4, "feeds" => $feedUrls);
            }
        }
        //use feed url as new URL
        $url = key($feedUrls);
    }
    if ($cat_id == "0" || !$cat_id) {
        $cat_qpart = "NULL";
    } else {
        $cat_qpart = "'{$cat_id}'";
    }
    $result = db_query("SELECT id FROM ttrss_feeds\n\t\t\tWHERE feed_url = '{$url}' AND owner_uid = " . $_SESSION["uid"]);
    if (strlen(FEED_CRYPT_KEY) > 0) {
        require_once "crypt.php";
        $auth_pass = substr(encrypt_string($auth_pass), 0, 250);
        $auth_pass_encrypted = 'true';
    } else {
        $auth_pass_encrypted = 'false';
    }
    $auth_pass = db_escape_string($auth_pass);
    if (db_num_rows($result) == 0) {
        $result = db_query("INSERT INTO ttrss_feeds\n\t\t\t\t\t(owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)\n\t\t\t\tVALUES ('" . $_SESSION["uid"] . "', '{$url}',\n\t\t\t\t'[Unknown]', {$cat_qpart}, '{$auth_login}', '{$auth_pass}', 0, {$auth_pass_encrypted})");
        $result = db_query("SELECT id FROM ttrss_feeds WHERE feed_url = '{$url}'\n\t\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
        $feed_id = db_fetch_result($result, 0, "id");
        if ($feed_id) {
            set_basic_feed_info($feed_id);
        }
        return array("code" => 1);
    } else {
        return array("code" => 0);
    }
}
示例#21
0
 function set_current_folder()
 {
     $root_dir = new Dir($this->get_user_root());
     $folder = Params::get("folder");
     if (!$root_dir->isParentOf($folder)) {
         throw new InvalidDataException("La cartella specificata non e' valida!!");
     }
     Session::set(self::SESSION_GALLERY_CURRENT_FOLDER, Params::get("folder"));
     if (is_html()) {
         return Redirect::success();
     } else {
         return Result::ok();
     }
 }