Beispiel #1
0
function downloadFile($url, $path)
{
    if (isValidUrl($url)) {
        touch($path);
        $remoteFile = fopen($url, "rb");
        if ($remoteFile) {
            $newFile = fopen($path, "wb");
            if ($newFile) {
                while (!feof($remoteFile)) {
                    fwrite($newFile, fread($remoteFile, 1024 * 8), 1024 * 8);
                }
            }
        } else {
            return false;
        }
        if ($remoteFile) {
            fclose($remoteFile);
        }
        if ($newFile) {
            fclose($newFile);
        }
        return true;
    } else {
        notFound();
        return false;
    }
}
Beispiel #2
0
function addShortUrl()
{
    if (isset($_POST['url']) && $_POST['url']) {
        $link = $_POST['url'];
        if (isValidUrl($link)) {
            $result = insertShortUrl($link);
            $shortIsValid = $result['success'];
            while (!$shortIsValid) {
                $result = insertShortUrl($link);
                $shortIsValid = $result['success'];
            }
            echo DOMAIN_URL . $result['short'];
        } else {
            echo 'Invalid link !';
        }
    }
}
Beispiel #3
0
            }
        }

        if (GETPOST('deletephoto')) $object->logo = '';
        else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);

        // Check parameters
        if (empty($_POST["cancel"]))
        {
            if (! empty($object->email) && ! isValidEMail($object->email))
            {
                $langs->load("errors");
                $error++; $errors[] = $langs->trans("ErrorBadEMail",$object->email);
                $action = ($action=='add'?'create':'edit');
            }
            if (! empty($object->url) && ! isValidUrl($object->url))
            {
                $langs->load("errors");
                $error++; $errors[] = $langs->trans("ErrorBadUrl",$object->url);
                $action = ($action=='add'?'create':'edit');
            }
            if ($object->fournisseur && ! $conf->fournisseur->enabled)
            {
                $langs->load("errors");
                $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
                $action = ($action=='add'?'create':'edit');
            }

            // Check for duplicate prof id
        	for ($i = 1; $i < 3; $i++)
        	{
 /**
  *	Load data control
  *
  *	@param	int		$action	Action code
  *	@return	void
  */
 function doActions(&$action)
 {
     global $conf, $user, $langs;
     if ($_POST["getcustomercode"]) {
         // We defined value code_client
         $_POST["code_client"] = "Acompleter";
     }
     if ($_POST["getsuppliercode"]) {
         // We defined value code_fournisseur
         $_POST["code_fournisseur"] = "Acompleter";
     }
     // Add new third party
     if (!$_POST["getcustomercode"] && !$_POST["getsuppliercode"] && ($action == 'add' || $action == 'update')) {
         require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
         $error = 0;
         if (GETPOST("private") == 1) {
             $this->object->particulier = GETPOST("private");
             $this->object->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? trim($_POST["firstname"] . ' ' . $_POST["lastname"]) : trim($_POST["lastname"] . ' ' . $_POST["firstname"]);
             $this->object->civility_id = $_POST["civility_id"];
             // Add non official properties
             $this->object->name_bis = $_POST["lastname"];
             $this->object->firstname = $_POST["firstname"];
         } else {
             $this->object->name = $_POST["nom"];
         }
         $this->object->address = $_POST["adresse"];
         $this->object->zip = $_POST["zipcode"];
         $this->object->town = $_POST["town"];
         $this->object->country_id = $_POST["country_id"];
         $this->object->state_id = $_POST["state_id"];
         $this->object->phone = $_POST["tel"];
         $this->object->fax = $_POST["fax"];
         $this->object->email = trim($_POST["email"]);
         $this->object->url = $_POST["url"];
         $this->object->idprof1 = $_POST["idprof1"];
         $this->object->idprof2 = $_POST["idprof2"];
         $this->object->idprof3 = $_POST["idprof3"];
         $this->object->idprof4 = $_POST["idprof4"];
         $this->object->prefix_comm = $_POST["prefix_comm"];
         $this->object->code_client = $_POST["code_client"];
         $this->object->code_fournisseur = $_POST["code_fournisseur"];
         $this->object->capital = $_POST["capital"];
         $this->object->barcode = $_POST["barcode"];
         $this->object->canvas = GETPOST("canvas");
         $this->object->tva_assuj = $_POST["assujtva_value"];
         // Local Taxes
         $this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
         $this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
         $this->object->tva_intra = $_POST["tva_intra"];
         $this->object->forme_juridique_code = $_POST["forme_juridique_code"];
         $this->object->effectif_id = $_POST["effectif_id"];
         if (GETPOST("private") == 1) {
             $this->object->typent_id = dol_getIdFromCode($db, 'TE_PRIVATE', 'c_typent');
         } else {
             $this->object->typent_id = $_POST["typent_id"];
         }
         $this->object->client = $_POST["client"];
         $this->object->fournisseur = $_POST["fournisseur"];
         $this->object->commercial_id = $_POST["commercial_id"];
         $this->object->default_lang = $_POST["default_lang"];
         // Check parameters
         if (empty($_POST["cancel"])) {
             if (!empty($this->object->email) && !isValidEMail($this->object->email)) {
                 $error = 1;
                 $langs->load("errors");
                 $this->error = $langs->trans("ErrorBadEMail", $this->object->email);
                 $action = $action == 'add' ? 'create' : 'edit';
             }
             if (!empty($this->object->url) && !isValidUrl($this->object->url)) {
                 $error = 1;
                 $langs->load("errors");
                 $this->error = $langs->trans("ErrorBadUrl", $this->object->url);
                 $action = $action == 'add' ? 'create' : 'edit';
             }
             if ($this->object->fournisseur && !$conf->fournisseur->enabled) {
                 $error = 1;
                 $langs->load("errors");
                 $this->error = $langs->trans("ErrorSupplierModuleNotEnabled");
                 $action = $action == 'add' ? 'create' : 'edit';
             }
         }
         if (!$error) {
             if ($action == 'add') {
                 $this->db->begin();
                 if (empty($this->object->client)) {
                     $this->object->code_client = '';
                 }
                 if (empty($this->object->fournisseur)) {
                     $this->object->code_fournisseur = '';
                 }
                 $result = $this->object->create($user);
                 if ($result >= 0) {
                     if ($this->object->particulier) {
                         dol_syslog(get_class($this) . "::doActions This thirdparty is a personal people", LOG_DEBUG);
                         $contact = new Contact($this->db);
                         $contact->civility_id = $this->object->civility_id;
                         $contact->name = $this->object->name_bis;
                         $contact->firstname = $this->object->firstname;
                         $contact->address = $this->object->address;
                         $contact->zip = $this->object->zip;
                         $contact->town = $this->object->town;
                         $contact->country_id = $this->object->country_id;
                         $contact->socid = $this->object->id;
                         // fk_soc
                         $contact->status = 1;
                         $contact->email = $this->object->email;
                         $contact->priv = 0;
                         $result = $contact->create($user);
                     }
                 } else {
                     $this->errors = $this->object->errors;
                 }
                 if ($result >= 0) {
                     $this->db->commit();
                     if ($this->object->client == 1) {
                         header("Location: " . DOL_URL_ROOT . "/comm/fiche.php?socid=" . $this->object->id);
                         return;
                     } else {
                         if ($this->object->fournisseur == 1) {
                             header("Location: " . DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $this->object->id);
                             return;
                         } else {
                             header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
                             return;
                         }
                     }
                     exit;
                 } else {
                     $this->db->rollback();
                     $this->errors = $this->object->errors;
                     $action = 'create';
                 }
             }
             if ($action == 'update') {
                 if ($_POST["cancel"]) {
                     header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
                     exit;
                 }
                 $oldsoccanvas = dol_clone($this->object);
                 // To avoid setting code if third party is not concerned. But if it had values, we keep them.
                 if (empty($this->object->client) && empty($oldsoccanvas->code_client)) {
                     $this->object->code_client = '';
                 }
                 if (empty($this->object->fournisseur) && empty($oldsoccanvas->code_fournisseur)) {
                     $this->object->code_fournisseur = '';
                 }
                 $result = $this->object->update($this->object->id, $user, 1, $oldsoccanvas->codeclient_modifiable(), $oldsoccanvas->codefournisseur_modifiable());
                 if ($result >= 0) {
                     header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
                     exit;
                 } else {
                     $reload = 0;
                     $this->errors = $this->object->errors;
                     $action = "edit";
                 }
             }
         }
     }
     if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
         $result = $this->object->delete($this->object->id);
         if ($result >= 0) {
             header("Location: " . DOL_URL_ROOT . "/societe/societe.php?delsoc=" . $this->object->nom . "");
             exit;
         } else {
             $reload = 0;
             $this->errors = $this->object->errors;
             $action = '';
         }
     }
     /*
      * Generate document
      */
     if ($action == 'builddoc') {
         if (is_numeric(GETPOST('model'))) {
             $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
         } else {
             require_once DOL_DOCUMENT_ROOT . '/core/modules/societe/modules_societe.class.php';
             $this->object->fetch_thirdparty();
             // Define output language
             $outputlangs = $langs;
             $newlang = '';
             if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) {
                 $newlang = GETPOST('lang_id');
             }
             if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
                 $newlang = $this->object->default_lang;
             }
             if (!empty($newlang)) {
                 $outputlangs = new Translate("", $conf);
                 $outputlangs->setDefaultLang($newlang);
             }
             $result = thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model', 'alpha'), $outputlangs);
             if ($result <= 0) {
                 dol_print_error($this->db, $result);
                 exit;
             }
         }
     }
 }
         foreach ($links as $link) {
             $scrapedUrls[] = $link->nodeValue;
         }
     } else {
         $links = $xpath->query(".//h3[@class='r']/a/@href");
         foreach ($links as $link) {
             $theLink = $link->nodeValue;
             $theLink = rel2abs($theLink, $url);
             $parts = GetQueryParameters(trim($theLink));
             $foundUrl = "EMPTY";
             if (isset($parts['url'])) {
                 $foundUrl = urldecode($parts['url']);
             } elseif (isset($parts['q'])) {
                 $foundUrl = urldecode($parts['q']);
             }
             if (isValidUrl($foundUrl)) {
                 //$converter = new idna_convert(); << used to decode punycode
                 //$foundUrl = $converter->decode($foundUrl); << used to decode punycode
                 $scrapedUrls[] = $foundUrl;
                 //echo "\n$foundUrl\t$theLink\n";
             }
         }
     }
 }
 echo "\nKeyword {$kw} done!\n";
 $records = array();
 foreach ($scrapedUrls as $p => $u) {
     echo "{$u}\n";
     $records[] = array("Date" => $today, "Keyword" => $kw, "Position" => $p + 1, "URL" => $u);
 }
 scraperwiki::save_sqlite(array("Date", "Keyword", "Position"), $records);
Beispiel #6
0
     $error++;
     $errors[] = $langs->trans("ErrorBadUrl", $object->url);
     $action = $action == 'add' ? 'create' : 'edit';
 }
 if ($object->fournisseur && !$conf->fournisseur->enabled) {
     $langs->load("errors");
     $error++;
     $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
     $action = $action == 'add' ? 'create' : 'edit';
 }
 if (!empty($object->webservices_url)) {
     //Check if has transport, without any the soap client will give error
     if (strpos($object->webservices_url, "http") === false) {
         $object->webservices_url = "http://" . $object->webservices_url;
     }
     if (!isValidUrl($object->webservices_url)) {
         $langs->load("errors");
         $error++;
         $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url);
         $action = $action == 'add' ? 'create' : 'edit';
     }
 }
 // We set country_id, country_code and country for the selected country
 $object->country_id = GETPOST('country_id') != '' ? GETPOST('country_id') : $mysoc->country_id;
 if ($object->country_id) {
     $tmparray = getCountry($object->country_id, 'all');
     $object->country_code = $tmparray['code'];
     $object->country = $tmparray['label'];
 }
 // Check for duplicate or mandatory prof id
 for ($i = 1; $i < 5; $i++) {
Beispiel #7
0
			curl_close($c);
			if ($response->status == "OK") {
				$object->gps = array($response->results[0]->geometry->location->lat, $response->results[0]->geometry->location->lng);
			} else {
				$object->gps = array(0, 0);
			}
		}

		if (GETPOST('deletephoto'))
			$object->logo = '';
		else if (!empty($_FILES['photo']['name']))
			$object->logo = dol_sanitizeFileName($_FILES['photo']['name']);

		// Check parameters
		if (empty($_POST["cancel"])) {
			if (!empty($object->url->Web) && !isValidUrl($object->url->Web)) {
				$langs->load("errors");
				$error++;
				$errors[] = $langs->trans("ErrorBadUrl", $object->url->Web);
				$action = ($action == 'add' ? 'create' : 'edit');
			}
			if ($object->fournisseur && !$conf->fournisseur->enabled) {
				$langs->load("errors");
				$error++;
				$errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
				$action = ($action == 'add' ? 'create' : 'edit');
			}

			/* for ($i = 1; $i < 3; $i++)
			  {
			  $slabel="idprof".$i;
    /**
     *    Load data control
     */
    function doActions($socid)
    {
        global $conf, $user, $langs;

        if ($_POST["getcustomercode"])
        {
            // We defined value code_client
            $_POST["code_client"]="Acompleter";
        }

        if ($_POST["getsuppliercode"])
        {
            // We defined value code_fournisseur
            $_POST["code_fournisseur"]="Acompleter";
        }

        // Add new third party
        if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
        && ($_POST["action"] == 'add' || $_POST["action"] == 'update'))
        {
            require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
            $error=0;

            if ($_POST["action"] == 'update')
            {
                // Load properties of company
                $this->object->fetch($socid);
            }

            if ($_REQUEST["private"] == 1)
            {
                $this->object->particulier           = $_REQUEST["private"];

                $this->object->nom                   = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]);
                $this->object->nom_particulier       = $_POST["nom"];
                $this->object->prenom                = $_POST["prenom"];
                $this->object->civilite_id           = $_POST["civilite_id"];
            }
            else
            {
                $this->object->nom                   = $_POST["nom"];
            }

            $this->object->address                  = $_POST["adresse"];
            $this->object->adresse                  = $_POST["adresse"]; // TODO obsolete
            $this->object->cp                       = $_POST["zipcode"];
            $this->object->ville                    = $_POST["town"];
            $this->object->pays_id                  = $_POST["pays_id"];
            $this->object->departement_id           = $_POST["departement_id"];
            $this->object->tel                      = $_POST["tel"];
            $this->object->fax                      = $_POST["fax"];
            $this->object->email                    = trim($_POST["email"]);
            $this->object->url                      = $_POST["url"];
            $this->object->siren                    = $_POST["idprof1"];
            $this->object->siret                    = $_POST["idprof2"];
            $this->object->ape                      = $_POST["idprof3"];
            $this->object->idprof4                  = $_POST["idprof4"];
            $this->object->prefix_comm              = $_POST["prefix_comm"];
            $this->object->code_client              = $_POST["code_client"];
            $this->object->code_fournisseur         = $_POST["code_fournisseur"];
            $this->object->capital                  = $_POST["capital"];
            $this->object->gencod                   = $_POST["gencod"];
            $this->object->canvas                   = $_REQUEST["canvas"];

            $this->object->tva_assuj                = $_POST["assujtva_value"];

            // Local Taxes
            $this->object->localtax1_assuj          = $_POST["localtax1assuj_value"];
            $this->object->localtax2_assuj          = $_POST["localtax2assuj_value"];
            $this->object->tva_intra                = $_POST["tva_intra"];

            $this->object->forme_juridique_code     = $_POST["forme_juridique_code"];
            $this->object->effectif_id              = $_POST["effectif_id"];
            if ($_REQUEST["private"] == 1)
            {
                $this->object->typent_id            = 8; // TODO predict another method if the field "special" change of rowid
            }
            else
            {
                $this->object->typent_id            = $_POST["typent_id"];
            }
            $this->object->client                   = $_POST["client"];
            $this->object->fournisseur              = $_POST["fournisseur"];
            $this->object->fournisseur_categorie    = $_POST["fournisseur_categorie"];

            $this->object->commercial_id            = $_POST["commercial_id"];
            $this->object->default_lang             = $_POST["default_lang"];

            // Check parameters
            if (empty($_POST["cancel"]))
            {
                if (! empty($this->object->email) && ! isValidEMail($this->object->email))
                {
                    $error = 1;
                    $langs->load("errors");
                    $this->error = $langs->trans("ErrorBadEMail",$this->object->email);
                    $_GET["action"] = $_POST["action"]=='add'?'create':'edit';
                }
                if (! empty($this->object->url) && ! isValidUrl($this->object->url))
                {
                    $error = 1;
                    $langs->load("errors");
                    $this->error = $langs->trans("ErrorBadUrl",$this->object->url);
                    $_GET["action"] = $_POST["action"]=='add'?'create':'edit';
                }
                if ($this->object->fournisseur && ! $conf->fournisseur->enabled)
                {
                    $error = 1;
                    $langs->load("errors");
                    $this->error = $langs->trans("ErrorSupplierModuleNotEnabled");
                    $_GET["action"] = $_POST["action"]=='add'?'create':'edit';
                }
            }

            if (! $error)
            {
                if ($_POST["action"] == 'add')
                {
                    $this->db->begin();

                    if (empty($this->object->client))      $this->object->code_client='';
                    if (empty($this->object->fournisseur)) $this->object->code_fournisseur='';

                    $result = $this->object->create($user);
                    if ($result >= 0)
                    {
                        if ($this->object->particulier)
                        {
                            dol_syslog("This thirdparty is a personal people",LOG_DEBUG);
                            $contact=new Contact($this->db);

                            $contact->civilite_id   = $this->object->civilite_id;
                            $contact->name          = $this->object->nom_particulier;
                            $contact->firstname     = $this->object->prenom;
                            $contact->address       = $this->object->address;
                            $contact->cp            = $this->object->cp;
                            $contact->ville         = $this->object->ville;
                            $contact->fk_pays       = $this->object->fk_pays;
                            $contact->socid         = $this->object->id;                // fk_soc
                            $contact->status        = 1;
                            $contact->email         = $this->object->email;
                            $contact->priv          = 0;

                            $result=$contact->create($user);
                        }
                    }
                    else
                    {
                        $this->errors=$this->object->errors;
                    }

                    if ($result >= 0)
                    {
                        $this->db->commit();

                        if ( $this->object->client == 1 )
                        {
                            Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$this->object->id);
                            return;
                        }
                        else
                        {
                            if (  $this->object->fournisseur == 1 )
                            {
                                Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$this->object->id);
                                return;
                            }
                            else
                            {
                                Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$this->object->id);
                                return;
                            }
                        }
                        exit;
                    }
                    else
                    {
                        $this->db->rollback();

                        $this->errors=$this->object->errors;
                        $_GET["action"]='create';
                    }
                }

                if ($_POST["action"] == 'update')
                {
                    if ($_POST["cancel"])
                    {
                        Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
                        exit;
                    }

                    $oldsoccanvas = new Canvas($this->db);
                    $oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
                    $result=$oldsoccanvas->control->object->fetch($socid);

                    // To avoid setting code if third party is not concerned. But if it had values, we keep them.
                    if (empty($this->object->client) && empty($oldsoccanvas->control->object->code_client))             $this->object->code_client='';
                    if (empty($this->object->fournisseur)&& empty($oldsoccanvas->control->object->code_fournisseur))    $this->object->code_fournisseur='';                    //var_dump($soccanvas);exit;

                    $result = $this->object->update($socid,$user,1,$oldsoccanvas->control->object->codeclient_modifiable(),$oldsoccanvas->control->object->codefournisseur_modifiable());
                    if ($result >= 0)
                    {
                        Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
                        exit;
                    }
                    else
                    {
                        $this->object->id = $socid;
                        $reload = 0;
                        $this->errors = $this->object->errors;
                        $_GET["action"]="edit";
                    }
                }
            }
        }

        if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes')
        {
            $this->object->fetch($socid);

            $result = $this->object->delete($socid);

            if ($result >= 0)
            {
                Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$this->object->nom."");
                exit;
            }
            else
            {
                $reload = 0;
                $this->errors=$this->object->errors;
                $_GET["action"]='';
            }
        }

        /*
         * Generate document
         */
        if (GETPOST('action') == 'builddoc')    // En get ou en post
        {
            if (is_numeric(GETPOST('model')))
            {
                $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
            }
            else
            {
                require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');

                $this->object->fetch($socid);
                $this->object->fetch_thirdparty();

                // Define output language
                $outputlangs = $langs;
                $newlang='';
                if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id') ) $newlang=GETPOST('lang_id');
                if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$this->object->default_lang;
                if (! empty($newlang))
                {
                    $outputlangs = new Translate("",$conf);
                    $outputlangs->setDefaultLang($newlang);
                }
                $result=thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model'), $outputlangs);
                if ($result <= 0)
                {
                    dol_print_error($this->db,$result);
                    exit;
                }
                else
                {
                    Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$this->object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
                    exit;
                }
            }
        }
    }
function new_config()
{
    #Begin creation of config.php
    $config = "<?php\n";
    #Define all the required variables for config.php
    $needed = array("os_ip", "os_pw", "pass_file", "cache_file", "log_file", "lang", "weather_provider", "wapikey");
    #Cycle through each needed key
    foreach ($needed as $key) {
        #If required variable is not submitted then fail
        if (!isset($_REQUEST[$key])) {
            fail();
        }
        $data = $_REQUEST[$key];
        #If processing OS IP then check if the IP is valid and if not, fail with error code 2
        if ($key == "os_ip") {
            if (!isValidUrl("http://" . $data)) {
                echo 2;
                exit;
            }
            $config .= "\$is_ospi = " . isOSPi("http://" . $data) . ";\n";
        }
        #If processing password file then go ahead and generate it with proper username/password hash
        if ($key == "pass_file") {
            #If username or password is not submitted fail
            if (!isset($_REQUEST["username"]) || !isset($_REQUEST["password"])) {
                fail();
            }
            $file = fopen($data, 'w');
            #If unable to open the pass file fail
            if (!$file) {
                fail();
            } else {
                $r = fwrite($file, $_REQUEST["username"] . ":" . base64_encode(sha1($_REQUEST["password"])));
                if (!$r) {
                    fail();
                }
                fclose($file);
            }
        }
        #Attempt to make the cache file and log file file
        if ($key == "cache_file" || $key == "log_file") {
            make_file($data);
        }
        #Append current key/data pair to config.php string.
        $config .= "\$" . $key . " = '" . $data . "';\n";
    }
    if (isset($_REQUEST["force_ssl"])) {
        $config .= "\$force_ssl=1;\n";
    } else {
        $config .= "\$force_ssl=0;\n";
    }
    if (isset($_REQUEST["local_assets"])) {
        $config .= "\$local_assets=1;\n";
    } else {
        $config .= "\$local_assets=0;\n";
    }
    #Attempt to open config.php for writing
    $file = fopen("config.php", 'w');
    #If unable, fail
    if (!$file) {
        fail();
    }
    #Write the config out
    $r = fwrite($file, $config . "?>");
    #If unable to write the config, fail
    if (!$r) {
        fail();
    }
    try {
        #Add the watcher for logs to crontab
        $output = shell_exec('crontab -l');
        if (strpos($output, "/watcher.php >/dev/null 2>&1") === false) {
            file_put_contents('/tmp/crontab.txt', $output . '* * * * * cd ' . dirname(__FILE__) . '; php ' . dirname(__FILE__) . '/watcher.php >/dev/null 2>&1' . PHP_EOL);
            exec('crontab /tmp/crontab.txt');
        }
    } catch (Exception $e) {
        echo 3;
        exit;
    }
    #Tell javascript action was succesful
    echo 1;
}
Beispiel #10
0
 */
header('HTTP/1.0 500 Internal Server Error');
require 'www-header.php';
//PHP converts dots to underscore, so hub.mode becomes hub_mode
if (!isset($_GET['hub_mode'])) {
    header('HTTP/1.0 400 Bad Request');
    echo "Parameter missing: hub.mode\n";
    exit(1);
}
$hubMode = $_GET['hub_mode'];
if (!isset($_GET['hub_topic'])) {
    header('HTTP/1.0 400 Bad Request');
    echo "Parameter missing: hub.topic\n";
    exit(1);
}
if (!isValidUrl($_GET['hub_topic'])) {
    header('HTTP/1.0 400 Bad Request');
    echo "Invalid parameter value for hub.topic: Invalid URL\n";
    exit(1);
}
$hubTopic = $_GET['hub_topic'];
$subDb = new Subscriptions();
if ($hubMode == 'denied') {
    //TODO: Inspect Location header to retry subscription
    //TODO: remove subscription
    return;
} else {
    if ($hubMode == 'subscribe') {
        //FIXME
        $pos = array_search($hubTopic, $GLOBALS['phinde']['subscriptions']);
        if ($pos === false) {
Beispiel #11
0
    die("DB ERROR");
}
while ($obj = mysql_fetch_object($rs)) {
    $id = $obj->id;
    $celular = $obj->celular;
    $qrImgName = $id . ".jpg";
    $downloadOk = getFtpFiles(FTP_PATH . "/{$qrImgName}");
    if ($downloadOk === TRUE) {
        // leer qr
        $qrRead = readQRCode($qrImgName);
        // parse result
        if (qrFound($qrRead) === TRUE) {
            $qrFound = TRUE;
            $urlPush = readUrl($qrRead);
            // valido url
            if (isValidUrl($urlPush) === TRUE) {
                // send sms push
                $msgPush = "Ir a";
                $push = new pushAntel($dbc->db, SMS_SC, $celular, $msgPush);
                $sent = $push->enviarPush($urlPush, $msgPush);
            } else {
                // send sms
                $msgSms = ERROR_MSG_BADURL;
                $sent = enviarSMS($celular, $msgSms);
            }
            // actualizo enviados
            if ($sent === TRUE) {
                $enviado = "OK";
            } else {
                $enviado = "ERR";
            }
Beispiel #12
0
 /**
  * testIsValidURL
  *
  * @return	void
  */
 public function testIsValidUrl()
 {
     //Simple check
     $result = isValidUrl('http://google.com');
     $this->assertEquals(1, $result);
     $result = isValidUrl('goo=gle');
     // This is good, it might be an alias of hostname
     $this->assertEquals(1, $result);
     //With scheme check
     $result = isValidUrl('http://www.google.com', 1);
     $this->assertEquals(1, $result);
     $result = isValidUrl('ftp://www.google.com', 1);
     $this->assertEquals(0, $result);
     //With password check invalid. This test should be ko but currently it is not
     //$result = isValidUrl('http://*****:*****@http://www.google.com', 1, 1);
     //$this->assertEquals(0, $result);
     //With password check valid
     $result = isValidUrl('http://*****:*****@www.google.com', 1, 1);
     $this->assertEquals(1, $result);
     $result = isValidUrl('http://www.google.com', 1, 1);
     $this->assertEquals(0, $result);
     //With port check
     $result = isValidUrl('http://google.com:8080', 0, 0, 1);
     $this->assertEquals(1, $result);
     $result = isValidUrl('http://google.com', 0, 0, 1);
     $this->assertEquals(0, $result);
     //With path check
     $result = isValidUrl('http://google.com/search', 0, 0, 0, 1);
     $this->assertEquals(1, $result);
     $result = isValidUrl('http://google.com', 0, 0, 0, 0);
     $this->assertEquals(1, $result);
     //With query check
     $result = isValidUrl('http://google.com/search?test=test', 0, 0, 0, 0, 1);
     $this->assertEquals(1, $result);
     //With query check
     $result = isValidUrl('http://google.com?test=test', 0, 0, 0, 0, 1);
     $this->assertEquals(1, $result);
     $result = isValidUrl('http://google.com', 0, 0, 0, 0, 1);
     $this->assertEquals(0, $result);
     //With anchor check
     $result = isValidUrl('http://google.com/search#done', 0, 0, 0, 0, 0, 1);
     $this->assertEquals(1, $result);
     $result = isValidUrl('http://google.com/search', 0, 0, 0, 0, 0, 1);
     $this->assertEquals(0, $result);
 }