Example #1
0
 function create($_userid, $_remember)
 {
     global $dbh;
     $this->_userid = sqlSanitize($_userid, $dbh);
     $this->_gid = $this->guidNbr();
     $this->_subnet = $this->getSubnet();
     $this->_updated_at = getCURDATE();
     $sql = "INSERT INTO sessions (\r\n\t\t\t\tid,\r\n\t\t\t\tuserid,\r\n\t\t\t\tgid,\r\n\t\t\t\tsubnet,\r\n\t\t\t\tupdated_at) VALUES (\r\n\t\t\t\tNULL,\r\n\t\t\t\t" . $this->_userid . ",\r\n\t\t\t\t" . returnQuotedString($this->_gid) . ",\r\n\t\t\t\t" . returnQuotedString($this->_subnet) . ",\r\n\t\t\t\tNOW())";
     mysql_query($sql, $dbh);
     $cookieTime = 0;
     if ($_remember) {
         $cookieTime = time() + 3600 * 24 * 365;
     }
     setcookie(COOKIE_REMEMBER, $this->_gid, $cookieTime, "/");
     $this->maintenance();
 }
Example #2
0
 function parseJs($_content)
 {
     if ($_content != "") {
         global $User;
         # find all current active strings for this properties file
         global $dbh;
         $strings = array();
         $sql = "SELECT * from strings WHERE is_active = 1 AND file_id = {$this->file_id}";
         $rs_strings = mysql_query($sql, $dbh);
         while ($myrow_strings = mysql_fetch_assoc($rs_strings)) {
             $string = new String();
             $string->string_id = $myrow_strings['string_id'];
             $string->file_id = $myrow_strings['file_id'];
             $string->name = $myrow_strings['name'];
             $string->value = $myrow_strings['value'];
             $string->userid = $myrow_strings['userid'];
             $string->created_on = $myrow_strings['created_on'];
             $string->is_active = $myrow_strings['is_active'];
             $strings[$string->string_id] = $string;
         }
         # import existing strings, $String->save() will deal with merges
         $file_contents = preg_replace("/NON-NLS-(.*)/", "", $_content);
         $file_contents = preg_replace("/\\/\\/\\\$/", "", $file_contents);
         $file_contents = preg_replace("/((.*?(\n))+.*?)define\\(/", "define(", $file_contents);
         $file_contents = preg_replace("/define\\(((.*?(\n))+.*?)\\)\\;/", "\$1", $file_contents);
         $jsons = new Services_JSON();
         $lines = $jsons->decode($file_contents);
         foreach ($lines as $key => $value) {
             # escape newlines and tabs
             $value = preg_replace("/\\n/", "\\\\n", $value);
             $value = preg_replace("/\\t/", "\\\\t", $value);
             $String = new String();
             $String->file_id = $this->file_id;
             $String->name = $key;
             $String->value = $value;
             $String->userid = $User->userid;
             $String->created_on = getCURDATE();
             $String->is_active = 1;
             $String->saveJs();
             # remove the string from the list
             unset($strings[$String->string_id]);
         }
         # remove strings that are no longer in the properties file
         foreach ($strings as $string) {
             $string->is_active = 0;
             if (!$string->saveJs()) {
                 echo "***ERROR: Cannot deactivate string {$string->name} in file {$string->file_id}\n";
             }
         }
     }
 }
Example #3
0
 function parseProperties($_content)
 {
     $rValue = "";
     if ($_content != "") {
         global $User;
         # step 1 - import existing strings.  $String->save() will deal with merges
         $previous_line = "";
         $lines = explode("\n", $_content);
         foreach ($lines as $line) {
             if (strlen($line) > 0 && $line[0] != "#" && $line[0] != ";") {
                 # Bug 235553 - don't trim the space at the end of a line!
                 # $line = trim($line);
                 # Does line end with a \ ?
                 if (preg_match("/\\\\\$/", $line)) {
                     # Line ends with \
                     # strip the backslash
                     $previous_line .= $line . "\n";
                 } else {
                     if ($previous_line != "") {
                         $line = $previous_line . $line;
                         $previous_line = "";
                     }
                     $tags = explode("=", $line, 2);
                     if (count($tags) > 1) {
                         if ($rValue != "") {
                             $rValue .= ",";
                         }
                         $tags[0] = trim($tags[0]);
                         # Bug 235553 - don't trim the space at the end of a line!
                         # Bug 258749 - use ltrim() to remove spaces at the beginning of value string
                         $tags[1] = ltrim($tags[1]);
                         $rValue .= $tags[0];
                         $String = new String();
                         $String->file_id = $this->file_id;
                         $String->name = $tags[0];
                         $String->value = $tags[1];
                         $String->userid = $User->userid;
                         $String->created_on = getCURDATE();
                         $String->is_active = 1;
                         $String->save();
                     }
                 }
             }
         }
         # step 2 - remove strings that are no longer in the properties file
         $String = new String();
         $aStrings = $String->getActiveStrings($this->file_id);
         foreach ($aStrings as $String) {
             $found = false;
             $aStringList = explode(",", $rValue);
             foreach ($aStringList as $strName) {
                 if ($strName == $String->name) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $String->deactivate($String->string_id);
             }
         }
     }
     return $rValue;
 }